diff --git a/phpunit/blocks/render-block-image-test.php b/phpunit/blocks/render-block-image-test.php new file mode 100644 index 00000000000000..fe39aee8c50b9d --- /dev/null +++ b/phpunit/blocks/render-block-image-test.php @@ -0,0 +1,62 @@ +'; + $parsed_blocks = parse_blocks( + '' + ); + $parsed_block = $parsed_blocks[0]; + $block = new WP_Block( $parsed_block ); + + $rendered_block = gutenberg_render_block_core_image( $attributes, $content, $block ); + $this->assertStringContainsString( 'aria-label="test render"', $rendered_block ); + } + + /** + * @covers ::render_block_core_image + */ + public function test_should_not_render_block_core_image_when_src_is_not_defined() { + $attributes = array(); + $content = '
'; + $parsed_blocks = parse_blocks( + '' + ); + $parsed_block = $parsed_blocks[0]; + $block = new WP_Block( $parsed_block ); + + $rendered_block = gutenberg_render_block_core_image( $attributes, $content, $block ); + $this->assertEquals( '', $rendered_block ); + } + + /** + * @covers ::render_block_core_image + */ + public function test_should_not_render_block_core_image_when_src_is_empty_string() { + $attributes = array(); + $content = '
'; + $parsed_blocks = parse_blocks( + '' + ); + $parsed_block = $parsed_blocks[0]; + $block = new WP_Block( $parsed_block ); + + $rendered_block = gutenberg_render_block_core_image( $attributes, $content, $block ); + $this->assertEquals( '', $rendered_block ); + } +}