From 910a4c6bc28fbb3528531415097a6c265a5300cb Mon Sep 17 00:00:00 2001 From: haritpanchal Date: Tue, 15 Sep 2026 12:33:46 +0530 Subject: [PATCH] Build/Test Tools: Use strict assertions in the interactivity-api tests. Trac ticket: https://core.trac.wordpress.org/ticket/64895 --- .../interactivity-api/wpInteractivityAPI.php | 2 +- .../wpInteractivityAPIDirectivesProcessor.php | 64 +++++++++---------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php index 430fe606f9277..9d5a4024fc6c9 100644 --- a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php +++ b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php @@ -1209,7 +1209,7 @@ public function test_get_directive_entries() { $p->next_tag(); $results = $get_directive_entries->invoke( $this->interactivity, $p, 'test' ); $this->assertCount( 6, $results ); - $this->assertEquals( + $this->assertSame( array( array( null, null ), array( null, 'a' ), diff --git a/tests/phpunit/tests/interactivity-api/wpInteractivityAPIDirectivesProcessor.php b/tests/phpunit/tests/interactivity-api/wpInteractivityAPIDirectivesProcessor.php index d674f5e54ce06..b6586b957332b 100644 --- a/tests/phpunit/tests/interactivity-api/wpInteractivityAPIDirectivesProcessor.php +++ b/tests/phpunit/tests/interactivity-api/wpInteractivityAPIDirectivesProcessor.php @@ -182,18 +182,18 @@ public function test_set_content_between_balanced_tags_standard_tags() { $p->next_tag(); $result = $p->set_content_between_balanced_tags( 'New text' ); $this->assertTrue( $result ); - $this->assertEquals( '
New text
', $p ); + $this->assertSame( '
New text
', $p->get_updated_html() ); $content = '
Text
More text
'; $p = new WP_Interactivity_API_Directives_Processor( $content ); $p->next_tag(); $result = $p->set_content_between_balanced_tags( 'New text' ); $this->assertTrue( $result ); - $this->assertEquals( '
New text
More text
', $p ); + $this->assertSame( '
New text
More text
', $p->get_updated_html() ); $p->next_tag(); $result = $p->set_content_between_balanced_tags( 'More new text' ); $this->assertTrue( $result ); - $this->assertEquals( '
New text
More new text
', $p ); + $this->assertSame( '
New text
More new text
', $p->get_updated_html() ); } /** @@ -211,7 +211,7 @@ public function test_set_content_between_balanced_tags_on_closing_tag() { $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->set_content_between_balanced_tags( 'New text' ); $this->assertFalse( $result ); - $this->assertEquals( '
Text
', $p ); + $this->assertSame( '
Text
', $p->get_updated_html() ); } /** @@ -228,10 +228,10 @@ public function test_set_content_between_balanced_tags_multiple_calls_in_same_ta $p->next_tag(); $result = $p->set_content_between_balanced_tags( 'New text' ); $this->assertTrue( $result ); - $this->assertEquals( '
New text
', $p ); + $this->assertSame( '
New text
', $p->get_updated_html() ); $result = $p->set_content_between_balanced_tags( 'More text' ); $this->assertTrue( $result ); - $this->assertEquals( '
More text
', $p ); + $this->assertSame( '
More text
', $p->get_updated_html() ); } /** @@ -249,7 +249,7 @@ public function test_set_content_between_balanced_tags_with_set_attribute() { $p->set_attribute( 'class', 'test' ); $result = $p->set_content_between_balanced_tags( 'New text' ); $this->assertTrue( $result ); - $this->assertEquals( '
New text
', $p ); + $this->assertSame( '
New text
', $p->get_updated_html() ); $content = '
Text
'; $p = new WP_Interactivity_API_Directives_Processor( $content ); @@ -257,7 +257,7 @@ public function test_set_content_between_balanced_tags_with_set_attribute() { $result = $p->set_content_between_balanced_tags( 'New text' ); $this->assertTrue( $result ); $p->set_attribute( 'class', 'test' ); - $this->assertEquals( '
New text
', $p ); + $this->assertSame( '
New text
', $p->get_updated_html() ); } /** @@ -274,7 +274,7 @@ public function test_set_content_between_balanced_tags_with_existing_tags() { $p->next_tag(); $result = $p->set_content_between_balanced_tags( 'New text' ); $this->assertTrue( $result ); - $this->assertEquals( '
New text
', $p ); + $this->assertSame( '
New text
', $p->get_updated_html() ); } /** @@ -291,7 +291,7 @@ public function test_set_content_between_balanced_tags_with_new_tags() { $p = new WP_Interactivity_API_Directives_Processor( $content ); $p->next_tag(); $p->set_content_between_balanced_tags( $new_content ); - $this->assertEquals( '
<span>New text</span><a href="#">Link</a>
', $p ); + $this->assertSame( '
<span>New text</span><a href="#">Link</a>
', $p->get_updated_html() ); } /** @@ -307,14 +307,14 @@ public function test_set_content_between_balanced_tags_empty() { $p->next_tag(); $result = $p->set_content_between_balanced_tags( '' ); $this->assertTrue( $result ); - $this->assertEquals( '
', $p ); + $this->assertSame( '
', $p->get_updated_html() ); $content = '
Text
'; $p = new WP_Interactivity_API_Directives_Processor( $content ); $p->next_tag(); $result = $p->set_content_between_balanced_tags( '' ); $this->assertTrue( $result ); - $this->assertEquals( '
', $p ); + $this->assertSame( '
', $p->get_updated_html() ); } /** @@ -330,7 +330,7 @@ public function test_set_content_between_balanced_tags_self_closing_tag() { $p->next_tag(); $result = $p->set_content_between_balanced_tags( 'New text' ); $this->assertFalse( $result ); - $this->assertEquals( $content, $p ); + $this->assertSame( $content, $p->get_updated_html() ); } /** @@ -346,7 +346,7 @@ public function test_set_content_between_balanced_tags_non_existent_tag() { $p->next_tag(); $result = $p->set_content_between_balanced_tags( 'New text' ); $this->assertFalse( $result ); - $this->assertEquals( $content, $p ); + $this->assertSame( $content, $p->get_updated_html() ); } /** @@ -364,21 +364,21 @@ public function test_set_content_between_balanced_tags_with_unbalanced_tags() { $p->next_tag(); $result = $p->set_content_between_balanced_tags( $new_content ); $this->assertFalse( $result ); - $this->assertEquals( $content, $p ); + $this->assertSame( $content, $p->get_updated_html() ); $content = '
Missing closing div
'; $p = new WP_Interactivity_API_Directives_Processor( $content ); $p->next_tag(); $result = $p->set_content_between_balanced_tags( $new_content ); $this->assertFalse( $result ); - $this->assertEquals( $content, $p ); + $this->assertSame( $content, $p->get_updated_html() ); $content = '
Missing closing div'; $p = new WP_Interactivity_API_Directives_Processor( $content ); $p->next_tag(); $result = $p->set_content_between_balanced_tags( $new_content ); $this->assertFalse( $result ); - $this->assertEquals( $content, $p ); + $this->assertSame( $content, $p->get_updated_html() ); // It supports unbalanced tags inside the content. $content = '
Missing opening span
'; @@ -386,7 +386,7 @@ public function test_set_content_between_balanced_tags_with_unbalanced_tags() { $p->next_tag(); $result = $p->set_content_between_balanced_tags( $new_content ); $this->assertTrue( $result ); - $this->assertEquals( '
New text
', $p ); + $this->assertSame( '
New text
', $p->get_updated_html() ); } /** @@ -456,7 +456,7 @@ public function test_append_content_after_template_tag_closer_simple_text() { $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( $content_2 ); $this->assertTrue( $result ); - $this->assertEquals( $content_1 . $content_2, $p ); + $this->assertSame( $content_1 . $content_2, $p->get_updated_html() ); $this->assertFalse( $p->next_tag() ); // There are no more tags. } @@ -477,14 +477,14 @@ public function test_append_content_after_template_tag_closer_simple_tags() { $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( $content_2 ); $this->assertTrue( $result ); - $this->assertEquals( $content_1 . $content_2, $p ); + $this->assertSame( $content_1 . $content_2, $p->get_updated_html() ); $p->next_tag( array( 'tag_closers' => 'visit' ) ); $this->assertSame( 'content-2', $p->get_attribute( 'class' ) ); $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( $content_3 ); $this->assertTrue( $result ); $p->next_tag( array( 'tag_closers' => 'visit' ) ); - $this->assertEquals( $content_1 . $content_2 . $content_3, $p ); + $this->assertSame( $content_1 . $content_2 . $content_3, $p->get_updated_html() ); $this->assertSame( 'content-3', $p->get_attribute( 'class' ) ); } @@ -507,7 +507,7 @@ public function test_append_content_after_template_tag_closer_in_the_middle_of_t $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( $content_2 ); $this->assertTrue( $result ); - $this->assertEquals( $content_1 . $content_2 . $content_3, $p ); + $this->assertSame( $content_1 . $content_2 . $content_3, $p->get_updated_html() ); $p->next_tag( array( 'tag_closers' => 'visit' ) ); $this->assertSame( 'content-3', $p->get_attribute( 'class' ) ); @@ -516,7 +516,7 @@ public function test_append_content_after_template_tag_closer_in_the_middle_of_t $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( $content_4 ); $this->assertTrue( $result ); - $this->assertEquals( $content_1 . $content_4 . $content_3, $p ); + $this->assertSame( $content_1 . $content_4 . $content_3, $p->get_updated_html() ); $p->next_tag( array( 'tag_closers' => 'visit' ) ); $this->assertSame( 'content-4', $p->get_attribute( 'class' ) ); } @@ -535,7 +535,7 @@ public function test_append_content_after_template_tag_closer_on_opener_tag() { $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( 'New text' ); $this->assertFalse( $result ); - $this->assertEquals( $content, $p ); + $this->assertSame( $content, $p->get_updated_html() ); } /** @@ -556,7 +556,7 @@ public function test_append_content_after_template_tag_closer_multiple_calls_in_ $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( $content_2 ); $this->assertTrue( $result ); - $this->assertEquals( $content_1 . $content_2, $p ); + $this->assertSame( $content_1 . $content_2, $p->get_updated_html() ); $p->next_tag( array( 'tag_closers' => 'visit' ) ); $this->assertSame( 'content-2', $p->get_attribute( 'class' ) ); // Rewinds to the first template. @@ -565,7 +565,7 @@ public function test_append_content_after_template_tag_closer_multiple_calls_in_ $this->assertSame( 'content-1', $p->get_attribute( 'class' ) ); $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( $content_3 ); - $this->assertEquals( $content_1 . $content_3 . $content_2, $p ); + $this->assertSame( $content_1 . $content_3 . $content_2, $p->get_updated_html() ); $p->next_tag( array( 'tag_closers' => 'visit' ) ); $this->assertSame( 'content-3', $p->get_attribute( 'class' ) ); } @@ -588,7 +588,7 @@ public function test_append_content_after_template_tag_closer_with_set_attribute $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( $content_2 ); $this->assertTrue( $result ); - $this->assertEquals( '' . $content_2, $p ); + $this->assertSame( '' . $content_2, $p->get_updated_html() ); } /** @@ -613,7 +613,7 @@ public function test_append_content_after_template_tag_closer_with_existing_tags ); $result = $p->append_content_after_template_tag_closer( $content_2 ); $this->assertTrue( $result ); - $this->assertEquals( $content_1 . $content_2, $p ); + $this->assertSame( $content_1 . $content_2, $p->get_updated_html() ); $p->next_tag(); $this->assertSame( 'content-2-template-1', $p->get_attribute( 'class' ) ); $p->next_tag(); @@ -621,7 +621,7 @@ public function test_append_content_after_template_tag_closer_with_existing_tags $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( $content_3 ); $this->assertTrue( $result ); - $this->assertEquals( $content_1 . '', $p ); + $this->assertSame( $content_1 . '', $p->get_updated_html() ); } /** @@ -639,7 +639,7 @@ public function test_append_content_after_template_tag_closer_empty() { $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( '' ); $this->assertFalse( $result ); - $this->assertEquals( $content, $p ); + $this->assertSame( $content, $p->get_updated_html() ); $this->assertSame( 'TEMPLATE', $p->get_tag() ); // It didn't move. $this->assertTrue( $p->is_tag_closer() ); // It didn't move. } @@ -659,7 +659,7 @@ public function test_append_content_after_template_tag_closer_non_existent_tag() $p->next_tag(); $result = $p->append_content_after_template_tag_closer( $content_2 ); $this->assertFalse( $result ); - $this->assertEquals( $content_1, $p ); + $this->assertSame( $content_1, $p->get_updated_html() ); } /** @@ -678,7 +678,7 @@ public function test_append_content_after_template_tag_closer_non_template_tags( $p->next_tag( array( 'tag_closers' => 'visit' ) ); $result = $p->append_content_after_template_tag_closer( $content_2 ); $this->assertFalse( $result ); - $this->assertEquals( $content_1, $p ); + $this->assertSame( $content_1, $p->get_updated_html() ); } /**