You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tests: Use assertSame() in navigation fallback tests.
This ensures that not only the return values match the expected results, but also that their type is the same.
Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.
Follow-up to [56052].
See #60705.
git-svn-id: https://develop.svn.wordpress.org/trunk@58183 602fd350-edb4-49c9-b593-d223f7449a82
Copy file name to clipboardExpand all lines: tests/phpunit/tests/editor/classic-to-block-menu-converter.php
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -31,9 +31,9 @@ public function test_passing_non_menu_object_to_converter_returns_wp_error( $dat
31
31
32
32
$this->assertTrue( is_wp_error( $result ), 'Should be a WP_Error instance' );
33
33
34
-
$this->assertEquals( 'invalid_menu', $result->get_error_code(), 'Error code should indicate invalidity of menu argument.' );
34
+
$this->assertSame( 'invalid_menu', $result->get_error_code(), 'Error code should indicate invalidity of menu argument.' );
35
35
36
-
$this->assertEquals( 'The menu provided is not a valid menu.', $result->get_error_message(), 'Error message should communicate invalidity of menu argument.' );
36
+
$this->assertSame( 'The menu provided is not a valid menu.', $result->get_error_message(), 'Error message should communicate invalidity of menu argument.' );
37
37
}
38
38
39
39
/**
@@ -104,24 +104,24 @@ public function test_can_convert_classic_menu_to_blocks() {
@@ -146,11 +146,11 @@ public function test_should_return_the_most_recently_created_navigation_menu() {
146
146
147
147
$this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' );
148
148
149
-
$this->assertEquals( $most_recently_published_nav->post_title, $data->post_title, 'Fallback menu title should be the same as the most recently created menu.' );
149
+
$this->assertSame( $most_recently_published_nav->post_title, $data->post_title, 'Fallback menu title should be the same as the most recently created menu.' );
150
150
151
-
$this->assertEquals( $most_recently_published_nav->post_name, $data->post_name, 'Post name should be the same as the most recently created menu.' );
151
+
$this->assertSame( $most_recently_published_nav->post_name, $data->post_name, 'Post name should be the same as the most recently created menu.' );
152
152
153
-
$this->assertEquals( $most_recently_published_nav->post_content, $data->post_content, 'Post content should be the same as the most recently created menu.' );
153
+
$this->assertSame( $most_recently_published_nav->post_content, $data->post_content, 'Post content should be the same as the most recently created menu.' );
@@ -179,7 +179,7 @@ public function test_should_return_fallback_navigation_from_existing_classic_men
179
179
180
180
$this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' );
181
181
182
-
$this->assertEquals( 'Existing Classic Menu', $data->post_title, 'Fallback menu title should be the same as the classic menu.' );
182
+
$this->assertSame( 'Existing Classic Menu', $data->post_title, 'Fallback menu title should be the same as the classic menu.' );
183
183
184
184
// Assert that the fallback contains a navigation-link block.
185
185
$this->assertStringContainsString( '<!-- wp:navigation-link', $data->post_content, 'The fallback Navigation Menu should contain a `core/navigation-link` block.' );
@@ -233,7 +233,7 @@ public function test_should_prioritise_fallback_to_classic_menu_in_primary_locat
233
233
234
234
$this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' );
235
235
236
-
$this->assertEquals( 'Classic Menu in Primary Location', $data->post_title, 'Fallback menu title should match the menu in the "primary" location.' );
236
+
$this->assertSame( 'Classic Menu in Primary Location', $data->post_title, 'Fallback menu title should match the menu in the "primary" location.' );
237
237
}
238
238
239
239
/**
@@ -271,7 +271,7 @@ public function test_should_fallback_to_classic_menu_with_primary_slug() {
271
271
272
272
$this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' );
273
273
274
-
$this->assertEquals( 'Primary', $data->post_title, 'Fallback menu title should match the menu with the slug "primary".' );
274
+
$this->assertSame( 'Primary', $data->post_title, 'Fallback menu title should match the menu with the slug "primary".' );
275
275
}
276
276
277
277
/**
@@ -309,7 +309,7 @@ public function test_should_fallback_to_most_recently_created_classic_menu() {
309
309
310
310
$this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' );
311
311
312
-
$this->assertEquals( 'Most Recent Classic Menu', $data->post_title, 'Fallback menu title should match the menu that was created most recently.' );
312
+
$this->assertSame( 'Most Recent Classic Menu', $data->post_title, 'Fallback menu title should match the menu that was created most recently.' );
313
313
}
314
314
315
315
/**
@@ -341,9 +341,9 @@ public function test_should_not_create_fallback_from_classic_menu_if_a_navigatio
341
341
342
342
$this->assertInstanceOf( 'WP_Post', $data, 'Response should be of the correct type.' );
343
343
344
-
$this->assertEquals( $existing_navigation_menu->post_title, $data->post_title, 'Fallback menu title should be the same as the existing Navigation menu.' );
344
+
$this->assertSame( $existing_navigation_menu->post_title, $data->post_title, 'Fallback menu title should be the same as the existing Navigation menu.' );
345
345
346
-
$this->assertNotEquals( 'Existing Classic Menu', $data->post_title, 'Fallback menu title should not be the same as the Classic Menu.' );
346
+
$this->assertNotSame( 'Existing Classic Menu', $data->post_title, 'Fallback menu title should not be the same as the Classic Menu.' );
347
347
348
348
// Check that only a single Navigation fallback was created.
0 commit comments