Skip to content

Commit 045b1f2

Browse files
committed
Switch to assertEqualHTML assertions
1 parent 51006c6 commit 045b1f2

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

tests/phpunit/tests/dependencies/scripts.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,15 +1580,13 @@ public function test_loading_strategy_with_valid_blocking_registration() {
15801580
wp_enqueue_script( 'main-script-b1', '/main-script-b1.js', array(), null );
15811581
$output = get_echo( 'wp_print_scripts' );
15821582
$expected = "<script type='text/javascript' src='/main-script-b1.js' id='main-script-b1-js'></script>\n";
1583-
$expected = str_replace( "'", '"', $expected );
1584-
$this->assertSame( $expected, $output, 'Scripts registered with a "blocking" strategy, and who have no dependencies, should have no loading strategy attributes printed.' );
1583+
$this->assertEqualHTML( $expected, $output, '<body>', 'Scripts registered with a "blocking" strategy, and who have no dependencies, should have no loading strategy attributes printed.' );
15851584

15861585
// strategy args not set.
15871586
wp_enqueue_script( 'main-script-b2', '/main-script-b2.js', array(), null, array() );
15881587
$output = get_echo( 'wp_print_scripts' );
15891588
$expected = "<script type='text/javascript' src='/main-script-b2.js' id='main-script-b2-js'></script>\n";
1590-
$expected = str_replace( "'", '"', $expected );
1591-
$this->assertSame( $expected, $output, 'Scripts registered with no strategy assigned, and who have no dependencies, should have no loading strategy attributes printed.' );
1589+
$this->assertEqualHTML( $expected, $output, '<body>', 'Scripts registered with no strategy assigned, and who have no dependencies, should have no loading strategy attributes printed.' );
15921590
}
15931591

15941592
/**

tests/phpunit/tests/dependencies/wpScriptTag.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Tests_Functions_wpScriptTag extends WP_UnitTestCase {
1111
public function get_script_tag_type_set() {
1212
add_theme_support( 'html5', array( 'script' ) );
1313

14-
$this->assertSame(
14+
$this->assertEqualHTML(
1515
'<script src="https://localhost/PATH/FILE.js" type="application/javascript" nomodule></script>' . "\n",
1616
wp_get_script_tag(
1717
array(
@@ -25,7 +25,7 @@ public function get_script_tag_type_set() {
2525

2626
remove_theme_support( 'html5' );
2727

28-
$this->assertSame(
28+
$this->assertEqualHTML(
2929
'<script src="https://localhost/PATH/FILE.js" type="application/javascript" nomodule></script>' . "\n",
3030
wp_get_script_tag(
3131
array(
@@ -44,7 +44,7 @@ public function get_script_tag_type_set() {
4444
public function test_get_script_tag_type_not_set() {
4545
add_theme_support( 'html5', array( 'script' ) );
4646

47-
$this->assertSame(
47+
$this->assertEqualHTML(
4848
'<script src="https://localhost/PATH/FILE.js" nomodule></script>' . "\n",
4949
wp_get_script_tag(
5050
array(
@@ -80,7 +80,7 @@ static function ( $attributes ) {
8080
'nomodule' => true,
8181
);
8282

83-
$this->assertSame(
83+
$this->assertEqualHTML(
8484
wp_get_script_tag( $attributes ),
8585
get_echo(
8686
'wp_print_script_tag',
@@ -90,7 +90,7 @@ static function ( $attributes ) {
9090

9191
remove_theme_support( 'html5' );
9292

93-
$this->assertSame(
93+
$this->assertEqualHTML(
9494
wp_get_script_tag( $attributes ),
9595
get_echo(
9696
'wp_print_script_tag',

0 commit comments

Comments
 (0)