diff --git a/tests/phpunit/data/themedir1/block-theme/parts/template-part-shortcode.html b/tests/phpunit/data/themedir1/block-theme/parts/template-part-shortcode.html index d5de7e166312e..42d66f403353c 100644 --- a/tests/phpunit/data/themedir1/block-theme/parts/template-part-shortcode.html +++ b/tests/phpunit/data/themedir1/block-theme/parts/template-part-shortcode.html @@ -1,7 +1,18 @@
+

wptexturize

+

'cause today's effort makes it worth tomorrow's "holiday"...

+

convert_smilies

+

:)

+

shortcode_unautop (shortcode wrapped in paragraph)

+

[test_shortcode]_unautop

+

wp_filter_content_tags

+ +

do_shortcode

- [test_shortcode] + [test_shortcode]_shortcode_block +

$wp_embed->autoembed

+ https://youtube.com/shorts/_H4vwkGvWjE?feature=share
diff --git a/tests/phpunit/tests/block-template-utils.php b/tests/phpunit/tests/block-template-utils.php index 77cdfaa46fd69..9cf1a87ca2231 100644 --- a/tests/phpunit/tests/block-template-utils.php +++ b/tests/phpunit/tests/block-template-utils.php @@ -344,12 +344,12 @@ public function test_wp_generate_block_templates_export_file() { } /** - * Should expand shortcodes in block template part. + * Should run `do_shortcode` in block template part. * * @ticket 56780 * @covers ::block_template_part */ - public function test_block_template_part_render_shortcode() { + public function test_block_template_part_do_shortcode() { add_shortcode( self::TEST_SHORTCODE, array( $this, 'render_test_shortcode' ) ); ob_start(); @@ -358,7 +358,65 @@ public function test_block_template_part_render_shortcode() { remove_shortcode( self::TEST_SHORTCODE ); - $this->assertStringContainsString( 'test_shortcode_rendered', $generated_content ); + $this->assertStringContainsString( 'test_shortcode_rendered_unautop', $generated_content, 'Should render shortcodes in paragraph tags' ); + $this->assertStringContainsString( 'test_shortcode_rendered_shortcode_block', $generated_content, 'Should render shortcodes in shortcode blocks' ); + } + + /** + * Should run `wp_filter_content_tags` in block template part. + * + * @ticket 56780 + * @covers ::block_template_part + */ + public function test_block_template_part_wp_filter_content_tags() { + ob_start(); + block_template_part( 'template-part-shortcode' ); + $generated_content = ob_get_clean(); + + $this->assertStringContainsString( '', $generated_content ); + } + + /** + * Should run `convert_smilies` in block template part. + * + * @ticket 56780 + * @covers ::block_template_part + */ + public function test_block_template_part_convert_smilies() { + ob_start(); + block_template_part( 'template-part-shortcode' ); + $generated_content = ob_get_clean(); + + $this->assertStringContainsString( '🙂', $generated_content ); + } + + /** + * Should run `WP_Embed::autoembed` in block template part. + * + * @ticket 56780 + * @covers ::block_template_part + */ + public function test_block_template_part_autoembed() { + ob_start(); + block_template_part( 'template-part-shortcode' ); + $generated_content = ob_get_clean(); + + $this->assertStringContainsString( 'assertStringContainsString( 'src="https://www.youtube.com/embed/_H4vwkGvWjE', $generated_content, 'Should use the correct src for the iframe' ); + } + + /** + * Should run `wptexturize` in block template part. + * + * @ticket 56780 + * @covers ::block_template_part + */ + public function test_block_template_part_wptexturize() { + ob_start(); + block_template_part( 'template-part-shortcode' ); + $generated_content = ob_get_clean(); + + $this->assertStringContainsString( '’cause today’s effort makes it worth tomorrow’s “holiday”…', $generated_content ); } public function render_test_shortcode() {