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' => 480, 'height' => 360, ], [ '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), ], ], ] ); } }