From 6dca3bf3da1ce445828348500d0c91e71343238e Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Fri, 10 Oct 2025 11:08:17 +0300 Subject: [PATCH 1/3] Try to fix PHP tests --- phpunit/block-supports/background-test.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/phpunit/block-supports/background-test.php b/phpunit/block-supports/background-test.php index dace3b4dabc762..b5cbcbac9aef51 100644 --- a/phpunit/block-supports/background-test.php +++ b/phpunit/block-supports/background-test.php @@ -64,6 +64,10 @@ public function filter_set_theme_root() { return $this->theme_root; } + private function get_apostrophe_entity() { + return version_compare( get_bloginfo( 'version' ), '6.9', '>=' ) ? ''' : '''; + } + /** * Tests that background image block support works as expected. * @@ -121,6 +125,8 @@ public function test_background_block_support( $theme_name, $block_name, $backgr * @return array */ public function data_background_block_support() { + $apos = $this->get_apostrophe_entity(); + return array( 'background image style is applied' => array( 'theme_name' => 'block-theme-child-with-fluid-typography', @@ -133,7 +139,7 @@ public function data_background_block_support() { 'url' => 'https://example.com/image.jpg', ), ), - 'expected_wrapper' => '
Content
', + 'expected_wrapper' => '
Content
', 'wrapper' => '
Content
', ), 'background image style is applied when backgroundImage is a string' => array( @@ -145,7 +151,7 @@ public function data_background_block_support() { 'background_style' => array( 'backgroundImage' => "url('https://example.com/image.jpg')", ), - 'expected_wrapper' => '
Content
', + 'expected_wrapper' => '
Content
', 'wrapper' => '
Content
', ), 'background image style with contain, position, attachment, and repeat is applied' => array( @@ -162,7 +168,7 @@ public function data_background_block_support() { 'backgroundSize' => 'contain', 'backgroundAttachment' => 'fixed', ), - 'expected_wrapper' => '
Content
', + 'expected_wrapper' => '
Content
', 'wrapper' => '
Content
', ), 'background image style is appended if a style attribute already exists' => array( @@ -176,7 +182,7 @@ public function data_background_block_support() { 'url' => 'https://example.com/image.jpg', ), ), - 'expected_wrapper' => '
Content
', + 'expected_wrapper' => '
Content
', 'wrapper' => '
Content
', ), 'background image style is appended if a style attribute containing multiple styles already exists' => array( @@ -190,7 +196,7 @@ public function data_background_block_support() { 'url' => 'https://example.com/image.jpg', ), ), - 'expected_wrapper' => '
Content
', + 'expected_wrapper' => '
Content
', 'wrapper' => '
Content
', ), 'background image style is not applied if the block does not support background image' => array( From 285db941aa918771c742f69b10391222d5275644 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Fri, 10 Oct 2025 11:24:16 +0300 Subject: [PATCH 2/3] try 2 --- phpunit/block-supports/background-test.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/phpunit/block-supports/background-test.php b/phpunit/block-supports/background-test.php index b5cbcbac9aef51..2dea187f9fd433 100644 --- a/phpunit/block-supports/background-test.php +++ b/phpunit/block-supports/background-test.php @@ -83,6 +83,9 @@ private function get_apostrophe_entity() { * @param string $wrapper Existing markup for the block wrapper. */ public function test_background_block_support( $theme_name, $block_name, $background_settings, $background_style, $expected_wrapper, $wrapper ) { + // Replace the placeholder with the actual apostrophe encoding based on WP version. + $expected_wrapper = str_replace( '{{APOS}}', $this->get_apostrophe_entity(), $expected_wrapper ); + switch_theme( $theme_name ); $this->test_block_name = $block_name; @@ -125,7 +128,9 @@ public function test_background_block_support( $theme_name, $block_name, $backgr * @return array */ public function data_background_block_support() { - $apos = $this->get_apostrophe_entity(); + // Use a placeholder that will be replaced in the test method + // when WordPress is fully loaded and get_bloginfo() is available. + $apos = '{{APOS}}'; return array( 'background image style is applied' => array( From 22b8652dddbdb4dd915b066c19400b82eb9fe5ba Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Fri, 10 Oct 2025 11:56:03 +0300 Subject: [PATCH 3/3] try 3 --- phpunit/block-supports/background-test.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/phpunit/block-supports/background-test.php b/phpunit/block-supports/background-test.php index 2dea187f9fd433..8a16604d67e57f 100644 --- a/phpunit/block-supports/background-test.php +++ b/phpunit/block-supports/background-test.php @@ -65,7 +65,9 @@ public function filter_set_theme_root() { } private function get_apostrophe_entity() { - return version_compare( get_bloginfo( 'version' ), '6.9', '>=' ) ? ''' : '''; + // WP 6.9+ has get_block_bindings_supported_attributes() and uses ' + // WP 6.8 and earlier use ' + return function_exists( 'get_block_bindings_supported_attributes' ) ? ''' : '''; } /** @@ -83,9 +85,6 @@ private function get_apostrophe_entity() { * @param string $wrapper Existing markup for the block wrapper. */ public function test_background_block_support( $theme_name, $block_name, $background_settings, $background_style, $expected_wrapper, $wrapper ) { - // Replace the placeholder with the actual apostrophe encoding based on WP version. - $expected_wrapper = str_replace( '{{APOS}}', $this->get_apostrophe_entity(), $expected_wrapper ); - switch_theme( $theme_name ); $this->test_block_name = $block_name; @@ -128,9 +127,9 @@ public function test_background_block_support( $theme_name, $block_name, $backgr * @return array */ public function data_background_block_support() { - // Use a placeholder that will be replaced in the test method - // when WordPress is fully loaded and get_bloginfo() is available. - $apos = '{{APOS}}'; + // Get the appropriate apostrophe encoding based on WordPress version. + // function_exists() works in data providers, unlike get_bloginfo(). + $apos = $this->get_apostrophe_entity(); return array( 'background image style is applied' => array(