diff --git a/tests/php/test-class-amp-youtube-embed-handler.php b/tests/php/test-class-amp-youtube-embed-handler.php index 4c7d85a1ff2..738fc3b867e 100644 --- a/tests/php/test-class-amp-youtube-embed-handler.php +++ b/tests/php/test-class-amp-youtube-embed-handler.php @@ -101,6 +101,50 @@ public function mock_http_request( $preempt, $r, $url ) { ]; } + /** + * data provider for $this->test_sanitize_raw_embeds() + * + * @return string[][] + */ + public function sanitize_raw_embeds_data_provider() { + + return [ + 'youtube-embed' => [ + 'source' => '', + 'expected' => '', + ], + 'short-url' => [ + 'source' => '', + 'expected' => '', + ], + 'none-youtube' => [ + 'source' => '', + 'expected' => '', + ], + ]; + } + + /** + * @dataProvider sanitize_raw_embeds_data_provider + * + * @covers AMP_YouTube_Embed_Handler::sanitize_raw_embeds + */ + public function test_sanitize_raw_embeds( $source, $expected ) { + + $embed = new AMP_YouTube_Embed_Handler(); + $embed->register_embed(); + + $dom = AMP_DOM_Utils::get_dom_from_content( $source ); + $embed->sanitize_raw_embeds( $dom ); + + $layout_sanitizer = new AMP_Layout_Sanitizer( $dom ); + $layout_sanitizer->sanitize(); + + $content = AMP_DOM_Utils::get_content_from_dom( $dom ); + + $this->assertEquals( $expected, trim( $content ) ); + } + /** * Test video_override(). * @@ -160,7 +204,7 @@ public function get_conversion_data() { 'url_with_querystring' => [ 'http://www.youtube.com/watch?v=kfVsfOSbJY0&hl=en&fs=1&w=425&h=349' . PHP_EOL, - '

Rebecca Black - Friday

' . PHP_EOL, + '

Rebecca Black - Friday

' . PHP_EOL, '

' . PHP_EOL, ],