diff --git a/tests/phpunit/tests/dependencies/wpInlineScriptTag.php b/tests/phpunit/tests/dependencies/wpInlineScriptTag.php index 76e53db9c235e..9958a2468706b 100644 --- a/tests/phpunit/tests/dependencies/wpInlineScriptTag.php +++ b/tests/phpunit/tests/dependencies/wpInlineScriptTag.php @@ -94,4 +94,74 @@ static function ( $attributes ) { ) ); } + + /** + * Test the behavior of generated script tag attributes passed different values and types of values. + * + * @ticket 64500 + */ + public function test_script_tag_attribute_value_types() { + $expected = <<<'HTML' + + +HTML; + + $this->assertEqualHTML( + $expected, + wp_get_inline_script_tag( + '"script data";', + array( + 'true' => true, + 'false' => false, + 'null' => null, + 'empty-string' => '', + '0-string' => '0', + '1-string' => '1', + '0-numeric' => 0, + '1-numeric' => 1, + ) + ), + ); + } + + /** + * Test the behavior of generated script tag repeated attributes. + * + * HTML will ignore case-insensitive repeated attributes. Ensure that the handling of input + * attributes aligns with expectations. + * + * @ticket 64500 + */ + public function test_script_tag_repeat_attributes() { + $expected = <<<'HTML' + + +HTML; + + $this->assertEqualHTML( + $expected, + wp_get_inline_script_tag( + '"script data";', + array( + 'test' => 'test-a', + 'tesT' => 'tesT-b', + 'teST' => 'teST-c', + 'tEST' => 'tEST-d', + 'TEST' => 'TEST-e', + ) + ), + ); + } } diff --git a/tests/phpunit/tests/dependencies/wpScriptTag.php b/tests/phpunit/tests/dependencies/wpScriptTag.php index c06a86b2db57f..7b8c88bb9e465 100644 --- a/tests/phpunit/tests/dependencies/wpScriptTag.php +++ b/tests/phpunit/tests/dependencies/wpScriptTag.php @@ -98,4 +98,68 @@ static function ( $attributes ) { ) ); } + + /** + * Test the behavior of generated script tag attributes passed different values and types of values. + * + * @ticket 64500 + */ + public function test_script_tag_attribute_value_types() { + $expected = <<<'HTML' + + +HTML; + + $this->assertEqualHTML( + $expected, + wp_get_script_tag( + array( + 'true' => true, + 'false' => false, + 'null' => null, + 'empty-string' => '', + '0-string' => '0', + '1-string' => '1', + '0-numeric' => 0, + '1-numeric' => 1, + ) + ), + ); + } + + /** + * Test the behavior of generated script tag repeated attributes. + * + * HTML will ignore case-insensitive repeated attributes. Ensure that the handling of input + * attributes aligns with expectations. + * + * @ticket 64500 + */ + public function test_script_tag_repeat_attributes() { + $expected = <<<'HTML' + + +HTML; + + $this->assertEqualHTML( + $expected, + wp_get_script_tag( + array( + 'test' => 'test-a', + 'tesT' => 'tesT-b', + 'teST' => 'teST-c', + 'tEST' => 'tEST-d', + 'TEST' => 'TEST-e', + ) + ), + ); + } }