@@ -36,13 +36,12 @@ public static function wpTearDownAfterClass() {
3636 }
3737
3838 /**
39- * Renders a Post Featured Image block and returns the class and style
40- * attributes of the image and the overlay.
39+ * Renders a Post Featured Image block and returns the image's class and style attributes.
4140 *
4241 * @param array $attributes Block attributes.
43- * @return array Class and style of the image and the overlay .
42+ * @return array Class and style of the image.
4443 */
45- private function render_attributes ( $ attributes ) {
44+ private function render_image_attributes ( $ attributes ) {
4645 $ block = new WP_Block (
4746 array (
4847 'blockName ' => 'core/post-featured-image ' ,
@@ -53,31 +52,17 @@ private function render_attributes( $attributes ) {
5352
5453 $ processor = new WP_HTML_Tag_Processor ( $ block ->render () );
5554 $ this ->assertTrue ( $ processor ->next_tag ( 'img ' ) );
56- $ actual = array (
57- 'image_class ' => $ processor ->get_attribute ( 'class ' ),
58- 'image_style ' => $ processor ->get_attribute ( 'style ' ),
59- );
60- if ( $ processor ->next_tag ( 'span ' ) ) {
61- $ actual ['overlay_class ' ] = $ processor ->get_attribute ( 'class ' );
62- $ actual ['overlay_style ' ] = $ processor ->get_attribute ( 'style ' );
63- }
64-
65- return $ actual ;
66- }
6755
68- public function test_shadow_is_applied_to_the_image () {
69- $ actual = $ this -> render_attributes (
70- array ( 'style ' => array ( 'shadow ' => ' var:preset|shadow|natural ' ) )
56+ return array (
57+ ' class ' => $ processor -> get_attribute ( ' class ' ),
58+ 'style ' => $ processor -> get_attribute ( 'style ' ),
7159 );
72-
73- $ this ->assertSame ( 'object-fit:cover;box-shadow:var(--wp--preset--shadow--natural); ' , $ actual ['image_style ' ] );
7460 }
7561
76- public function test_shadow_follows_border_and_dimensions_on_the_image () {
77- $ actual = $ this ->render_attributes (
62+ public function test_shadow_follows_border_on_the_image () {
63+ $ actual = $ this ->render_image_attributes (
7864 array (
79- 'dimRatio ' => 50 ,
80- 'style ' => array (
65+ 'style ' => array (
8166 'border ' => array (
8267 'radius ' => '10px ' ,
8368 'color ' => '#ff0000 ' ,
@@ -87,15 +72,7 @@ public function test_shadow_follows_border_and_dimensions_on_the_image() {
8772 )
8873 );
8974
90- $ this ->assertSame ( 'has-border-color wp-post-image ' , $ actual ['image_class ' ] );
91- $ this ->assertSame ( 'border-color:#ff0000;border-radius:10px;object-fit:cover;box-shadow:1px 1px 1px #000; ' , $ actual ['image_style ' ] );
92- $ this ->assertSame ( 'wp-block-post-featured-image__overlay has-border-color has-background-dim has-background-dim-50 ' , $ actual ['overlay_class ' ] );
93- $ this ->assertSame ( 'border-color:#ff0000;border-radius:10px ' , $ actual ['overlay_style ' ] );
94- }
95-
96- public function test_empty_shadow_is_ignored () {
97- $ actual = $ this ->render_attributes ( array ( 'style ' => array ( 'shadow ' => '' ) ) );
98-
99- $ this ->assertSame ( 'object-fit:cover; ' , $ actual ['image_style ' ] );
75+ $ this ->assertSame ( 'has-border-color wp-post-image ' , $ actual ['class ' ] );
76+ $ this ->assertSame ( 'border-color:#ff0000;border-radius:10px;object-fit:cover;box-shadow:1px 1px 1px #000; ' , $ actual ['style ' ] );
10077 }
10178}
0 commit comments