assertEquals(preg_replace('/\s+/', '', $a), preg_replace('/\s+/', '', $b), $message); } public function testYoutube() { /** @var string $result */ $result = $this->mockRequest( [ 'url' => static::$test_youtube, 'caption' => 'A nice video', 'width' => 777, 'height' => 437, ], [ 'version' => '1.0', 'provider_url' => 'https://www.youtube.com/', 'title' => 'SilverStripe Platform 2 min introduction', 'html' => '', 'provider_name' => 'YouTube', 'thumbnail_width' => 480, 'type' => 'video', 'thumbnail_url' => 'https://i.ytimg.com/vi/dM15HfUYwF0/hqdefault.jpg', 'thumbnail_height' => 360, 'width' => 480, 'author_url' => 'https://www.youtube.com/user/SilverStripe', 'author_name' => 'SilverStripe', 'height' => 270, ] ); $this->assertEqualIgnoringWhitespace( <<

A nice video

EOS , $result ); } public function testSoundcloud() { /** @var string $result */ $result = $this->mockRequest( ['url' => static::$test_soundcloud], [ 'version' => 1, 'type' => 'rich', 'provider_name' => 'SoundCloud', 'provider_url' => 'http://soundcloud.com', 'height' => 400, 'width' => '100%', 'title' => 'DELAIN - Suckerpunch by Napalm Records', 'description' => 'Taken from the EP "Lunar Prelude": http://shop.napalmrecords.com/delain', 'thumbnail_url' => 'http://i1.sndcdn.com/artworks-000143578557-af0v6l-t500x500.jpg', 'html' => '', 'author_name' => 'Napalm Records', 'author_url' => 'http://soundcloud.com/napalmrecords', ] ); $this->assertEqualIgnoringWhitespace( << EOS , $result ); } /** * Mock an oembed request * * @param array $arguments Input arguments * @param array $response JSON response body * @return string */ protected function mockRequest($arguments, $response) { return EmbedShortcodeProvider::handle_shortcode( $arguments, '', null, 'embed', [ 'resolver' => [ 'class' => MockResolver::class, 'config' => [ 'expectedContent' => json_encode($response), ], ], ] ); } public function testFlushCachedShortcodes() { /** @var CacheInterface $cache */ $url = 'http://www.test-service.com/abc123'; $content = '

Some content with an [embed url="' . $url . '" thumbnail="https://example.com/mythumb.jpg" ' . 'class="leftAlone ss-htmleditorfield-file embed" width="480" height="270"]' . $url . '[/embed]

'; $embedHtml = '