Skip to content

Commit

Permalink
Update PHP tests to match new expected render
Browse files Browse the repository at this point in the history
  • Loading branch information
sgomes committed Sep 3, 2024
1 parent 9d10e74 commit a374697
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions phpunit/blocks/render-block-media-text-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ public function test_render_block_core_media_text_featured_image() {
$rendered = gutenberg_render_block_core_media_text( $attributes, $content );
$this->assertStringContainsString( '<img alt="" src="' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . '"', $rendered );

// Assert that the rendered block contains the featured image as the background-image url,
// and not the image element, when image fill is true.
// Assert that the rendered block contains the featured image as an image element
// and not as a background-image url, when image fill is true.
$attributes = array(
'useFeaturedImage' => true,
'imageFill' => true,
);
$rendered = gutenberg_render_block_core_media_text( $attributes, $content );
$this->assertStringContainsString( 'background-image:url(' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . ')', $rendered );
$this->assertStringNotContainsString( '<img', $rendered );
$this->assertStringNotContainsString( 'background-image:', $rendered );
$this->assertStringContainsString( '<img alt="" src="' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . '"', $rendered );
}

/**
Expand All @@ -107,15 +107,15 @@ public function test_render_block_core_media_text_featured_image_nested() {
$rendered = gutenberg_render_block_core_media_text( $attributes, $content );
$this->assertStringContainsString( '<img alt="" src="' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . '"', $rendered );

// Assert that the rendered block contains the featured image as the background-image url,
// and not the image element, when image fill is true.
// Assert that the rendered block contains the featured image as an image element
// and not as a background-image url, when image fill is true.
$attributes = array(
'useFeaturedImage' => true,
'imageFill' => true,
);
$rendered = gutenberg_render_block_core_media_text( $attributes, $content );
$this->assertStringContainsString( 'background-image:url(' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . ')', $rendered );
$this->assertStringNotContainsString( '<img', $rendered );
$this->assertStringNotContainsString( 'background-image:', $rendered );
$this->assertStringContainsString( '<img alt="" src="' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . '"', $rendered );
}

/**
Expand All @@ -134,16 +134,16 @@ public function test_render_block_core_media_text_featured_image_media_on_right(
$rendered = gutenberg_render_block_core_media_text( $attributes, $content );
$this->assertStringContainsString( '<img alt="" src="' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . '"', $rendered );

// Assert that the rendered block contains the featured image as the background-image url,
// and not the image element, when image fill is true and the media is on the right.
// Assert that the rendered block contains the featured image as an image element
// and not as a background-image url, when image fill is true and the media is on the right.
$attributes = array(
'useFeaturedImage' => true,
'mediaPosition' => 'right',
'imageFill' => true,
);
$rendered = gutenberg_render_block_core_media_text( $attributes, $content );
$this->assertStringContainsString( 'background-image:url(' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . ')', $rendered );
$this->assertStringNotContainsString( '<img', $rendered );
$this->assertStringNotContainsString( 'background-image:', $rendered );
$this->assertStringContainsString( '<img alt="" src="' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . '"', $rendered );
}

/**
Expand All @@ -164,16 +164,16 @@ public function test_render_block_core_media_text_featured_image_media_on_right_
$rendered = gutenberg_render_block_core_media_text( $attributes, $content );
$this->assertStringContainsString( '<img alt="" src="' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . '"', $rendered );

// Assert that the rendered block contains the featured image as the background-image url,
// and not the image element, when image fill is true and the media is on the right.
// Assert that the rendered block contains the featured image as an image element
// and not as a background-image url, when image fill is true and the media is on the right.
$attributes = array(
'useFeaturedImage' => true,
'mediaPosition' => 'right',
'imageFill' => true,
);

$rendered = gutenberg_render_block_core_media_text( $attributes, $content );
$this->assertStringContainsString( 'background-image:url(' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . ')', $rendered );
$this->assertStringNotContainsString( '<img', $rendered );
$this->assertStringNotContainsString( 'background-image:', $rendered );
$this->assertStringContainsString( '<img alt="" src="' . wp_get_attachment_image_url( self::$attachment_id, 'full' ) . '"', $rendered );
}
}

0 comments on commit a374697

Please sign in to comment.