Skip to content

Commit

Permalink
Add youtube test back
Browse files Browse the repository at this point in the history
  • Loading branch information
arthur791004 committed Aug 28, 2024
1 parent 3f07377 commit 4c74a9d
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,32 @@ public function get_youtube_id_options() {
);
}

/**
* @author Toro_Unit
* @covers ::youtube_shortcode
* @since 3.9
*/
public function test_replace_url_with_iframe_in_the_content() {
global $post;

$youtube_id = 'JaNH56Vpg-A';
$url = 'http://www.youtube.com/watch?v=' . $youtube_id;
$post = self::factory()->post->create_and_get( array( 'post_content' => "[youtube $url]" ) );

wpcom_youtube_embed_crazy_url_init();

Check failure on line 107 in projects/plugins/jetpack/tests/php/modules/shortcodes/test-class.youtube.php

View workflow job for this annotation

GitHub Actions / Static analysis

UndefError PhanUndeclaredFunction Call to undeclared function \wpcom_youtube_embed_crazy_url_init()
setup_postdata( $post );
ob_start();
// This below is needed since Core inserts "loading=lazy" right after the iframe opener.
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
the_content();
remove_all_filters( 'wp_lazy_loading_enabled' );
$actual = ob_get_clean();
wp_reset_postdata();
$this->assertStringContainsString( '<span class="embed-youtube"', $actual );
$this->assertStringContainsString( '<iframe class="youtube-player"', $actual );
$this->assertStringContainsString( "https://www.youtube.com/embed/$youtube_id", $actual );
}

/**
* Gets the test data for jetpack_shortcode_youtube_args().
*
Expand Down

0 comments on commit 4c74a9d

Please sign in to comment.