diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php index 259d601f93..6825192c9d 100644 --- a/tests/phpunit/includes/abstract-testcase.php +++ b/tests/phpunit/includes/abstract-testcase.php @@ -659,16 +659,29 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase { $this->assertEquals( preg_replace( '/\s*/', '', $expected ), preg_replace( '/\s*/', '', $actual ) ); } + /** + * Asserts that two values have the same type and value, with EOL differences discarded. + * + * @since 5.6.0 + * + * @param string $expected The expected value. + * @param string $actual The actual value. + */ + public function assertSameIgnoreEOL( $expected, $actual ) { + $this->assertSame( str_replace( "\r\n", "\n", $expected ), str_replace( "\r\n", "\n", $actual ) ); + } + /** * Asserts that two values are equal, with EOL differences discarded. * * @since 5.4.0 + * @since 5.6.0 Turned into an alias for `::assertSameIgnoreEOL()`. * * @param string $expected The expected value. * @param string $actual The actual value. */ public function assertEqualsIgnoreEOL( $expected, $actual ) { - $this->assertEquals( str_replace( "\r\n", "\n", $expected ), str_replace( "\r\n", "\n", $actual ) ); + $this->assertSameIgnoreEOL( $expected, $actual ); } /** diff --git a/tests/phpunit/tests/actions.php b/tests/phpunit/tests/actions.php index 6e4cb701a0..ee92d104e8 100644 --- a/tests/phpunit/tests/actions.php +++ b/tests/phpunit/tests/actions.php @@ -15,13 +15,13 @@ class Tests_Actions extends WP_UnitTestCase { do_action( $tag ); // Only one event occurred for the hook, with empty args. - $this->assertEquals( 1, $a->get_call_count() ); + $this->assertSame( 1, $a->get_call_count() ); // Only our hook was called. - $this->assertEquals( array( $tag ), $a->get_tags() ); + $this->assertSame( array( $tag ), $a->get_tags() ); $argsvar = $a->get_args(); $args = array_pop( $argsvar ); - $this->assertEquals( array( '' ), $args ); + $this->assertSame( array( '' ), $args ); } function test_remove_action() { @@ -32,14 +32,14 @@ class Tests_Actions extends WP_UnitTestCase { do_action( $tag ); // Make sure our hook was called correctly. - $this->assertEquals( 1, $a->get_call_count() ); - $this->assertEquals( array( $tag ), $a->get_tags() ); + $this->assertSame( 1, $a->get_call_count() ); + $this->assertSame( array( $tag ), $a->get_tags() ); // Now remove the action, do it again, and make sure it's not called this time. remove_action( $tag, array( &$a, 'action' ) ); do_action( $tag ); - $this->assertEquals( 1, $a->get_call_count() ); - $this->assertEquals( array( $tag ), $a->get_tags() ); + $this->assertSame( 1, $a->get_call_count() ); + $this->assertSame( array( $tag ), $a->get_tags() ); } @@ -50,7 +50,7 @@ class Tests_Actions extends WP_UnitTestCase { $this->assertFalse( has_action( $tag, $func ) ); $this->assertFalse( has_action( $tag ) ); add_action( $tag, $func ); - $this->assertEquals( 10, has_action( $tag, $func ) ); + $this->assertSame( 10, has_action( $tag, $func ) ); $this->assertTrue( has_action( $tag ) ); remove_action( $tag, $func ); $this->assertFalse( has_action( $tag, $func ) ); @@ -70,8 +70,8 @@ class Tests_Actions extends WP_UnitTestCase { do_action( $tag ); // Both actions called once each. - $this->assertEquals( 1, $a1->get_call_count() ); - $this->assertEquals( 1, $a2->get_call_count() ); + $this->assertSame( 1, $a1->get_call_count() ); + $this->assertSame( 1, $a2->get_call_count() ); } function test_action_args_1() { @@ -84,9 +84,9 @@ class Tests_Actions extends WP_UnitTestCase { do_action( $tag, $val ); $call_count = $a->get_call_count(); - $this->assertEquals( 1, $call_count ); + $this->assertSame( 1, $call_count ); $argsvar = $a->get_args(); - $this->assertEquals( array( $val ), array_pop( $argsvar ) ); + $this->assertSame( array( $val ), array_pop( $argsvar ) ); } function test_action_args_2() { @@ -104,14 +104,14 @@ class Tests_Actions extends WP_UnitTestCase { $call_count = $a1->get_call_count(); // $a1 should be called with both args. - $this->assertEquals( 1, $call_count ); + $this->assertSame( 1, $call_count ); $argsvar1 = $a1->get_args(); - $this->assertEquals( array( $val1, $val2 ), array_pop( $argsvar1 ) ); + $this->assertSame( array( $val1, $val2 ), array_pop( $argsvar1 ) ); // $a2 should be called with one only. - $this->assertEquals( 1, $a2->get_call_count() ); + $this->assertSame( 1, $a2->get_call_count() ); $argsvar2 = $a2->get_args(); - $this->assertEquals( array( $val1 ), array_pop( $argsvar2 ) ); + $this->assertSame( array( $val1 ), array_pop( $argsvar2 ) ); } /** @@ -138,19 +138,19 @@ class Tests_Actions extends WP_UnitTestCase { $call_count = $a1->get_call_count(); // $a1 should be called with both args. - $this->assertEquals( 1, $call_count ); + $this->assertSame( 1, $call_count ); $argsvar1 = $a1->get_args(); - $this->assertEquals( array( $val1, $val2 ), array_pop( $argsvar1 ) ); + $this->assertSame( array( $val1, $val2 ), array_pop( $argsvar1 ) ); // $a2 should be called with one only. - $this->assertEquals( 1, $a2->get_call_count() ); + $this->assertSame( 1, $a2->get_call_count() ); $argsvar2 = $a2->get_args(); - $this->assertEquals( array( $val1 ), array_pop( $argsvar2 ) ); + $this->assertSame( array( $val1 ), array_pop( $argsvar2 ) ); // $a3 should be called with both args. - $this->assertEquals( 1, $a3->get_call_count() ); + $this->assertSame( 1, $a3->get_call_count() ); $argsvar3 = $a3->get_args(); - $this->assertEquals( array( $val1, $val2 ), array_pop( $argsvar3 ) ); + $this->assertSame( array( $val1, $val2 ), array_pop( $argsvar3 ) ); } /** @@ -181,7 +181,7 @@ class Tests_Actions extends WP_UnitTestCase { do_action( $tag ); // Two events, one per action. - $this->assertEquals( 2, $a->get_call_count() ); + $this->assertSame( 2, $a->get_call_count() ); $expected = array( // 'action2' is called first because it has priority 9. @@ -198,7 +198,7 @@ class Tests_Actions extends WP_UnitTestCase { ), ); - $this->assertEquals( $expected, $a->get_events() ); + $this->assertSame( $expected, $a->get_events() ); } function test_did_action() { @@ -207,8 +207,8 @@ class Tests_Actions extends WP_UnitTestCase { // Do action $tag1 but not $tag2. do_action( $tag1 ); - $this->assertEquals( 1, did_action( $tag1 ) ); - $this->assertEquals( 0, did_action( $tag2 ) ); + $this->assertSame( 1, did_action( $tag1 ) ); + $this->assertSame( 0, did_action( $tag2 ) ); // Do action $tag2 a random number of times. $count = rand( 0, 10 ); @@ -217,8 +217,8 @@ class Tests_Actions extends WP_UnitTestCase { } // $tag1's count hasn't changed, $tag2 should be correct. - $this->assertEquals( 1, did_action( $tag1 ) ); - $this->assertEquals( $count, did_action( $tag2 ) ); + $this->assertSame( 1, did_action( $tag1 ) ); + $this->assertSame( $count, did_action( $tag2 ) ); } @@ -229,7 +229,7 @@ class Tests_Actions extends WP_UnitTestCase { // Add an 'all' action. add_action( 'all', array( &$a, 'action' ) ); - $this->assertEquals( 10, has_filter( 'all', array( &$a, 'action' ) ) ); + $this->assertSame( 10, has_filter( 'all', array( &$a, 'action' ) ) ); // Do some actions. do_action( $tag1 ); do_action( $tag2 ); @@ -237,9 +237,9 @@ class Tests_Actions extends WP_UnitTestCase { do_action( $tag1 ); // Our action should have been called once for each tag. - $this->assertEquals( 4, $a->get_call_count() ); + $this->assertSame( 4, $a->get_call_count() ); // Only our hook was called. - $this->assertEquals( array( $tag1, $tag2, $tag1, $tag1 ), $a->get_tags() ); + $this->assertSame( array( $tag1, $tag2, $tag1, $tag1 ), $a->get_tags() ); remove_action( 'all', array( &$a, 'action' ) ); $this->assertFalse( has_filter( 'all', array( &$a, 'action' ) ) ); @@ -251,19 +251,19 @@ class Tests_Actions extends WP_UnitTestCase { $tag = __FUNCTION__; add_action( 'all', array( &$a, 'action' ) ); - $this->assertEquals( 10, has_filter( 'all', array( &$a, 'action' ) ) ); + $this->assertSame( 10, has_filter( 'all', array( &$a, 'action' ) ) ); do_action( $tag ); // Make sure our hook was called correctly. - $this->assertEquals( 1, $a->get_call_count() ); - $this->assertEquals( array( $tag ), $a->get_tags() ); + $this->assertSame( 1, $a->get_call_count() ); + $this->assertSame( array( $tag ), $a->get_tags() ); // Now remove the action, do it again, and make sure it's not called this time. remove_action( 'all', array( &$a, 'action' ) ); $this->assertFalse( has_filter( 'all', array( &$a, 'action' ) ) ); do_action( $tag ); - $this->assertEquals( 1, $a->get_call_count() ); - $this->assertEquals( array( $tag ), $a->get_tags() ); + $this->assertSame( 1, $a->get_call_count() ); + $this->assertSame( array( $tag ), $a->get_tags() ); } function test_action_ref_array() { @@ -312,7 +312,7 @@ class Tests_Actions extends WP_UnitTestCase { function test_action_self_removal() { add_action( 'test_action_self_removal', array( $this, 'action_self_removal' ) ); do_action( 'test_action_self_removal' ); - $this->assertEquals( 1, did_action( 'test_action_self_removal' ) ); + $this->assertSame( 1, did_action( 'test_action_self_removal' ) ); } function action_self_removal() { @@ -332,8 +332,8 @@ class Tests_Actions extends WP_UnitTestCase { add_action( $tag, array( $this, 'action_that_causes_recursion' ), 12, 1 ); do_action( $tag, $tag ); - $this->assertEquals( 2, $a->get_call_count(), 'recursive actions should call all callbacks with earlier priority' ); - $this->assertEquals( 2, $b->get_call_count(), 'recursive actions should call callbacks with later priority' ); + $this->assertSame( 2, $a->get_call_count(), 'recursive actions should call all callbacks with earlier priority' ); + $this->assertSame( 2, $b->get_call_count(), 'recursive actions should call callbacks with later priority' ); } function action_that_causes_recursion( $tag ) { @@ -364,11 +364,11 @@ class Tests_Actions extends WP_UnitTestCase { do_action( $tag, $tag, array( $a, $b, $c, $d, $e ) ); do_action( $tag, $tag, array( $a, $b, $c, $d, $e ) ); - $this->assertEquals( 2, $a->get_call_count(), 'callbacks should run unless otherwise instructed' ); - $this->assertEquals( 1, $b->get_call_count(), 'callback removed by same priority callback should still get called' ); - $this->assertEquals( 1, $c->get_call_count(), 'callback added by same priority callback should not get called' ); - $this->assertEquals( 2, $d->get_call_count(), 'callback added by earlier priority callback should get called' ); - $this->assertEquals( 1, $e->get_call_count(), 'callback added by later priority callback should not get called' ); + $this->assertSame( 2, $a->get_call_count(), 'callbacks should run unless otherwise instructed' ); + $this->assertSame( 1, $b->get_call_count(), 'callback removed by same priority callback should still get called' ); + $this->assertSame( 1, $c->get_call_count(), 'callback added by same priority callback should not get called' ); + $this->assertSame( 2, $d->get_call_count(), 'callback added by earlier priority callback should get called' ); + $this->assertSame( 1, $e->get_call_count(), 'callback added by later priority callback should not get called' ); } function action_that_manipulates_a_running_hook( $tag, $mocks ) { @@ -435,7 +435,7 @@ class Tests_Actions extends WP_UnitTestCase { 'accepted_args' => 1, ), ); - $this->assertEquals( 11, has_action( $tag, '__return_null' ) ); + $this->assertSame( 11, has_action( $tag, '__return_null' ) ); } /** @@ -448,7 +448,7 @@ class Tests_Actions extends WP_UnitTestCase { $wp_current_filter[] = 'first'; $wp_current_filter[] = 'second'; // Let's say a second action was invoked. - $this->assertEquals( 'second', current_action() ); + $this->assertSame( 'second', current_action() ); } /** @@ -498,7 +498,7 @@ class Tests_Actions extends WP_UnitTestCase { add_filter( 'testing', array( $this, 'apply_testing_filter' ) ); $this->assertTrue( has_action( 'testing' ) ); - $this->assertEquals( 10, has_action( 'testing', array( $this, 'apply_testing_filter' ) ) ); + $this->assertSame( 10, has_action( 'testing', array( $this, 'apply_testing_filter' ) ) ); apply_filters( 'testing', '' ); @@ -519,7 +519,7 @@ class Tests_Actions extends WP_UnitTestCase { add_filter( 'testing_nested', array( $this, 'apply_testing_nested_filter' ) ); $this->assertTrue( has_action( 'testing_nested' ) ); - $this->assertEquals( 10, has_action( 'testing_nested', array( $this, 'apply_testing_nested_filter' ) ) ); + $this->assertSame( 10, has_action( 'testing_nested', array( $this, 'apply_testing_nested_filter' ) ) ); apply_filters( 'testing_nested', '' ); diff --git a/tests/phpunit/tests/actions/callbacks.php b/tests/phpunit/tests/actions/callbacks.php index 41db3dac3a..fc58c33906 100644 --- a/tests/phpunit/tests/actions/callbacks.php +++ b/tests/phpunit/tests/actions/callbacks.php @@ -15,8 +15,8 @@ class Tests_Actions_Callbacks extends WP_UnitTestCase { add_action( $tag, array( 'Class', 'method' ) ); - $this->assertEquals( 10, has_action( $tag, array( 'Class', 'method' ) ) ); + $this->assertSame( 10, has_action( $tag, array( 'Class', 'method' ) ) ); - $this->assertEquals( 10, has_action( $tag, 'Class::method' ) ); + $this->assertSame( 10, has_action( $tag, 'Class::method' ) ); } } diff --git a/tests/phpunit/tests/admin/includesCommunityEvents.php b/tests/phpunit/tests/admin/includesCommunityEvents.php index 2145431336..4dec1dbf27 100644 --- a/tests/phpunit/tests/admin/includesCommunityEvents.php +++ b/tests/phpunit/tests/admin/includesCommunityEvents.php @@ -164,8 +164,8 @@ class Test_WP_Community_Events extends WP_UnitTestCase { $this->assertNotWPError( $response ); $this->assertEqualSetsWithIndex( $this->get_user_location(), $response['location'] ); - $this->assertEquals( gmdate( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $response['events'][0]['formatted_date'] ); - $this->assertEquals( '1:00 pm', $response['events'][0]['formatted_time'] ); + $this->assertSame( gmdate( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $response['events'][0]['formatted_date'] ); + $this->assertSame( '1:00 pm', $response['events'][0]['formatted_time'] ); remove_filter( 'pre_http_request', array( $this, '_http_request_valid_response' ) ); } @@ -185,8 +185,8 @@ class Test_WP_Community_Events extends WP_UnitTestCase { $this->assertNotWPError( $cached_events ); $this->assertEqualSetsWithIndex( $this->get_user_location(), $cached_events['location'] ); - $this->assertEquals( gmdate( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $cached_events['events'][0]['formatted_date'] ); - $this->assertEquals( '1:00 pm', $cached_events['events'][0]['formatted_time'] ); + $this->assertSame( gmdate( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $cached_events['events'][0]['formatted_date'] ); + $this->assertSame( '1:00 pm', $cached_events['events'][0]['formatted_time'] ); remove_filter( 'pre_http_request', array( $this, '_http_request_valid_response' ) ); } @@ -273,9 +273,9 @@ class Test_WP_Community_Events extends WP_UnitTestCase { * so that it remains in the list. The other events should remain unchanged. */ $this->assertCount( 3, $response_body['events'] ); - $this->assertEquals( $response_body['events'][0]['title'], 'Flexbox + CSS Grid: Magic for Responsive Layouts' ); - $this->assertEquals( $response_body['events'][1]['title'], 'Part 3- Site Maintenance - Tools to Make It Easy' ); - $this->assertEquals( $response_body['events'][2]['title'], 'WordCamp San Diego' ); + $this->assertSame( $response_body['events'][0]['title'], 'Flexbox + CSS Grid: Magic for Responsive Layouts' ); + $this->assertSame( $response_body['events'][1]['title'], 'Part 3- Site Maintenance - Tools to Make It Easy' ); + $this->assertSame( $response_body['events'][2]['title'], 'WordCamp San Diego' ); remove_filter( 'pre_http_request', array( $this, '_http_request_valid_response_unpinned_wordcamp' ) ); } @@ -375,9 +375,9 @@ class Test_WP_Community_Events extends WP_UnitTestCase { * WordCamp LA should not be stuck to the list, because San Diego already appears naturally. */ $this->assertCount( 3, $response_body['events'] ); - $this->assertEquals( $response_body['events'][0]['title'], 'WordCamp San Diego' ); - $this->assertEquals( $response_body['events'][1]['title'], 'Part 3- Site Maintenance - Tools to Make It Easy' ); - $this->assertEquals( $response_body['events'][2]['title'], 'WordPress Q&A' ); + $this->assertSame( $response_body['events'][0]['title'], 'WordCamp San Diego' ); + $this->assertSame( $response_body['events'][1]['title'], 'Part 3- Site Maintenance - Tools to Make It Easy' ); + $this->assertSame( $response_body['events'][2]['title'], 'WordPress Q&A' ); remove_filter( 'pre_http_request', array( $this, '_http_request_valid_response_multiple_wordcamps' ) ); } @@ -488,7 +488,7 @@ class Test_WP_Community_Events extends WP_UnitTestCase { $_SERVER['HTTP_CLIENT_IP'] = $raw_ip; $actual_result = WP_Community_Events::get_unsafe_client_ip(); - $this->assertEquals( $expected_result, $actual_result ); + $this->assertSame( $expected_result, $actual_result ); } /** diff --git a/tests/phpunit/tests/admin/includesFile.php b/tests/phpunit/tests/admin/includesFile.php index 70c8fab1ab..a3af5da2d1 100644 --- a/tests/phpunit/tests/admin/includesFile.php +++ b/tests/phpunit/tests/admin/includesFile.php @@ -13,19 +13,19 @@ class Tests_Admin_includesFile extends WP_UnitTestCase { $home = get_option( 'home' ); $siteurl = get_option( 'siteurl' ); $sfn = $_SERVER['SCRIPT_FILENAME']; - $this->assertEquals( str_replace( '\\', '/', ABSPATH ), get_home_path() ); + $this->assertSame( str_replace( '\\', '/', ABSPATH ), get_home_path() ); update_option( 'home', 'http://localhost' ); update_option( 'siteurl', 'http://localhost/wp' ); $_SERVER['SCRIPT_FILENAME'] = 'D:\root\vhosts\site\httpdocs\wp\wp-admin\options-permalink.php'; - $this->assertEquals( 'D:/root/vhosts/site/httpdocs/', get_home_path() ); + $this->assertSame( 'D:/root/vhosts/site/httpdocs/', get_home_path() ); $_SERVER['SCRIPT_FILENAME'] = '/Users/foo/public_html/trunk/wp/wp-admin/options-permalink.php'; - $this->assertEquals( '/Users/foo/public_html/trunk/', get_home_path() ); + $this->assertSame( '/Users/foo/public_html/trunk/', get_home_path() ); $_SERVER['SCRIPT_FILENAME'] = 'S:/home/wordpress/trunk/wp/wp-admin/options-permalink.php'; - $this->assertEquals( 'S:/home/wordpress/trunk/', get_home_path() ); + $this->assertSame( 'S:/home/wordpress/trunk/', get_home_path() ); update_option( 'home', $home ); update_option( 'siteurl', $siteurl ); @@ -40,7 +40,7 @@ class Tests_Admin_includesFile extends WP_UnitTestCase { $error = download_url( 'test_download_url_non_200' ); $this->assertWPError( $error ); - $this->assertEquals( + $this->assertSame( array( 'code' => 418, 'body' => 'This is an unexpected error message from your favorite server.', @@ -52,7 +52,7 @@ class Tests_Admin_includesFile extends WP_UnitTestCase { $error = download_url( 'test_download_url_non_200' ); $this->assertWPError( $error ); - $this->assertEquals( + $this->assertSame( array( 'code' => 418, 'body' => 'This ', diff --git a/tests/phpunit/tests/admin/includesMisc.php b/tests/phpunit/tests/admin/includesMisc.php index 47db6a3746..93951af4e5 100644 --- a/tests/phpunit/tests/admin/includesMisc.php +++ b/tests/phpunit/tests/admin/includesMisc.php @@ -20,7 +20,7 @@ class Tests_Admin_includesMisc extends WP_UnitTestCase { => 'wordpress.org/about/philosophy/#…', // Shorten to 32 if > 35 after cleaning. ); foreach ( $tests as $k => $v ) { - $this->assertEquals( $v, url_shorten( $k ) ); + $this->assertSame( $v, url_shorten( $k ) ); } } } diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php index 1c9d0f8254..310173b27a 100644 --- a/tests/phpunit/tests/admin/includesPlugin.php +++ b/tests/phpunit/tests/admin/includesPlugin.php @@ -23,7 +23,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { foreach ( $default_headers as $name => $value ) { $this->assertTrue( isset( $data[ $name ] ) ); - $this->assertEquals( $value, $data[ $name ] ); + $this->assertSame( $value, $data[ $name ] ); } } @@ -51,7 +51,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { $expected['testpages'] = 'http://example.com/wp-admin/edit.php?post_type=page&page=testpages'; foreach ( $expected as $name => $value ) { - $this->assertEquals( $value, menu_page_url( $name, false ) ); + $this->assertSame( $value, menu_page_url( $name, false ) ); } wp_set_current_user( $current_user ); @@ -349,7 +349,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { */ public function test_get_plugin_files_single() { $name = 'hello.php'; - $this->assertEquals( array( $name ), get_plugin_files( $name ) ); + $this->assertSame( array( $name ), get_plugin_files( $name ) ); } /** @@ -369,7 +369,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { 'list_files_test_plugin/list_files_test_plugin.php', 'list_files_test_plugin/subdir/subfile.php', ); - $this->assertEquals( $expected, $plugin_files ); + $this->assertSame( $expected, $plugin_files ); unlink( $sub_dir . '/subfile.php' ); unlink( $plugin[1] ); @@ -389,7 +389,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { mkdir( WPMU_PLUGIN_DIR ); } - $this->assertEquals( array(), get_mu_plugins() ); + $this->assertSame( array(), get_mu_plugins() ); // Clean up. if ( $exists ) { @@ -410,7 +410,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { rmdir( WPMU_PLUGIN_DIR ); } - $this->assertEquals( array(), get_mu_plugins() ); + $this->assertSame( array(), get_mu_plugins() ); // Clean up. if ( $exists ) { @@ -432,7 +432,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { } $this->_create_plugin( 'assertEquals( array(), get_mu_plugins() ); + $this->assertSame( array(), get_mu_plugins() ); // Clean up. unlink( WPMU_PLUGIN_DIR . '/index.php' ); @@ -457,7 +457,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { $this->_create_plugin( 'assertEquals( array( 'index.php' ), array_keys( $found ) ); + $this->assertSame( array( 'index.php' ), array_keys( $found ) ); // Clean up. unlink( WPMU_PLUGIN_DIR . '/index.php' ); @@ -483,7 +483,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { $this->_create_plugin( '_create_plugin( 'assertEquals( array( 'foo.php' ), array_keys( $found ) ); + $this->assertSame( array( 'foo.php' ), array_keys( $found ) ); // Clean up. unlink( WPMU_PLUGIN_DIR . '/foo.php' ); @@ -501,7 +501,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { public function test__sort_uname_callback() { $this->assertLessThan( 0, _sort_uname_callback( array( 'Name' => 'a' ), array( 'Name' => 'b' ) ) ); $this->assertGreaterThan( 0, _sort_uname_callback( array( 'Name' => 'c' ), array( 'Name' => 'b' ) ) ); - $this->assertEquals( 0, _sort_uname_callback( array( 'Name' => 'a' ), array( 'Name' => 'a' ) ) ); + $this->assertSame( 0, _sort_uname_callback( array( 'Name' => 'a' ), array( 'Name' => 'a' ) ) ); } /** @@ -510,7 +510,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { public function test_get_dropins_empty() { $this->_back_up_drop_ins(); - $this->assertEquals( array(), get_dropins() ); + $this->assertSame( array(), get_dropins() ); // Clean up. $this->_restore_drop_ins(); @@ -526,7 +526,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { $p2 = $this->_create_plugin( "assertEquals( array( 'advanced-cache.php' ), array_keys( $dropins ) ); + $this->assertSame( array( 'advanced-cache.php' ), array_keys( $dropins ) ); unlink( $p1[1] ); unlink( $p2[1] ); @@ -590,7 +590,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase { * @covers ::validate_active_plugins */ public function test_validate_active_plugins_empty() { - $this->assertEquals( array(), validate_active_plugins() ); + $this->assertSame( array(), validate_active_plugins() ); } /** diff --git a/tests/phpunit/tests/admin/includesPost.php b/tests/phpunit/tests/admin/includesPost.php index 155dd0e326..fcb74ced2d 100644 --- a/tests/phpunit/tests/admin/includesPost.php +++ b/tests/phpunit/tests/admin/includesPost.php @@ -37,8 +37,8 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { $_results = _wp_translate_postdata( false, $_post_data ); $this->assertNotWPError( $_results ); - $this->assertEquals( $_post_data['post_author'], $_results['post_author'] ); - $this->assertEquals( 'draft', $_results['post_status'] ); + $this->assertSame( $_post_data['post_author'], $_results['post_author'] ); + $this->assertSame( 'draft', $_results['post_status'] ); // Submit post for approval. $_post_data = array(); @@ -48,8 +48,8 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { $_results = _wp_translate_postdata( false, $_post_data ); $this->assertNotWPError( $_results ); - $this->assertEquals( $_post_data['post_author'], $_results['post_author'] ); - $this->assertEquals( 'pending', $_results['post_status'] ); + $this->assertSame( $_post_data['post_author'], $_results['post_author'] ); + $this->assertSame( 'pending', $_results['post_status'] ); // Create new draft post for another user. $_post_data = array(); @@ -59,8 +59,8 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { $_results = _wp_translate_postdata( false, $_post_data ); $this->assertInstanceOf( 'WP_Error', $_results ); - $this->assertEquals( 'edit_others_posts', $_results->get_error_code() ); - $this->assertEquals( 'Sorry, you are not allowed to create posts as this user.', $_results->get_error_message() ); + $this->assertSame( 'edit_others_posts', $_results->get_error_code() ); + $this->assertSame( 'Sorry, you are not allowed to create posts as this user.', $_results->get_error_message() ); // Edit draft post for another user. $_post_data = array(); @@ -72,8 +72,8 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { $_results = _wp_translate_postdata( true, $_post_data ); $this->assertInstanceOf( 'WP_Error', $_results ); - $this->assertEquals( 'edit_others_posts', $_results->get_error_code() ); - $this->assertEquals( 'Sorry, you are not allowed to edit posts as this user.', $_results->get_error_message() ); + $this->assertSame( 'edit_others_posts', $_results->get_error_code() ); + $this->assertSame( 'Sorry, you are not allowed to edit posts as this user.', $_results->get_error_message() ); } function test__wp_translate_postdata_cap_checks_editor() { @@ -87,8 +87,8 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { $_results = _wp_translate_postdata( false, $_post_data ); $this->assertNotWPError( $_results ); - $this->assertEquals( $_post_data['post_author'], $_results['post_author'] ); - $this->assertEquals( 'draft', $_results['post_status'] ); + $this->assertSame( $_post_data['post_author'], $_results['post_author'] ); + $this->assertSame( 'draft', $_results['post_status'] ); // Publish post. $_post_data = array(); @@ -98,8 +98,8 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { $_results = _wp_translate_postdata( false, $_post_data ); $this->assertNotWPError( $_results ); - $this->assertEquals( $_post_data['post_author'], $_results['post_author'] ); - $this->assertEquals( 'publish', $_results['post_status'] ); + $this->assertSame( $_post_data['post_author'], $_results['post_author'] ); + $this->assertSame( 'publish', $_results['post_status'] ); // Create new draft post for another user. $_post_data = array(); @@ -109,8 +109,8 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { $_results = _wp_translate_postdata( false, $_post_data ); $this->assertNotWPError( $_results ); - $this->assertEquals( $_post_data['post_author'], $_results['post_author'] ); - $this->assertEquals( 'draft', $_results['post_status'] ); + $this->assertSame( $_post_data['post_author'], $_results['post_author'] ); + $this->assertSame( 'draft', $_results['post_status'] ); // Edit draft post for another user. $_post_data = array(); @@ -122,8 +122,8 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { $_results = _wp_translate_postdata( true, $_post_data ); $this->assertNotWPError( $_results ); - $this->assertEquals( $_post_data['post_author'], $_results['post_author'] ); - $this->assertEquals( 'draft', $_results['post_status'] ); + $this->assertSame( $_post_data['post_author'], $_results['post_author'] ); + $this->assertSame( 'draft', $_results['post_status'] ); } /** @@ -134,7 +134,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { function test_edit_post_auto_draft() { wp_set_current_user( self::$editor_id ); $post = self::factory()->post->create_and_get( array( 'post_status' => 'auto-draft' ) ); - $this->assertEquals( 'auto-draft', $post->post_status ); + $this->assertSame( 'auto-draft', $post->post_status ); $post_data = array( 'post_title' => 'Post title', 'content' => 'Post content', @@ -142,7 +142,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { 'post_ID' => $post->ID, ); edit_post( $post_data ); - $this->assertEquals( 'draft', get_post( $post->ID )->post_status ); + $this->assertSame( 'draft', get_post( $post->ID )->post_status ); } /** @@ -252,10 +252,10 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { $post = get_post( $post2 ); // Check that the first post's values don't stomp the second post. - $this->assertEquals( 'draft', $post->post_status ); + $this->assertSame( 'draft', $post->post_status ); $this->assertEquals( self::$author_ids[1], $post->post_author ); - $this->assertEquals( 'closed', $post->comment_status ); - $this->assertEquals( 'closed', $post->ping_status ); + $this->assertSame( 'closed', $post->comment_status ); + $this->assertSame( 'closed', $post->ping_status ); } /** @@ -314,7 +314,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { public function check_post_format( $post_id ) { if ( self::$post_id === $post_id ) { - $this->assertEquals( 'aside', get_post_format( $post_id ) ); + $this->assertSame( 'aside', get_post_format( $post_id ) ); } } @@ -538,7 +538,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { ); $found = get_sample_permalink( $p ); - $this->assertEquals( '2015-2', $found[1] ); + $this->assertSame( '2015-2', $found[1] ); } /** @@ -554,7 +554,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { ); $found = get_sample_permalink( $p ); - $this->assertEquals( '2015', $found[1] ); + $this->assertSame( '2015', $found[1] ); } /** @@ -570,7 +570,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { ); $found = get_sample_permalink( $p ); - $this->assertEquals( '11-2', $found[1] ); + $this->assertSame( '11-2', $found[1] ); } /** @@ -586,7 +586,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { ); $found = get_sample_permalink( $p ); - $this->assertEquals( '13', $found[1] ); + $this->assertSame( '13', $found[1] ); } /** @@ -602,7 +602,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { ); $found = get_sample_permalink( $p ); - $this->assertEquals( '30-2', $found[1] ); + $this->assertSame( '30-2', $found[1] ); } /** @@ -624,7 +624,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { ); $found = get_sample_permalink( $p ); - $this->assertEquals( '30-3', $found[1] ); + $this->assertSame( '30-3', $found[1] ); } /** @@ -640,7 +640,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { ); $found = get_sample_permalink( $p ); - $this->assertEquals( '32', $found[1] ); + $this->assertSame( '32', $found[1] ); } /** @@ -656,7 +656,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { ); $found = get_sample_permalink( $p ); - $this->assertEquals( '30', $found[1] ); + $this->assertSame( '30', $found[1] ); } /** @@ -825,8 +825,8 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { function test_get_block_editor_server_block_settings() { $name = 'core/test'; $settings = array( - 'category' => 'common', 'icon' => 'text', + 'category' => 'common', 'render_callback' => 'foo', ); @@ -837,12 +837,12 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { unregister_block_type( $name ); $this->assertArrayHasKey( $name, $blocks ); - $this->assertEquals( + $this->assertSame( array( 'title' => '', 'description' => '', - 'category' => 'common', 'icon' => 'text', + 'category' => 'common', 'keywords' => array(), 'usesContext' => array(), 'styles' => array(), @@ -865,7 +865,7 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase { wp_set_current_user( self::$admin_id ); $this->assertNotFalse( add_meta( $p ) ); - $this->assertEquals( '', get_post_meta( $p, 'testkey', true ) ); + $this->assertSame( '', get_post_meta( $p, 'testkey', true ) ); } /** diff --git a/tests/phpunit/tests/admin/includesSchema.php b/tests/phpunit/tests/admin/includesSchema.php index 4fec944459..d770128bf3 100644 --- a/tests/phpunit/tests/admin/includesSchema.php +++ b/tests/phpunit/tests/admin/includesSchema.php @@ -110,7 +110,7 @@ class Tests_Admin_Includes_Schema extends WP_UnitTestCase { $wpdb->options = $orig_options; - $this->assertEquals( $expected, $results ); + $this->assertSame( $expected, $results ); } public function data_populate_options() { @@ -119,8 +119,8 @@ class Tests_Admin_Includes_Schema extends WP_UnitTestCase { array(), array( // Random options to check. - 'posts_per_rss' => 10, - 'rss_use_excerpt' => 0, + 'posts_per_rss' => '10', + 'rss_use_excerpt' => '0', 'mailserver_url' => 'mail.example.com', 'mailserver_login' => 'login@example.com', 'mailserver_pass' => 'password', @@ -128,13 +128,13 @@ class Tests_Admin_Includes_Schema extends WP_UnitTestCase { ), array( array( - 'posts_per_rss' => 7, - 'rss_use_excerpt' => 1, + 'posts_per_rss' => '7', + 'rss_use_excerpt' => '1', ), array( // Random options to check. - 'posts_per_rss' => 7, - 'rss_use_excerpt' => 1, + 'posts_per_rss' => '7', + 'rss_use_excerpt' => '1', 'mailserver_url' => 'mail.example.com', 'mailserver_login' => 'login@example.com', 'mailserver_pass' => 'password', @@ -147,8 +147,8 @@ class Tests_Admin_Includes_Schema extends WP_UnitTestCase { array( // Random options to check. 'custom_option' => '1', - 'posts_per_rss' => 10, - 'rss_use_excerpt' => 0, + 'posts_per_rss' => '10', + 'rss_use_excerpt' => '0', 'mailserver_url' => 'mail.example.com', 'mailserver_login' => 'login@example.com', 'mailserver_pass' => 'password', @@ -200,7 +200,7 @@ class Tests_Admin_Includes_Schema extends WP_UnitTestCase { $wpdb->blogmeta = $orig_blogmeta; - $this->assertEquals( $expected, $results ); + $this->assertSame( $expected, $results ); } public function data_populate_site_meta() { @@ -248,7 +248,7 @@ class Tests_Admin_Includes_Schema extends WP_UnitTestCase { $wpdb->sitemeta = $orig_sitemeta; - $this->assertEquals( $expected, $results ); + $this->assertSame( $expected, $results ); } public function data_populate_network_meta() { @@ -258,8 +258,8 @@ class Tests_Admin_Includes_Schema extends WP_UnitTestCase { array( // Random meta to check. 'registration' => 'none', - 'blog_upload_space' => 100, - 'fileupload_maxk' => 1500, + 'blog_upload_space' => '100', + 'fileupload_maxk' => '1500', ), ), array( @@ -271,8 +271,8 @@ class Tests_Admin_Includes_Schema extends WP_UnitTestCase { // Random meta to check. 'site_name' => 'My Great Network', 'registration' => 'none', - 'blog_upload_space' => 100, - 'fileupload_maxk' => 1500, + 'blog_upload_space' => '100', + 'fileupload_maxk' => '1500', 'WPLANG' => 'fr_FR', ), ), @@ -284,8 +284,8 @@ class Tests_Admin_Includes_Schema extends WP_UnitTestCase { // Random meta to check. 'custom_meta' => '1', 'registration' => 'none', - 'blog_upload_space' => 100, - 'fileupload_maxk' => 1500, + 'blog_upload_space' => '100', + 'fileupload_maxk' => '1500', ), ), ); diff --git a/tests/phpunit/tests/admin/includesScreen.php b/tests/phpunit/tests/admin/includesScreen.php index 56013dfee6..16e4c68d8b 100644 --- a/tests/phpunit/tests/admin/includesScreen.php +++ b/tests/phpunit/tests/admin/includesScreen.php @@ -203,18 +203,18 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { $GLOBALS['hook_suffix'] = $hook['path']; set_current_screen(); - $this->assertEquals( $screen->id, $current_screen->id, $hook_name ); - $this->assertEquals( $screen->base, $current_screen->base, $hook_name ); + $this->assertSame( $screen->id, $current_screen->id, $hook_name ); + $this->assertSame( $screen->base, $current_screen->base, $hook_name ); if ( isset( $screen->action ) ) { - $this->assertEquals( $screen->action, $current_screen->action, $hook_name ); + $this->assertSame( $screen->action, $current_screen->action, $hook_name ); } if ( isset( $screen->post_type ) ) { - $this->assertEquals( $screen->post_type, $current_screen->post_type, $hook_name ); + $this->assertSame( $screen->post_type, $current_screen->post_type, $hook_name ); } else { $this->assertEmpty( $current_screen->post_type, $hook_name ); } if ( isset( $screen->taxonomy ) ) { - $this->assertEquals( $screen->taxonomy, $current_screen->taxonomy, $hook_name ); + $this->assertSame( $screen->taxonomy, $current_screen->taxonomy, $hook_name ); } $this->assertTrue( $current_screen->in_admin() ); @@ -237,48 +237,48 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { function test_post_type_as_hookname() { $screen = convert_to_screen( 'page' ); - $this->assertEquals( $screen->post_type, 'page' ); - $this->assertEquals( $screen->base, 'post' ); - $this->assertEquals( $screen->id, 'page' ); + $this->assertSame( $screen->post_type, 'page' ); + $this->assertSame( $screen->base, 'post' ); + $this->assertSame( $screen->id, 'page' ); $this->assertTrue( $screen->is_block_editor ); } function test_post_type_with_special_suffix_as_hookname() { register_post_type( 'value-add' ); $screen = convert_to_screen( 'value-add' ); // The '-add' part is key. - $this->assertEquals( $screen->post_type, 'value-add' ); - $this->assertEquals( $screen->base, 'post' ); - $this->assertEquals( $screen->id, 'value-add' ); + $this->assertSame( $screen->post_type, 'value-add' ); + $this->assertSame( $screen->base, 'post' ); + $this->assertSame( $screen->id, 'value-add' ); $this->assertFalse( $screen->is_block_editor ); // Post types do not support `show_in_rest` by default. $screen = convert_to_screen( 'edit-value-add' ); // The '-add' part is key. - $this->assertEquals( $screen->post_type, 'value-add' ); - $this->assertEquals( $screen->base, 'edit' ); - $this->assertEquals( $screen->id, 'edit-value-add' ); + $this->assertSame( $screen->post_type, 'value-add' ); + $this->assertSame( $screen->base, 'edit' ); + $this->assertSame( $screen->id, 'edit-value-add' ); $this->assertFalse( $screen->is_block_editor ); // Post types do not support `show_in_rest` by default. } function test_taxonomy_with_special_suffix_as_hookname() { register_taxonomy( 'old-or-new', 'post' ); $screen = convert_to_screen( 'edit-old-or-new' ); // The '-new' part is key. - $this->assertEquals( $screen->taxonomy, 'old-or-new' ); - $this->assertEquals( $screen->base, 'edit-tags' ); - $this->assertEquals( $screen->id, 'edit-old-or-new' ); + $this->assertSame( $screen->taxonomy, 'old-or-new' ); + $this->assertSame( $screen->base, 'edit-tags' ); + $this->assertSame( $screen->id, 'edit-old-or-new' ); $this->assertFalse( $screen->is_block_editor ); } function test_post_type_with_edit_prefix() { register_post_type( 'edit-some-thing' ); $screen = convert_to_screen( 'edit-some-thing' ); - $this->assertEquals( $screen->post_type, 'edit-some-thing' ); - $this->assertEquals( $screen->base, 'post' ); - $this->assertEquals( $screen->id, 'edit-some-thing' ); + $this->assertSame( $screen->post_type, 'edit-some-thing' ); + $this->assertSame( $screen->base, 'post' ); + $this->assertSame( $screen->id, 'edit-some-thing' ); $this->assertFalse( $screen->is_block_editor ); // Post types do not support `show_in_rest` by default. $screen = convert_to_screen( 'edit-edit-some-thing' ); - $this->assertEquals( $screen->post_type, 'edit-some-thing' ); - $this->assertEquals( $screen->base, 'edit' ); - $this->assertEquals( $screen->id, 'edit-edit-some-thing' ); + $this->assertSame( $screen->post_type, 'edit-some-thing' ); + $this->assertSame( $screen->base, 'edit' ); + $this->assertSame( $screen->id, 'edit-edit-some-thing' ); $this->assertFalse( $screen->is_block_editor ); // Post types do not support `show_in_rest` by default. } @@ -288,36 +288,36 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { // Sorry, core wins here. $screen = convert_to_screen( 'edit-comments' ); - $this->assertEquals( $screen->base, 'edit-comments' ); + $this->assertSame( $screen->base, 'edit-comments' ); // The post type wins here. convert_to_screen( $post_type ) is only relevant for meta boxes anyway. $screen = convert_to_screen( 'comments' ); - $this->assertEquals( $screen->base, 'post' ); + $this->assertSame( $screen->base, 'post' ); // Core wins. $screen = convert_to_screen( 'edit-tags' ); - $this->assertEquals( $screen->base, 'edit-tags' ); + $this->assertSame( $screen->base, 'edit-tags' ); $screen = convert_to_screen( 'tags' ); - $this->assertEquals( $screen->base, 'post' ); + $this->assertSame( $screen->base, 'post' ); } function test_help_tabs() { $tab = __FUNCTION__; $tab_args = array( - 'id' => $tab, 'title' => 'Help!', + 'id' => $tab, 'content' => 'Some content', 'callback' => false, ); $screen = get_current_screen(); $screen->add_help_tab( $tab_args ); - $this->assertEquals( + $this->assertSame( $screen->get_help_tab( $tab ), array( - 'id' => $tab, 'title' => 'Help!', + 'id' => $tab, 'content' => 'Some content', 'callback' => false, 'priority' => 10, @@ -331,7 +331,7 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { $this->assertNull( $screen->get_help_tab( $tab ) ); $screen->remove_help_tabs(); - $this->assertEquals( $screen->get_help_tabs(), array() ); + $this->assertSame( $screen->get_help_tabs(), array() ); } /** @@ -380,18 +380,18 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { $this->assertequals( $screen->get_help_tab( $tab_1 ), $tab_1_args ); $screen->add_help_tab( $tab_2_args ); - $this->assertEquals( $screen->get_help_tab( $tab_2 ), $tab_2_args ); + $this->assertSame( $screen->get_help_tab( $tab_2 ), $tab_2_args ); $screen->add_help_tab( $tab_3_args ); - $this->assertEquals( $screen->get_help_tab( $tab_3 ), $tab_3_args ); + $this->assertSame( $screen->get_help_tab( $tab_3 ), $tab_3_args ); $screen->add_help_tab( $tab_4_args ); // Priority is added with the default for future calls. $tab_4_args['priority'] = 10; - $this->assertEquals( $screen->get_help_tab( $tab_4 ), $tab_4_args ); + $this->assertSame( $screen->get_help_tab( $tab_4 ), $tab_4_args ); $tabs = $screen->get_help_tabs(); - $this->assertEquals( 4, count( $tabs ) ); + $this->assertSame( 4, count( $tabs ) ); $this->assertArrayHasKey( $tab_1, $tabs ); $this->assertArrayHasKey( $tab_2, $tabs ); $this->assertArrayHasKey( $tab_3, $tabs ); @@ -426,7 +426,7 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { $this->assertSame( 0, count( $screen->get_help_tabs() ) ); $screen->remove_help_tabs(); - $this->assertEquals( array(), $screen->get_help_tabs() ); + $this->assertSame( array(), $screen->get_help_tabs() ); } /** @@ -443,7 +443,7 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { $screen = get_current_screen(); $screen->add_option( $option, $option_args ); - $this->assertEquals( $screen->get_option( $option ), $option_args ); + $this->assertSame( $screen->get_option( $option ), $option_args ); $options = $screen->get_options(); $this->assertArrayHasKey( $option, $options ); @@ -452,7 +452,7 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { $this->assertNull( $screen->get_option( $option ) ); $screen->remove_options(); - $this->assertEquals( $screen->get_options(), array() ); + $this->assertSame( $screen->get_options(), array() ); } function test_in_admin() { diff --git a/tests/phpunit/tests/admin/includesTheme.php b/tests/phpunit/tests/admin/includesTheme.php index 9e8354c36e..20a3e278b6 100644 --- a/tests/phpunit/tests/admin/includesTheme.php +++ b/tests/phpunit/tests/admin/includesTheme.php @@ -95,7 +95,7 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase { ), get_page_templates( null, 'post' ) ); - $this->assertEquals( array(), get_page_templates( null, 'bar' ) ); + $this->assertSame( array(), get_page_templates( null, 'bar' ) ); } /** @@ -166,7 +166,7 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase { get_page_templates() ); - $this->assertEquals( array(), get_page_templates( null, 'bar' ) ); + $this->assertSame( array(), get_page_templates( null, 'bar' ) ); } /** diff --git a/tests/phpunit/tests/adminbar.php b/tests/phpunit/tests/adminbar.php index 27f8c1ffac..760a1dec4c 100644 --- a/tests/phpunit/tests/adminbar.php +++ b/tests/phpunit/tests/adminbar.php @@ -43,7 +43,7 @@ class Tests_AdminBar extends WP_UnitTestCase { $nodes = $admin_bar->get_nodes(); $this->assertFalse( $nodes['new-content']->parent ); - $this->assertEquals( 'new-content', $nodes['add-new-content']->parent ); + $this->assertSame( 'new-content', $nodes['add-new-content']->parent ); _unregister_post_type( 'content' ); } @@ -64,7 +64,7 @@ class Tests_AdminBar extends WP_UnitTestCase { ); $node1 = $admin_bar->get_node( 'test-node' ); - $this->assertEquals( array( 'class' => 'test-class' ), $node1->meta ); + $this->assertSame( array( 'class' => 'test-class' ), $node1->meta ); $admin_bar->add_node( array( @@ -74,7 +74,7 @@ class Tests_AdminBar extends WP_UnitTestCase { ); $node2 = $admin_bar->get_node( 'test-node' ); - $this->assertEquals( + $this->assertSame( array( 'class' => 'test-class', 'some-meta' => 'value', @@ -100,7 +100,7 @@ class Tests_AdminBar extends WP_UnitTestCase { $node_edit_profile = $wp_admin_bar->get_node( 'edit-profile' ); // Site menu points to the home page instead of the admin URL. - $this->assertEquals( home_url( '/' ), $node_site_name->href ); + $this->assertSame( home_url( '/' ), $node_site_name->href ); // No profile links as the user doesn't have any permissions on the site. $this->assertFalse( $node_my_account->href ); @@ -125,14 +125,14 @@ class Tests_AdminBar extends WP_UnitTestCase { $node_edit_profile = $wp_admin_bar->get_node( 'edit-profile' ); // Site menu points to the admin URL. - $this->assertEquals( admin_url( '/' ), $node_site_name->href ); + $this->assertSame( admin_url( '/' ), $node_site_name->href ); $profile_url = admin_url( 'profile.php' ); // Profile URLs point to profile.php. - $this->assertEquals( $profile_url, $node_my_account->href ); - $this->assertEquals( $profile_url, $node_user_info->href ); - $this->assertEquals( $profile_url, $node_edit_profile->href ); + $this->assertSame( $profile_url, $node_my_account->href ); + $this->assertSame( $profile_url, $node_user_info->href ); + $this->assertSame( $profile_url, $node_edit_profile->href ); } /** @@ -177,9 +177,9 @@ class Tests_AdminBar extends WP_UnitTestCase { $this->assertNotEquals( $primary_profile_url, admin_url( 'profile.php' ) ); // Profile URLs should go to the user's primary blog. - $this->assertEquals( $primary_profile_url, $node_my_account->href ); - $this->assertEquals( $primary_profile_url, $node_user_info->href ); - $this->assertEquals( $primary_profile_url, $node_edit_profile->href ); + $this->assertSame( $primary_profile_url, $node_my_account->href ); + $this->assertSame( $primary_profile_url, $node_user_info->href ); + $this->assertSame( $primary_profile_url, $node_edit_profile->href ); restore_current_blog(); } @@ -232,9 +232,9 @@ class Tests_AdminBar extends WP_UnitTestCase { $this->assertNotEquals( $user_profile_url, admin_url( 'profile.php' ) ); // Profile URLs should go to the user's primary blog. - $this->assertEquals( $user_profile_url, $node_my_account->href ); - $this->assertEquals( $user_profile_url, $node_user_info->href ); - $this->assertEquals( $user_profile_url, $node_edit_profile->href ); + $this->assertSame( $user_profile_url, $node_my_account->href ); + $this->assertSame( $user_profile_url, $node_user_info->href ); + $this->assertSame( $user_profile_url, $node_edit_profile->href ); restore_current_blog(); } @@ -463,7 +463,7 @@ class Tests_AdminBar extends WP_UnitTestCase { $about_node = $wp_admin_bar->get_node( 'about' ); $this->assertNotNull( $wp_logo_node ); - $this->assertSame( false, $wp_logo_node->href ); + $this->assertFalse( $wp_logo_node->href ); $this->assertArrayHasKey( 'tabindex', $wp_logo_node->meta ); $this->assertSame( 0, $wp_logo_node->meta['tabindex'] ); $this->assertNull( $about_node ); @@ -687,7 +687,7 @@ class Tests_AdminBar extends WP_UnitTestCase { $parsed_url = wp_parse_url( $node->href ); $query_params = array(); wp_parse_str( $parsed_url['query'], $query_params ); - $this->assertEquals( $uuid, $query_params['changeset_uuid'] ); + $this->assertSame( $uuid, $query_params['changeset_uuid'] ); $this->assertNotContains( 'changeset_uuid', $query_params['url'] ); } diff --git a/tests/phpunit/tests/ajax/AddMeta.php b/tests/phpunit/tests/ajax/AddMeta.php index 964802d1b1..12ec710a0d 100644 --- a/tests/phpunit/tests/ajax/AddMeta.php +++ b/tests/phpunit/tests/ajax/AddMeta.php @@ -34,7 +34,7 @@ class Tests_Ajax_AddMeta extends WP_Ajax_UnitTestCase { unset( $e ); } - $this->assertEquals( '', get_post_meta( $p, 'testkey', true ) ); + $this->assertSame( '', get_post_meta( $p, 'testkey', true ) ); } /** @@ -66,6 +66,6 @@ class Tests_Ajax_AddMeta extends WP_Ajax_UnitTestCase { unset( $e ); } - $this->assertEquals( '', get_post_meta( $p, 'testkey', true ) ); + $this->assertSame( '', get_post_meta( $p, 'testkey', true ) ); } } diff --git a/tests/phpunit/tests/ajax/Attachments.php b/tests/phpunit/tests/ajax/Attachments.php index 47d5aba579..0f3b19b203 100644 --- a/tests/phpunit/tests/ajax/Attachments.php +++ b/tests/phpunit/tests/ajax/Attachments.php @@ -58,7 +58,7 @@ class Tests_Ajax_Attachments extends WP_Ajax_UnitTestCase { // Ensure everything is correct. $this->assertTrue( $response['success'] ); - $this->assertEquals( $expected, $response['data'] ); + $this->assertSame( $expected, $response['data'] ); } /** @@ -111,6 +111,6 @@ class Tests_Ajax_Attachments extends WP_Ajax_UnitTestCase { // Ensure everything is correct. $this->assertTrue( $response['success'] ); - $this->assertEquals( $expected, $response['data'] ); + $this->assertSame( $expected, $response['data'] ); } } diff --git a/tests/phpunit/tests/ajax/Compression.php b/tests/phpunit/tests/ajax/Compression.php index 92516cb575..8e42a1e66d 100644 --- a/tests/phpunit/tests/ajax/Compression.php +++ b/tests/phpunit/tests/ajax/Compression.php @@ -144,7 +144,7 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase { } // Check the site option is not changed due to lack of nonce. - $this->assertEquals( 0, get_site_option( 'can_compress_scripts' ) ); + $this->assertSame( 0, get_site_option( 'can_compress_scripts' ) ); // Add a nonce. $_GET['_ajax_nonce'] = wp_create_nonce( 'update_can_compress_scripts' ); @@ -157,7 +157,7 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase { } // Check the site option is changed. - $this->assertEquals( 1, get_site_option( 'can_compress_scripts' ) ); + $this->assertSame( 1, get_site_option( 'can_compress_scripts' ) ); } /** @@ -182,7 +182,7 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase { } // Check the site option is not changed due to lack of nonce. - $this->assertEquals( 1, get_site_option( 'can_compress_scripts' ) ); + $this->assertSame( 1, get_site_option( 'can_compress_scripts' ) ); // Add a nonce. $_GET['_ajax_nonce'] = wp_create_nonce( 'update_can_compress_scripts' ); @@ -195,7 +195,7 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase { } // Check the site option is changed. - $this->assertEquals( 0, get_site_option( 'can_compress_scripts' ) ); + $this->assertSame( 0, get_site_option( 'can_compress_scripts' ) ); } /** diff --git a/tests/phpunit/tests/ajax/CustomizeManager.php b/tests/phpunit/tests/ajax/CustomizeManager.php index e9a03de711..6955097a30 100644 --- a/tests/phpunit/tests/ajax/CustomizeManager.php +++ b/tests/phpunit/tests/ajax/CustomizeManager.php @@ -115,7 +115,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { wp_set_current_user( 0 ); $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'unauthenticated', $this->_last_response_parsed['data'] ); + $this->assertSame( 'unauthenticated', $this->_last_response_parsed['data'] ); // Unauthorized. wp_set_current_user( self::$subscriber_user_id ); @@ -141,7 +141,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $_REQUEST['nonce'] = $nonce; $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'not_preview', $this->_last_response_parsed['data'] ); + $this->assertSame( 'not_preview', $this->_last_response_parsed['data'] ); // Bad nonce. $_POST['nonce'] = 'bad'; @@ -150,7 +150,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $wp_customize->setup_theme(); $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'invalid_nonce', $this->_last_response_parsed['data'] ); + $this->assertSame( 'invalid_nonce', $this->_last_response_parsed['data'] ); // User cannot create. $nonce = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() ); @@ -161,7 +161,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $post_type_obj->cap->create_posts = 'create_customize_changesets'; $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'cannot_create_changeset_post', $this->_last_response_parsed['data'] ); + $this->assertSame( 'cannot_create_changeset_post', $this->_last_response_parsed['data'] ); $this->overridden_caps[ $post_type_obj->cap->create_posts ] = true; $this->make_ajax_call( 'customize_save' ); $this->assertTrue( $this->_last_response_parsed['success'] ); @@ -172,7 +172,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $wp_customize->save_changeset_post( array( 'status' => 'publish' ) ); $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'changeset_already_published', $this->_last_response_parsed['data']['code'] ); + $this->assertSame( 'changeset_already_published', $this->_last_response_parsed['data']['code'] ); wp_update_post( array( 'ID' => $wp_customize->changeset_post_id(), @@ -185,7 +185,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $post_type_obj->cap->edit_post = 'edit_customize_changesets'; $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'cannot_edit_changeset_post', $this->_last_response_parsed['data'] ); + $this->assertSame( 'cannot_edit_changeset_post', $this->_last_response_parsed['data'] ); $this->overridden_caps[ $post_type_obj->cap->edit_post ] = true; $this->make_ajax_call( 'customize_save' ); $this->assertTrue( $this->_last_response_parsed['success'] ); @@ -195,14 +195,14 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $_POST['customize_changeset_data'] = '[MALFORMED]'; $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'invalid_customize_changeset_data', $this->_last_response_parsed['data'] ); + $this->assertSame( 'invalid_customize_changeset_data', $this->_last_response_parsed['data'] ); // Bad customize_changeset_status. $_POST['customize_changeset_data'] = '{}'; $_POST['customize_changeset_status'] = 'unrecognized'; $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'bad_customize_changeset_status', $this->_last_response_parsed['data'] ); + $this->assertSame( 'bad_customize_changeset_status', $this->_last_response_parsed['data'] ); // Disallowed publish posts if not allowed. $post_type_obj = get_post_type_object( 'customize_changeset' ); @@ -210,11 +210,11 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $_POST['customize_changeset_status'] = 'publish'; $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'changeset_publish_unauthorized', $this->_last_response_parsed['data'] ); + $this->assertSame( 'changeset_publish_unauthorized', $this->_last_response_parsed['data'] ); $_POST['customize_changeset_status'] = 'future'; $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'changeset_publish_unauthorized', $this->_last_response_parsed['data'] ); + $this->assertSame( 'changeset_publish_unauthorized', $this->_last_response_parsed['data'] ); $post_type_obj->cap->publish_posts = 'customize'; // Restore. // Validate date. @@ -222,11 +222,11 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $_POST['customize_changeset_date'] = 'BAD DATE'; $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'bad_customize_changeset_date', $this->_last_response_parsed['data'] ); + $this->assertSame( 'bad_customize_changeset_date', $this->_last_response_parsed['data'] ); $_POST['customize_changeset_date'] = '2010-01-01 00:00:00'; $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'not_future_date', $this->_last_response_parsed['data']['code'] ); + $this->assertSame( 'not_future_date', $this->_last_response_parsed['data']['code'] ); $_POST['customize_changeset_date'] = ( gmdate( 'Y' ) + 1 ) . '-01-01 00:00:00'; $this->make_ajax_call( 'customize_save' ); $this->assertTrue( $this->_last_response_parsed['success'] ); @@ -234,7 +234,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $_POST['customize_changeset_date'] = '+10 minutes'; $this->make_ajax_call( 'customize_save' ); $this->assertTrue( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'future', get_post_status( $wp_customize->changeset_post_id() ) ); + $this->assertSame( 'future', get_post_status( $wp_customize->changeset_post_id() ) ); wp_update_post( array( 'ID' => $wp_customize->changeset_post_id(), @@ -288,11 +288,11 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $this->assertTrue( $this->_last_response_parsed['success'] ); $this->assertInternalType( 'array', $this->_last_response_parsed['data'] ); - $this->assertEquals( 'publish', $this->_last_response_parsed['data']['changeset_status'] ); + $this->assertSame( 'publish', $this->_last_response_parsed['data']['changeset_status'] ); $this->assertArrayHasKey( 'next_changeset_uuid', $this->_last_response_parsed['data'] ); $this->assertTrue( wp_is_uuid( $this->_last_response_parsed['data']['next_changeset_uuid'], 4 ) ); - $this->assertEquals( 'Success Changeset', get_post( $wp_customize->changeset_post_id() )->post_title ); - $this->assertEquals( 'Successful Site Title', get_option( 'blogname' ) ); + $this->assertSame( 'Success Changeset', get_post( $wp_customize->changeset_post_id() )->post_title ); + $this->assertSame( 'Successful Site Title', get_option( 'blogname' ) ); } /** @@ -327,11 +327,11 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $this->assertTrue( $this->_last_response_parsed['success'] ); $this->assertInternalType( 'array', $this->_last_response_parsed['data'] ); - $this->assertEquals( 'publish', $this->_last_response_parsed['data']['changeset_status'] ); + $this->assertSame( 'publish', $this->_last_response_parsed['data']['changeset_status'] ); $this->assertArrayHasKey( 'next_changeset_uuid', $this->_last_response_parsed['data'] ); $this->assertTrue( wp_is_uuid( $this->_last_response_parsed['data']['next_changeset_uuid'], 4 ) ); - $this->assertEquals( 'New Site Title', get_option( 'blogname' ) ); - $this->assertEquals( 'Published', get_post( $post_id )->post_title ); + $this->assertSame( 'New Site Title', get_option( 'blogname' ) ); + $this->assertSame( 'Published', get_post( $post_id )->post_title ); } /** @@ -368,7 +368,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $this->assertTrue( $this->_last_response_parsed['success'] ); $this->assertArrayHasKey( 'changeset_date', $this->_last_response_parsed['data'] ); $changeset_post_schedule = get_post( $post_id ); - $this->assertEquals( $future_date, $changeset_post_schedule->post_date ); + $this->assertSame( $future_date, $changeset_post_schedule->post_date ); // Success future changeset change to draft keeping existing date. unset( $_POST['customize_changeset_date'] ); @@ -377,7 +377,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $this->assertTrue( $this->_last_response_parsed['success'] ); $this->assertArrayNotHasKey( 'changeset_date', $this->_last_response_parsed['data'] ); $changeset_post_draft = get_post( $post_id ); - $this->assertEquals( $future_date, $changeset_post_draft->post_date ); + $this->assertSame( $future_date, $changeset_post_draft->post_date ); // Success if date is not passed with schedule changeset and stored changeset have future date. $_POST['customize_changeset_status'] = 'future'; @@ -385,7 +385,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $this->assertTrue( $this->_last_response_parsed['success'] ); $this->assertArrayHasKey( 'changeset_date', $this->_last_response_parsed['data'] ); $changeset_post_schedule = get_post( $post_id ); - $this->assertEquals( $future_date, $changeset_post_schedule->post_date ); + $this->assertSame( $future_date, $changeset_post_schedule->post_date ); // Success if draft with past date. $now = current_time( 'mysql' ); wp_update_post( @@ -402,7 +402,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { unset( $_POST['customize_changeset_date'] ); $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'not_future_date', $this->_last_response_parsed['data']['code'] ); + $this->assertSame( 'not_future_date', $this->_last_response_parsed['data']['code'] ); // Success publish changeset reset date to current. wp_update_post( @@ -423,11 +423,11 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $this->assertNotEquals( $future_date, $changeset_post_publish->post_date ); // Check response when trying to update an already-published post. - $this->assertEquals( 'trash', get_post_status( $post_id ) ); + $this->assertSame( 'trash', get_post_status( $post_id ) ); $_POST['customize_changeset_status'] = 'publish'; $this->make_ajax_call( 'customize_save' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'changeset_already_published', $this->_last_response_parsed['data']['code'] ); + $this->assertSame( 'changeset_already_published', $this->_last_response_parsed['data']['code'] ); $this->assertArrayHasKey( 'next_changeset_uuid', $this->_last_response_parsed['data'] ); $this->assertTrue( wp_is_uuid( $this->_last_response_parsed['data']['next_changeset_uuid'], 4 ) ); } @@ -470,7 +470,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $_POST['customize_changeset_autosave'] = 'on'; $this->make_ajax_call( 'customize_save' ); $this->assertTrue( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'draft', $this->_last_response_parsed['data']['changeset_status'] ); + $this->assertSame( 'draft', $this->_last_response_parsed['data']['changeset_status'] ); $autosave_revision = wp_get_post_autosave( $post_id ); $this->assertInstanceOf( 'WP_Post', $autosave_revision ); @@ -490,7 +490,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $this->make_ajax_call( 'customize_trash' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'invalid_nonce', $this->_last_response_parsed['data']['code'] ); + $this->assertSame( 'invalid_nonce', $this->_last_response_parsed['data']['code'] ); $nonce = wp_create_nonce( 'trash_customize_changeset' ); $_POST['nonce'] = $nonce; @@ -498,7 +498,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $_REQUEST['nonce'] = $nonce; $this->make_ajax_call( 'customize_trash' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'non_existent_changeset', $this->_last_response_parsed['data']['code'] ); + $this->assertSame( 'non_existent_changeset', $this->_last_response_parsed['data']['code'] ); $wp_customize->register_controls(); // And settings too. $wp_customize->set_post_value( 'blogname', 'HELLO' ); @@ -511,7 +511,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { add_filter( 'map_meta_cap', array( $this, 'return_do_not_allow' ) ); $this->make_ajax_call( 'customize_trash' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'changeset_trash_unauthorized', $this->_last_response_parsed['data']['code'] ); + $this->assertSame( 'changeset_trash_unauthorized', $this->_last_response_parsed['data']['code'] ); remove_filter( 'map_meta_cap', array( $this, 'return_do_not_allow' ) ); $lock_user_id = static::factory()->user->create( array( 'role' => 'administrator' ) ); @@ -521,7 +521,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { wp_set_current_user( $previous_user ); $this->make_ajax_call( 'customize_trash' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'changeset_locked', $this->_last_response_parsed['data']['code'] ); + $this->assertSame( 'changeset_locked', $this->_last_response_parsed['data']['code'] ); delete_post_meta( $wp_customize->changeset_post_id(), '_edit_lock' ); wp_update_post( @@ -532,7 +532,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { ); $this->make_ajax_call( 'customize_trash' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'changeset_already_trashed', $this->_last_response_parsed['data']['code'] ); + $this->assertSame( 'changeset_already_trashed', $this->_last_response_parsed['data']['code'] ); wp_update_post( array( @@ -545,16 +545,16 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { add_filter( 'pre_trash_post', '__return_false' ); $this->make_ajax_call( 'customize_trash' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'changeset_trash_failure', $this->_last_response_parsed['data']['code'] ); + $this->assertSame( 'changeset_trash_failure', $this->_last_response_parsed['data']['code'] ); remove_filter( 'pre_trash_post', '__return_false' ); - $this->assertEquals( $wp_trash_post_count, did_action( 'wp_trash_post' ) ); + $this->assertSame( $wp_trash_post_count, did_action( 'wp_trash_post' ) ); $wp_trash_post_count = did_action( 'wp_trash_post' ); - $this->assertEquals( 'draft', get_post_status( $wp_customize->changeset_post_id() ) ); + $this->assertSame( 'draft', get_post_status( $wp_customize->changeset_post_id() ) ); $this->make_ajax_call( 'customize_trash' ); $this->assertTrue( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'trash', get_post_status( $wp_customize->changeset_post_id() ) ); - $this->assertEquals( $wp_trash_post_count + 1, did_action( 'wp_trash_post' ) ); + $this->assertSame( 'trash', get_post_status( $wp_customize->changeset_post_id() ) ); + $this->assertSame( $wp_trash_post_count + 1, did_action( 'wp_trash_post' ) ); } /** @@ -582,12 +582,12 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { wp_set_current_user( 0 ); $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'unauthenticated', $this->_last_response_parsed['data'] ); + $this->assertSame( 'unauthenticated', $this->_last_response_parsed['data'] ); wp_set_current_user( $valid_user_id ); $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'invalid_nonce', $this->_last_response_parsed['data'] ); + $this->assertSame( 'invalid_nonce', $this->_last_response_parsed['data'] ); $nonce = wp_create_nonce( 'customize_dismiss_autosave_or_lock' ); $_POST['nonce'] = $nonce; @@ -599,14 +599,14 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $_REQUEST['dismiss_lock'] = true; $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'no_changeset_to_dismiss_lock', $this->_last_response_parsed['data'] ); + $this->assertSame( 'no_changeset_to_dismiss_lock', $this->_last_response_parsed['data'] ); $_POST['dismiss_autosave'] = true; $_GET['dismiss_autosave'] = true; $_REQUEST['dismiss_autosave'] = true; $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] ); + $this->assertSame( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] ); $other_user_id = $this->factory()->user->create(); @@ -640,20 +640,20 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { } $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); $this->assertTrue( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'auto_draft_dismissed', $this->_last_response_parsed['data'] ); + $this->assertSame( 'auto_draft_dismissed', $this->_last_response_parsed['data'] ); foreach ( $user_auto_draft_ids as $post_id ) { - $this->assertEquals( 'auto-draft', get_post_status( $post_id ) ); + $this->assertSame( 'auto-draft', get_post_status( $post_id ) ); $this->assertTrue( (bool) get_post_meta( $post_id, '_customize_restore_dismissed', true ) ); } foreach ( $other_user_auto_draft_ids as $post_id ) { - $this->assertEquals( 'auto-draft', get_post_status( $post_id ) ); + $this->assertSame( 'auto-draft', get_post_status( $post_id ) ); $this->assertFalse( (bool) get_post_meta( $post_id, '_customize_restore_dismissed', true ) ); } // Subsequent test results in none dismissed. $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] ); + $this->assertSame( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] ); // Save a changeset as a draft. $r = $wp_customize->save_changeset_post( @@ -672,7 +672,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $_REQUEST['dismiss_autosave'] = false; $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); $this->assertTrue( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'changeset_lock_dismissed', $this->_last_response_parsed['data'] ); + $this->assertSame( 'changeset_lock_dismissed', $this->_last_response_parsed['data'] ); $_POST['dismiss_autosave'] = true; $_GET['dismiss_autosave'] = true; @@ -684,7 +684,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { // Since no autosave yet, confirm no action. $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] ); + $this->assertSame( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] ); // Add the autosave revision. $r = $wp_customize->save_changeset_post( @@ -706,12 +706,12 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { // Confirm autosave gets deleted. $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); $this->assertTrue( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'autosave_revision_deleted', $this->_last_response_parsed['data'] ); + $this->assertSame( 'autosave_revision_deleted', $this->_last_response_parsed['data'] ); $this->assertFalse( wp_get_post_autosave( $wp_customize->changeset_post_id() ) ); // Since no autosave yet, confirm no action. $this->make_ajax_call( 'customize_dismiss_autosave_or_lock' ); $this->assertFalse( $this->_last_response_parsed['success'] ); - $this->assertEquals( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] ); + $this->assertSame( 'no_autosave_revision_to_delete', $this->_last_response_parsed['data'] ); } } diff --git a/tests/phpunit/tests/ajax/CustomizeMenus.php b/tests/phpunit/tests/ajax/CustomizeMenus.php index 09ca59fcc7..3baa07758d 100644 --- a/tests/phpunit/tests/ajax/CustomizeMenus.php +++ b/tests/phpunit/tests/ajax/CustomizeMenus.php @@ -549,7 +549,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $response = json_decode( $this->_last_response, true ); if ( isset( $post_args['search'] ) && 'test' === $post_args['search'] ) { - $this->assertsame( true, $response['success'] ); + $this->assertTrue( $response['success'] ); $this->assertSame( 6, count( $response['data']['items'] ) ); $item_ids = wp_list_pluck( $response['data']['items'], 'id' ); $this->assertContains( 'post-' . $included_auto_draft_post->ID, $item_ids ); @@ -628,11 +628,11 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $this->assertArrayHasKey( 'post_id', $response['data'] ); $this->assertArrayHasKey( 'url', $response['data'] ); $post = get_post( $response['data']['post_id'] ); - $this->assertEquals( 'Hello World', $post->post_title ); - $this->assertEquals( 'post', $post->post_type ); - $this->assertEquals( '', $post->post_name ); - $this->assertEquals( 'hello-world', get_post_meta( $post->ID, '_customize_draft_post_name', true ) ); - $this->assertEquals( $this->wp_customize->changeset_uuid(), get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ); + $this->assertSame( 'Hello World', $post->post_title ); + $this->assertSame( 'post', $post->post_type ); + $this->assertSame( '', $post->post_name ); + $this->assertSame( 'hello-world', get_post_meta( $post->ID, '_customize_draft_post_name', true ) ); + $this->assertSame( $this->wp_customize->changeset_uuid(), get_post_meta( $post->ID, '_customize_changeset_uuid', true ) ); } /** @@ -647,7 +647,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $this->make_ajax_call( 'customize-nav-menus-insert-auto-draft' ); $response = json_decode( $this->_last_response, true ); $this->assertFalse( $response['success'] ); - $this->assertEquals( 'bad_nonce', $response['data'] ); + $this->assertSame( 'bad_nonce', $response['data'] ); // Bad nonce. $_POST = wp_slash( @@ -659,7 +659,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $this->make_ajax_call( 'customize-nav-menus-insert-auto-draft' ); $response = json_decode( $this->_last_response, true ); $this->assertFalse( $response['success'] ); - $this->assertEquals( 'bad_nonce', $response['data'] ); + $this->assertSame( 'bad_nonce', $response['data'] ); // Bad nonce. wp_set_current_user( $this->factory()->user->create( array( 'role' => 'subscriber' ) ) ); @@ -672,7 +672,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $this->make_ajax_call( 'customize-nav-menus-insert-auto-draft' ); $response = json_decode( $this->_last_response, true ); $this->assertFalse( $response['success'] ); - $this->assertEquals( 'customize_not_allowed', $response['data'] ); + $this->assertSame( 'customize_not_allowed', $response['data'] ); // Missing params. wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) ); @@ -685,7 +685,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $this->make_ajax_call( 'customize-nav-menus-insert-auto-draft' ); $response = json_decode( $this->_last_response, true ); $this->assertFalse( $response['success'] ); - $this->assertEquals( 'missing_params', $response['data'] ); + $this->assertSame( 'missing_params', $response['data'] ); // insufficient_post_permissions. register_post_type( 'privilege', array( 'capability_type' => 'privilege' ) ); @@ -701,7 +701,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $this->make_ajax_call( 'customize-nav-menus-insert-auto-draft' ); $response = json_decode( $this->_last_response, true ); $this->assertFalse( $response['success'] ); - $this->assertEquals( 'insufficient_post_permissions', $response['data'] ); + $this->assertSame( 'insufficient_post_permissions', $response['data'] ); // insufficient_post_permissions. $_POST = wp_slash( @@ -716,7 +716,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $this->make_ajax_call( 'customize-nav-menus-insert-auto-draft' ); $response = json_decode( $this->_last_response, true ); $this->assertFalse( $response['success'] ); - $this->assertEquals( 'missing_post_type_param', $response['data'] ); + $this->assertSame( 'missing_post_type_param', $response['data'] ); // missing_post_title. $_POST = wp_slash( @@ -732,7 +732,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $this->make_ajax_call( 'customize-nav-menus-insert-auto-draft' ); $response = json_decode( $this->_last_response, true ); $this->assertFalse( $response['success'] ); - $this->assertEquals( 'missing_post_title', $response['data'] ); + $this->assertSame( 'missing_post_title', $response['data'] ); // illegal_params. $_POST = wp_slash( @@ -750,6 +750,6 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { $this->make_ajax_call( 'customize-nav-menus-insert-auto-draft' ); $response = json_decode( $this->_last_response, true ); $this->assertFalse( $response['success'] ); - $this->assertEquals( 'illegal_params', $response['data'] ); + $this->assertSame( 'illegal_params', $response['data'] ); } } diff --git a/tests/phpunit/tests/ajax/DeleteComment.php b/tests/phpunit/tests/ajax/DeleteComment.php index d1afb740e6..cc2624872c 100644 --- a/tests/phpunit/tests/ajax/DeleteComment.php +++ b/tests/phpunit/tests/ajax/DeleteComment.php @@ -88,8 +88,8 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase { $xml = simplexml_load_string( $this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA ); // Ensure everything is correct. - $this->assertEquals( $comment->comment_ID, (string) $xml->response[0]->comment['id'] ); - $this->assertEquals( 'delete-comment_' . $comment->comment_ID, (string) $xml->response['action'] ); + $this->assertSame( $comment->comment_ID, (string) $xml->response[0]->comment['id'] ); + $this->assertSame( 'delete-comment_' . $comment->comment_ID, (string) $xml->response['action'] ); $this->assertGreaterThanOrEqual( time() - 10, (int) $xml->response[0]->comment[0]->supplemental[0]->time[0] ); $this->assertLessThanOrEqual( time(), (int) $xml->response[0]->comment[0]->supplemental[0]->time[0] ); @@ -202,7 +202,7 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase { $this->_handleAjax( 'delete-comment' ); $this->fail( 'Expected exception: WPAjaxDieStopException' ); } catch ( WPAjaxDieStopException $e ) { - $this->assertEquals( 10, strlen( $e->getMessage() ) ); + $this->assertSame( 10, strlen( $e->getMessage() ) ); $this->assertTrue( is_numeric( $e->getMessage() ) ); } catch ( Exception $e ) { $this->fail( 'Unexpected exception type: ' . get_class( $e ) ); @@ -252,7 +252,7 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase { $this->_handleAjax( 'delete-comment' ); $this->fail( 'Expected exception: WPAjaxDieStopException' ); } catch ( WPAjaxDieStopException $e ) { - $this->assertEquals( 10, strlen( $e->getMessage() ) ); + $this->assertSame( 10, strlen( $e->getMessage() ) ); $this->assertTrue( is_numeric( $e->getMessage() ) ); } catch ( Exception $e ) { $this->fail( 'Unexpected exception type: ' . get_class( $e ) ); diff --git a/tests/phpunit/tests/ajax/DimComment.php b/tests/phpunit/tests/ajax/DimComment.php index 979a55f000..51fb2bb9a6 100644 --- a/tests/phpunit/tests/ajax/DimComment.php +++ b/tests/phpunit/tests/ajax/DimComment.php @@ -82,17 +82,17 @@ class Tests_Ajax_DimComment extends WP_Ajax_UnitTestCase { $xml = simplexml_load_string( $this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA ); // Ensure everything is correct. - $this->assertEquals( $comment->comment_ID, (string) $xml->response[0]->comment['id'] ); - $this->assertEquals( 'dim-comment_' . $comment->comment_ID, (string) $xml->response['action'] ); + $this->assertSame( $comment->comment_ID, (string) $xml->response[0]->comment['id'] ); + $this->assertSame( 'dim-comment_' . $comment->comment_ID, (string) $xml->response['action'] ); $this->assertGreaterThanOrEqual( time() - 10, (int) $xml->response[0]->comment[0]->supplemental[0]->time[0] ); $this->assertLessThanOrEqual( time(), (int) $xml->response[0]->comment[0]->supplemental[0]->time[0] ); // Check the status. $current = wp_get_comment_status( $comment->comment_ID ); if ( in_array( $prev_status, array( 'unapproved', 'spam' ), true ) ) { - $this->assertEquals( 'approved', $current ); + $this->assertSame( 'approved', $current ); } else { - $this->assertEquals( 'unapproved', $current ); + $this->assertSame( 'unapproved', $current ); } // The total is calculated based on a page break -OR- a random number. Let's look for both possible outcomes. @@ -193,8 +193,8 @@ class Tests_Ajax_DimComment extends WP_Ajax_UnitTestCase { $xml = simplexml_load_string( $this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA ); // Ensure everything is correct. - $this->assertEquals( '0', (string) $xml->response[0]->comment['id'] ); - $this->assertEquals( 'dim-comment_0', (string) $xml->response['action'] ); + $this->assertSame( '0', (string) $xml->response[0]->comment['id'] ); + $this->assertSame( 'dim-comment_0', (string) $xml->response['action'] ); $this->assertContains( 'Comment ' . $_POST['id'] . ' does not exist', $this->_last_response ); } catch ( Exception $e ) { diff --git a/tests/phpunit/tests/ajax/EditComment.php b/tests/phpunit/tests/ajax/EditComment.php index 7b50da4b68..66ecdae8b4 100644 --- a/tests/phpunit/tests/ajax/EditComment.php +++ b/tests/phpunit/tests/ajax/EditComment.php @@ -66,9 +66,9 @@ class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase { $xml = simplexml_load_string( $this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA ); // Check the meta data. - $this->assertEquals( -1, (string) $xml->response[0]->edit_comment['position'] ); - $this->assertEquals( $comment->comment_ID, (string) $xml->response[0]->edit_comment['id'] ); - $this->assertEquals( 'edit-comment_' . $comment->comment_ID, (string) $xml->response['action'] ); + $this->assertSame( '-1', (string) $xml->response[0]->edit_comment['position'] ); + $this->assertSame( $comment->comment_ID, (string) $xml->response[0]->edit_comment['id'] ); + $this->assertSame( 'edit-comment_' . $comment->comment_ID, (string) $xml->response['action'] ); // Check the payload. $this->assertNotEmpty( (string) $xml->response[0]->edit_comment[0]->response_data ); @@ -114,9 +114,9 @@ class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase { $xml = simplexml_load_string( $this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA ); // Check the meta data. - $this->assertEquals( -1, (string) $xml->response[0]->edit_comment['position'] ); - $this->assertEquals( $comment->comment_ID, (string) $xml->response[0]->edit_comment['id'] ); - $this->assertEquals( 'edit-comment_' . $comment->comment_ID, (string) $xml->response['action'] ); + $this->assertSame( '-1', (string) $xml->response[0]->edit_comment['position'] ); + $this->assertSame( $comment->comment_ID, (string) $xml->response[0]->edit_comment['id'] ); + $this->assertSame( 'edit-comment_' . $comment->comment_ID, (string) $xml->response['action'] ); // Check the payload. $this->assertNotEmpty( (string) $xml->response[0]->edit_comment[0]->response_data ); diff --git a/tests/phpunit/tests/ajax/GetComments.php b/tests/phpunit/tests/ajax/GetComments.php index 0a27c13e69..b1812ca892 100644 --- a/tests/phpunit/tests/ajax/GetComments.php +++ b/tests/phpunit/tests/ajax/GetComments.php @@ -63,9 +63,9 @@ class Tests_Ajax_GetComments extends WP_Ajax_UnitTestCase { $xml = simplexml_load_string( $this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA ); // Check the meta data. - $this->assertEquals( 1, (string) $xml->response[0]->comments['position'] ); - $this->assertEquals( 0, (string) $xml->response[0]->comments['id'] ); - $this->assertEquals( 'get-comments_0', (string) $xml->response['action'] ); + $this->assertSame( '1', (string) $xml->response[0]->comments['position'] ); + $this->assertSame( '0', (string) $xml->response[0]->comments['id'] ); + $this->assertSame( 'get-comments_0', (string) $xml->response['action'] ); // Check the payload. $this->assertNotEmpty( (string) $xml->response[0]->comments[0]->response_data ); diff --git a/tests/phpunit/tests/ajax/ReplytoComment.php b/tests/phpunit/tests/ajax/ReplytoComment.php index 256b63362d..2b160c4597 100644 --- a/tests/phpunit/tests/ajax/ReplytoComment.php +++ b/tests/phpunit/tests/ajax/ReplytoComment.php @@ -77,7 +77,7 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { $xml = simplexml_load_string( $this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA ); // Check the meta data. - $this->assertEquals( -1, (string) $xml->response[0]->comment['position'] ); + $this->assertSame( '-1', (string) $xml->response[0]->comment['position'] ); $this->assertGreaterThan( 0, (int) $xml->response[0]->comment['id'] ); $this->assertNotEmpty( (string) $xml->response['action'] ); diff --git a/tests/phpunit/tests/ajax/TagSearch.php b/tests/phpunit/tests/ajax/TagSearch.php index b8177bf60f..80a327ee93 100644 --- a/tests/phpunit/tests/ajax/TagSearch.php +++ b/tests/phpunit/tests/ajax/TagSearch.php @@ -57,7 +57,7 @@ class Tests_Ajax_TagSearch extends WP_Ajax_UnitTestCase { } // Ensure we found the right match. - $this->assertEquals( $this->_last_response, 'chattels' ); + $this->assertSame( $this->_last_response, 'chattels' ); } /** @@ -98,7 +98,7 @@ class Tests_Ajax_TagSearch extends WP_Ajax_UnitTestCase { } // Ensure we found the right match. - $this->assertEquals( $this->_last_response, 'chattels' ); + $this->assertSame( $this->_last_response, 'chattels' ); } /** diff --git a/tests/phpunit/tests/attachment/slashes.php b/tests/phpunit/tests/attachment/slashes.php index ad5811b193..082efb110e 100644 --- a/tests/phpunit/tests/attachment/slashes.php +++ b/tests/phpunit/tests/attachment/slashes.php @@ -37,9 +37,9 @@ class Tests_Attachment_Slashes extends WP_UnitTestCase { ); $post = get_post( $id ); - $this->assertEquals( wp_unslash( $this->slash_1 ), $post->post_title ); - $this->assertEquals( wp_unslash( $this->slash_3 ), $post->post_content_filtered ); - $this->assertEquals( wp_unslash( $this->slash_5 ), $post->post_excerpt ); + $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title ); + $this->assertSame( wp_unslash( $this->slash_3 ), $post->post_content_filtered ); + $this->assertSame( wp_unslash( $this->slash_5 ), $post->post_excerpt ); $id = wp_insert_attachment( array( @@ -52,9 +52,9 @@ class Tests_Attachment_Slashes extends WP_UnitTestCase { ); $post = get_post( $id ); - $this->assertEquals( wp_unslash( $this->slash_2 ), $post->post_title ); - $this->assertEquals( wp_unslash( $this->slash_4 ), $post->post_content_filtered ); - $this->assertEquals( wp_unslash( $this->slash_6 ), $post->post_excerpt ); + $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title ); + $this->assertSame( wp_unslash( $this->slash_4 ), $post->post_content_filtered ); + $this->assertSame( wp_unslash( $this->slash_6 ), $post->post_excerpt ); } } diff --git a/tests/phpunit/tests/auth.php b/tests/phpunit/tests/auth.php index d1046cd940..f91da68073 100644 --- a/tests/phpunit/tests/auth.php +++ b/tests/phpunit/tests/auth.php @@ -37,7 +37,7 @@ class Tests_Auth extends WP_UnitTestCase { function test_auth_cookie_valid() { $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'auth' ); - $this->assertEquals( self::$user_id, wp_validate_auth_cookie( $cookie, 'auth' ) ); + $this->assertSame( self::$user_id, wp_validate_auth_cookie( $cookie, 'auth' ) ); } function test_auth_cookie_invalid() { @@ -45,25 +45,25 @@ class Tests_Auth extends WP_UnitTestCase { // as an ajax test may have defined DOING_AJAX, failing the test. $cookie = wp_generate_auth_cookie( self::$user_id, time() - 7200, 'auth' ); - $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'auth' ), 'expired cookie' ); + $this->assertFalse( wp_validate_auth_cookie( $cookie, 'auth' ), 'expired cookie' ); $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'auth' ); - $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'logged_in' ), 'wrong auth scheme' ); + $this->assertFalse( wp_validate_auth_cookie( $cookie, 'logged_in' ), 'wrong auth scheme' ); $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'auth' ); list($a, $b, $c) = explode( '|', $cookie ); $cookie = $a . '|' . ( $b + 1 ) . '|' . $c; - $this->assertEquals( false, wp_validate_auth_cookie( self::$user_id, 'auth' ), 'altered cookie' ); + $this->assertFalse( wp_validate_auth_cookie( self::$user_id, 'auth' ), 'altered cookie' ); } function test_auth_cookie_scheme() { // Arbitrary scheme name. $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' ); - $this->assertEquals( self::$user_id, wp_validate_auth_cookie( $cookie, 'foo' ) ); + $this->assertSame( self::$user_id, wp_validate_auth_cookie( $cookie, 'foo' ) ); // Wrong scheme name - should fail. $cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' ); - $this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'bar' ) ); + $this->assertFalse( wp_validate_auth_cookie( $cookie, 'bar' ) ); } /** @@ -82,7 +82,7 @@ class Tests_Auth extends WP_UnitTestCase { $authed_user = wp_authenticate( $this->user->user_login, $password_to_test ); $this->assertInstanceOf( 'WP_User', $authed_user ); - $this->assertEquals( $this->user->ID, $authed_user->ID ); + $this->assertSame( $this->user->ID, $authed_user->ID ); } } @@ -136,7 +136,7 @@ class Tests_Auth extends WP_UnitTestCase { wp_verify_nonce( $nonce, 'nonce_test_action' ); - $this->assertEquals( ( $count + 1 ), did_action( $this->nonce_failure_hook ) ); + $this->assertSame( ( $count + 1 ), did_action( $this->nonce_failure_hook ) ); } /** @@ -148,7 +148,7 @@ class Tests_Auth extends WP_UnitTestCase { wp_verify_nonce( $nonce, 'nonce_test_action' ); - $this->assertEquals( $count, did_action( $this->nonce_failure_hook ) ); + $this->assertSame( $count, did_action( $this->nonce_failure_hook ) ); } /** @@ -201,7 +201,7 @@ class Tests_Auth extends WP_UnitTestCase { $user = wp_authenticate( $this->user->user_login, $limit ); $this->assertInstanceOf( 'WP_User', $user ); - $this->assertEquals( self::$user_id, $user->ID ); + $this->assertSame( self::$user_id, $user->ID ); // One char too many. $user = wp_authenticate( $this->user->user_login, $limit . 'a' ); @@ -211,7 +211,7 @@ class Tests_Auth extends WP_UnitTestCase { wp_set_password( $limit . 'a', self::$user_id ); $user = get_user_by( 'id', self::$user_id ); // Password broken by setting it to be too long. - $this->assertEquals( '*', $user->data->user_pass ); + $this->assertSame( '*', $user->data->user_pass ); $user = wp_authenticate( $this->user->user_login, '*' ); $this->assertInstanceOf( 'WP_Error', $user ); diff --git a/tests/phpunit/tests/avatar.php b/tests/phpunit/tests/avatar.php index 5649944230..4867bdbf9c 100644 --- a/tests/phpunit/tests/avatar.php +++ b/tests/phpunit/tests/avatar.php @@ -11,7 +11,7 @@ class Tests_Avatar extends WP_UnitTestCase { */ public function test_get_avatar_url_gravatar_url() { $url = get_avatar_url( 1 ); - $this->assertEquals( preg_match( '|^http?://[0-9]+.gravatar.com/avatar/[0-9a-f]{32}\?|', $url ), 1 ); + $this->assertSame( preg_match( '|^http?://[0-9]+.gravatar.com/avatar/[0-9a-f]{32}\?|', $url ), 1 ); } /** @@ -19,11 +19,11 @@ class Tests_Avatar extends WP_UnitTestCase { */ public function test_get_avatar_url_size() { $url = get_avatar_url( 1 ); - $this->assertEquals( preg_match( '|\?.*s=96|', $url ), 1 ); + $this->assertSame( preg_match( '|\?.*s=96|', $url ), 1 ); $args = array( 'size' => 100 ); $url = get_avatar_url( 1, $args ); - $this->assertEquals( preg_match( '|\?.*s=100|', $url ), 1 ); + $this->assertSame( preg_match( '|\?.*s=100|', $url ), 1 ); } /** @@ -31,16 +31,16 @@ class Tests_Avatar extends WP_UnitTestCase { */ public function test_get_avatar_url_default() { $url = get_avatar_url( 1 ); - $this->assertEquals( preg_match( '|\?.*d=mm|', $url ), 1 ); + $this->assertSame( preg_match( '|\?.*d=mm|', $url ), 1 ); $args = array( 'default' => 'wavatar' ); $url = get_avatar_url( 1, $args ); - $this->assertEquals( preg_match( '|\?.*d=wavatar|', $url ), 1 ); + $this->assertSame( preg_match( '|\?.*d=wavatar|', $url ), 1 ); - $this->assertEquals( preg_match( '|\?.*f=y|', $url ), 0 ); + $this->assertSame( preg_match( '|\?.*f=y|', $url ), 0 ); $args = array( 'force_default' => true ); $url = get_avatar_url( 1, $args ); - $this->assertEquals( preg_match( '|\?.*f=y|', $url ), 1 ); + $this->assertSame( preg_match( '|\?.*f=y|', $url ), 1 ); } /** @@ -48,11 +48,11 @@ class Tests_Avatar extends WP_UnitTestCase { */ public function test_get_avatar_url_rating() { $url = get_avatar_url( 1 ); - $this->assertEquals( preg_match( '|\?.*r=g|', $url ), 1 ); + $this->assertSame( preg_match( '|\?.*r=g|', $url ), 1 ); $args = array( 'rating' => 'M' ); $url = get_avatar_url( 1, $args ); - $this->assertEquals( preg_match( '|\?.*r=m|', $url ), 1 ); + $this->assertSame( preg_match( '|\?.*r=m|', $url ), 1 ); } /** @@ -60,15 +60,15 @@ class Tests_Avatar extends WP_UnitTestCase { */ public function test_get_avatar_url_scheme() { $url = get_avatar_url( 1 ); - $this->assertEquals( preg_match( '|^http://|', $url ), 1 ); + $this->assertSame( preg_match( '|^http://|', $url ), 1 ); $args = array( 'scheme' => 'https' ); $url = get_avatar_url( 1, $args ); - $this->assertEquals( preg_match( '|^https://|', $url ), 1 ); + $this->assertSame( preg_match( '|^https://|', $url ), 1 ); $args = array( 'scheme' => 'lolcat' ); $url = get_avatar_url( 1, $args ); - $this->assertEquals( preg_match( '|^lolcat://|', $url ), 0 ); + $this->assertSame( preg_match( '|^lolcat://|', $url ), 0 ); } /** @@ -78,19 +78,19 @@ class Tests_Avatar extends WP_UnitTestCase { $url = get_avatar_url( 1 ); $url2 = get_avatar_url( WP_TESTS_EMAIL ); - $this->assertEquals( $url, $url2 ); + $this->assertSame( $url, $url2 ); $url2 = get_avatar_url( md5( WP_TESTS_EMAIL ) . '@md5.gravatar.com' ); - $this->assertEquals( $url, $url2 ); + $this->assertSame( $url, $url2 ); $user = get_user_by( 'id', 1 ); $url2 = get_avatar_url( $user ); - $this->assertEquals( $url, $url2 ); + $this->assertSame( $url, $url2 ); $post_id = self::factory()->post->create( array( 'post_author' => 1 ) ); $post = get_post( $post_id ); $url2 = get_avatar_url( $post ); - $this->assertEquals( $url, $url2 ); + $this->assertSame( $url, $url2 ); $comment_id = self::factory()->comment->create( array( @@ -100,7 +100,7 @@ class Tests_Avatar extends WP_UnitTestCase { ); $comment = get_comment( $comment_id ); $url2 = get_avatar_url( $comment ); - $this->assertEquals( $url, $url2 ); + $this->assertSame( $url, $url2 ); } protected $fake_url; @@ -114,7 +114,7 @@ class Tests_Avatar extends WP_UnitTestCase { $url = get_avatar_url( 1 ); remove_filter( 'pre_get_avatar_data', array( $this, 'pre_get_avatar_url_filter' ), 10 ); - $this->assertEquals( $url, $this->fake_url ); + $this->assertSame( $url, $this->fake_url ); } public function pre_get_avatar_url_filter( $args ) { $args['url'] = $this->fake_url; @@ -131,7 +131,7 @@ class Tests_Avatar extends WP_UnitTestCase { $url = get_avatar_url( 1 ); remove_filter( 'get_avatar_url', array( $this, 'get_avatar_url_filter' ), 10 ); - $this->assertEquals( $url, $this->fake_url ); + $this->assertSame( $url, $this->fake_url ); } public function get_avatar_url_filter( $url ) { return $this->fake_url; @@ -160,7 +160,7 @@ class Tests_Avatar extends WP_UnitTestCase { $url2 = get_avatar_url( $comment ); remove_filter( 'get_avatar_comment_types', array( $this, 'get_avatar_comment_types_filter' ), 10 ); - $this->assertEquals( $url, $url2 ); + $this->assertSame( $url, $url2 ); } public function get_avatar_comment_types_filter( $comment_types ) { $comment_types[] = 'pingback'; @@ -169,30 +169,30 @@ class Tests_Avatar extends WP_UnitTestCase { public function test_get_avatar() { $img = get_avatar( 1 ); - $this->assertEquals( preg_match( "|^[^$|", $img ), 1 ); + $this->assertSame( preg_match( "|^[^$|", $img ), 1 ); } public function test_get_avatar_size() { $size = '100'; $img = get_avatar( 1, $size ); - $this->assertEquals( preg_match( "|^assertSame( preg_match( "|^assertEquals( preg_match( "|^$altassertSame( preg_match( "|^$alt $class ) ); - $this->assertEquals( preg_match( "|^assertSame( preg_match( "|^ true ) ); - $this->assertEquals( preg_match( "|^assertSame( preg_match( "|^assertEquals( $img, $this->fake_img ); + $this->assertSame( $img, $this->fake_img ); } public function pre_get_avatar_filter( $img ) { return $this->fake_img; @@ -234,7 +234,7 @@ class Tests_Avatar extends WP_UnitTestCase { $img = get_avatar( 1 ); remove_filter( 'get_avatar', array( $this, 'get_avatar_filter' ), 10 ); - $this->assertEquals( $img, $this->fake_url ); + $this->assertSame( $img, $this->fake_url ); } public function get_avatar_filter( $img ) { return $this->fake_url; diff --git a/tests/phpunit/tests/basic.php b/tests/phpunit/tests/basic.php index 4facb8454b..6941c91e44 100644 --- a/tests/phpunit/tests/basic.php +++ b/tests/phpunit/tests/basic.php @@ -14,7 +14,7 @@ class Tests_Basic extends WP_UnitTestCase { $license = file_get_contents( ABSPATH . 'license.txt' ); preg_match( '#Copyright 2011-(\d+) by the contributors#', $license, $matches ); $this_year = gmdate( 'Y' ); - $this->assertEquals( $this_year, trim( $matches[1] ), "license.txt's year needs to be updated to $this_year." ); + $this->assertSame( $this_year, trim( $matches[1] ), "license.txt's year needs to be updated to $this_year." ); } function test_security_md() { @@ -25,7 +25,7 @@ class Tests_Basic extends WP_UnitTestCase { preg_match( '#\d.\d.x#', $security, $matches ); $current_version = substr( $GLOBALS['wp_version'], 0, 3 ); $latest_stable = sprintf( '%s.x', (float) $current_version - 0.1 ); - $this->assertEquals( $latest_stable, trim( $matches[0] ), "SECURITY.md's version needs to be updated to $latest_stable." ); + $this->assertSame( $latest_stable, trim( $matches[0] ), "SECURITY.md's version needs to be updated to $latest_stable." ); } function test_package_json() { @@ -36,7 +36,7 @@ class Tests_Basic extends WP_UnitTestCase { if ( 1 === substr_count( $version, '.' ) ) { $version .= '.0'; } - $this->assertEquals( $version, $package_json['version'], "package.json's version needs to be updated to $version." ); + $this->assertSame( $version, $package_json['version'], "package.json's version needs to be updated to $version." ); return $package_json; } @@ -53,9 +53,9 @@ class Tests_Basic extends WP_UnitTestCase { // Test some helper utility functions. function test_strip_ws() { - $this->assertEquals( '', strip_ws( '' ) ); - $this->assertEquals( 'foo', strip_ws( 'foo' ) ); - $this->assertEquals( '', strip_ws( "\r\n\t \n\r\t" ) ); + $this->assertSame( '', strip_ws( '' ) ); + $this->assertSame( 'foo', strip_ws( 'foo' ) ); + $this->assertSame( '', strip_ws( "\r\n\t \n\r\t" ) ); $in = "asdf\n"; $in .= "asdf asdf\n"; @@ -75,7 +75,7 @@ class Tests_Basic extends WP_UnitTestCase { $expected .= "foo bar\n"; $expected .= 'foo'; - $this->assertEquals( $expected, strip_ws( $in ) ); + $this->assertSame( $expected, strip_ws( $in ) ); } @@ -93,6 +93,6 @@ EOF;

If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)

  1. Current author: Alex Shiels
    Create user
    or map to existingassertContains( 'assertEquals( 'search-2', $params['widget_id'] ); - $this->assertEquals( 'search', $params['widget_id_base'] ); + $this->assertSame( 'search-2', $params['widget_id'] ); + $this->assertSame( 'search', $params['widget_id_base'] ); $this->assertArrayHasKey( 'sidebar_id', $params ); $this->assertArrayHasKey( 'width', $params ); $this->assertArrayHasKey( 'height', $params ); @@ -496,7 +496,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { $this->assertInternalType( 'array', $result ); $this->assertArrayHasKey( 'instance', $result ); $this->assertArrayHasKey( 'form', $result ); - $this->assertEquals( $instance, $result['instance'] ); + $this->assertSame( $instance, $result['instance'] ); $this->assertContains( sprintf( 'value="%s"', esc_attr( $instance['title'] ) ), $result['form'] ); $post_values = $this->manager->unsanitized_post_values(); @@ -507,7 +507,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { $this->assertArrayHasKey( 'encoded_serialized_instance', $post_value ); $this->assertArrayHasKey( 'instance_hash_key', $post_value ); $this->assertArrayHasKey( 'is_widget_customizer_js_value', $post_value ); - $this->assertEquals( $post_value, $this->manager->widgets->sanitize_widget_js_instance( $instance ) ); + $this->assertSame( $post_value, $this->manager->widgets->sanitize_widget_js_instance( $instance ) ); } /** @@ -520,14 +520,14 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { $args = apply_filters( 'customize_dynamic_partial_args', false, 'widget[search-2]' ); $this->assertInternalType( 'array', $args ); - $this->assertEquals( 'widget', $args['type'] ); - $this->assertEquals( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] ); + $this->assertSame( 'widget', $args['type'] ); + $this->assertSame( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] ); $this->assertTrue( $args['container_inclusive'] ); $args = apply_filters( 'customize_dynamic_partial_args', array( 'fallback_refresh' => false ), 'widget[search-2]' ); $this->assertInternalType( 'array', $args ); - $this->assertEquals( 'widget', $args['type'] ); - $this->assertEquals( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] ); + $this->assertSame( 'widget', $args['type'] ); + $this->assertSame( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] ); $this->assertTrue( $args['container_inclusive'] ); $this->assertFalse( $args['fallback_refresh'] ); @@ -544,10 +544,10 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { function test_selective_refresh_init_with_theme_support() { add_theme_support( 'customize-selective-refresh-widgets' ); $this->manager->widgets->selective_refresh_init(); - $this->assertEquals( 10, has_action( 'dynamic_sidebar_before', array( $this->manager->widgets, 'start_dynamic_sidebar' ) ) ); - $this->assertEquals( 10, has_action( 'dynamic_sidebar_after', array( $this->manager->widgets, 'end_dynamic_sidebar' ) ) ); - $this->assertEquals( 10, has_filter( 'dynamic_sidebar_params', array( $this->manager->widgets, 'filter_dynamic_sidebar_params' ) ) ); - $this->assertEquals( 10, has_filter( 'wp_kses_allowed_html', array( $this->manager->widgets, 'filter_wp_kses_allowed_data_attributes' ) ) ); + $this->assertSame( 10, has_action( 'dynamic_sidebar_before', array( $this->manager->widgets, 'start_dynamic_sidebar' ) ) ); + $this->assertSame( 10, has_action( 'dynamic_sidebar_after', array( $this->manager->widgets, 'end_dynamic_sidebar' ) ) ); + $this->assertSame( 10, has_filter( 'dynamic_sidebar_params', array( $this->manager->widgets, 'filter_dynamic_sidebar_params' ) ) ); + $this->assertSame( 10, has_filter( 'wp_kses_allowed_html', array( $this->manager->widgets, 'filter_wp_kses_allowed_data_attributes' ) ) ); } /** @@ -603,31 +603,31 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { ), array(), ); - $this->assertEquals( $params, $this->manager->widgets->filter_dynamic_sidebar_params( $params ), 'Expected short-circuit if not called after dynamic_sidebar_before.' ); + $this->assertSame( $params, $this->manager->widgets->filter_dynamic_sidebar_params( $params ), 'Expected short-circuit if not called after dynamic_sidebar_before.' ); ob_start(); do_action( 'dynamic_sidebar_before', 'foo' ); $output = ob_get_clean(); - $this->assertEquals( '', trim( $output ) ); + $this->assertSame( '', trim( $output ) ); $bad_params = $params; unset( $bad_params[0]['id'] ); - $this->assertEquals( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) ); + $this->assertSame( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) ); $bad_params = $params; $bad_params[0]['id'] = 'non-existing'; - $this->assertEquals( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) ); + $this->assertSame( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) ); $bad_params = $params; $bad_params[0]['before_widget'] = ' '; - $this->assertEquals( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) ); + $this->assertSame( $bad_params, $this->manager->widgets->filter_dynamic_sidebar_params( $bad_params ) ); $filtered_params = $this->manager->widgets->filter_dynamic_sidebar_params( $params ); $this->assertNotEquals( $params, $filtered_params ); ob_start(); do_action( 'dynamic_sidebar_after', 'foo' ); $output = ob_get_clean(); - $this->assertEquals( '', trim( $output ) ); + $this->assertSame( '', trim( $output ) ); $output = wp_kses_post( $filtered_params[0]['before_widget'] ); $this->assertContains( 'data-customize-partial-id="widget[search-2]"', $output ); @@ -648,15 +648,15 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { $partials = $this->manager->selective_refresh->add_dynamic_partials( array( $partial_id ) ); $this->assertNotEmpty( $partials ); $partial = array_shift( $partials ); - $this->assertEquals( $partial_id, $partial->id ); + $this->assertSame( $partial_id, $partial->id ); $this->assertFalse( $this->manager->widgets->render_widget_partial( $partial, array() ) ); $this->assertFalse( $this->manager->widgets->render_widget_partial( $partial, array( 'sidebar_id' => 'non-existing' ) ) ); $output = $this->manager->widgets->render_widget_partial( $partial, array( 'sidebar_id' => 'sidebar-1' ) ); - $this->assertEquals( 1, substr_count( $output, 'data-customize-partial-id' ) ); - $this->assertEquals( 1, substr_count( $output, 'data-customize-partial-type="widget"' ) ); + $this->assertSame( 1, substr_count( $output, 'data-customize-partial-id' ) ); + $this->assertSame( 1, substr_count( $output, 'data-customize-partial-type="widget"' ) ); $this->assertContains( ' id="search-2"', $output ); } diff --git a/tests/phpunit/tests/date/dateI18n.php b/tests/phpunit/tests/date/dateI18n.php index 84c43efc4c..0a81990d63 100644 --- a/tests/phpunit/tests/date/dateI18n.php +++ b/tests/phpunit/tests/date/dateI18n.php @@ -33,8 +33,8 @@ class Tests_Date_I18n extends WP_UnitTestCase { ); $rfc3339 = $datetime->format( DATE_RFC3339 ); - $this->assertEquals( 0, date_i18n( 'U', 0 ) ); - $this->assertEquals( $rfc3339, date_i18n( DATE_RFC3339, 0 ) ); + $this->assertSame( 0, date_i18n( 'U', 0 ) ); + $this->assertSame( $rfc3339, date_i18n( DATE_RFC3339, 0 ) ); } public function test_should_format_date() { @@ -42,7 +42,7 @@ class Tests_Date_I18n extends WP_UnitTestCase { } public function test_should_use_custom_timestamp() { - $this->assertEquals( '2012-12-01 00:00:00', date_i18n( 'Y-m-d H:i:s', strtotime( '2012-12-01 00:00:00' ) ) ); + $this->assertSame( '2012-12-01 00:00:00', date_i18n( 'Y-m-d H:i:s', strtotime( '2012-12-01 00:00:00' ) ) ); } public function test_date_should_be_in_gmt() { @@ -64,7 +64,7 @@ class Tests_Date_I18n extends WP_UnitTestCase { public function test_date_should_be_in_gmt_with_custom_timezone_setting_and_timestamp() { update_option( 'timezone_string', 'America/Regina' ); - $this->assertEquals( '2012-12-01 00:00:00', date_i18n( 'Y-m-d H:i:s', strtotime( '2012-12-01 00:00:00' ) ) ); + $this->assertSame( '2012-12-01 00:00:00', date_i18n( 'Y-m-d H:i:s', strtotime( '2012-12-01 00:00:00' ) ) ); } public function test_adjusts_format_based_on_locale() { @@ -87,13 +87,13 @@ class Tests_Date_I18n extends WP_UnitTestCase { // Restore original locale. $GLOBALS['wp_locale'] = $original_locale; - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } public function test_adjusts_format_based_on_timezone_string() { update_option( 'timezone_string', 'America/Regina' ); - $this->assertEquals( '2012-12-01 00:00:00 CST -06:00 America/Regina', date_i18n( 'Y-m-d H:i:s T P e', strtotime( '2012-12-01 00:00:00' ) ) ); + $this->assertSame( '2012-12-01 00:00:00 CST -06:00 America/Regina', date_i18n( 'Y-m-d H:i:s T P e', strtotime( '2012-12-01 00:00:00' ) ) ); } /** @@ -110,7 +110,7 @@ class Tests_Date_I18n extends WP_UnitTestCase { $datetime = new DateTime( 'now', $datetimezone ); $datetime = new DateTime( $datetime->format( 'P' ) ); - $this->assertEquals( $datetime->format( $timezone_formats ), date_i18n( $timezone_formats ) ); + $this->assertSame( $datetime->format( $timezone_formats ), date_i18n( $timezone_formats ) ); } /** @@ -122,7 +122,7 @@ class Tests_Date_I18n extends WP_UnitTestCase { update_option( 'timezone_string', 'America/Regina' ); $this->assertEquals( strtotime( date_i18n( $full ) ), strtotime( date_i18n( $short ) ), 'The dates should be equal', 2 ); - $this->assertEquals( $short, date_i18n( '\\' . $short ) ); + $this->assertSame( $short, date_i18n( '\\' . $short ) ); } public function data_formats() { @@ -150,7 +150,7 @@ class Tests_Date_I18n extends WP_UnitTestCase { $this->assertEquals( $wp_timestamp, date_i18n( 'U' ), 'The dates should be equal', 2 ); $this->assertEquals( $timestamp, date_i18n( 'U', false, true ), 'The dates should be equal', 2 ); - $this->assertEquals( $wp_timestamp, date_i18n( 'U', $wp_timestamp ) ); + $this->assertSame( $wp_timestamp, date_i18n( 'U', $wp_timestamp ) ); } /** @@ -159,7 +159,7 @@ class Tests_Date_I18n extends WP_UnitTestCase { public function test_swatch_internet_time_with_wp_timestamp() { update_option( 'timezone_string', 'America/Regina' ); - $this->assertEquals( gmdate( 'B' ), date_i18n( 'B' ) ); + $this->assertSame( gmdate( 'B' ), date_i18n( 'B' ) ); } /** @@ -168,7 +168,7 @@ class Tests_Date_I18n extends WP_UnitTestCase { public function test_should_handle_escaped_formats() { $format = 'D | \D | \\D | \\\D | \\\\D | \\\\\D | \\\\\\D'; - $this->assertEquals( gmdate( $format ), date_i18n( $format ) ); + $this->assertSame( gmdate( $format ), date_i18n( $format ) ); } /** @@ -187,7 +187,7 @@ class Tests_Date_I18n extends WP_UnitTestCase { $wp_timestamp = strtotime( $time ); $format = 'I ' . DATE_RFC3339; - $this->assertEquals( $datetime->format( $format ), date_i18n( $format, $wp_timestamp ) ); + $this->assertSame( $datetime->format( $format ), date_i18n( $format, $wp_timestamp ) ); } public function dst_times() { diff --git a/tests/phpunit/tests/date/getCommentDate.php b/tests/phpunit/tests/date/getCommentDate.php index e1d0834025..95175c3e16 100644 --- a/tests/phpunit/tests/date/getCommentDate.php +++ b/tests/phpunit/tests/date/getCommentDate.php @@ -13,7 +13,7 @@ class Tests_Date_Get_Comment_Date extends WP_UnitTestCase { public function test_get_comment_date_returns_correct_time_with_comment_id() { $c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) ); - $this->assertEquals( 'August 29, 2020', get_comment_date( 'F j, Y', $c ) ); + $this->assertSame( 'August 29, 2020', get_comment_date( 'F j, Y', $c ) ); } /** @@ -22,8 +22,8 @@ class Tests_Date_Get_Comment_Date extends WP_UnitTestCase { public function test_get_comment_date_returns_correct_time_with_empty_format() { $c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) ); - $this->assertEquals( 'August 29, 2020', get_comment_date( '', $c ) ); - $this->assertEquals( 'August 29, 2020', get_comment_date( false, $c ) ); + $this->assertSame( 'August 29, 2020', get_comment_date( '', $c ) ); + $this->assertSame( 'August 29, 2020', get_comment_date( false, $c ) ); } /** @@ -33,7 +33,7 @@ class Tests_Date_Get_Comment_Date extends WP_UnitTestCase { $c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) ); $GLOBALS['comment'] = get_comment( $c ); - $this->assertEquals( '1:51 am', get_comment_time( 'g:i a' ) ); + $this->assertSame( '1:51 am', get_comment_time( 'g:i a' ) ); } /** @@ -43,7 +43,7 @@ class Tests_Date_Get_Comment_Date extends WP_UnitTestCase { $c = self::factory()->comment->create( array( 'comment_date' => '2020-08-29 01:51:00' ) ); $GLOBALS['comment'] = get_comment( $c ); - $this->assertEquals( '1:51 am', get_comment_time( '' ) ); - $this->assertEquals( '1:51 am', get_comment_time( false ) ); + $this->assertSame( '1:51 am', get_comment_time( '' ) ); + $this->assertSame( '1:51 am', get_comment_time( false ) ); } } diff --git a/tests/phpunit/tests/date/getFeedBuildDate.php b/tests/phpunit/tests/date/getFeedBuildDate.php index afe5bbd1fa..31a825a394 100644 --- a/tests/phpunit/tests/date/getFeedBuildDate.php +++ b/tests/phpunit/tests/date/getFeedBuildDate.php @@ -35,7 +35,7 @@ class Tests_Date_Get_Feed_Build_Date extends WP_UnitTestCase { $wp_query = new WP_Query( array( 'p' => $post_id ) ); - $this->assertEquals( '2018-07-23T03:13:23+00:00', get_feed_build_date( DATE_RFC3339 ) ); + $this->assertSame( '2018-07-23T03:13:23+00:00', get_feed_build_date( DATE_RFC3339 ) ); } /** diff --git a/tests/phpunit/tests/date/getPermalink.php b/tests/phpunit/tests/date/getPermalink.php index 2b0e84f52b..782a0507fe 100644 --- a/tests/phpunit/tests/date/getPermalink.php +++ b/tests/phpunit/tests/date/getPermalink.php @@ -33,10 +33,10 @@ class Tests_Date_Get_Permalink extends WP_UnitTestCase { ) ); - $this->assertEquals( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) ); + $this->assertSame( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set date_default_timezone_set( $timezone ); - $this->assertEquals( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) ); + $this->assertSame( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) ); } } diff --git a/tests/phpunit/tests/date/getPostTime.php b/tests/phpunit/tests/date/getPostTime.php index d4cd203aa6..9a58476681 100644 --- a/tests/phpunit/tests/date/getPostTime.php +++ b/tests/phpunit/tests/date/getPostTime.php @@ -13,7 +13,7 @@ class Tests_Date_Get_Post_Time extends WP_UnitTestCase { public function test_get_post_time_returns_correct_time_with_post_id() { $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); - $this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) ); + $this->assertSame( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) ); } /** @@ -32,7 +32,7 @@ class Tests_Date_Get_Post_Time extends WP_UnitTestCase { public function test_get_post_modified_time_returns_correct_time_with_post_id() { $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); - $this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) ); + $this->assertSame( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) ); } /** @@ -64,14 +64,14 @@ class Tests_Date_Get_Post_Time extends WP_UnitTestCase { ) ); - $this->assertEquals( $wp_timestamp, get_post_time( 'U', false, $post_id ) ); - $this->assertEquals( $wp_timestamp, get_post_time( 'G', false, $post_id ) ); - $this->assertEquals( $timestamp, get_post_time( 'U', true, $post_id ) ); - $this->assertEquals( $timestamp, get_post_time( 'G', true, $post_id ) ); - $this->assertEquals( $wp_timestamp, get_post_modified_time( 'U', false, $post_id ) ); - $this->assertEquals( $wp_timestamp, get_post_modified_time( 'G', false, $post_id ) ); - $this->assertEquals( $timestamp, get_post_modified_time( 'U', true, $post_id ) ); - $this->assertEquals( $timestamp, get_post_modified_time( 'G', true, $post_id ) ); + $this->assertSame( $wp_timestamp, get_post_time( 'U', false, $post_id ) ); + $this->assertSame( $wp_timestamp, get_post_time( 'G', false, $post_id ) ); + $this->assertSame( $timestamp, get_post_time( 'U', true, $post_id ) ); + $this->assertSame( $timestamp, get_post_time( 'G', true, $post_id ) ); + $this->assertSame( $wp_timestamp, get_post_modified_time( 'U', false, $post_id ) ); + $this->assertSame( $wp_timestamp, get_post_modified_time( 'G', false, $post_id ) ); + $this->assertSame( $timestamp, get_post_modified_time( 'U', true, $post_id ) ); + $this->assertSame( $timestamp, get_post_modified_time( 'G', true, $post_id ) ); } /** @@ -92,14 +92,14 @@ class Tests_Date_Get_Post_Time extends WP_UnitTestCase { ) ); - $this->assertEquals( $rfc3339, get_post_time( DATE_RFC3339, false, $post_id ) ); - $this->assertEquals( $rfc3339_utc, get_post_time( DATE_RFC3339, true, $post_id ) ); - $this->assertEquals( $rfc3339, get_post_time( DATE_RFC3339, false, $post_id, true ) ); - $this->assertEquals( $rfc3339_utc, get_post_time( DATE_RFC3339, true, $post_id, true ) ); - $this->assertEquals( $rfc3339, get_post_modified_time( DATE_RFC3339, false, $post_id ) ); - $this->assertEquals( $rfc3339_utc, get_post_modified_time( DATE_RFC3339, true, $post_id ) ); - $this->assertEquals( $rfc3339, get_post_modified_time( DATE_RFC3339, false, $post_id, true ) ); - $this->assertEquals( $rfc3339_utc, get_post_modified_time( DATE_RFC3339, true, $post_id, true ) ); + $this->assertSame( $rfc3339, get_post_time( DATE_RFC3339, false, $post_id ) ); + $this->assertSame( $rfc3339_utc, get_post_time( DATE_RFC3339, true, $post_id ) ); + $this->assertSame( $rfc3339, get_post_time( DATE_RFC3339, false, $post_id, true ) ); + $this->assertSame( $rfc3339_utc, get_post_time( DATE_RFC3339, true, $post_id, true ) ); + $this->assertSame( $rfc3339, get_post_modified_time( DATE_RFC3339, false, $post_id ) ); + $this->assertSame( $rfc3339_utc, get_post_modified_time( DATE_RFC3339, true, $post_id ) ); + $this->assertSame( $rfc3339, get_post_modified_time( DATE_RFC3339, false, $post_id, true ) ); + $this->assertSame( $rfc3339_utc, get_post_modified_time( DATE_RFC3339, true, $post_id, true ) ); } /** @@ -121,7 +121,7 @@ class Tests_Date_Get_Post_Time extends WP_UnitTestCase { update_option( 'timezone_string', 'Europe/Kiev' ); - $this->assertEquals( $rfc3339, get_post_time( DATE_RFC3339, true, $post_id ) ); - $this->assertEquals( $rfc3339, get_post_modified_time( DATE_RFC3339, true, $post_id ) ); + $this->assertSame( $rfc3339, get_post_time( DATE_RFC3339, true, $post_id ) ); + $this->assertSame( $rfc3339, get_post_modified_time( DATE_RFC3339, true, $post_id ) ); } } diff --git a/tests/phpunit/tests/date/getTheDate.php b/tests/phpunit/tests/date/getTheDate.php index 778936684c..1f1f8f223f 100644 --- a/tests/phpunit/tests/date/getTheDate.php +++ b/tests/phpunit/tests/date/getTheDate.php @@ -13,7 +13,7 @@ class Tests_Date_Get_The_Date extends WP_UnitTestCase { public function test_get_the_date_returns_correct_time_with_post_id() { $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); - $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) ); + $this->assertSame( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) ); } /** @@ -32,8 +32,8 @@ class Tests_Date_Get_The_Date extends WP_UnitTestCase { public function test_get_the_date_returns_correct_time_with_empty_format() { $post_id = self::factory()->post->create( array( 'post_date' => '2020-08-29 01:51:00' ) ); - $this->assertEquals( 'August 29, 2020', get_the_date( '', $post_id ) ); - $this->assertEquals( 'August 29, 2020', get_the_date( false, $post_id ) ); + $this->assertSame( 'August 29, 2020', get_the_date( '', $post_id ) ); + $this->assertSame( 'August 29, 2020', get_the_date( false, $post_id ) ); } /** @@ -42,7 +42,7 @@ class Tests_Date_Get_The_Date extends WP_UnitTestCase { public function test_get_the_time_returns_correct_time_with_post_id() { $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); - $this->assertEquals( '16:35:00', get_the_time( 'H:i:s', $post_id ) ); + $this->assertSame( '16:35:00', get_the_time( 'H:i:s', $post_id ) ); } /** @@ -61,7 +61,7 @@ class Tests_Date_Get_The_Date extends WP_UnitTestCase { public function test_get_the_time_returns_correct_time_with_empty_format() { $post_id = self::factory()->post->create( array( 'post_date' => '2020-08-29 01:51:00' ) ); - $this->assertEquals( '1:51 am', get_the_time( '', $post_id ) ); - $this->assertEquals( '1:51 am', get_the_time( false, $post_id ) ); + $this->assertSame( '1:51 am', get_the_time( '', $post_id ) ); + $this->assertSame( '1:51 am', get_the_time( false, $post_id ) ); } } diff --git a/tests/phpunit/tests/date/getTheModifiedDate.php b/tests/phpunit/tests/date/getTheModifiedDate.php index 9f104ae61a..6ff1fb752e 100644 --- a/tests/phpunit/tests/date/getTheModifiedDate.php +++ b/tests/phpunit/tests/date/getTheModifiedDate.php @@ -23,7 +23,7 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase { $format = 'Y-m-d'; $expected = '2016-01-21'; $actual = get_the_modified_date( $format, $post_id ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** @@ -46,7 +46,7 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase { $expected = '2016-01-21'; $format = 'Y-m-d'; $actual = get_the_modified_date( $format ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** @@ -63,14 +63,14 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase { $expected = 'filtered modified date failure result'; add_filter( 'get_the_modified_date', array( $this, '_filter_get_the_modified_date_failure' ) ); $actual = get_the_modified_date(); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); remove_filter( 'get_the_modified_date', array( $this, '_filter_get_the_modified_date_failure' ) ); } public function _filter_get_the_modified_date_failure( $the_date ) { $expected = false; $actual = $the_date; - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); if ( false === $the_date ) { return 'filtered modified date failure result'; @@ -94,8 +94,8 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase { public function test_get_the_modified_date_returns_correct_time_with_empty_format() { $post_id = self::factory()->post->create( array( 'post_date' => '2020-08-31 23:14:00' ) ); - $this->assertEquals( 'August 31, 2020', get_the_modified_date( '', $post_id ) ); - $this->assertEquals( 'August 31, 2020', get_the_modified_date( false, $post_id ) ); + $this->assertSame( 'August 31, 2020', get_the_modified_date( '', $post_id ) ); + $this->assertSame( 'August 31, 2020', get_the_modified_date( false, $post_id ) ); } /** @@ -112,9 +112,9 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase { ); $post_id = $this->factory->post->create( $details ); $format = 'G'; - $expected = '1453390476'; + $expected = 1453390476; $actual = get_the_modified_time( $format, $post_id ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** @@ -134,10 +134,10 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase { $GLOBALS['post'] = $post; - $expected = '1453390476'; + $expected = 1453390476; $format = 'G'; $actual = get_the_modified_time( $format ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** @@ -154,14 +154,14 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase { $expected = 'filtered modified time failure result'; add_filter( 'get_the_modified_time', array( $this, '_filter_get_the_modified_time_failure' ) ); $actual = get_the_modified_time(); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); remove_filter( 'get_the_modified_time', array( $this, '_filter_get_the_modified_time_failure' ) ); } public function _filter_get_the_modified_time_failure( $the_time ) { $expected = false; $actual = $the_time; - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); if ( false === $the_time ) { return 'filtered modified time failure result'; @@ -185,7 +185,7 @@ class Tests_Date_Get_The_Modified_Date extends WP_UnitTestCase { public function test_get_the_modified_time_returns_correct_time_with_empty_format() { $post_id = self::factory()->post->create( array( 'post_date' => '2020-08-31 23:14:00' ) ); - $this->assertEquals( '11:14 pm', get_the_modified_time( '', $post_id ) ); - $this->assertEquals( '11:14 pm', get_the_modified_time( false, $post_id ) ); + $this->assertSame( '11:14 pm', get_the_modified_time( '', $post_id ) ); + $this->assertSame( '11:14 pm', get_the_modified_time( false, $post_id ) ); } } diff --git a/tests/phpunit/tests/date/maybeDeclineDate.php b/tests/phpunit/tests/date/maybeDeclineDate.php index a3edf8b971..400662a5e2 100644 --- a/tests/phpunit/tests/date/maybeDeclineDate.php +++ b/tests/phpunit/tests/date/maybeDeclineDate.php @@ -57,7 +57,7 @@ class Tests_Functions_MaybeDeclineDate extends WP_UnitTestCase { remove_filter( 'gettext_with_context', array( $this, 'filter__enable_months_names_declension' ), 10 ); - $this->assertEquals( $output, $declined_date ); + $this->assertSame( $output, $declined_date ); } public function filter__enable_months_names_declension( $translation, $text, $context ) { diff --git a/tests/phpunit/tests/date/mysql2date.php b/tests/phpunit/tests/date/mysql2date.php index 863f812d89..81ae9f13d0 100644 --- a/tests/phpunit/tests/date/mysql2date.php +++ b/tests/phpunit/tests/date/mysql2date.php @@ -24,8 +24,8 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { * @ticket 28310 */ function test_mysql2date_returns_gmt_or_unix_timestamp() { - $this->assertEquals( '441013392', mysql2date( 'G', '1983-12-23 07:43:12' ) ); - $this->assertEquals( '441013392', mysql2date( 'U', '1983-12-23 07:43:12' ) ); + $this->assertSame( 441013392, mysql2date( 'G', '1983-12-23 07:43:12' ) ); + $this->assertSame( 441013392, mysql2date( 'U', '1983-12-23 07:43:12' ) ); } /** @@ -38,8 +38,8 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { $rfc3339 = $datetime->format( DATE_RFC3339 ); $mysql = $datetime->format( 'Y-m-d H:i:s' ); - $this->assertEquals( $rfc3339, mysql2date( DATE_RFC3339, $mysql ) ); - $this->assertEquals( $rfc3339, mysql2date( DATE_RFC3339, $mysql, false ) ); + $this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql ) ); + $this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql, false ) ); } /** @@ -54,8 +54,8 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { $rfc3339 = $datetime->format( DATE_RFC3339 ); $mysql = $datetime->format( 'Y-m-d H:i:s' ); - $this->assertEquals( $rfc3339, mysql2date( DATE_RFC3339, $mysql ) ); - $this->assertEquals( $rfc3339, mysql2date( DATE_RFC3339, $mysql, false ) ); + $this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql ) ); + $this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql, false ) ); } /** @@ -68,8 +68,8 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { $wp_timestamp = $datetime->getTimestamp() + $datetime->getOffset(); $mysql = $datetime->format( 'Y-m-d H:i:s' ); - $this->assertEquals( $wp_timestamp, mysql2date( 'U', $mysql, false ) ); - $this->assertEquals( $wp_timestamp, mysql2date( 'G', $mysql, false ) ); + $this->assertSame( $wp_timestamp, mysql2date( 'U', $mysql, false ) ); + $this->assertSame( $wp_timestamp, mysql2date( 'G', $mysql, false ) ); } /** @@ -82,7 +82,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { $timestamp = $datetime->getTimestamp(); $mysql = $datetime->format( 'Y-m-d H:i:s' ); - $this->assertEquals( $timestamp, mysql2date( 'U', $mysql, false ) ); - $this->assertEquals( $timestamp, mysql2date( 'G', $mysql, false ) ); + $this->assertSame( $timestamp, mysql2date( 'U', $mysql, false ) ); + $this->assertSame( $timestamp, mysql2date( 'G', $mysql, false ) ); } } diff --git a/tests/phpunit/tests/date/query.php b/tests/phpunit/tests/date/query.php index de4cf987dd..187979606a 100644 --- a/tests/phpunit/tests/date/query.php +++ b/tests/phpunit/tests/date/query.php @@ -110,7 +110,7 @@ class Tests_WP_Date_Query extends WP_UnitTestCase { 'relation' => 'AND', ); - $this->assertEquals( $expected, $q->queries ); + $this->assertSame( $expected, $q->queries ); } public function test_get_compare_empty() { @@ -1078,7 +1078,7 @@ class Tests_WP_Date_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), $q->posts ); + $this->assertSame( array( $p2 ), $q->posts ); } /** @@ -1100,7 +1100,7 @@ class Tests_WP_Date_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), $q->posts ); + $this->assertSame( array( $p2 ), $q->posts ); } /** @@ -1124,7 +1124,7 @@ class Tests_WP_Date_Query extends WP_UnitTestCase { ); // MySQL ignores the invalid clause. - $this->assertEquals( array( $p1, $p2 ), $q->posts ); + $this->assertSame( array( $p1, $p2 ), $q->posts ); } /** Helpers */ diff --git a/tests/phpunit/tests/date/theDate.php b/tests/phpunit/tests/date/theDate.php index 46fff6709e..a6e67eaf41 100644 --- a/tests/phpunit/tests/date/theDate.php +++ b/tests/phpunit/tests/date/theDate.php @@ -61,20 +61,20 @@ class Tests_Date_The_Date extends WP_UnitTestCase { ob_end_clean(); - $this->assertEquals( 1, $this->hooks_called['the_time'] ); - $this->assertEquals( 2, $this->hooks_called['get_the_time'] ); + $this->assertSame( 1, $this->hooks_called['the_time'] ); + $this->assertSame( 2, $this->hooks_called['get_the_time'] ); - $this->assertEquals( 1, $this->hooks_called['the_modified_time'] ); - $this->assertEquals( 2, $this->hooks_called['get_the_modified_time'] ); + $this->assertSame( 1, $this->hooks_called['the_modified_time'] ); + $this->assertSame( 2, $this->hooks_called['get_the_modified_time'] ); - $this->assertEquals( 1, $this->hooks_called['the_date'] ); - $this->assertEquals( 2, $this->hooks_called['get_the_date'] ); + $this->assertSame( 1, $this->hooks_called['the_date'] ); + $this->assertSame( 2, $this->hooks_called['get_the_date'] ); - $this->assertEquals( 1, $this->hooks_called['the_modified_date'] ); - $this->assertEquals( 2, $this->hooks_called['get_the_modified_date'] ); + $this->assertSame( 1, $this->hooks_called['the_modified_date'] ); + $this->assertSame( 2, $this->hooks_called['get_the_modified_date'] ); - $this->assertEquals( 5, $this->hooks_called['get_post_time'] ); - $this->assertEquals( 5, $this->hooks_called['get_post_modified_time'] ); + $this->assertSame( 5, $this->hooks_called['get_post_time'] ); + $this->assertSame( 5, $this->hooks_called['get_post_modified_time'] ); } public function count_hook( $input ) { @@ -90,7 +90,7 @@ class Tests_Date_The_Date extends WP_UnitTestCase { ob_start(); the_date(); $actual = ob_get_clean(); - $this->assertEquals( '', $actual ); + $this->assertSame( '', $actual ); $GLOBALS['post'] = self::factory()->post->create_and_get( array( @@ -102,25 +102,25 @@ class Tests_Date_The_Date extends WP_UnitTestCase { $GLOBALS['currentday'] = '18.09.15'; $GLOBALS['previousday'] = '17.09.15'; the_date(); - $this->assertEquals( 'September 16, 2015', ob_get_clean() ); + $this->assertSame( 'September 16, 2015', ob_get_clean() ); ob_start(); $GLOBALS['currentday'] = '18.09.15'; $GLOBALS['previousday'] = '17.09.15'; the_date( 'Y' ); - $this->assertEquals( '2015', ob_get_clean() ); + $this->assertSame( '2015', ob_get_clean() ); ob_start(); $GLOBALS['currentday'] = '18.09.15'; $GLOBALS['previousday'] = '17.09.15'; the_date( 'Y', 'before ', ' after' ); - $this->assertEquals( 'before 2015 after', ob_get_clean() ); + $this->assertSame( 'before 2015 after', ob_get_clean() ); ob_start(); $GLOBALS['currentday'] = '18.09.15'; $GLOBALS['previousday'] = '17.09.15'; the_date( 'Y', 'before ', ' after', false ); - $this->assertEquals( '', ob_get_clean() ); + $this->assertSame( '', ob_get_clean() ); } /** @@ -130,7 +130,7 @@ class Tests_Date_The_Date extends WP_UnitTestCase { ob_start(); the_weekday_date(); $actual = ob_get_clean(); - $this->assertEquals( '', $actual ); + $this->assertSame( '', $actual ); $GLOBALS['post'] = self::factory()->post->create_and_get( array( @@ -142,12 +142,12 @@ class Tests_Date_The_Date extends WP_UnitTestCase { $GLOBALS['currentday'] = '18.09.15'; $GLOBALS['previousweekday'] = '17.09.15'; the_weekday_date(); - $this->assertEquals( 'Wednesday', ob_get_clean() ); + $this->assertSame( 'Wednesday', ob_get_clean() ); ob_start(); $GLOBALS['currentday'] = '18.09.15'; $GLOBALS['previousweekday'] = '17.09.15'; the_weekday_date( 'before ', ' after' ); - $this->assertEquals( 'before Wednesday after', ob_get_clean() ); + $this->assertSame( 'before Wednesday after', ob_get_clean() ); } } diff --git a/tests/phpunit/tests/date/wpDate.php b/tests/phpunit/tests/date/wpDate.php index 01145c82c4..2b3212f395 100644 --- a/tests/phpunit/tests/date/wpDate.php +++ b/tests/phpunit/tests/date/wpDate.php @@ -43,7 +43,7 @@ class Tests_Date_WP_Date extends WP_UnitTestCase { $utc = new DateTimeZone( 'UTC' ); $datetime = new DateTimeImmutable( '2019-10-17', $utc ); - $this->assertEquals( '10月', wp_date( 'F', $datetime->getTimestamp(), $utc ) ); + $this->assertSame( '10月', wp_date( 'F', $datetime->getTimestamp(), $utc ) ); } /** @@ -58,6 +58,6 @@ class Tests_Date_WP_Date extends WP_UnitTestCase { $utc = new DateTimeZone( 'UTC' ); $datetime = new DateTimeImmutable( '2019-10-17', $utc ); - $this->assertEquals( $string, wp_date( 'F', $datetime->getTimestamp(), $utc ) ); + $this->assertSame( $string, wp_date( 'F', $datetime->getTimestamp(), $utc ) ); } } diff --git a/tests/phpunit/tests/date/wpTimezone.php b/tests/phpunit/tests/date/wpTimezone.php index 359ab1244f..5306b77786 100644 --- a/tests/phpunit/tests/date/wpTimezone.php +++ b/tests/phpunit/tests/date/wpTimezone.php @@ -18,11 +18,11 @@ class Tests_Date_WP_Timezone extends WP_UnitTestCase { delete_option( 'timezone_string' ); update_option( 'gmt_offset', $gmt_offset ); - $this->assertEquals( $tz_name, wp_timezone_string() ); + $this->assertSame( $tz_name, wp_timezone_string() ); $timezone = wp_timezone(); - $this->assertEquals( $tz_name, $timezone->getName() ); + $this->assertSame( $tz_name, $timezone->getName() ); } /** @@ -31,11 +31,11 @@ class Tests_Date_WP_Timezone extends WP_UnitTestCase { public function test_should_return_timezone_string() { update_option( 'timezone_string', 'Europe/Kiev' ); - $this->assertEquals( 'Europe/Kiev', wp_timezone_string() ); + $this->assertSame( 'Europe/Kiev', wp_timezone_string() ); $timezone = wp_timezone(); - $this->assertEquals( 'Europe/Kiev', $timezone->getName() ); + $this->assertSame( 'Europe/Kiev', $timezone->getName() ); } /** diff --git a/tests/phpunit/tests/date/xmlrpc.php b/tests/phpunit/tests/date/xmlrpc.php index 46d269ff0a..285cddd645 100644 --- a/tests/phpunit/tests/date/xmlrpc.php +++ b/tests/phpunit/tests/date/xmlrpc.php @@ -34,7 +34,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( $datetime->format( 'Y-m-d H:i:s' ), $post->post_date, 'UTC time with explicit time zone into mw_newPost' @@ -55,7 +55,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( $datetime->format( 'Y-m-d H:i:s' ), $post->post_date, 'Local time w/o time zone into mw_newPost' @@ -76,7 +76,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( $datetime->format( 'Y-m-d H:i:s' ), $post->post_date, 'UTC time into mw_newPost' @@ -97,7 +97,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( $datetime->format( 'Y-m-d H:i:s' ), $post->post_date, 'Local time into wp_newPost' @@ -118,7 +118,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( $datetime->format( 'Y-m-d H:i:s' ), $post->post_date, 'UTC time into wp_newPost' @@ -158,7 +158,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase { $fetched_post = get_post( $post_id ); $this->assertTrue( $result ); - $this->assertEquals( + $this->assertSame( $datetime->format( 'Y-m-d H:i:s' ), $fetched_post->post_date, 'Local time into mw_editPost' @@ -185,7 +185,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase { $fetched_post = get_post( $post_id ); $this->assertTrue( $result ); - $this->assertEquals( + $this->assertSame( $datetime->format( 'Y-m-d H:i:s' ), $fetched_post->post_date, 'UTC time into mw_editPost' @@ -231,7 +231,7 @@ class Tests_Date_XMLRPC extends WP_XMLRPC_UnitTestCase { $fetched_comment = get_comment( $comment_id ); $this->assertTrue( $result ); - $this->assertEquals( + $this->assertSame( $datetime->format( 'Y-m-d H:i:s' ), $fetched_comment->comment_date, 'UTC time into wp_editComment' diff --git a/tests/phpunit/tests/db.php b/tests/phpunit/tests/db.php index c3d43b1fa3..d55ac179f7 100644 --- a/tests/phpunit/tests/db.php +++ b/tests/phpunit/tests/db.php @@ -148,7 +148,7 @@ class Tests_DB extends WP_UnitTestCase { ); foreach ( $inputs as $key => $input ) { - $this->assertEquals( $expected[ $key ], $wpdb->esc_like( $input ) ); + $this->assertSame( $expected[ $key ], $wpdb->esc_like( $input ) ); } } @@ -167,7 +167,7 @@ class Tests_DB extends WP_UnitTestCase { */ function test_like_query( $data, $like, $result ) { global $wpdb; - return $this->assertEquals( $result, $wpdb->get_var( $wpdb->prepare( 'SELECT %s LIKE %s', $data, $wpdb->esc_like( $like ) ) ) ); + return $this->assertSame( $result, $wpdb->get_var( $wpdb->prepare( 'SELECT %s LIKE %s', $data, $wpdb->esc_like( $like ) ) ) ); } function data_like_query() { @@ -253,7 +253,7 @@ class Tests_DB extends WP_UnitTestCase { $wpdb->col_meta = $new_meta; $this->assertNotEquals( $col_meta, $new_meta ); - $this->assertEquals( $col_meta, $wpdb->col_meta ); + $this->assertSame( $col_meta, $wpdb->col_meta ); } /** @@ -281,7 +281,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertContains( $wpdb->placeholder_escape(), $sql ); $sql = $wpdb->remove_placeholder_escape( $sql ); - $this->assertEquals( "UPDATE test_table SET string_column = '%f is a float, %d is an int 3, %s is a string', field = '4'", $sql ); + $this->assertSame( "UPDATE test_table SET string_column = '%f is a float, %d is an int 3, %s is a string', field = '4'", $sql ); } @@ -367,14 +367,14 @@ class Tests_DB extends WP_UnitTestCase { // This, obviously, is an incorrect prepare. // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared $prepared = $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = $id", $id ); - $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0", $prepared ); + $this->assertSame( "SELECT * FROM $wpdb->users WHERE id = 0", $prepared ); } function test_prepare_sprintf() { global $wpdb; $prepared = $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", 1, 'admin' ); - $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = 'admin'", $prepared ); + $this->assertSame( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = 'admin'", $prepared ); } /** @@ -385,18 +385,18 @@ class Tests_DB extends WP_UnitTestCase { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", 1, array( 'admin' ) ); - $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = ''", $prepared ); + $this->assertSame( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = ''", $prepared ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( 1 ), 'admin' ); - $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared ); + $this->assertSame( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared ); } function test_prepare_vsprintf() { global $wpdb; $prepared = $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( 1, 'admin' ) ); - $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = 'admin'", $prepared ); + $this->assertSame( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = 'admin'", $prepared ); } /** @@ -407,11 +407,11 @@ class Tests_DB extends WP_UnitTestCase { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( 1, array( 'admin' ) ) ); - $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = ''", $prepared ); + $this->assertSame( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = ''", $prepared ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( array( 1 ), 'admin' ) ); - $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared ); + $this->assertSame( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared ); } /** @@ -490,7 +490,7 @@ class Tests_DB extends WP_UnitTestCase { $str = $wpdb->get_caller(); $calls = explode( ', ', $str ); $called = join( '->', array( __CLASS__, __FUNCTION__ ) ); - $this->assertEquals( $called, end( $calls ) ); + $this->assertSame( $called, end( $calls ) ); } function test_has_cap() { @@ -501,11 +501,11 @@ class Tests_DB extends WP_UnitTestCase { $this->assertTrue( $wpdb->has_cap( 'COLLATION' ) ); $this->assertTrue( $wpdb->has_cap( 'GROUP_CONCAT' ) ); $this->assertTrue( $wpdb->has_cap( 'SUBQUERIES' ) ); - $this->assertEquals( + $this->assertSame( version_compare( $wpdb->db_version(), '5.0.7', '>=' ), $wpdb->has_cap( 'set_charset' ) ); - $this->assertEquals( + $this->assertSame( version_compare( $wpdb->db_version(), '5.0.7', '>=' ), $wpdb->has_cap( 'SET_CHARSET' ) ); @@ -548,29 +548,29 @@ class Tests_DB extends WP_UnitTestCase { $wpdb->get_results( "SELECT ID FROM $wpdb->users" ); - $this->assertEquals( array( 'ID' ), $wpdb->get_col_info() ); - $this->assertEquals( array( $wpdb->users ), $wpdb->get_col_info( 'table' ) ); - $this->assertEquals( $wpdb->users, $wpdb->get_col_info( 'table', 0 ) ); + $this->assertSame( array( 'ID' ), $wpdb->get_col_info() ); + $this->assertSame( array( $wpdb->users ), $wpdb->get_col_info( 'table' ) ); + $this->assertSame( $wpdb->users, $wpdb->get_col_info( 'table', 0 ) ); } function test_query_and_delete() { global $wpdb; $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" ); - $this->assertEquals( 1, $rows ); + $this->assertSame( 1, $rows ); $this->assertNotEmpty( $wpdb->insert_id ); $d_rows = $wpdb->delete( $wpdb->users, array( 'ID' => $wpdb->insert_id ) ); - $this->assertEquals( 1, $d_rows ); + $this->assertSame( 1, $d_rows ); } function test_get_row() { global $wpdb; $rows = $wpdb->query( "INSERT INTO $wpdb->users (display_name) VALUES ('Walter Sobchak')" ); - $this->assertEquals( 1, $rows ); + $this->assertSame( 1, $rows ); $this->assertNotEmpty( $wpdb->insert_id ); $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $wpdb->insert_id ) ); $this->assertInternalType( 'object', $row ); - $this->assertEquals( 'Walter Sobchak', $row->display_name ); + $this->assertSame( 'Walter Sobchak', $row->display_name ); } /** @@ -667,7 +667,7 @@ class Tests_DB extends WP_UnitTestCase { function test_replace() { global $wpdb; $rows1 = $wpdb->insert( $wpdb->users, array( 'display_name' => 'Walter Sobchak' ) ); - $this->assertEquals( 1, $rows1 ); + $this->assertSame( 1, $rows1 ); $this->assertNotEmpty( $wpdb->insert_id ); $last = $wpdb->insert_id; @@ -678,13 +678,13 @@ class Tests_DB extends WP_UnitTestCase { 'display_name' => 'Walter Replace Sobchak', ) ); - $this->assertEquals( 2, $rows2 ); + $this->assertSame( 2, $rows2 ); $this->assertNotEmpty( $wpdb->insert_id ); - $this->assertEquals( $last, $wpdb->insert_id ); + $this->assertSame( $last, $wpdb->insert_id ); $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $last ) ); - $this->assertEquals( 'Walter Replace Sobchak', $row->display_name ); + $this->assertSame( 'Walter Replace Sobchak', $row->display_name ); } /** @@ -699,13 +699,13 @@ class Tests_DB extends WP_UnitTestCase { $expected1 = "UPDATE `{$wpdb->posts}` SET `post_name` = 'burrito' WHERE "; $this->assertNotEmpty( $wpdb->last_error ); - $this->assertEquals( $expected1, $wpdb->last_query ); + $this->assertSame( $expected1, $wpdb->last_query ); $wpdb->update( $wpdb->posts, array( 'post_name' => 'burrito' ), array( 'post_status' => 'taco' ) ); $expected2 = "UPDATE `{$wpdb->posts}` SET `post_name` = 'burrito' WHERE `post_status` = 'taco'"; $this->assertEmpty( $wpdb->last_error ); - $this->assertEquals( $expected2, $wpdb->last_query ); + $this->assertSame( $expected2, $wpdb->last_query ); $wpdb->suppress_errors( $suppress ); } @@ -875,7 +875,7 @@ class Tests_DB extends WP_UnitTestCase { * @ticket 21212 */ function test_get_table_from_query( $query, $table ) { - $this->assertEquals( $table, self::$_wpdb->get_table_from_query( $query ) ); + $this->assertSame( $table, self::$_wpdb->get_table_from_query( $query ) ); } function data_get_table_from_query_false() { @@ -917,7 +917,7 @@ class Tests_DB extends WP_UnitTestCase { * @ticket 38751 */ function test_get_escaped_table_from_show_query( $query, $table ) { - $this->assertEquals( $table, self::$_wpdb->get_table_from_query( $query ) ); + $this->assertSame( $table, self::$_wpdb->get_table_from_query( $query ) ); } /** @@ -1084,7 +1084,7 @@ class Tests_DB extends WP_UnitTestCase { $charset = self::$_wpdb->get_table_charset( 'some_table' ); remove_filter( 'pre_get_table_charset', array( $this, 'filter_pre_get_table_charset' ), 10 ); - $this->assertEquals( $charset, 'fake_charset' ); + $this->assertSame( $charset, 'fake_charset' ); } function filter_pre_get_table_charset( $charset, $table ) { return 'fake_charset'; @@ -1098,7 +1098,7 @@ class Tests_DB extends WP_UnitTestCase { $charset = self::$_wpdb->get_col_charset( 'some_table', 'some_col' ); remove_filter( 'pre_get_col_charset', array( $this, 'filter_pre_get_col_charset' ), 10 ); - $this->assertEquals( $charset, 'fake_col_charset' ); + $this->assertSame( $charset, 'fake_col_charset' ); } function filter_pre_get_col_charset( $charset, $table, $column ) { return 'fake_col_charset'; @@ -1366,7 +1366,7 @@ class Tests_DB extends WP_UnitTestCase { // phpcs:ignore WordPress.DB.PreparedSQL $sql = $wpdb->prepare( $sql, ...$values ); - $this->assertEquals( $expected, $sql ); + $this->assertSame( $expected, $sql ); } /** @@ -1385,7 +1385,7 @@ class Tests_DB extends WP_UnitTestCase { // phpcs:ignore WordPress.DB.PreparedSQL $sql = $wpdb->prepare( $sql, $values ); - $this->assertEquals( $expected, $sql ); + $this->assertSame( $expected, $sql ); } function data_prepare_with_placeholders() { @@ -1580,7 +1580,7 @@ class Tests_DB extends WP_UnitTestCase { // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared $actual = $wpdb->prepare( $sql, $values ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function data_escape_and_prepare() { @@ -1668,7 +1668,7 @@ class Tests_DB extends WP_UnitTestCase { $wpdb->query( "DROP TABLE {$wpdb->prefix}test_placeholder" ); $this->assertNotContains( '%s', $sql ); - $this->assertEquals( $value, $actual ); + $this->assertSame( $value, $actual ); } function test_esc_sql_with_unsupported_placeholder_type() { @@ -1678,7 +1678,7 @@ class Tests_DB extends WP_UnitTestCase { // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared $sql = $wpdb->prepare( " $sql %s ", 'foo' ); - $this->assertEquals( " 'foo' {$wpdb->placeholder_escape()}1\$c 'foo' ", $sql ); + $this->assertSame( " 'foo' {$wpdb->placeholder_escape()}1\$c 'foo' ", $sql ); } /** diff --git a/tests/phpunit/tests/db/charset.php b/tests/phpunit/tests/db/charset.php index 0596c696f3..7a7fc82353 100644 --- a/tests/phpunit/tests/db/charset.php +++ b/tests/phpunit/tests/db/charset.php @@ -416,7 +416,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { $conv_utf8 = mb_convert_encoding( $big5, 'UTF-8', 'BIG-5' ); // Make sure PHP's multibyte conversions are working correctly. $this->assertNotEquals( $utf8, $big5 ); - $this->assertEquals( $utf8, $conv_utf8 ); + $this->assertSame( $utf8, $conv_utf8 ); $fields['big5'] = array( 'charset' => 'big5', @@ -647,7 +647,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { $value = "H€llo\xe0\x80\x80World\xf0\xff\xff\xff¢"; $expected = 'H€lloWorld¢'; $actual = $wpdb->strip_invalid_text_for_column( $wpdb->posts, 'post_content', $value ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** @@ -754,10 +754,10 @@ class Tests_DB_Charset extends WP_UnitTestCase { self::$_wpdb->query( $create ); $charset = self::$_wpdb->get_table_charset( $table ); - $this->assertEquals( $charset, $expected_charset ); + $this->assertSame( $charset, $expected_charset ); $charset = self::$_wpdb->get_table_charset( strtoupper( $table ) ); - $this->assertEquals( $charset, $expected_charset ); + $this->assertSame( $charset, $expected_charset ); self::$_wpdb->query( $drop ); } @@ -794,8 +794,8 @@ class Tests_DB_Charset extends WP_UnitTestCase { self::$_wpdb->query( $create ); foreach ( $expected_charset as $column => $charset ) { - $this->assertEquals( $charset, self::$_wpdb->get_col_charset( $table, $column ) ); - $this->assertEquals( $charset, self::$_wpdb->get_col_charset( strtoupper( $table ), strtoupper( $column ) ) ); + $this->assertSame( $charset, self::$_wpdb->get_col_charset( $table, $column ) ); + $this->assertSame( $charset, self::$_wpdb->get_col_charset( strtoupper( $table ), strtoupper( $column ) ) ); } self::$_wpdb->query( $drop ); @@ -819,7 +819,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { $columns = array_keys( $columns ); foreach ( $columns as $column => $charset ) { - $this->assertEquals( false, self::$_wpdb->get_col_charset( $table, $column ) ); + $this->assertFalse( self::$_wpdb->get_col_charset( $table, $column ) ); } self::$_wpdb->query( $drop ); @@ -845,7 +845,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { $columns = array_keys( $columns ); foreach ( $columns as $column => $charset ) { - $this->assertEquals( false, self::$_wpdb->get_col_charset( $table, $column ) ); + $this->assertFalse( self::$_wpdb->get_col_charset( $table, $column ) ); } self::$_wpdb->query( $drop ); @@ -901,7 +901,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { self::$_wpdb->query( $create ); $return = self::$_wpdb->strip_invalid_text_from_query( $query ); - $this->assertEquals( $expected, $return ); + $this->assertSame( $expected, $return ); self::$_wpdb->query( $drop ); } @@ -935,7 +935,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { */ function test_dont_strip_text_from_schema_queries( $query ) { $return = self::$_wpdb->strip_invalid_text_from_query( $query ); - $this->assertEquals( $query, $return ); + $this->assertSame( $query, $return ); } /** @@ -1017,7 +1017,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { self::$_wpdb->query( $create ); $return = self::$_wpdb->check_safe_collation( $query ); - $this->assertEquals( $expected, $return ); + $this->assertSame( $expected, $return ); foreach ( $always_true as $true_query ) { $return = self::$_wpdb->check_safe_collation( $true_query ); @@ -1032,11 +1032,11 @@ class Tests_DB_Charset extends WP_UnitTestCase { // TEXT column. $stripped = $wpdb->strip_invalid_text_for_column( $wpdb->comments, 'comment_content', str_repeat( 'A', 65536 ) ); - $this->assertEquals( 65535, strlen( $stripped ) ); + $this->assertSame( 65535, strlen( $stripped ) ); // VARCHAR column. $stripped = $wpdb->strip_invalid_text_for_column( $wpdb->comments, 'comment_agent', str_repeat( 'A', 256 ) ); - $this->assertEquals( 255, strlen( $stripped ) ); + $this->assertSame( 255, strlen( $stripped ) ); } /** @@ -1053,7 +1053,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { self::$_wpdb->query( "DROP TABLE $tablename" ); - $this->assertEquals( $safe_query, $stripped_query ); + $this->assertSame( $safe_query, $stripped_query ); } /** @@ -1075,7 +1075,7 @@ class Tests_DB_Charset extends WP_UnitTestCase { self::$_wpdb->charset = $charset; - $this->assertEquals( $safe_query, $stripped_query ); + $this->assertSame( $safe_query, $stripped_query ); } /** @@ -1084,11 +1084,11 @@ class Tests_DB_Charset extends WP_UnitTestCase { function test_set_charset_changes_the_connection_collation() { self::$_wpdb->set_charset( self::$_wpdb->dbh, 'utf8', 'utf8_general_ci' ); $results = self::$_wpdb->get_results( "SHOW VARIABLES WHERE Variable_name='collation_connection'" ); - $this->assertEquals( 'utf8_general_ci', $results[0]->Value ); + $this->assertSame( 'utf8_general_ci', $results[0]->Value ); self::$_wpdb->set_charset( self::$_wpdb->dbh, 'utf8mb4', 'utf8mb4_unicode_ci' ); $results = self::$_wpdb->get_results( "SHOW VARIABLES WHERE Variable_name='collation_connection'" ); - $this->assertEquals( 'utf8mb4_unicode_ci', $results[0]->Value ); + $this->assertSame( 'utf8mb4_unicode_ci', $results[0]->Value ); self::$_wpdb->set_charset( self::$_wpdb->dbh ); } diff --git a/tests/phpunit/tests/dbdelta.php b/tests/phpunit/tests/dbdelta.php index d88d1c807c..c54f9cc4dd 100644 --- a/tests/phpunit/tests/dbdelta.php +++ b/tests/phpunit/tests/dbdelta.php @@ -116,9 +116,9 @@ class Tests_dbDelta extends WP_UnitTestCase { "{$wpdb->prefix}dbdelta_create_test" => "Created table {$wpdb->prefix}dbdelta_create_test", ); - $this->assertEquals( $expected, $updates ); + $this->assertSame( $expected, $updates ); - $this->assertEquals( + $this->assertSame( "{$wpdb->prefix}dbdelta_create_test", $wpdb->get_var( $wpdb->prepare( @@ -150,7 +150,7 @@ class Tests_dbDelta extends WP_UnitTestCase { " ); - $this->assertEquals( array(), $updates ); + $this->assertSame( array(), $updates ); } /** @@ -173,7 +173,7 @@ class Tests_dbDelta extends WP_UnitTestCase { " ); - $this->assertEquals( + $this->assertSame( array( "{$wpdb->prefix}dbdelta_test.id" => "Changed type of {$wpdb->prefix}dbdelta_test.id from bigint{$this->bigint_display_width} to int(11)", @@ -202,7 +202,7 @@ class Tests_dbDelta extends WP_UnitTestCase { " ); - $this->assertEquals( + $this->assertSame( array( "{$wpdb->prefix}dbdelta_test.extra_col" => "Added column {$wpdb->prefix}dbdelta_test.extra_col", @@ -235,7 +235,7 @@ class Tests_dbDelta extends WP_UnitTestCase { " ); - $this->assertEquals( array(), $updates ); + $this->assertSame( array(), $updates ); $this->assertTableHasColumn( 'column_1', $wpdb->prefix . 'dbdelta_test' ); } @@ -262,7 +262,7 @@ class Tests_dbDelta extends WP_UnitTestCase { false // Don't execute. ); - $this->assertEquals( + $this->assertSame( array( "{$wpdb->prefix}dbdelta_test.extra_col" => "Added column {$wpdb->prefix}dbdelta_test.extra_col", @@ -283,7 +283,7 @@ class Tests_dbDelta extends WP_UnitTestCase { "INSERT INTO {$wpdb->prefix}dbdelta_test (column_1) VALUES ('wcphilly2015')" ); - $this->assertEquals( + $this->assertSame( array(), $insert ); diff --git a/tests/phpunit/tests/dependencies.php b/tests/phpunit/tests/dependencies.php index 75b350e592..5ec6f2b276 100644 --- a/tests/phpunit/tests/dependencies.php +++ b/tests/phpunit/tests/dependencies.php @@ -76,12 +76,12 @@ class Tests_Dependencies extends WP_UnitTestCase { $dep->enqueue( 'one?arg' ); $this->assertTrue( $dep->query( 'one', 'queue' ) ); $this->assertFalse( $dep->query( 'two', 'queue' ) ); - $this->assertEquals( 'arg', $dep->args['one'] ); + $this->assertSame( 'arg', $dep->args['one'] ); $dep->enqueue( 'two?arg' ); $this->assertTrue( $dep->query( 'one', 'queue' ) ); $this->assertTrue( $dep->query( 'two', 'queue' ) ); - $this->assertEquals( 'arg', $dep->args['two'] ); + $this->assertSame( 'arg', $dep->args['two'] ); } function test_dequeue_args() { @@ -94,8 +94,8 @@ class Tests_Dependencies extends WP_UnitTestCase { $dep->enqueue( 'two?arg' ); $this->assertTrue( $dep->query( 'one', 'queue' ) ); $this->assertTrue( $dep->query( 'two', 'queue' ) ); - $this->assertEquals( 'arg', $dep->args['one'] ); - $this->assertEquals( 'arg', $dep->args['two'] ); + $this->assertSame( 'arg', $dep->args['one'] ); + $this->assertSame( 'arg', $dep->args['two'] ); $dep->dequeue( 'one' ); $this->assertFalse( $dep->query( 'one', 'queue' ) ); diff --git a/tests/phpunit/tests/dependencies/jquery.php b/tests/phpunit/tests/dependencies/jquery.php index 1d38833992..33cbb3693e 100644 --- a/tests/phpunit/tests/dependencies/jquery.php +++ b/tests/phpunit/tests/dependencies/jquery.php @@ -31,7 +31,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase { $o = $scripts->query( $dep, 'registered' ); $this->assertInstanceOf( '_WP_Dependency', $object ); $this->assertTrue( isset( $jquery_scripts[ $dep ] ) ); - $this->assertEquals( $jquery_scripts[ $dep ], $o->src ); + $this->assertSame( $jquery_scripts[ $dep ], $o->src ); } */ } @@ -40,7 +40,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase { $contents = trim( file_get_contents( ABSPATH . WPINC . '/js/jquery/jquery.js' ) ); $noconflict = 'jQuery.noConflict();'; $end = substr( $contents, - strlen( $noconflict ) ); - $this->assertEquals( $noconflict, $end ); + $this->assertSame( $noconflict, $end ); } /** diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 028d85d09d..bf286822ec 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -51,10 +51,10 @@ JS; $expected .= "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); // No scripts left to print. - $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); + $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); } /** @@ -71,7 +71,7 @@ JS; $ver = get_bloginfo( 'version' ); $expected = "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -110,10 +110,10 @@ JS; $expected .= "\n"; // Go! - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); // No scripts left to print. - $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); + $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); // Cleanup. $wp_scripts->base_url = $base_url_backup; @@ -138,7 +138,7 @@ JS; $ver = get_bloginfo( 'version' ); $expected = "\n"; - $this->assertEquals( $expected, $print_scripts ); + $this->assertSame( $expected, $print_scripts ); } /** @@ -154,10 +154,10 @@ JS; $expected .= "\n"; // Go! - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); // No scripts left to print. - $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); + $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); } /** @@ -172,10 +172,10 @@ JS; $expected = "\n"; // Go! - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); // No scripts left to print. - $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); + $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); } /** @@ -192,10 +192,10 @@ JS; $expected .= "\n"; // Go! - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); // No scripts left to print. - $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); + $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); } /** @@ -210,10 +210,10 @@ JS; $expected = "\n"; // Go! - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); // No scripts left to print. - $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); + $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); } /** @@ -239,7 +239,7 @@ JS; wp_enqueue_script( 'handle-three' ); - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -323,8 +323,8 @@ JS; $expected_header .= "\n"; $expected_footer = "\n"; - $this->assertEquals( $expected_header, $header ); - $this->assertEquals( $expected_footer, $footer ); + $this->assertSame( $expected_header, $header ); + $this->assertSame( $expected_footer, $footer ); } /** @@ -344,8 +344,8 @@ JS; $expected_footer = "\n"; $expected_footer .= "\n"; - $this->assertEquals( $expected_header, $header ); - $this->assertEquals( $expected_footer, $footer ); + $this->assertSame( $expected_header, $header ); + $this->assertSame( $expected_footer, $footer ); } /** @@ -375,8 +375,8 @@ JS; $expected_footer .= "\n"; $expected_footer .= "\n"; - $this->assertEquals( $expected_header, $header ); - $this->assertEquals( $expected_footer, $footer ); + $this->assertSame( $expected_header, $header ); + $this->assertSame( $expected_footer, $footer ); } /** @@ -393,7 +393,7 @@ JS; */ function test_wp_add_inline_script_unknown_handle() { $this->assertFalse( wp_add_inline_script( 'test-invalid', 'console.log("before");', 'before' ) ); - $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); + $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); } /** @@ -406,7 +406,7 @@ JS; $expected = "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -419,7 +419,7 @@ JS; $expected = "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -434,7 +434,7 @@ JS; $expected .= "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -447,7 +447,7 @@ JS; $expected = "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -460,7 +460,7 @@ JS; $expected = "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -475,7 +475,7 @@ JS; $expected = "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -492,7 +492,7 @@ JS; $expected .= "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -509,7 +509,7 @@ JS; $expected .= "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -535,7 +535,7 @@ JS; $expected .= "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -559,7 +559,7 @@ JS; $expected .= "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -587,7 +587,7 @@ JS; $expected .= "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -615,8 +615,8 @@ JS; wp_add_inline_script( 'test-example', 'console.log("after");' ); wp_script_add_data( 'test-example', 'conditional', 'gte IE 9' ); - $this->assertEquals( $expected_localized, get_echo( 'wp_print_scripts' ) ); - $this->assertEquals( $expected, $wp_scripts->print_html ); + $this->assertSame( $expected_localized, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, $wp_scripts->print_html ); $this->assertTrue( $wp_scripts->do_concat ); } @@ -642,7 +642,7 @@ JS; wp_print_scripts(); $print_scripts = get_echo( '_print_scripts' ); - $this->assertEquals( $expected, $print_scripts ); + $this->assertSame( $expected, $print_scripts ); } /** @@ -670,7 +670,7 @@ JS; wp_print_scripts(); $print_scripts = get_echo( '_print_scripts' ); - $this->assertEquals( $expected, $print_scripts ); + $this->assertSame( $expected, $print_scripts ); } /** @@ -696,7 +696,7 @@ JS; wp_print_scripts(); $print_scripts = get_echo( '_print_scripts' ); - $this->assertEquals( $expected, $print_scripts ); + $this->assertSame( $expected, $print_scripts ); } /** @@ -752,7 +752,7 @@ JS; $print_scripts // Printed scripts. ); - $this->assertEqualsIgnoreEOL( $expected, $print_scripts ); + $this->assertSameIgnoreEOL( $expected, $print_scripts ); } /** @@ -780,7 +780,7 @@ JS; $print_scripts .= get_echo( '_print_scripts' ); $tail = substr( $print_scripts, strrpos( $print_scripts, "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -829,7 +829,7 @@ JS; $expected .= "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -856,7 +856,7 @@ JS; ); $expected .= "\n"; - $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -883,7 +883,7 @@ JS; ); $expected .= "\n"; - $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -910,7 +910,7 @@ JS; ); $expected .= "\n"; - $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -937,7 +937,7 @@ JS; ); $expected .= "\n"; - $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -979,7 +979,7 @@ JS; ); $expected .= "\n"; - $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -1008,7 +1008,7 @@ JS; ); $expected .= "\n"; - $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); } /** @@ -1038,7 +1038,7 @@ JS; $expected .= "\n"; $expected .= "\n"; - $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); + $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) ); } /** diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index 6f79a20a91..72931a2e5c 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -63,10 +63,10 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { $expected .= "\n"; $expected .= "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_styles' ) ); // No styles left to print. - $this->assertEquals( '', get_echo( 'wp_print_styles' ) ); + $this->assertSame( '', get_echo( 'wp_print_styles' ) ); } /** @@ -83,7 +83,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { $ver = get_bloginfo( 'version' ); $expected = "\n"; - $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_styles' ) ); } /** @@ -122,10 +122,10 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { $expected .= "\n"; // Go! - $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_styles' ) ); // No styles left to print. - $this->assertEquals( '', get_echo( 'wp_print_styles' ) ); + $this->assertSame( '', get_echo( 'wp_print_styles' ) ); // Cleanup. $wp_styles->base_url = $base_url_backup; @@ -151,7 +151,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { wp_add_inline_style( 'handle', $style ); // No styles left to print. - $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_styles' ) ); } /** @@ -180,7 +180,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { wp_add_inline_style( 'handle', $style ); wp_print_styles(); - $this->assertEquals( $expected, $wp_styles->print_html ); + $this->assertSame( $expected, $wp_styles->print_html ); } @@ -210,7 +210,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { wp_add_inline_style( 'handle', $style2 ); // No styles left to print. - $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_styles' ) ); } @@ -235,7 +235,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { wp_add_inline_style( 'handle', $style ); - $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_styles' ) ); } @@ -250,7 +250,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); - $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_styles' ) ); } @@ -272,7 +272,7 @@ CSS; wp_style_add_data( 'handle', 'conditional', 'IE' ); wp_add_inline_style( 'handle', 'a { color: blue; }' ); - $this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_styles' ) ); + $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_styles' ) ); } /** @@ -304,7 +304,7 @@ CSS; wp_enqueue_style( 'handle-three' ); wp_add_inline_style( 'handle-three', $style ); - $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); + $this->assertSame( $expected, get_echo( 'wp_print_styles' ) ); } /** diff --git a/tests/phpunit/tests/error-protection/recovery-mode-cookie-service.php b/tests/phpunit/tests/error-protection/recovery-mode-cookie-service.php index 78f9099758..90ca646114 100644 --- a/tests/phpunit/tests/error-protection/recovery-mode-cookie-service.php +++ b/tests/phpunit/tests/error-protection/recovery-mode-cookie-service.php @@ -14,15 +14,15 @@ class Tests_Recovery_Mode_Cookie_Service extends WP_UnitTestCase { $error = $service->validate_cookie( 'gibbersih' ); $this->assertWPError( $error ); - $this->assertEquals( 'invalid_format', $error->get_error_code() ); + $this->assertSame( 'invalid_format', $error->get_error_code() ); $error = $service->validate_cookie( base64_encode( 'test|data|format' ) ); $this->assertWPError( $error ); - $this->assertEquals( 'invalid_format', $error->get_error_code() ); + $this->assertSame( 'invalid_format', $error->get_error_code() ); $error = $service->validate_cookie( base64_encode( 'test|data|format|to|long' ) ); $this->assertWPError( $error ); - $this->assertEquals( 'invalid_format', $error->get_error_code() ); + $this->assertSame( 'invalid_format', $error->get_error_code() ); } /** @@ -39,7 +39,7 @@ class Tests_Recovery_Mode_Cookie_Service extends WP_UnitTestCase { $error = $service->validate_cookie( $cookie ); $this->assertWPError( $error ); - $this->assertEquals( 'expired', $error->get_error_code() ); + $this->assertSame( 'expired', $error->get_error_code() ); } /** @@ -55,7 +55,7 @@ class Tests_Recovery_Mode_Cookie_Service extends WP_UnitTestCase { $error = $service->validate_cookie( $cookie ); $this->assertWPError( $error ); - $this->assertEquals( 'signature_mismatch', $error->get_error_code() ); + $this->assertSame( 'signature_mismatch', $error->get_error_code() ); } /** @@ -72,7 +72,7 @@ class Tests_Recovery_Mode_Cookie_Service extends WP_UnitTestCase { $error = $service->validate_cookie( $cookie ); $this->assertWPError( $error ); - $this->assertEquals( 'invalid_created_at', $error->get_error_code() ); + $this->assertSame( 'invalid_created_at', $error->get_error_code() ); } /** diff --git a/tests/phpunit/tests/error-protection/recovery-mode-key-service.php b/tests/phpunit/tests/error-protection/recovery-mode-key-service.php index c309a73a20..d5c513c3d1 100644 --- a/tests/phpunit/tests/error-protection/recovery-mode-key-service.php +++ b/tests/phpunit/tests/error-protection/recovery-mode-key-service.php @@ -24,7 +24,7 @@ class Tests_Recovery_Mode_Key_Service extends WP_UnitTestCase { $error = $service->validate_recovery_mode_key( '', 'abcd', HOUR_IN_SECONDS ); $this->assertWPError( $error ); - $this->assertEquals( 'token_not_found', $error->get_error_code() ); + $this->assertSame( 'token_not_found', $error->get_error_code() ); } /** @@ -37,7 +37,7 @@ class Tests_Recovery_Mode_Key_Service extends WP_UnitTestCase { $error = $service->validate_recovery_mode_key( '', 'abcd', HOUR_IN_SECONDS ); $this->assertWPError( $error ); - $this->assertEquals( 'token_not_found', $error->get_error_code() ); + $this->assertSame( 'token_not_found', $error->get_error_code() ); } /** @@ -50,7 +50,7 @@ class Tests_Recovery_Mode_Key_Service extends WP_UnitTestCase { $error = $service->validate_recovery_mode_key( 'token', 'abcd', HOUR_IN_SECONDS ); $this->assertWPError( $error ); - $this->assertEquals( 'invalid_recovery_key_format', $error->get_error_code() ); + $this->assertSame( 'invalid_recovery_key_format', $error->get_error_code() ); } @@ -66,7 +66,7 @@ class Tests_Recovery_Mode_Key_Service extends WP_UnitTestCase { $error = $service->validate_recovery_mode_key( $token, 'abcd', HOUR_IN_SECONDS ); $this->assertWPError( $error ); - $this->assertEquals( 'invalid_recovery_key_format', $error->get_error_code() ); + $this->assertSame( 'invalid_recovery_key_format', $error->get_error_code() ); } /** @@ -79,7 +79,7 @@ class Tests_Recovery_Mode_Key_Service extends WP_UnitTestCase { $error = $service->validate_recovery_mode_key( $token, '', HOUR_IN_SECONDS ); $this->assertWPError( $error ); - $this->assertEquals( 'hash_mismatch', $error->get_error_code() ); + $this->assertSame( 'hash_mismatch', $error->get_error_code() ); } /** @@ -92,7 +92,7 @@ class Tests_Recovery_Mode_Key_Service extends WP_UnitTestCase { $error = $service->validate_recovery_mode_key( $token, 'abcd', HOUR_IN_SECONDS ); $this->assertWPError( $error ); - $this->assertEquals( 'hash_mismatch', $error->get_error_code() ); + $this->assertSame( 'hash_mismatch', $error->get_error_code() ); } /** @@ -110,7 +110,7 @@ class Tests_Recovery_Mode_Key_Service extends WP_UnitTestCase { $error = $service->validate_recovery_mode_key( $token, $key, HOUR_IN_SECONDS ); $this->assertWPError( $error ); - $this->assertEquals( 'key_expired', $error->get_error_code() ); + $this->assertSame( 'key_expired', $error->get_error_code() ); } /** @@ -137,7 +137,7 @@ class Tests_Recovery_Mode_Key_Service extends WP_UnitTestCase { $error = $service->validate_recovery_mode_key( $token, $key, HOUR_IN_SECONDS ); $this->assertWPError( $error ); - $this->assertEquals( 'token_not_found', $error->get_error_code() ); + $this->assertSame( 'token_not_found', $error->get_error_code() ); } /** @@ -159,7 +159,7 @@ class Tests_Recovery_Mode_Key_Service extends WP_UnitTestCase { $error = $service->validate_recovery_mode_key( $token, $key, HOUR_IN_SECONDS ); $this->assertWPError( $error ); - $this->assertEquals( 'token_not_found', $error->get_error_code() ); + $this->assertSame( 'token_not_found', $error->get_error_code() ); } /** diff --git a/tests/phpunit/tests/feed/atom.php b/tests/phpunit/tests/feed/atom.php index 55a428e586..cc9a30af72 100644 --- a/tests/phpunit/tests/feed/atom.php +++ b/tests/phpunit/tests/feed/atom.php @@ -97,33 +97,33 @@ class Tests_Feeds_Atom extends WP_UnitTestCase { $this->assertCount( 1, $atom ); // Verify attributes. - $this->assertEquals( 'http://www.w3.org/2005/Atom', $atom[0]['attributes']['xmlns'] ); - $this->assertEquals( 'http://purl.org/syndication/thread/1.0', $atom[0]['attributes']['xmlns:thr'] ); - $this->assertEquals( site_url( '/wp-atom.php' ), $atom[0]['attributes']['xml:base'] ); + $this->assertSame( 'http://www.w3.org/2005/Atom', $atom[0]['attributes']['xmlns'] ); + $this->assertSame( 'http://purl.org/syndication/thread/1.0', $atom[0]['attributes']['xmlns:thr'] ); + $this->assertSame( site_url( '/wp-atom.php' ), $atom[0]['attributes']['xml:base'] ); // Verify the element is present and contains a child element. $title = xml_find( $xml, 'feed', 'title' ); - $this->assertEquals( get_option( 'blogname' ), $title[0]['content'] ); + $this->assertSame( get_option( 'blogname' ), $title[0]['content'] ); // Verify the <feed> element is present and contains a <updated> child element. $updated = xml_find( $xml, 'feed', 'updated' ); - $this->assertEquals( strtotime( get_lastpostmodified() ), strtotime( $updated[0]['content'] ) ); + $this->assertSame( strtotime( get_lastpostmodified() ), strtotime( $updated[0]['content'] ) ); // Verify the <feed> element is present and contains a <subtitle> child element. $subtitle = xml_find( $xml, 'feed', 'subtitle' ); - $this->assertEquals( get_option( 'blogdescription' ), $subtitle[0]['content'] ); + $this->assertSame( get_option( 'blogdescription' ), $subtitle[0]['content'] ); // Verify the <feed> element is present and contains two <link> child elements. $link = xml_find( $xml, 'feed', 'link' ); $this->assertCount( 2, $link ); // Verify the <feed> element is present and contains a <link rel="alternate"> child element. - $this->assertEquals( 'alternate', $link[0]['attributes']['rel'] ); - $this->assertEquals( home_url(), $link[0]['attributes']['href'] ); + $this->assertSame( 'alternate', $link[0]['attributes']['rel'] ); + $this->assertSame( home_url(), $link[0]['attributes']['href'] ); // Verify the <feed> element is present and contains a <link rel="href"> child element. - $this->assertEquals( 'self', $link[1]['attributes']['rel'] ); - $this->assertEquals( home_url( '/?feed=atom' ), $link[1]['attributes']['href'] ); + $this->assertSame( 'self', $link[1]['attributes']['rel'] ); + $this->assertSame( home_url( '/?feed=atom' ), $link[1]['attributes']['href'] ); } /** @@ -154,31 +154,31 @@ class Tests_Feeds_Atom extends WP_UnitTestCase { // Author. $author = xml_find( $entries[ $key ]['child'], 'author', 'name' ); $user = new WP_User( $post->post_author ); - $this->assertEquals( $user->display_name, $author[0]['content'] ); + $this->assertSame( $user->display_name, $author[0]['content'] ); // Title. $title = xml_find( $entries[ $key ]['child'], 'title' ); - $this->assertEquals( $post->post_title, $title[0]['content'] ); + $this->assertSame( $post->post_title, $title[0]['content'] ); // Link rel="alternate". $link_alts = xml_find( $entries[ $key ]['child'], 'link' ); foreach ( $link_alts as $link_alt ) { if ( 'alternate' === $link_alt['attributes']['rel'] ) { - $this->assertEquals( get_permalink( $post ), $link_alt['attributes']['href'] ); + $this->assertSame( get_permalink( $post ), $link_alt['attributes']['href'] ); } } // ID. $guid = xml_find( $entries[ $key ]['child'], 'id' ); - $this->assertEquals( $post->guid, $id[0]['content'] ); + $this->assertSame( $post->guid, $id[0]['content'] ); // Updated. $updated = xml_find( $entries[ $key ]['child'], 'updated' ); - $this->assertEquals( strtotime( $post->post_modified_gmt ), strtotime( $updated[0]['content'] ) ); + $this->assertSame( strtotime( $post->post_modified_gmt ), strtotime( $updated[0]['content'] ) ); // Published. $published = xml_find( $entries[ $key ]['child'], 'published' ); - $this->assertEquals( strtotime( $post->post_date_gmt ), strtotime( $published[0]['content'] ) ); + $this->assertSame( strtotime( $post->post_date_gmt ), strtotime( $published[0]['content'] ) ); // Category. foreach ( get_the_category( $post->ID ) as $term ) { @@ -193,14 +193,14 @@ class Tests_Feeds_Atom extends WP_UnitTestCase { // Content. if ( ! $this->excerpt_only ) { $content = xml_find( $entries[ $key ]['child'], 'content' ); - $this->assertEquals( trim( apply_filters( 'the_content', $post->post_content ) ), trim( $content[0]['content'] ) ); + $this->assertSame( trim( apply_filters( 'the_content', $post->post_content ) ), trim( $content[0]['content'] ) ); } // Link rel="replies". $link_replies = xml_find( $entries[ $key ]['child'], 'link' ); foreach ( $link_replies as $link_reply ) { if ( 'replies' === $link_reply['attributes']['rel'] && 'application/atom+xml' === $link_reply['attributes']['type'] ) { - $this->assertEquals( get_post_comments_feed_link( $post->ID, 'atom' ), $link_reply['attributes']['href'] ); + $this->assertSame( get_post_comments_feed_link( $post->ID, 'atom' ), $link_reply['attributes']['href'] ); } } } @@ -273,9 +273,9 @@ class Tests_Feeds_Atom extends WP_UnitTestCase { $i = 0; foreach ( (array) $links as $link ) { if ( 'enclosure' === $link['attributes']['rel'] ) { - $this->assertEquals( $enclosures[ $i ]['expected']['href'], $link['attributes']['href'] ); + $this->assertSame( $enclosures[ $i ]['expected']['href'], $link['attributes']['href'] ); $this->assertEquals( $enclosures[ $i ]['expected']['length'], $link['attributes']['length'] ); - $this->assertEquals( $enclosures[ $i ]['expected']['type'], $link['attributes']['type'] ); + $this->assertSame( $enclosures[ $i ]['expected']['type'], $link['attributes']['type'] ); $i++; } } diff --git a/tests/phpunit/tests/feed/rss2.php b/tests/phpunit/tests/feed/rss2.php index cadba0330e..8eda26e9d2 100644 --- a/tests/phpunit/tests/feed/rss2.php +++ b/tests/phpunit/tests/feed/rss2.php @@ -106,15 +106,15 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one <rss> child element. - $this->assertEquals( 1, count( $rss ) ); + $this->assertSame( 1, count( $rss ) ); - $this->assertEquals( '2.0', $rss[0]['attributes']['version'] ); - $this->assertEquals( 'http://purl.org/rss/1.0/modules/content/', $rss[0]['attributes']['xmlns:content'] ); - $this->assertEquals( 'http://wellformedweb.org/CommentAPI/', $rss[0]['attributes']['xmlns:wfw'] ); - $this->assertEquals( 'http://purl.org/dc/elements/1.1/', $rss[0]['attributes']['xmlns:dc'] ); + $this->assertSame( '2.0', $rss[0]['attributes']['version'] ); + $this->assertSame( 'http://purl.org/rss/1.0/modules/content/', $rss[0]['attributes']['xmlns:content'] ); + $this->assertSame( 'http://wellformedweb.org/CommentAPI/', $rss[0]['attributes']['xmlns:wfw'] ); + $this->assertSame( 'http://purl.org/dc/elements/1.1/', $rss[0]['attributes']['xmlns:dc'] ); // RSS should have exactly one child element (channel). - $this->assertEquals( 1, count( $rss[0]['child'] ) ); + $this->assertSame( 1, count( $rss[0]['child'] ) ); } /** @@ -135,16 +135,16 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { // Verify the channel is present and contains a title child element. $title = xml_find( $xml, 'rss', 'channel', 'title' ); - $this->assertEquals( get_option( 'blogname' ), $title[0]['content'] ); + $this->assertSame( get_option( 'blogname' ), $title[0]['content'] ); $desc = xml_find( $xml, 'rss', 'channel', 'description' ); - $this->assertEquals( get_option( 'blogdescription' ), $desc[0]['content'] ); + $this->assertSame( get_option( 'blogdescription' ), $desc[0]['content'] ); $link = xml_find( $xml, 'rss', 'channel', 'link' ); - $this->assertEquals( get_option( 'siteurl' ), $link[0]['content'] ); + $this->assertSame( get_option( 'siteurl' ), $link[0]['content'] ); $pubdate = xml_find( $xml, 'rss', 'channel', 'lastBuildDate' ); - $this->assertEquals( strtotime( get_lastpostmodified() ), strtotime( $pubdate[0]['content'] ) ); + $this->assertSame( strtotime( get_lastpostmodified() ), strtotime( $pubdate[0]['content'] ) ); } /** @@ -199,24 +199,24 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { // Title. $title = xml_find( $items[ $key ]['child'], 'title' ); - $this->assertEquals( $post->post_title, $title[0]['content'] ); + $this->assertSame( $post->post_title, $title[0]['content'] ); // Link. $link = xml_find( $items[ $key ]['child'], 'link' ); - $this->assertEquals( get_permalink( $post ), $link[0]['content'] ); + $this->assertSame( get_permalink( $post ), $link[0]['content'] ); // Comment link. $comments_link = xml_find( $items[ $key ]['child'], 'comments' ); - $this->assertEquals( get_permalink( $post ) . '#respond', $comments_link[0]['content'] ); + $this->assertSame( get_permalink( $post ) . '#respond', $comments_link[0]['content'] ); // Pub date. $pubdate = xml_find( $items[ $key ]['child'], 'pubDate' ); - $this->assertEquals( strtotime( $post->post_date_gmt ), strtotime( $pubdate[0]['content'] ) ); + $this->assertSame( strtotime( $post->post_date_gmt ), strtotime( $pubdate[0]['content'] ) ); // Author. $creator = xml_find( $items[ $key ]['child'], 'dc:creator' ); $user = new WP_User( $post->post_author ); - $this->assertEquals( $user->display_name, $creator[0]['content'] ); + $this->assertSame( $user->display_name, $creator[0]['content'] ); // Categories (perhaps multiple). $categories = xml_find( $items[ $key ]['child'], 'category' ); @@ -233,33 +233,33 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { } $cats = array_filter( $cats ); // Should be the same number of categories. - $this->assertEquals( count( $cats ), count( $categories ) ); + $this->assertSame( count( $cats ), count( $categories ) ); // ..with the same names. foreach ( $cats as $id => $cat ) { - $this->assertEquals( $cat, $categories[ $id ]['content'] ); + $this->assertSame( $cat, $categories[ $id ]['content'] ); } // GUID. $guid = xml_find( $items[ $key ]['child'], 'guid' ); - $this->assertEquals( 'false', $guid[0]['attributes']['isPermaLink'] ); - $this->assertEquals( $post->guid, $guid[0]['content'] ); + $this->assertSame( 'false', $guid[0]['attributes']['isPermaLink'] ); + $this->assertSame( $post->guid, $guid[0]['content'] ); // Description / Excerpt. if ( ! empty( $post->post_excerpt ) ) { $description = xml_find( $items[ $key ]['child'], 'description' ); - $this->assertEquals( trim( $post->post_excerpt ), trim( $description[0]['content'] ) ); + $this->assertSame( trim( $post->post_excerpt ), trim( $description[0]['content'] ) ); } // Post content. if ( ! $this->excerpt_only ) { $content = xml_find( $items[ $key ]['child'], 'content:encoded' ); - $this->assertEquals( trim( apply_filters( 'the_content', $post->post_content ) ), trim( $content[0]['content'] ) ); + $this->assertSame( trim( apply_filters( 'the_content', $post->post_content ) ), trim( $content[0]['content'] ) ); } // Comment RSS. $comment_rss = xml_find( $items[ $key ]['child'], 'wfw:commentRss' ); - $this->assertEquals( html_entity_decode( get_post_comments_feed_link( $post->ID ) ), $comment_rss[0]['content'] ); + $this->assertSame( html_entity_decode( get_post_comments_feed_link( $post->ID ) ), $comment_rss[0]['content'] ); } } @@ -320,7 +320,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one <rss> child element. - $this->assertEquals( 1, count( $rss ) ); + $this->assertSame( 1, count( $rss ) ); } /* @@ -348,7 +348,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one <rss> child element. - $this->assertEquals( 1, count( $rss ) ); + $this->assertSame( 1, count( $rss ) ); } /* @@ -381,7 +381,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one <rss> child element. - $this->assertEquals( 1, count( $rss ) ); + $this->assertSame( 1, count( $rss ) ); } /* @@ -409,7 +409,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one <rss> child element. - $this->assertEquals( 1, count( $rss ) ); + $this->assertSame( 1, count( $rss ) ); } /* @@ -437,7 +437,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one <rss> child element. - $this->assertEquals( 1, count( $rss ) ); + $this->assertSame( 1, count( $rss ) ); } /* @@ -465,7 +465,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one <rss> child element. - $this->assertEquals( 1, count( $rss ) ); + $this->assertSame( 1, count( $rss ) ); } /** @@ -483,7 +483,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { // Get the <rss> child element of <xml>. $rss = xml_find( $xml, $element ); $last_build_date = $rss[0]['child'][0]['child'][4]['content']; - $this->assertEquals( strtotime( get_feed_build_date( 'r' ) ), strtotime( $last_build_date ) ); + $this->assertSame( strtotime( get_feed_build_date( 'r' ) ), strtotime( $last_build_date ) ); } diff --git a/tests/phpunit/tests/file.php b/tests/phpunit/tests/file.php index 934bb751e4..730d72c5c1 100644 --- a/tests/phpunit/tests/file.php +++ b/tests/phpunit/tests/file.php @@ -39,7 +39,7 @@ class Tests_File extends WP_UnitTestCase { ); foreach ( $actual as $header => $value ) { - $this->assertEquals( $expected[ $header ], $value, $header ); + $this->assertSame( $expected[ $header ], $value, $header ); } } @@ -61,7 +61,7 @@ class Tests_File extends WP_UnitTestCase { ); foreach ( $actual as $header => $value ) { - $this->assertEquals( $expected[ $header ], $value, $header ); + $this->assertSame( $expected[ $header ], $value, $header ); } } @@ -118,7 +118,7 @@ class Tests_File extends WP_UnitTestCase { $filename = wp_unique_filename( $this->dir, $name . $this->badchars . '.txt' ); // Make sure the bad characters were all stripped out. - $this->assertEquals( $name . '.txt', $filename ); + $this->assertSame( $name . '.txt', $filename ); $this->assertTrue( $this->is_unique_writable_file( $this->dir, $filename ) ); @@ -131,7 +131,7 @@ class Tests_File extends WP_UnitTestCase { $filename = wp_unique_filename( $this->dir, $name . '/' . $name . '.txt' ); // The slash should be removed, i.e. "foofoo.txt". - $this->assertEquals( $name . $name . '.txt', $filename ); + $this->assertSame( $name . $name . '.txt', $filename ); $this->assertTrue( $this->is_unique_writable_file( $this->dir, $filename ) ); @@ -143,7 +143,7 @@ class Tests_File extends WP_UnitTestCase { $filename = wp_unique_filename( $this->dir, $name . '.php.txt' ); // "foo.php.txt" becomes "foo.php_.txt". - $this->assertEquals( $name . '.php_.txt', $filename ); + $this->assertSame( $name . '.php_.txt', $filename ); $this->assertTrue( $this->is_unique_writable_file( $this->dir, $filename ) ); @@ -154,7 +154,7 @@ class Tests_File extends WP_UnitTestCase { $name = __FUNCTION__; $filename = wp_unique_filename( $this->dir, $name ); - $this->assertEquals( $name, $filename ); + $this->assertSame( $name, $filename ); $this->assertTrue( $this->is_unique_writable_file( $this->dir, $filename ) ); @@ -231,7 +231,7 @@ class Tests_File extends WP_UnitTestCase { } $this->assertWPError( $verify ); - $this->assertEquals( 'signature_verification_failed', $verify->get_error_code() ); + $this->assertSame( 'signature_verification_failed', $verify->get_error_code() ); } function filter_trust_plus85Tq_key( $keys ) { diff --git a/tests/phpunit/tests/filesystem/findFolder.php b/tests/phpunit/tests/filesystem/findFolder.php index fce3d05950..3b517531ed 100644 --- a/tests/phpunit/tests/filesystem/findFolder.php +++ b/tests/phpunit/tests/filesystem/findFolder.php @@ -20,7 +20,7 @@ class WP_Filesystem_find_folder_UnitTestCases extends WP_Filesystem_UnitTestCase ); $path = $fs->find_folder( '/var/www/wordpress/' ); - $this->assertEquals( '/var/www/wordpress/', $path ); + $this->assertSame( '/var/www/wordpress/', $path ); $path = $fs->find_folder( '/this/directory/doesnt/exist/' ); $this->assertFalse( $path ); @@ -44,10 +44,10 @@ class WP_Filesystem_find_folder_UnitTestCases extends WP_Filesystem_UnitTestCase ); $path = $fs->find_folder( '/var/www/example.com/wordpress/' ); - $this->assertEquals( '/www/example.com/wordpress/', $path ); + $this->assertSame( '/www/example.com/wordpress/', $path ); $path = $fs->find_folder( '/var/www/wp.example.com/wordpress/wp-content/' ); - $this->assertEquals( '/www/wp.example.com/wordpress/wp-content/', $path ); + $this->assertSame( '/www/wp.example.com/wordpress/wp-content/', $path ); } @@ -72,10 +72,10 @@ class WP_Filesystem_find_folder_UnitTestCases extends WP_Filesystem_UnitTestCase ); $path = $fs->abspath( '/var/www/example.com/wp.example.com/wordpress/' ); - $this->assertEquals( '/wp.example.com/wordpress/', $path ); + $this->assertSame( '/wp.example.com/wordpress/', $path ); $path = $fs->abspath( '/var/www/example.com/' ); - $this->assertEquals( '/', $path ); + $this->assertSame( '/', $path ); } @@ -103,15 +103,15 @@ class WP_Filesystem_find_folder_UnitTestCases extends WP_Filesystem_UnitTestCase // www.example.com $path = $fs->abspath( '/var/www/example.com/www/' ); - $this->assertEquals( '/example.com/www/', $path ); + $this->assertSame( '/example.com/www/', $path ); // sub.example.com $path = $fs->abspath( '/var/www/example.com/sub/' ); - $this->assertEquals( '/example.com/sub/', $path ); + $this->assertSame( '/example.com/sub/', $path ); // sub.example.com - Plugins. $path = $fs->find_folder( '/var/www/example.com/sub/wp-content/plugins/' ); - $this->assertEquals( '/example.com/sub/wp-content/plugins/', $path ); + $this->assertSame( '/example.com/sub/wp-content/plugins/', $path ); } } diff --git a/tests/phpunit/tests/filters.php b/tests/phpunit/tests/filters.php index 7de61629c2..d3c4d0aff9 100644 --- a/tests/phpunit/tests/filters.php +++ b/tests/phpunit/tests/filters.php @@ -13,16 +13,16 @@ class Tests_Filters extends WP_UnitTestCase { $val = __FUNCTION__ . '_val'; add_filter( $tag, array( $a, 'filter' ) ); - $this->assertEquals( $val, apply_filters( $tag, $val ) ); + $this->assertSame( $val, apply_filters( $tag, $val ) ); // Only one event occurred for the hook, with empty args. - $this->assertEquals( 1, $a->get_call_count() ); + $this->assertSame( 1, $a->get_call_count() ); // Only our hook was called. - $this->assertEquals( array( $tag ), $a->get_tags() ); + $this->assertSame( array( $tag ), $a->get_tags() ); $argsvar = $a->get_args(); $args = array_pop( $argsvar ); - $this->assertEquals( array( $val ), $args ); + $this->assertSame( array( $val ), $args ); } function test_remove_filter() { @@ -31,17 +31,17 @@ class Tests_Filters extends WP_UnitTestCase { $val = __FUNCTION__ . '_val'; add_filter( $tag, array( $a, 'filter' ) ); - $this->assertEquals( $val, apply_filters( $tag, $val ) ); + $this->assertSame( $val, apply_filters( $tag, $val ) ); // Make sure our hook was called correctly. - $this->assertEquals( 1, $a->get_call_count() ); - $this->assertEquals( array( $tag ), $a->get_tags() ); + $this->assertSame( 1, $a->get_call_count() ); + $this->assertSame( array( $tag ), $a->get_tags() ); // Now remove the filter, do it again, and make sure it's not called this time. remove_filter( $tag, array( $a, 'filter' ) ); - $this->assertEquals( $val, apply_filters( $tag, $val ) ); - $this->assertEquals( 1, $a->get_call_count() ); - $this->assertEquals( array( $tag ), $a->get_tags() ); + $this->assertSame( $val, apply_filters( $tag, $val ) ); + $this->assertSame( 1, $a->get_call_count() ); + $this->assertSame( array( $tag ), $a->get_tags() ); } @@ -52,7 +52,7 @@ class Tests_Filters extends WP_UnitTestCase { $this->assertFalse( has_filter( $tag, $func ) ); $this->assertFalse( has_filter( $tag ) ); add_filter( $tag, $func ); - $this->assertEquals( 10, has_filter( $tag, $func ) ); + $this->assertSame( 10, has_filter( $tag, $func ) ); $this->assertTrue( has_filter( $tag ) ); remove_filter( $tag, $func ); $this->assertFalse( has_filter( $tag, $func ) ); @@ -70,11 +70,11 @@ class Tests_Filters extends WP_UnitTestCase { add_filter( $tag, array( $a1, 'filter' ) ); add_filter( $tag, array( $a2, 'filter' ) ); - $this->assertEquals( $val, apply_filters( $tag, $val ) ); + $this->assertSame( $val, apply_filters( $tag, $val ) ); // Both filters called once each. - $this->assertEquals( 1, $a1->get_call_count() ); - $this->assertEquals( 1, $a2->get_call_count() ); + $this->assertSame( 1, $a1->get_call_count() ); + $this->assertSame( 1, $a2->get_call_count() ); } function test_filter_args_1() { @@ -85,11 +85,11 @@ class Tests_Filters extends WP_UnitTestCase { add_filter( $tag, array( $a, 'filter' ), 10, 2 ); // Call the filter with a single argument. - $this->assertEquals( $val, apply_filters( $tag, $val, $arg1 ) ); + $this->assertSame( $val, apply_filters( $tag, $val, $arg1 ) ); - $this->assertEquals( 1, $a->get_call_count() ); + $this->assertSame( 1, $a->get_call_count() ); $argsvar = $a->get_args(); - $this->assertEquals( array( $val, $arg1 ), array_pop( $argsvar ) ); + $this->assertSame( array( $val, $arg1 ), array_pop( $argsvar ) ); } function test_filter_args_2() { @@ -104,17 +104,17 @@ class Tests_Filters extends WP_UnitTestCase { add_filter( $tag, array( $a1, 'filter' ), 10, 3 ); add_filter( $tag, array( $a2, 'filter' ) ); // Call the filter with two arguments. - $this->assertEquals( $val, apply_filters( $tag, $val, $arg1, $arg2 ) ); + $this->assertSame( $val, apply_filters( $tag, $val, $arg1, $arg2 ) ); // $a1 should be called with both args. - $this->assertEquals( 1, $a1->get_call_count() ); + $this->assertSame( 1, $a1->get_call_count() ); $argsvar1 = $a1->get_args(); - $this->assertEquals( array( $val, $arg1, $arg2 ), array_pop( $argsvar1 ) ); + $this->assertSame( array( $val, $arg1, $arg2 ), array_pop( $argsvar1 ) ); // $a2 should be called with one only. - $this->assertEquals( 1, $a2->get_call_count() ); + $this->assertSame( 1, $a2->get_call_count() ); $argsvar2 = $a2->get_args(); - $this->assertEquals( array( $val ), array_pop( $argsvar2 ) ); + $this->assertSame( array( $val ), array_pop( $argsvar2 ) ); } function test_filter_priority() { @@ -125,10 +125,10 @@ class Tests_Filters extends WP_UnitTestCase { // Make two filters with different priorities. add_filter( $tag, array( $a, 'filter' ), 10 ); add_filter( $tag, array( $a, 'filter2' ), 9 ); - $this->assertEquals( $val, apply_filters( $tag, $val ) ); + $this->assertSame( $val, apply_filters( $tag, $val ) ); // There should be two events, one per filter. - $this->assertEquals( 2, $a->get_call_count() ); + $this->assertSame( 2, $a->get_call_count() ); $expected = array( // 'filter2' is called first because it has priority 9. @@ -145,7 +145,7 @@ class Tests_Filters extends WP_UnitTestCase { ), ); - $this->assertEquals( $expected, $a->get_events() ); + $this->assertSame( $expected, $a->get_events() ); } function test_all_filter() { @@ -157,15 +157,15 @@ class Tests_Filters extends WP_UnitTestCase { // Add an 'all' filter. add_filter( 'all', array( $a, 'filterall' ) ); // Apply some filters. - $this->assertEquals( $val, apply_filters( $tag1, $val ) ); - $this->assertEquals( $val, apply_filters( $tag2, $val ) ); - $this->assertEquals( $val, apply_filters( $tag1, $val ) ); - $this->assertEquals( $val, apply_filters( $tag1, $val ) ); + $this->assertSame( $val, apply_filters( $tag1, $val ) ); + $this->assertSame( $val, apply_filters( $tag2, $val ) ); + $this->assertSame( $val, apply_filters( $tag1, $val ) ); + $this->assertSame( $val, apply_filters( $tag1, $val ) ); // Our filter should have been called once for each apply_filters call. - $this->assertEquals( 4, $a->get_call_count() ); + $this->assertSame( 4, $a->get_call_count() ); // The right hooks should have been called in order. - $this->assertEquals( array( $tag1, $tag2, $tag1, $tag1 ), $a->get_tags() ); + $this->assertSame( array( $tag1, $tag2, $tag1, $tag1 ), $a->get_tags() ); remove_filter( 'all', array( $a, 'filterall' ) ); $this->assertFalse( has_filter( 'all', array( $a, 'filterall' ) ) ); @@ -179,21 +179,21 @@ class Tests_Filters extends WP_UnitTestCase { add_filter( 'all', array( $a, 'filterall' ) ); $this->assertTrue( has_filter( 'all' ) ); - $this->assertEquals( 10, has_filter( 'all', array( $a, 'filterall' ) ) ); - $this->assertEquals( $val, apply_filters( $tag, $val ) ); + $this->assertSame( 10, has_filter( 'all', array( $a, 'filterall' ) ) ); + $this->assertSame( $val, apply_filters( $tag, $val ) ); // Make sure our hook was called correctly. - $this->assertEquals( 1, $a->get_call_count() ); - $this->assertEquals( array( $tag ), $a->get_tags() ); + $this->assertSame( 1, $a->get_call_count() ); + $this->assertSame( array( $tag ), $a->get_tags() ); // Now remove the filter, do it again, and make sure it's not called this time. remove_filter( 'all', array( $a, 'filterall' ) ); $this->assertFalse( has_filter( 'all', array( $a, 'filterall' ) ) ); $this->assertFalse( has_filter( 'all' ) ); - $this->assertEquals( $val, apply_filters( $tag, $val ) ); + $this->assertSame( $val, apply_filters( $tag, $val ) ); // Call cound should remain at 1. - $this->assertEquals( 1, $a->get_call_count() ); - $this->assertEquals( array( $tag ), $a->get_tags() ); + $this->assertSame( 1, $a->get_call_count() ); + $this->assertSame( array( $tag ), $a->get_tags() ); } /** @@ -248,7 +248,7 @@ class Tests_Filters extends WP_UnitTestCase { $result = apply_filters_ref_array( $tag, array( 'string', &$obj ) ); - $this->assertEquals( $result, 'string_append_append' ); + $this->assertSame( $result, 'string_append_append' ); $args = $a->get_args(); $this->assertSame( $args[0][1], $obj ); @@ -373,7 +373,7 @@ class Tests_Filters extends WP_UnitTestCase { do_action( 'test_current_priority' ); remove_action( 'test_current_priority', array( $this, '_other_priority_action' ), 99 ); - $this->assertSame( false, $this->current_priority ); + $this->assertFalse( $this->current_priority ); } public function _other_priority_action() { diff --git a/tests/phpunit/tests/formatting/Autop.php b/tests/phpunit/tests/formatting/Autop.php index 6a672345d7..25e09d4c88 100644 --- a/tests/phpunit/tests/formatting/Autop.php +++ b/tests/phpunit/tests/formatting/Autop.php @@ -62,7 +62,7 @@ PS. Not yet subscribed for update notifications? <a href="%1$s" title="Subscri // On Windows environments, the EOL-style is \r\n. $expected = str_replace( "\r\n", "\n", $expected ); - $this->assertEquals( $expected, wpautop( $test_data ) ); + $this->assertSame( $expected, wpautop( $test_data ) ); } /** @@ -77,19 +77,19 @@ PS. Not yet subscribed for update notifications? <a href="%1$s" title="Subscri // Not wrapped in <p> tags. $str = "<pre>$code</pre>"; - $this->assertEquals( $str, trim( wpautop( $str ) ) ); + $this->assertSame( $str, trim( wpautop( $str ) ) ); // Text before/after is wrapped in <p> tags. $str = "Look at this code\n\n<pre>$code</pre>\n\nIsn't that cool?"; // Expected text after wpautop(). $expected = '<p>Look at this code</p>' . "\n<pre>" . $code . "</pre>\n" . '<p>Isn\'t that cool?</p>'; - $this->assertEquals( $expected, trim( wpautop( $str ) ) ); + $this->assertSame( $expected, trim( wpautop( $str ) ) ); // Make sure HTML breaks are maintained if manually inserted. $str = "Look at this code\n\n<pre>Line1<br />Line2<br>Line3<br/>Line4\nActual Line 2\nActual Line 3</pre>\n\nCool, huh?"; $expected = "<p>Look at this code</p>\n<pre>Line1<br />Line2<br>Line3<br/>Line4\nActual Line 2\nActual Line 3</pre>\n<p>Cool, huh?</p>"; - $this->assertEquals( $expected, trim( wpautop( $str ) ) ); + $this->assertSame( $expected, trim( wpautop( $str ) ) ); } /** @@ -99,7 +99,7 @@ PS. Not yet subscribed for update notifications? <a href="%1$s" title="Subscri */ public function test_skip_input_elements() { $str = 'Username: <input type="text" id="username" name="username" /><br />Password: <input type="password" id="password1" name="password1" />'; - $this->assertEquals( "<p>$str</p>", trim( wpautop( $str ) ) ); + $this->assertSame( "<p>$str</p>", trim( wpautop( $str ) ) ); } /** @@ -183,9 +183,9 @@ PS. Not yet subscribed for update notifications? <a href="%1$s" title="Subscri "[/video]</p>\n" . '<p>Paragraph two.</p>'; - $this->assertEquals( $expected, trim( wpautop( $content ) ) ); - $this->assertEquals( $expected, trim( wpautop( $content2 ) ) ); - $this->assertEquals( $shortcode_expected, trim( wpautop( $shortcode_content ) ) ); + $this->assertSame( $expected, trim( wpautop( $content ) ) ); + $this->assertSame( $expected, trim( wpautop( $content2 ) ) ); + $this->assertSame( $shortcode_expected, trim( wpautop( $shortcode_content ) ) ); } /** @@ -263,8 +263,8 @@ Paragraph two.'; "</object></div>\n" . '<p>Paragraph two.</p>'; - $this->assertEquals( $expected1, trim( wpautop( $content1 ) ) ); - $this->assertEquals( $expected2, trim( wpautop( $content2 ) ) ); + $this->assertSame( $expected1, trim( wpautop( $content1 ) ) ); + $this->assertSame( $expected2, trim( wpautop( $content2 ) ) ); } /** @@ -274,7 +274,7 @@ Paragraph two.'; */ public function test_skip_select_option_elements() { $str = 'Country: <select id="state" name="state"><option value="1">Alabama</option><option value="2">Alaska</option><option value="3">Arizona</option><option value="4">Arkansas</option><option value="5">California</option></select>'; - $this->assertEquals( "<p>$str</p>", trim( wpautop( $str ) ) ); + $this->assertSame( "<p>$str</p>", trim( wpautop( $str ) ) ); } /** @@ -340,11 +340,11 @@ Paragraph two.'; $expected = join( "\n", $content ); $input = join( "\n\n", $content ); // Whitespace difference. - $this->assertEquals( $expected, trim( wpautop( $input ) ) ); + $this->assertSame( $expected, trim( wpautop( $input ) ) ); $input = join( '', $content ); // Whitespace difference. - $this->assertEquals( $expected, trim( wpautop( $input ) ) ); + $this->assertSame( $expected, trim( wpautop( $input ) ) ); // Check whitespace addition. $content = array(); @@ -356,7 +356,7 @@ Paragraph two.'; $expected = join( "\n", $content ); $input = join( '', $content ); - $this->assertEquals( $expected, trim( wpautop( $input ) ) ); + $this->assertSame( $expected, trim( wpautop( $input ) ) ); // Check whitespace addition with attributes. $content = array(); @@ -368,7 +368,7 @@ Paragraph two.'; $expected = join( "\n", $content ); $input = join( '', $content ); - $this->assertEquals( $expected, trim( wpautop( $input ) ) ); + $this->assertSame( $expected, trim( wpautop( $input ) ) ); } /** @@ -380,7 +380,7 @@ Paragraph two.'; $content = '<blockquote>foo</blockquote>'; $expected = '<blockquote><p>foo</p></blockquote>'; - $this->assertEquals( $expected, trim( wpautop( $content ) ) ); + $this->assertSame( $expected, trim( wpautop( $content ) ) ); } /** @@ -429,7 +429,7 @@ Paragraph two.'; $content = join( "\n\n", $content ); $expected = join( "\n", $expected ); - $this->assertEquals( $expected, trim( wpautop( $content ) ) ); + $this->assertSame( $expected, trim( wpautop( $content ) ) ); } /** @@ -439,7 +439,7 @@ Paragraph two.'; * @dataProvider data_element_sanity */ function test_element_sanity( $input, $output ) { - return $this->assertEquals( $output, wpautop( $input ) ); + return $this->assertSame( $output, wpautop( $input ) ); } function data_element_sanity() { @@ -505,7 +505,7 @@ line 3<br /> line 4<br /> line 5</p>'; - $this->assertEqualsIgnoreEOL( $expected, trim( wpautop( $content ) ) ); + $this->assertSameIgnoreEOL( $expected, trim( wpautop( $content ) ) ); } /** @@ -524,7 +524,7 @@ line 2<br/> $expected = '<p>line 1</p> <p>line 2</p>'; - $this->assertEqualsIgnoreEOL( $expected, trim( wpautop( $content ) ) ); + $this->assertSameIgnoreEOL( $expected, trim( wpautop( $content ) ) ); } @@ -535,7 +535,7 @@ line 2<br/> $content = 'a<div>b</div>'; $expected = "<p>a</p>\n<div>b</div>"; - $this->assertEquals( $expected, trim( wpautop( $content ) ) ); + $this->assertSame( $expected, trim( wpautop( $content ) ) ); } /** @@ -558,8 +558,8 @@ line 2<br/> $expected2 = '<figure> <img src="example.jpg" /><figcaption>Caption</figcaption></figure>'; - $this->assertEquals( $expected1, trim( wpautop( $content1 ) ) ); - $this->assertEqualsIgnoreEOL( $expected2, trim( wpautop( $content2 ) ) ); + $this->assertSame( $expected1, trim( wpautop( $content1 ) ) ); + $this->assertSameIgnoreEOL( $expected2, trim( wpautop( $content2 ) ) ); } /** @@ -569,7 +569,7 @@ line 2<br/> $content = 'paragraph1<hr>paragraph2'; $expected = "<p>paragraph1</p>\n<hr>\n<p>paragraph2</p>"; - $this->assertEquals( $expected, trim( wpautop( $content ) ) ); + $this->assertSame( $expected, trim( wpautop( $content ) ) ); } /** @@ -587,7 +587,7 @@ line 2<br/> $expected = '<p>' . $content . '</p>'; - $this->assertEqualsIgnoreEOL( $expected, trim( wpautop( $content ) ) ); + $this->assertSameIgnoreEOL( $expected, trim( wpautop( $content ) ) ); } /** @@ -603,6 +603,6 @@ line 2<br/> $expected = '<p>' . $content . '</p>'; - $this->assertEqualsIgnoreEOL( $expected, trim( wpautop( $content ) ) ); + $this->assertSameIgnoreEOL( $expected, trim( wpautop( $content ) ) ); } } diff --git a/tests/phpunit/tests/formatting/BlogInfo.php b/tests/phpunit/tests/formatting/BlogInfo.php index 15b32fa682..37ce3450fa 100644 --- a/tests/phpunit/tests/formatting/BlogInfo.php +++ b/tests/phpunit/tests/formatting/BlogInfo.php @@ -15,7 +15,7 @@ class Tests_Formatting_BlogInfo extends WP_UnitTestCase { $old_locale = $locale; $locale = $test_locale; - $this->assertEquals( $expected, get_bloginfo( 'language' ) ); + $this->assertSame( $expected, get_bloginfo( 'language' ) ); $locale = $old_locale; } @@ -54,16 +54,16 @@ class Tests_Formatting_BlogInfo extends WP_UnitTestCase { $sanitized_value = sanitize_option( 'blogname', $value ); update_option( 'blogname', $sanitized_value ); - $this->assertEquals( $expected, $sanitized_value ); - $this->assertEquals( $expected, get_bloginfo( 'name' ) ); - $this->assertEquals( $expected, get_bloginfo( 'name', 'display' ) ); + $this->assertSame( $expected, $sanitized_value ); + $this->assertSame( $expected, get_bloginfo( 'name' ) ); + $this->assertSame( $expected, get_bloginfo( 'name', 'display' ) ); $sanitized_value = sanitize_option( 'blogdescription', $value ); update_option( 'blogdescription', $sanitized_value ); - $this->assertEquals( $expected, $sanitized_value ); - $this->assertEquals( $expected, get_bloginfo( 'description' ) ); - $this->assertEquals( $expected, get_bloginfo( 'description', 'display' ) ); + $this->assertSame( $expected, $sanitized_value ); + $this->assertSame( $expected, get_bloginfo( 'description' ) ); + $this->assertSame( $expected, get_bloginfo( 'description', 'display' ) ); } // Restore old values. diff --git a/tests/phpunit/tests/formatting/CapitalPDangit.php b/tests/phpunit/tests/formatting/CapitalPDangit.php index 06aec81b49..70656a66a3 100644 --- a/tests/phpunit/tests/formatting/CapitalPDangit.php +++ b/tests/phpunit/tests/formatting/CapitalPDangit.php @@ -7,14 +7,14 @@ class Tests_Formatting_CapitalPDangit extends WP_UnitTestCase { function test_esc_attr_quotes() { global $wp_current_filter; - $this->assertEquals( 'Something about WordPress', capital_P_dangit( 'Something about Wordpress' ) ); - $this->assertEquals( 'Something about (WordPress', capital_P_dangit( 'Something about (Wordpress' ) ); - $this->assertEquals( 'Something about ‘WordPress', capital_P_dangit( 'Something about ‘Wordpress' ) ); - $this->assertEquals( 'Something about “WordPress', capital_P_dangit( 'Something about “Wordpress' ) ); - $this->assertEquals( 'Something about >WordPress', capital_P_dangit( 'Something about >Wordpress' ) ); - $this->assertEquals( 'Wordpress', capital_P_dangit( 'Wordpress' ) ); + $this->assertSame( 'Something about WordPress', capital_P_dangit( 'Something about Wordpress' ) ); + $this->assertSame( 'Something about (WordPress', capital_P_dangit( 'Something about (Wordpress' ) ); + $this->assertSame( 'Something about ‘WordPress', capital_P_dangit( 'Something about ‘Wordpress' ) ); + $this->assertSame( 'Something about “WordPress', capital_P_dangit( 'Something about “Wordpress' ) ); + $this->assertSame( 'Something about >WordPress', capital_P_dangit( 'Something about >Wordpress' ) ); + $this->assertSame( 'Wordpress', capital_P_dangit( 'Wordpress' ) ); $wp_current_filter = array( 'the_title' ); - $this->assertEquals( 'WordPress', capital_P_dangit( 'Wordpress' ) ); + $this->assertSame( 'WordPress', capital_P_dangit( 'Wordpress' ) ); } } diff --git a/tests/phpunit/tests/formatting/CleanPre.php b/tests/phpunit/tests/formatting/CleanPre.php index c49ad469e9..e5b1d965a1 100644 --- a/tests/phpunit/tests/formatting/CleanPre.php +++ b/tests/phpunit/tests/formatting/CleanPre.php @@ -13,13 +13,13 @@ class Tests_Formatting_CleanPre extends WP_UnitTestCase { $source = 'a b c\n<br />sldfj<br />'; $res = 'a b c\nsldfj'; - $this->assertEquals( $res, clean_pre( $source ) ); + $this->assertSame( $res, clean_pre( $source ) ); } function test_removes_self_closing_br_without_space() { $source = 'a b c\n<br/>sldfj<br/>'; $res = 'a b c\nsldfj'; - $this->assertEquals( $res, clean_pre( $source ) ); + $this->assertSame( $res, clean_pre( $source ) ); } // I don't think this can ever happen in production; @@ -29,12 +29,12 @@ class Tests_Formatting_CleanPre extends WP_UnitTestCase { function test_removes_html_br() { $source = 'a b c\n<br>sldfj<br>'; $res = 'a b c\nsldfj'; - $this->assertEquals( $res, clean_pre( $source ) ); + $this->assertSame( $res, clean_pre( $source ) ); } function test_removes_p() { $source = "<p>isn't this exciting!</p><p>oh indeed!</p>"; $res = "\nisn't this exciting!\noh indeed!"; - $this->assertEquals( $res, clean_pre( $source ) ); + $this->assertSame( $res, clean_pre( $source ) ); } } diff --git a/tests/phpunit/tests/formatting/ConvertInvalidEntries.php b/tests/phpunit/tests/formatting/ConvertInvalidEntries.php index 23192b8974..05e77fe6bf 100644 --- a/tests/phpunit/tests/formatting/ConvertInvalidEntries.php +++ b/tests/phpunit/tests/formatting/ConvertInvalidEntries.php @@ -7,7 +7,7 @@ class Tests_Formatting_ConvertInvalidEntities extends WP_UnitTestCase { function test_replaces_windows1252_entities_with_unicode_ones() { $input = '‚ƒ„…†‡ˆ‰Š‹Œ‘’“”•–—˜™š›œŸ'; $output = '‚ƒ„…†‡ˆ‰Š‹Œ‘’“”•–—˜™š›œŸ'; - $this->assertEquals( $output, convert_invalid_entities( $input ) ); + $this->assertSame( $output, convert_invalid_entities( $input ) ); } /** @@ -16,10 +16,10 @@ class Tests_Formatting_ConvertInvalidEntities extends WP_UnitTestCase { function test_replaces_latin_letter_z_with_caron() { $input = 'Žž'; $output = 'Žž'; - $this->assertEquals( $output, convert_invalid_entities( $input ) ); + $this->assertSame( $output, convert_invalid_entities( $input ) ); } function test_escapes_lone_ampersands() { - $this->assertEquals( 'at&t', convert_chars( 'at&t' ) ); + $this->assertSame( 'at&t', convert_chars( 'at&t' ) ); } } diff --git a/tests/phpunit/tests/formatting/EscAttr.php b/tests/phpunit/tests/formatting/EscAttr.php index faba68169b..65e661ca87 100644 --- a/tests/phpunit/tests/formatting/EscAttr.php +++ b/tests/phpunit/tests/formatting/EscAttr.php @@ -6,27 +6,27 @@ class Tests_Formatting_EscAttr extends WP_UnitTestCase { function test_esc_attr_quotes() { $attr = '"double quotes"'; - $this->assertEquals( '"double quotes"', esc_attr( $attr ) ); + $this->assertSame( '"double quotes"', esc_attr( $attr ) ); $attr = "'single quotes'"; - $this->assertEquals( ''single quotes'', esc_attr( $attr ) ); + $this->assertSame( ''single quotes'', esc_attr( $attr ) ); $attr = "'mixed' " . '"quotes"'; - $this->assertEquals( ''mixed' "quotes"', esc_attr( $attr ) ); + $this->assertSame( ''mixed' "quotes"', esc_attr( $attr ) ); // Handles double encoding? $attr = '"double quotes"'; - $this->assertEquals( '"double quotes"', esc_attr( esc_attr( $attr ) ) ); + $this->assertSame( '"double quotes"', esc_attr( esc_attr( $attr ) ) ); $attr = "'single quotes'"; - $this->assertEquals( ''single quotes'', esc_attr( esc_attr( $attr ) ) ); + $this->assertSame( ''single quotes'', esc_attr( esc_attr( $attr ) ) ); $attr = "'mixed' " . '"quotes"'; - $this->assertEquals( ''mixed' "quotes"', esc_attr( esc_attr( $attr ) ) ); + $this->assertSame( ''mixed' "quotes"', esc_attr( esc_attr( $attr ) ) ); } function test_esc_attr_amp() { $out = esc_attr( 'foo & bar &baz;  ' ); - $this->assertEquals( 'foo & bar &baz;  ', $out ); + $this->assertSame( 'foo & bar &baz;  ', $out ); } } diff --git a/tests/phpunit/tests/formatting/EscHtml.php b/tests/phpunit/tests/formatting/EscHtml.php index 0f30343eef..4db00dfb0a 100644 --- a/tests/phpunit/tests/formatting/EscHtml.php +++ b/tests/phpunit/tests/formatting/EscHtml.php @@ -7,34 +7,34 @@ class Tests_Formatting_EscHtml extends WP_UnitTestCase { function test_esc_html_basics() { // Simple string. $html = 'The quick brown fox.'; - $this->assertEquals( $html, esc_html( $html ) ); + $this->assertSame( $html, esc_html( $html ) ); // URL with &. $html = 'http://localhost/trunk/wp-login.php?action=logout&_wpnonce=cd57d75985'; $escaped = 'http://localhost/trunk/wp-login.php?action=logout&_wpnonce=cd57d75985'; - $this->assertEquals( $escaped, esc_html( $html ) ); + $this->assertSame( $escaped, esc_html( $html ) ); // SQL query. $html = "SELECT meta_key, meta_value FROM wp_trunk_sitemeta WHERE meta_key IN ('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled') AND site_id = 1"; $escaped = 'SELECT meta_key, meta_value FROM wp_trunk_sitemeta WHERE meta_key IN ('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled') AND site_id = 1'; - $this->assertEquals( $escaped, esc_html( $html ) ); + $this->assertSame( $escaped, esc_html( $html ) ); } function test_escapes_ampersands() { $source = 'penn & teller & at&t'; $res = 'penn & teller & at&t'; - $this->assertEquals( $res, esc_html( $source ) ); + $this->assertSame( $res, esc_html( $source ) ); } function test_escapes_greater_and_less_than() { $source = 'this > that < that <randomhtml />'; $res = 'this > that < that <randomhtml />'; - $this->assertEquals( $res, esc_html( $source ) ); + $this->assertSame( $res, esc_html( $source ) ); } function test_ignores_existing_entities() { $source = '& £ " &'; $res = '& £ " &'; - $this->assertEquals( $res, esc_html( $source ) ); + $this->assertSame( $res, esc_html( $source ) ); } } diff --git a/tests/phpunit/tests/formatting/EscTextarea.php b/tests/phpunit/tests/formatting/EscTextarea.php index 5ca9608492..e57f48f99e 100644 --- a/tests/phpunit/tests/formatting/EscTextarea.php +++ b/tests/phpunit/tests/formatting/EscTextarea.php @@ -16,7 +16,7 @@ class Tests_Formatting_EscTextarea extends WP_UnitTestCase { function test_esc_textarea_charset_iso_8859_1() { add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) ); $iso8859_1 = 'Fran' . chr( 135 ) . 'ais'; - $this->assertEquals( $iso8859_1, esc_textarea( $iso8859_1 ) ); + $this->assertSame( $iso8859_1, esc_textarea( $iso8859_1 ) ); remove_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) ); } @@ -30,7 +30,7 @@ class Tests_Formatting_EscTextarea extends WP_UnitTestCase { function test_esc_textarea_charset_utf_8() { add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) ); $utf8 = 'Fran' . chr( 195 ) . chr( 167 ) . 'ais'; - $this->assertEquals( $utf8, esc_textarea( $utf8 ) ); + $this->assertSame( $utf8, esc_textarea( $utf8 ) ); remove_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) ); } } diff --git a/tests/phpunit/tests/formatting/EscUrl.php b/tests/phpunit/tests/formatting/EscUrl.php index bf11db84cb..13ecc4af66 100644 --- a/tests/phpunit/tests/formatting/EscUrl.php +++ b/tests/phpunit/tests/formatting/EscUrl.php @@ -9,41 +9,41 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { * @ticket 23605 */ function test_spaces() { - $this->assertEquals( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr WordPress' ) ); - $this->assertEquals( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr%20WordPress' ) ); - $this->assertEquals( 'http://example.com/Mr%20%20WordPress', esc_url( 'http://example.com/Mr%20%20WordPress' ) ); - $this->assertEquals( 'http://example.com/Mr+WordPress', esc_url( 'http://example.com/Mr+WordPress' ) ); - $this->assertEquals( 'http://example.com/Mr+WordPress', esc_url( ' http://example.com/Mr+WordPress' ) ); + $this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr WordPress' ) ); + $this->assertSame( 'http://example.com/Mr%20WordPress', esc_url( 'http://example.com/Mr%20WordPress' ) ); + $this->assertSame( 'http://example.com/Mr%20%20WordPress', esc_url( 'http://example.com/Mr%20%20WordPress' ) ); + $this->assertSame( 'http://example.com/Mr+WordPress', esc_url( 'http://example.com/Mr+WordPress' ) ); + $this->assertSame( 'http://example.com/Mr+WordPress', esc_url( ' http://example.com/Mr+WordPress' ) ); - $this->assertEquals( 'http://example.com/?foo=one%20two%20three&bar=four', esc_url( 'http://example.com/?foo=one two three&bar=four' ) ); - $this->assertEquals( 'http://example.com/?foo=one%20two%20three&bar=four', esc_url( 'http://example.com/?foo=one%20two%20three&bar=four' ) ); + $this->assertSame( 'http://example.com/?foo=one%20two%20three&bar=four', esc_url( 'http://example.com/?foo=one two three&bar=four' ) ); + $this->assertSame( 'http://example.com/?foo=one%20two%20three&bar=four', esc_url( 'http://example.com/?foo=one%20two%20three&bar=four' ) ); } function test_bad_characters() { - $this->assertEquals( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0Ago' ) ); - $this->assertEquals( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0ago' ) ); - $this->assertEquals( 'http://example.com/watchthecarriagereturngo', esc_url( 'http://example.com/watchthecarriagereturn%0Dgo' ) ); - $this->assertEquals( 'http://example.com/watchthecarriagereturngo', esc_url( 'http://example.com/watchthecarriagereturn%0dgo' ) ); + $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0Ago' ) ); + $this->assertSame( 'http://example.com/watchthelinefeedgo', esc_url( 'http://example.com/watchthelinefeed%0ago' ) ); + $this->assertSame( 'http://example.com/watchthecarriagereturngo', esc_url( 'http://example.com/watchthecarriagereturn%0Dgo' ) ); + $this->assertSame( 'http://example.com/watchthecarriagereturngo', esc_url( 'http://example.com/watchthecarriagereturn%0dgo' ) ); // Nesting checks. - $this->assertEquals( 'http://example.com/watchthecarriagereturngo', esc_url( 'http://example.com/watchthecarriagereturn%0%0ddgo' ) ); - $this->assertEquals( 'http://example.com/watchthecarriagereturngo', esc_url( 'http://example.com/watchthecarriagereturn%0%0DDgo' ) ); - $this->assertEquals( 'http://example.com/', esc_url( 'http://example.com/%0%0%0DAD' ) ); - $this->assertEquals( 'http://example.com/', esc_url( 'http://example.com/%0%0%0ADA' ) ); - $this->assertEquals( 'http://example.com/', esc_url( 'http://example.com/%0%0%0DAd' ) ); - $this->assertEquals( 'http://example.com/', esc_url( 'http://example.com/%0%0%0ADa' ) ); + $this->assertSame( 'http://example.com/watchthecarriagereturngo', esc_url( 'http://example.com/watchthecarriagereturn%0%0ddgo' ) ); + $this->assertSame( 'http://example.com/watchthecarriagereturngo', esc_url( 'http://example.com/watchthecarriagereturn%0%0DDgo' ) ); + $this->assertSame( 'http://example.com/', esc_url( 'http://example.com/%0%0%0DAD' ) ); + $this->assertSame( 'http://example.com/', esc_url( 'http://example.com/%0%0%0ADA' ) ); + $this->assertSame( 'http://example.com/', esc_url( 'http://example.com/%0%0%0DAd' ) ); + $this->assertSame( 'http://example.com/', esc_url( 'http://example.com/%0%0%0ADa' ) ); } function test_relative() { - $this->assertEquals( '/example.php', esc_url( '/example.php' ) ); - $this->assertEquals( 'example.php', esc_url( 'example.php' ) ); - $this->assertEquals( '#fragment', esc_url( '#fragment' ) ); - $this->assertEquals( '?foo=bar', esc_url( '?foo=bar' ) ); + $this->assertSame( '/example.php', esc_url( '/example.php' ) ); + $this->assertSame( 'example.php', esc_url( 'example.php' ) ); + $this->assertSame( '#fragment', esc_url( '#fragment' ) ); + $this->assertSame( '?foo=bar', esc_url( '?foo=bar' ) ); } function test_all_url_parts() { $url = 'https://user:pass@host.example.com:1234/path;p=1?query=2&r[]=3#fragment'; - $this->assertEquals( + $this->assertSame( array( 'scheme' => 'https', 'host' => 'host.example.com', @@ -56,35 +56,35 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { ), parse_url( $url ) ); - $this->assertEquals( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url_raw( $url ) ); - $this->assertEquals( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url( $url ) ); + $this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url_raw( $url ) ); + $this->assertSame( 'https://user:pass@host.example.com:1234/path;p=1?query=2&r%5B%5D=3#fragment', esc_url( $url ) ); } function test_bare() { - $this->assertEquals( 'http://example.com?foo', esc_url( 'example.com?foo' ) ); - $this->assertEquals( 'http://example.com', esc_url( 'example.com' ) ); - $this->assertEquals( 'http://localhost', esc_url( 'localhost' ) ); - $this->assertEquals( 'http://example.com/foo', esc_url( 'example.com/foo' ) ); - $this->assertEquals( 'http://баба.org/баба', esc_url( 'баба.org/баба' ) ); + $this->assertSame( 'http://example.com?foo', esc_url( 'example.com?foo' ) ); + $this->assertSame( 'http://example.com', esc_url( 'example.com' ) ); + $this->assertSame( 'http://localhost', esc_url( 'localhost' ) ); + $this->assertSame( 'http://example.com/foo', esc_url( 'example.com/foo' ) ); + $this->assertSame( 'http://баба.org/баба', esc_url( 'баба.org/баба' ) ); } function test_encoding() { - $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); - $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); - $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); + $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); + $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); + $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url_raw( 'http://example.com?foo=1&bar=2' ) ); - $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) ); - $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) ); - $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) ); + $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) ); + $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) ); + $this->assertSame( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) ); $param = urlencode( 'http://example.com/?one=1&two=2' ); - $this->assertEquals( "http://example.com?url={$param}", esc_url( "http://example.com?url={$param}" ) ); + $this->assertSame( "http://example.com?url={$param}", esc_url( "http://example.com?url={$param}" ) ); } function test_protocol() { - $this->assertEquals( 'http://example.com', esc_url( 'http://example.com' ) ); - $this->assertEquals( '', esc_url( 'nasty://example.com/' ) ); - $this->assertEquals( + $this->assertSame( 'http://example.com', esc_url( 'http://example.com' ) ); + $this->assertSame( '', esc_url( 'nasty://example.com/' ) ); + $this->assertSame( '', esc_url( 'example.com', @@ -93,7 +93,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { ) ) ); - $this->assertEquals( + $this->assertSame( '', esc_url( 'http://example.com', @@ -102,7 +102,7 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { ) ) ); - $this->assertEquals( + $this->assertSame( 'https://example.com', esc_url( 'https://example.com', @@ -114,8 +114,8 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { ); foreach ( wp_allowed_protocols() as $scheme ) { - $this->assertEquals( "{$scheme}://example.com", esc_url( "{$scheme}://example.com" ), $scheme ); - $this->assertEquals( + $this->assertSame( "{$scheme}://example.com", esc_url( "{$scheme}://example.com" ), $scheme ); + $this->assertSame( "{$scheme}://example.com", esc_url( "{$scheme}://example.com", @@ -128,10 +128,10 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { } $this->assertTrue( ! in_array( 'data', wp_allowed_protocols(), true ) ); - $this->assertEquals( '', esc_url( 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' ) ); + $this->assertSame( '', esc_url( 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' ) ); $this->assertTrue( ! in_array( 'foo', wp_allowed_protocols(), true ) ); - $this->assertEquals( + $this->assertSame( 'foo://example.com', esc_url( 'foo://example.com', @@ -147,42 +147,42 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { * @ticket 23187 */ function test_protocol_case() { - $this->assertEquals( 'http://example.com', esc_url( 'HTTP://example.com' ) ); - $this->assertEquals( 'http://example.com', esc_url( 'Http://example.com' ) ); + $this->assertSame( 'http://example.com', esc_url( 'HTTP://example.com' ) ); + $this->assertSame( 'http://example.com', esc_url( 'Http://example.com' ) ); } function test_display_extras() { - $this->assertEquals( 'http://example.com/'quoted'', esc_url( 'http://example.com/\'quoted\'' ) ); - $this->assertEquals( 'http://example.com/\'quoted\'', esc_url( 'http://example.com/\'quoted\'', null, 'notdisplay' ) ); + $this->assertSame( 'http://example.com/'quoted'', esc_url( 'http://example.com/\'quoted\'' ) ); + $this->assertSame( 'http://example.com/\'quoted\'', esc_url( 'http://example.com/\'quoted\'', null, 'notdisplay' ) ); } function test_non_ascii() { - $this->assertEquals( 'http://example.org/баба', esc_url( 'http://example.org/баба' ) ); - $this->assertEquals( 'http://баба.org/баба', esc_url( 'http://баба.org/баба' ) ); - $this->assertEquals( 'http://müller.com/', esc_url( 'http://müller.com/' ) ); + $this->assertSame( 'http://example.org/баба', esc_url( 'http://example.org/баба' ) ); + $this->assertSame( 'http://баба.org/баба', esc_url( 'http://баба.org/баба' ) ); + $this->assertSame( 'http://müller.com/', esc_url( 'http://müller.com/' ) ); } function test_feed() { - $this->assertEquals( '', esc_url( 'feed:javascript:alert(1)' ) ); - $this->assertEquals( '', esc_url( 'feed:javascript:feed:alert(1)' ) ); - $this->assertEquals( '', esc_url( 'feed:feed:javascript:alert(1)' ) ); - $this->assertEquals( 'feed:feed:alert(1)', esc_url( 'feed:feed:alert(1)' ) ); - $this->assertEquals( 'feed:http://wordpress.org/feed/', esc_url( 'feed:http://wordpress.org/feed/' ) ); + $this->assertSame( '', esc_url( 'feed:javascript:alert(1)' ) ); + $this->assertSame( '', esc_url( 'feed:javascript:feed:alert(1)' ) ); + $this->assertSame( '', esc_url( 'feed:feed:javascript:alert(1)' ) ); + $this->assertSame( 'feed:feed:alert(1)', esc_url( 'feed:feed:alert(1)' ) ); + $this->assertSame( 'feed:http://wordpress.org/feed/', esc_url( 'feed:http://wordpress.org/feed/' ) ); } /** * @ticket 16859 */ function test_square_brackets() { - $this->assertEquals( '/example.php?one%5B%5D=two', esc_url( '/example.php?one[]=two' ) ); - $this->assertEquals( '?foo%5Bbar%5D=baz', esc_url( '?foo[bar]=baz' ) ); - $this->assertEquals( '//example.com/?foo%5Bbar%5D=baz', esc_url( '//example.com/?foo[bar]=baz' ) ); - $this->assertEquals( 'http://example.com/?foo%5Bbar%5D=baz', esc_url( 'example.com/?foo[bar]=baz' ) ); - $this->assertEquals( 'http://localhost?foo%5Bbar%5D=baz', esc_url( 'localhost?foo[bar]=baz' ) ); - $this->assertEquals( 'http://example.com/?foo%5Bbar%5D=baz', esc_url( 'http://example.com/?foo[bar]=baz' ) ); - $this->assertEquals( 'http://example.com/?foo%5Bbar%5D=baz', esc_url( 'http://example.com/?foo%5Bbar%5D=baz' ) ); - $this->assertEquals( 'http://example.com/?baz=bar&foo%5Bbar%5D=baz', esc_url( 'http://example.com/?baz=bar&foo[bar]=baz' ) ); - $this->assertEquals( 'http://example.com/?baz=bar&foo%5Bbar%5D=baz', esc_url( 'http://example.com/?baz=bar&foo%5Bbar%5D=baz' ) ); + $this->assertSame( '/example.php?one%5B%5D=two', esc_url( '/example.php?one[]=two' ) ); + $this->assertSame( '?foo%5Bbar%5D=baz', esc_url( '?foo[bar]=baz' ) ); + $this->assertSame( '//example.com/?foo%5Bbar%5D=baz', esc_url( '//example.com/?foo[bar]=baz' ) ); + $this->assertSame( 'http://example.com/?foo%5Bbar%5D=baz', esc_url( 'example.com/?foo[bar]=baz' ) ); + $this->assertSame( 'http://localhost?foo%5Bbar%5D=baz', esc_url( 'localhost?foo[bar]=baz' ) ); + $this->assertSame( 'http://example.com/?foo%5Bbar%5D=baz', esc_url( 'http://example.com/?foo[bar]=baz' ) ); + $this->assertSame( 'http://example.com/?foo%5Bbar%5D=baz', esc_url( 'http://example.com/?foo%5Bbar%5D=baz' ) ); + $this->assertSame( 'http://example.com/?baz=bar&foo%5Bbar%5D=baz', esc_url( 'http://example.com/?baz=bar&foo[bar]=baz' ) ); + $this->assertSame( 'http://example.com/?baz=bar&foo%5Bbar%5D=baz', esc_url( 'http://example.com/?baz=bar&foo%5Bbar%5D=baz' ) ); } /** @@ -190,14 +190,14 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase { */ function test_reserved_characters() { $url = "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$%27()*+,;=/?:@-._~!$%27()*+,;==#/?:@-._~!$&'()*+,;="; - $this->assertEquals( $url, esc_url_raw( $url ) ); + $this->assertSame( $url, esc_url_raw( $url ) ); } /** * @ticket 21974 */ function test_protocol_relative_with_colon() { - $this->assertEquals( '//example.com/foo?foo=abc:def', esc_url( '//example.com/foo?foo=abc:def' ) ); + $this->assertSame( '//example.com/foo?foo=abc:def', esc_url( '//example.com/foo?foo=abc:def' ) ); } /** @@ -212,7 +212,7 @@ EOT; $body = str_replace( "\r\n", "\n", $body ); $email_link = 'mailto:?body=' . rawurlencode( $body ); $email_link = esc_url( $email_link ); - $this->assertEquals( 'mailto:?body=Hi%20there%2C%0A%0AI%20thought%20you%20might%20want%20to%20sign%20up%20for%20this%20newsletter', $email_link ); + $this->assertSame( 'mailto:?body=Hi%20there%2C%0A%0AI%20thought%20you%20might%20want%20to%20sign%20up%20for%20this%20newsletter', $email_link ); } /** @@ -227,7 +227,7 @@ EOT; $body = str_replace( "\r\n", "\n", $body ); $email_link = 'http://example.com/mailto:?body=' . rawurlencode( $body ); $email_link = esc_url( $email_link ); - $this->assertEquals( 'http://example.com/mailto:?body=Hi%20there%2CI%20thought%20you%20might%20want%20to%20sign%20up%20for%20this%20newsletter', $email_link ); + $this->assertSame( 'http://example.com/mailto:?body=Hi%20there%2CI%20thought%20you%20might%20want%20to%20sign%20up%20for%20this%20newsletter', $email_link ); } /** @@ -238,7 +238,7 @@ EOT; $email_link = 'mailto:?body=' . $body; $email_link = esc_url( $email_link ); - $this->assertEquals( 'mailto:?body=Hi%20there,%20I%20thought%20you%20might%20want%20to%20sign%20up%20for%20this%20newsletter', $email_link ); + $this->assertSame( 'mailto:?body=Hi%20there,%20I%20thought%20you%20might%20want%20to%20sign%20up%20for%20this%20newsletter', $email_link ); } /** @@ -252,14 +252,14 @@ EOT; * @ticket 34202 */ function test_ipv6_hosts() { - $this->assertEquals( '//[::127.0.0.1]', esc_url( '//[::127.0.0.1]' ) ); - $this->assertEquals( 'http://[::FFFF::127.0.0.1]', esc_url( 'http://[::FFFF::127.0.0.1]' ) ); - $this->assertEquals( 'http://[::127.0.0.1]', esc_url( 'http://[::127.0.0.1]' ) ); - $this->assertEquals( 'http://[::DEAD:BEEF:DEAD:BEEF:DEAD:BEEF:DEAD:BEEF]', esc_url( 'http://[::DEAD:BEEF:DEAD:BEEF:DEAD:BEEF:DEAD:BEEF]' ) ); + $this->assertSame( '//[::127.0.0.1]', esc_url( '//[::127.0.0.1]' ) ); + $this->assertSame( 'http://[::FFFF::127.0.0.1]', esc_url( 'http://[::FFFF::127.0.0.1]' ) ); + $this->assertSame( 'http://[::127.0.0.1]', esc_url( 'http://[::127.0.0.1]' ) ); + $this->assertSame( 'http://[::DEAD:BEEF:DEAD:BEEF:DEAD:BEEF:DEAD:BEEF]', esc_url( 'http://[::DEAD:BEEF:DEAD:BEEF:DEAD:BEEF:DEAD:BEEF]' ) ); // IPv6 with square brackets in the query? Why not. - $this->assertEquals( '//[::FFFF::127.0.0.1]/?foo%5Bbar%5D=baz', esc_url( '//[::FFFF::127.0.0.1]/?foo[bar]=baz' ) ); - $this->assertEquals( 'http://[::FFFF::127.0.0.1]/?foo%5Bbar%5D=baz', esc_url( 'http://[::FFFF::127.0.0.1]/?foo[bar]=baz' ) ); + $this->assertSame( '//[::FFFF::127.0.0.1]/?foo%5Bbar%5D=baz', esc_url( '//[::FFFF::127.0.0.1]/?foo[bar]=baz' ) ); + $this->assertSame( 'http://[::FFFF::127.0.0.1]/?foo%5Bbar%5D=baz', esc_url( 'http://[::FFFF::127.0.0.1]/?foo[bar]=baz' ) ); } } diff --git a/tests/phpunit/tests/formatting/EscXml.php b/tests/phpunit/tests/formatting/EscXml.php index 0c453bdf54..fa6738dca0 100644 --- a/tests/phpunit/tests/formatting/EscXml.php +++ b/tests/phpunit/tests/formatting/EscXml.php @@ -14,7 +14,7 @@ class Tests_Formatting_EscXml extends WP_UnitTestCase { */ public function test_esc_xml_basics( $source, $expected ) { $actual = esc_xml( $source ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** @@ -49,21 +49,21 @@ class Tests_Formatting_EscXml extends WP_UnitTestCase { $source = 'penn & teller & at&t'; $expected = 'penn & teller & at&t'; $actual = esc_xml( $source ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } public function test_escapes_greater_and_less_than() { $source = 'this > that < that <randomhtml />'; $expected = 'this > that < that <randomhtml />'; $actual = esc_xml( $source ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } public function test_escapes_html_named_entities() { $source = 'this & is a … followed by › and more and a &nonexistent; entity'; $expected = 'this & is a … followed by › and more and a &nonexistent; entity'; $actual = esc_xml( $source ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } public function test_ignores_existing_entities() { @@ -71,7 +71,7 @@ class Tests_Formatting_EscXml extends WP_UnitTestCase { // note that _wp_specialchars() strips leading 0's from numeric character references. $expected = '& £ " &'; $actual = esc_xml( $source ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** @@ -84,7 +84,7 @@ class Tests_Formatting_EscXml extends WP_UnitTestCase { */ public function test_ignores_cdata_sections( $source, $expected ) { $actual = esc_xml( $source ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** diff --git a/tests/phpunit/tests/formatting/ExcerptRemoveBlocks.php b/tests/phpunit/tests/formatting/ExcerptRemoveBlocks.php index 8a27f18e81..70efe18d55 100644 --- a/tests/phpunit/tests/formatting/ExcerptRemoveBlocks.php +++ b/tests/phpunit/tests/formatting/ExcerptRemoveBlocks.php @@ -99,7 +99,7 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase { $this->assertEmpty( excerpt_remove_blocks( $content ) ); // Dynamic block with options, embedded in other content. - $this->assertEquals( $this->filtered_content, excerpt_remove_blocks( $this->content ) ); + $this->assertSame( $this->filtered_content, excerpt_remove_blocks( $this->content ) ); } /** diff --git a/tests/phpunit/tests/formatting/GetUrlInContent.php b/tests/phpunit/tests/formatting/GetUrlInContent.php index 7da4c9bdf0..edb6c6f656 100644 --- a/tests/phpunit/tests/formatting/GetUrlInContent.php +++ b/tests/phpunit/tests/formatting/GetUrlInContent.php @@ -45,6 +45,6 @@ class Tests_Formatting_GetUrlInContent extends WP_UnitTestCase { * @dataProvider get_input_output */ function test_get_url_in_content( $in_str, $exp_str ) { - $this->assertEquals( $exp_str, get_url_in_content( $in_str ) ); + $this->assertSame( $exp_str, get_url_in_content( $in_str ) ); } } diff --git a/tests/phpunit/tests/formatting/HtmlExcerpt.php b/tests/phpunit/tests/formatting/HtmlExcerpt.php index 9aeea365e5..36315fc541 100644 --- a/tests/phpunit/tests/formatting/HtmlExcerpt.php +++ b/tests/phpunit/tests/formatting/HtmlExcerpt.php @@ -5,15 +5,15 @@ */ class Tests_Formatting_HtmlExcerpt extends WP_UnitTestCase { function test_simple() { - $this->assertEquals( 'Baba', wp_html_excerpt( 'Baba told me not to come', 4 ) ); + $this->assertSame( 'Baba', wp_html_excerpt( 'Baba told me not to come', 4 ) ); } function test_html() { - $this->assertEquals( 'Baba', wp_html_excerpt( "<a href='http://baba.net/'>Baba</a> told me not to come", 4 ) ); + $this->assertSame( 'Baba', wp_html_excerpt( "<a href='http://baba.net/'>Baba</a> told me not to come", 4 ) ); } function test_entities() { - $this->assertEquals( 'Baba', wp_html_excerpt( 'Baba & Dyado', 8 ) ); - $this->assertEquals( 'Baba', wp_html_excerpt( 'Baba & Dyado', 8 ) ); - $this->assertEquals( 'Baba & D', wp_html_excerpt( 'Baba & Dyado', 12 ) ); - $this->assertEquals( 'Baba & Dyado', wp_html_excerpt( 'Baba & Dyado', 100 ) ); + $this->assertSame( 'Baba', wp_html_excerpt( 'Baba & Dyado', 8 ) ); + $this->assertSame( 'Baba', wp_html_excerpt( 'Baba & Dyado', 8 ) ); + $this->assertSame( 'Baba & D', wp_html_excerpt( 'Baba & Dyado', 12 ) ); + $this->assertSame( 'Baba & Dyado', wp_html_excerpt( 'Baba & Dyado', 100 ) ); } } diff --git a/tests/phpunit/tests/formatting/HumanTimeDiff.php b/tests/phpunit/tests/formatting/HumanTimeDiff.php index 473f5325d3..e990d2e49b 100644 --- a/tests/phpunit/tests/formatting/HumanTimeDiff.php +++ b/tests/phpunit/tests/formatting/HumanTimeDiff.php @@ -13,7 +13,7 @@ class Tests_Formatting_HumanTimeDiff extends WP_UnitTestCase { */ function test_human_time_diff( $expected, $stopdate, $message ) { $startdate = new DateTime( '2016-01-01 12:00:00' ); - $this->assertEquals( $expected, human_time_diff( $startdate->format( 'U' ), $stopdate->format( 'U' ) ), $message ); + $this->assertSame( $expected, human_time_diff( $startdate->format( 'U' ), $stopdate->format( 'U' ) ), $message ); } // Data for test_human_time_diff. diff --git a/tests/phpunit/tests/formatting/IsEmail.php b/tests/phpunit/tests/formatting/IsEmail.php index 7d0c7773ee..6a11c9862a 100644 --- a/tests/phpunit/tests/formatting/IsEmail.php +++ b/tests/phpunit/tests/formatting/IsEmail.php @@ -13,7 +13,7 @@ class Tests_Formatting_IsEmail extends WP_UnitTestCase { 'a@b.co', ); foreach ( $data as $datum ) { - $this->assertEquals( $datum, is_email( $datum ), $datum ); + $this->assertSame( $datum, is_email( $datum ), $datum ); } } diff --git a/tests/phpunit/tests/formatting/JSEscape.php b/tests/phpunit/tests/formatting/JSEscape.php index febd082617..1b5c73ce1b 100644 --- a/tests/phpunit/tests/formatting/JSEscape.php +++ b/tests/phpunit/tests/formatting/JSEscape.php @@ -6,30 +6,30 @@ class Tests_Formatting_JSEscape extends WP_UnitTestCase { function test_js_escape_simple() { $out = esc_js( 'foo bar baz();' ); - $this->assertEquals( 'foo bar baz();', $out ); + $this->assertSame( 'foo bar baz();', $out ); } function test_js_escape_quotes() { $out = esc_js( 'foo "bar" \'baz\'' ); // Does it make any sense to change " into "? Why not \"? - $this->assertEquals( "foo "bar" \'baz\'", $out ); + $this->assertSame( "foo "bar" \'baz\'", $out ); } function test_js_escape_backslash() { $bs = '\\'; $out = esc_js( 'foo ' . $bs . 't bar ' . $bs . $bs . ' baz' ); // \t becomes t - bug? - $this->assertEquals( 'foo t bar ' . $bs . $bs . ' baz', $out ); + $this->assertSame( 'foo t bar ' . $bs . $bs . ' baz', $out ); } function test_js_escape_amp() { $out = esc_js( 'foo & bar &baz;  ' ); - $this->assertEquals( 'foo & bar &baz;  ', $out ); + $this->assertSame( 'foo & bar &baz;  ', $out ); } function test_js_escape_quote_entity() { $out = esc_js( 'foo ' bar ' baz &' ); - $this->assertEquals( "foo \\' bar \\' baz &", $out ); + $this->assertSame( "foo \\' bar \\' baz &", $out ); } function test_js_no_carriage_return() { diff --git a/tests/phpunit/tests/formatting/LikeEscape.php b/tests/phpunit/tests/formatting/LikeEscape.php index 1c696ba0a0..a565e2fe9b 100644 --- a/tests/phpunit/tests/formatting/LikeEscape.php +++ b/tests/phpunit/tests/formatting/LikeEscape.php @@ -24,7 +24,7 @@ class Tests_Formatting_LikeEscape extends WP_UnitTestCase { ); foreach ( $inputs as $key => $input ) { - $this->assertEquals( $expected[ $key ], like_escape( $input ) ); + $this->assertSame( $expected[ $key ], like_escape( $input ) ); } } } diff --git a/tests/phpunit/tests/formatting/LinksAddTarget.php b/tests/phpunit/tests/formatting/LinksAddTarget.php index 1ffae4566f..f0ad0585ac 100644 --- a/tests/phpunit/tests/formatting/LinksAddTarget.php +++ b/tests/phpunit/tests/formatting/LinksAddTarget.php @@ -74,11 +74,11 @@ class Tests_Formatting_LinksAddTarget extends WP_UnitTestCase { */ function test_normalize_whitespace( $content, $target, $tags, $exp_str ) { if ( true === is_null( $target ) ) { - $this->assertEquals( $exp_str, links_add_target( $content ) ); + $this->assertSame( $exp_str, links_add_target( $content ) ); } elseif ( true === is_null( $tags ) ) { - $this->assertEquals( $exp_str, links_add_target( $content, $target ) ); + $this->assertSame( $exp_str, links_add_target( $content, $target ) ); } else { - $this->assertEquals( $exp_str, links_add_target( $content, $target, $tags ) ); + $this->assertSame( $exp_str, links_add_target( $content, $target, $tags ) ); } } } diff --git a/tests/phpunit/tests/formatting/MakeClickable.php b/tests/phpunit/tests/formatting/MakeClickable.php index a9ae2969cd..cc59179664 100644 --- a/tests/phpunit/tests/formatting/MakeClickable.php +++ b/tests/phpunit/tests/formatting/MakeClickable.php @@ -6,7 +6,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { function test_mailto_xss() { $in = 'testzzz@"STYLE="behavior:url(\'#default#time2\')"onBegin="alert(\'refresh-XSS\')"'; - $this->assertEquals( $in, make_clickable( $in ) ); + $this->assertSame( $in, make_clickable( $in ) ); } function test_valid_mailto() { @@ -18,7 +18,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { 'foo@example-example.com', ); foreach ( $valid_emails as $email ) { - $this->assertEquals( '<a href="mailto:' . $email . '">' . $email . '</a>', make_clickable( $email ) ); + $this->assertSame( '<a href="mailto:' . $email . '">' . $email . '</a>', make_clickable( $email ) ); } } @@ -32,7 +32,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { 'foo@example', ); foreach ( $invalid_emails as $email ) { - $this->assertEquals( $email, make_clickable( $email ) ); + $this->assertSame( $email, make_clickable( $email ) ); } } @@ -59,7 +59,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { ); foreach ( $urls_before as $key => $url ) { - $this->assertEquals( $urls_expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $urls_expected[ $key ], make_clickable( $url ) ); } } @@ -88,7 +88,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { ); foreach ( $urls_before as $key => $url ) { - $this->assertEquals( $urls_expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $urls_expected[ $key ], make_clickable( $url ) ); } } @@ -115,7 +115,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { ); foreach ( $urls_before as $key => $url ) { - $this->assertEquals( $urls_expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $urls_expected[ $key ], make_clickable( $url ) ); } } @@ -142,7 +142,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { ); foreach ( $urls_before as $key => $url ) { - $this->assertEquals( $urls_expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $urls_expected[ $key ], make_clickable( $url ) ); } } @@ -161,7 +161,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { '<a href="http://example.com/?a=баба&b=дядо" rel="nofollow">http://example.com/?a=баба&b=дядо</a>', ); foreach ( $urls_before as $key => $url ) { - $this->assertEquals( $urls_expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $urls_expected[ $key ], make_clickable( $url ) ); } } @@ -198,7 +198,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { Richard Hamming wrote about people getting more done with their doors closed, but', ); foreach ( $urls_before as $key => $url ) { - $this->assertEquals( $urls_expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $urls_expected[ $key ], make_clickable( $url ) ); } } @@ -221,7 +221,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { 'In his famous speech “You and Your research” (here: <a href="http://www.cs.virginia.edu/~robins/YouAndYourResearch.html" rel="nofollow">http://www.cs.virginia.edu/~robins/YouAndYourResearch.html</a>) Richard Hamming wrote about people getting more done with their doors closed...', ); foreach ( $urls_before as $key => $url ) { - $this->assertEquals( $urls_expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $urls_expected[ $key ], make_clickable( $url ) ); } } @@ -240,7 +240,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { 'This is a really good tweet <a href="http://twitter.com/#!/wordpress/status/25907440233" rel="nofollow">http://twitter.com/#!/wordpress/status/25907440233</a>!', ); foreach ( $urls_before as $key => $url ) { - $this->assertEquals( $urls_expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $urls_expected[ $key ], make_clickable( $url ) ); } } @@ -256,7 +256,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { 'mailto wrapped in angle brackets <foo@example.com>', ); foreach ( $before as $key => $url ) { - $this->assertEquals( $expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $expected[ $key ], make_clickable( $url ) ); } } @@ -278,7 +278,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { 'Question mark then URL?<a href="http://example.com/" rel="nofollow">http://example.com/</a>', ); foreach ( $before as $key => $url ) { - $this->assertEquals( $expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $expected[ $key ], make_clickable( $url ) ); } } @@ -302,7 +302,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { '<a href="http://example.com/example.gif" title="Image from http://example.com">Look at this image!</a>', ); foreach ( $urls_before as $key => $url ) { - $this->assertEquals( $urls_expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $urls_expected[ $key ], make_clickable( $url ) ); } } @@ -343,7 +343,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { ); foreach ( $before as $key => $url ) { - $this->assertEquals( $expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $expected[ $key ], make_clickable( $url ) ); } } @@ -360,7 +360,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { '<p><a href="http://example.com/" rel="nofollow">http://example.com/</a></p>', ); foreach ( $urls_before as $key => $url ) { - $this->assertEquals( $urls_expected[ $key ], make_clickable( $url ) ); + $this->assertSame( $urls_expected[ $key ], make_clickable( $url ) ); } } @@ -370,7 +370,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { // '<a href="http://wordpress.org">This is already a link www.wordpress.org</a>', // Fails in 3.3.1 too. ); foreach ( $in as $text ) { - $this->assertEquals( $text, make_clickable( $text ) ); + $this->assertSame( $text, make_clickable( $text ) ); } } @@ -380,7 +380,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { function test_no_segfault() { $in = str_repeat( 'http://example.com/2011/03/18/post-title/', 256 ); $out = make_clickable( $in ); - $this->assertEquals( $in, $out ); + $this->assertSame( $in, $out ); } /** @@ -389,7 +389,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { function test_line_break_in_existing_clickable_link() { $html = "<a href='mailto:someone@example.com'>someone@example.com</a>"; - $this->assertEquals( $html, make_clickable( $html ) ); + $this->assertSame( $html, make_clickable( $html ) ); } /** @@ -397,7 +397,7 @@ class Tests_Formatting_MakeClickable extends WP_UnitTestCase { * @dataProvider data_script_and_style_tags */ public function test_dont_link_script_and_style_tags( $tag ) { - $this->assertEquals( $tag, make_clickable( $tag ) ); + $this->assertSame( $tag, make_clickable( $tag ) ); } public function data_script_and_style_tags() { diff --git a/tests/phpunit/tests/formatting/MapDeep.php b/tests/phpunit/tests/formatting/MapDeep.php index cacd62cf68..0a291c9769 100644 --- a/tests/phpunit/tests/formatting/MapDeep.php +++ b/tests/phpunit/tests/formatting/MapDeep.php @@ -7,11 +7,11 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase { public function test_map_deep_with_any_function_over_empty_array_should_return_empty_array() { - $this->assertEquals( array(), map_deep( array(), array( $this, 'append_baba' ) ) ); + $this->assertSame( array(), map_deep( array(), array( $this, 'append_baba' ) ) ); } public function test_map_deep_should_map_each_element_of_array_one_level_deep() { - $this->assertEquals( + $this->assertSame( array( 'ababa', 'xbaba', @@ -27,7 +27,7 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase { } public function test_map_deep_should_map_each_element_of_array_two_levels_deep() { - $this->assertEquals( + $this->assertSame( array( 'ababa', array( @@ -67,11 +67,11 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase { } public function test_map_deep_should_apply_the_function_to_a_string() { - $this->assertEquals( 'xbaba', map_deep( 'x', array( $this, 'append_baba' ) ) ); + $this->assertSame( 'xbaba', map_deep( 'x', array( $this, 'append_baba' ) ) ); } public function test_map_deep_should_apply_the_function_to_an_integer() { - $this->assertEquals( '5baba', map_deep( 5, array( $this, 'append_baba' ) ) ); + $this->assertSame( '5baba', map_deep( 5, array( $this, 'append_baba' ) ) ); } public function test_map_deep_should_map_each_property_of_an_object() { @@ -157,7 +157,7 @@ class Tests_Formatting_MapDeep extends WP_UnitTestCase { 'var0' => &$array_a['var0'], 'var1' => 'x', ); - $this->assertEquals( + $this->assertSame( array( 'var0' => 'ababa', 'var1' => 'xbaba', diff --git a/tests/phpunit/tests/formatting/NormalizeWhitespace.php b/tests/phpunit/tests/formatting/NormalizeWhitespace.php index 9ed6b30ac2..9d963e0ef6 100644 --- a/tests/phpunit/tests/formatting/NormalizeWhitespace.php +++ b/tests/phpunit/tests/formatting/NormalizeWhitespace.php @@ -47,6 +47,6 @@ class Tests_Formatting_NormalizeWhitespace extends WP_UnitTestCase { * @dataProvider get_input_output */ function test_normalize_whitespace( $in_str, $exp_str ) { - $this->assertEquals( $exp_str, normalize_whitespace( $in_str ) ); + $this->assertSame( $exp_str, normalize_whitespace( $in_str ) ); } } diff --git a/tests/phpunit/tests/formatting/RemoveAccents.php b/tests/phpunit/tests/formatting/RemoveAccents.php index e68044d8c8..e66b876e02 100644 --- a/tests/phpunit/tests/formatting/RemoveAccents.php +++ b/tests/phpunit/tests/formatting/RemoveAccents.php @@ -5,7 +5,7 @@ */ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { public function test_remove_accents_simple() { - $this->assertEquals( 'abcdefghijkl', remove_accents( 'abcdefghijkl' ) ); + $this->assertSame( 'abcdefghijkl', remove_accents( 'abcdefghijkl' ) ); } /** @@ -15,23 +15,23 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { $input = 'ªºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'; $output = 'aoAAAAAAAECEEEEIIIIDNOOOOOOUUUUYTHsaaaaaaaeceeeeiiiidnoooooouuuuythy'; - $this->assertEquals( $output, remove_accents( $input ), 'remove_accents replaces Latin-1 Supplement' ); + $this->assertSame( $output, remove_accents( $input ), 'remove_accents replaces Latin-1 Supplement' ); } public function test_remove_accents_latin_extended_a() { $input = 'ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſ'; $output = 'AaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIJijJjKkkLlLlLlLlLlNnNnNnnNnOoOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZzs'; - $this->assertEquals( $output, remove_accents( $input ), 'remove_accents replaces Latin Extended A' ); + $this->assertSame( $output, remove_accents( $input ), 'remove_accents replaces Latin Extended A' ); } public function test_remove_accents_latin_extended_b() { - $this->assertEquals( 'SsTt', remove_accents( 'ȘșȚț' ), 'remove_accents replaces Latin Extended B' ); + $this->assertSame( 'SsTt', remove_accents( 'ȘșȚț' ), 'remove_accents replaces Latin Extended B' ); } public function test_remove_accents_euro_pound_signs() { - $this->assertEquals( 'E', remove_accents( '€' ), 'remove_accents replaces euro sign' ); - $this->assertEquals( '', remove_accents( '£' ), 'remove_accents replaces pound sign' ); + $this->assertSame( 'E', remove_accents( '€' ), 'remove_accents replaces euro sign' ); + $this->assertSame( '', remove_accents( '£' ), 'remove_accents replaces pound sign' ); } public function test_remove_accents_iso8859() { @@ -41,7 +41,7 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { $input = trim( $input ); $output = 'EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyyOEoeAEDHTHssaedhth'; - $this->assertEquals( $output, remove_accents( $input ), 'remove_accents from ISO-8859-1 text' ); + $this->assertSame( $output, remove_accents( $input ), 'remove_accents from ISO-8859-1 text' ); } /** @@ -50,17 +50,17 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { public function test_remove_accents_vowels_diacritic() { // Vowels with diacritic. // Unmarked. - $this->assertEquals( 'OoUu', remove_accents( 'ƠơƯư' ) ); + $this->assertSame( 'OoUu', remove_accents( 'ƠơƯư' ) ); // Grave accent. - $this->assertEquals( 'AaAaEeOoOoUuYy', remove_accents( 'ẦầẰằỀềỒồỜờỪừỲỳ' ) ); + $this->assertSame( 'AaAaEeOoOoUuYy', remove_accents( 'ẦầẰằỀềỒồỜờỪừỲỳ' ) ); // Hook. - $this->assertEquals( 'AaAaAaEeEeIiOoOoOoUuUuYy', remove_accents( 'ẢảẨẩẲẳẺẻỂểỈỉỎỏỔổỞởỦủỬửỶỷ' ) ); + $this->assertSame( 'AaAaAaEeEeIiOoOoOoUuUuYy', remove_accents( 'ẢảẨẩẲẳẺẻỂểỈỉỎỏỔổỞởỦủỬửỶỷ' ) ); // Tilde. - $this->assertEquals( 'AaAaEeEeOoOoUuYy', remove_accents( 'ẪẫẴẵẼẽỄễỖỗỠỡỮữỸỹ' ) ); + $this->assertSame( 'AaAaEeEeOoOoUuYy', remove_accents( 'ẪẫẴẵẼẽỄễỖỗỠỡỮữỸỹ' ) ); // Acute accent. - $this->assertEquals( 'AaAaEeOoOoUu', remove_accents( 'ẤấẮắẾếỐốỚớỨứ' ) ); + $this->assertSame( 'AaAaEeOoOoUu', remove_accents( 'ẤấẮắẾếỐốỚớỨứ' ) ); // Dot below. - $this->assertEquals( 'AaAaAaEeEeIiOoOoOoUuUuYy', remove_accents( 'ẠạẬậẶặẸẹỆệỊịỌọỘộỢợỤụỰựỴỵ' ) ); + $this->assertSame( 'AaAaAaEeEeIiOoOoOoUuUuYy', remove_accents( 'ẠạẬậẶặẸẹỆệỊịỌọỘộỢợỤụỰựỴỵ' ) ); } /** @@ -69,15 +69,15 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { public function test_remove_accents_hanyu_pinyin() { // Vowels with diacritic (Chinese, Hanyu Pinyin). // Macron. - $this->assertEquals( 'aeiouuAEIOUU', remove_accents( 'āēīōūǖĀĒĪŌŪǕ' ) ); + $this->assertSame( 'aeiouuAEIOUU', remove_accents( 'āēīōūǖĀĒĪŌŪǕ' ) ); // Acute accent. - $this->assertEquals( 'aeiouuAEIOUU', remove_accents( 'áéíóúǘÁÉÍÓÚǗ' ) ); + $this->assertSame( 'aeiouuAEIOUU', remove_accents( 'áéíóúǘÁÉÍÓÚǗ' ) ); // Caron. - $this->assertEquals( 'aeiouuAEIOUU', remove_accents( 'ǎěǐǒǔǚǍĚǏǑǓǙ' ) ); + $this->assertSame( 'aeiouuAEIOUU', remove_accents( 'ǎěǐǒǔǚǍĚǏǑǓǙ' ) ); // Grave accent. - $this->assertEquals( 'aeiouuAEIOUU', remove_accents( 'àèìòùǜÀÈÌÒÙǛ' ) ); + $this->assertSame( 'aeiouuAEIOUU', remove_accents( 'àèìòùǜÀÈÌÒÙǛ' ) ); // Unmarked. - $this->assertEquals( 'aaeiouuAEIOUU', remove_accents( 'aɑeiouüAEIOUÜ' ) ); + $this->assertSame( 'aaeiouuAEIOUU', remove_accents( 'aɑeiouüAEIOUÜ' ) ); } function _remove_accents_germanic_umlauts_cb() { @@ -90,7 +90,7 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { public function test_remove_accents_germanic_umlauts() { add_filter( 'locale', array( $this, '_remove_accents_germanic_umlauts_cb' ) ); - $this->assertEquals( 'AeOeUeaeoeuess', remove_accents( 'ÄÖÜäöüß' ) ); + $this->assertSame( 'AeOeUeaeoeuess', remove_accents( 'ÄÖÜäöüß' ) ); remove_filter( 'locale', array( $this, '_remove_accents_germanic_umlauts_cb' ) ); } @@ -105,7 +105,7 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { public function test_remove_danish_accents() { add_filter( 'locale', array( $this, '_set_locale_to_danish' ) ); - $this->assertEquals( 'AeOeAaaeoeaa', remove_accents( 'ÆØÅæøå' ) ); + $this->assertSame( 'AeOeAaaeoeaa', remove_accents( 'ÆØÅæøå' ) ); remove_filter( 'locale', array( $this, '_set_locale_to_danish' ) ); } @@ -120,11 +120,11 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { public function test_remove_catalan_middot() { add_filter( 'locale', array( $this, '_set_locale_to_catalan' ) ); - $this->assertEquals( 'allallalla', remove_accents( 'al·lallaŀla' ) ); + $this->assertSame( 'allallalla', remove_accents( 'al·lallaŀla' ) ); remove_filter( 'locale', array( $this, '_set_locale_to_catalan' ) ); - $this->assertEquals( 'al·lallalla', remove_accents( 'al·lallaŀla' ) ); + $this->assertSame( 'al·lallalla', remove_accents( 'al·lallaŀla' ) ); } public function _set_locale_to_serbian() { @@ -137,10 +137,10 @@ class Tests_Formatting_RemoveAccents extends WP_UnitTestCase { public function test_transcribe_serbian_crossed_d() { add_filter( 'locale', array( $this, '_set_locale_to_serbian' ) ); - $this->assertEquals( 'DJdj', remove_accents( 'Đđ' ) ); + $this->assertSame( 'DJdj', remove_accents( 'Đđ' ) ); remove_filter( 'locale', array( $this, '_set_locale_to_serbian' ) ); - $this->assertEquals( 'Dd', remove_accents( 'Đđ' ) ); + $this->assertSame( 'Dd', remove_accents( 'Đđ' ) ); } } diff --git a/tests/phpunit/tests/formatting/SanitizeFileName.php b/tests/phpunit/tests/formatting/SanitizeFileName.php index 3e01469329..39057aad06 100644 --- a/tests/phpunit/tests/formatting/SanitizeFileName.php +++ b/tests/phpunit/tests/formatting/SanitizeFileName.php @@ -7,7 +7,7 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { function test_munges_extensions() { # r17990 $file_name = sanitize_file_name( 'test.phtml.txt' ); - $this->assertEquals( 'test.phtml_.txt', $file_name ); + $this->assertSame( 'test.phtml_.txt', $file_name ); } function test_removes_special_chars() { @@ -17,7 +17,7 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { $string .= $char; } $string .= 'test'; - $this->assertEquals( 'testtest', sanitize_file_name( $string ) ); + $this->assertSame( 'testtest', sanitize_file_name( $string ) ); } /** @@ -26,7 +26,7 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { function test_removes_accents() { $in = 'àáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ'; $out = 'aaaaaaaeceeeeiiiinoooooouuuuyy'; - $this->assertEquals( $out, sanitize_file_name( $in ) ); + $this->assertSame( $out, sanitize_file_name( $in ) ); } /** @@ -43,46 +43,46 @@ class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase { ); foreach ( $urls as $test => $expected ) { - $this->assertEquals( $expected, sanitize_file_name( $test ) ); + $this->assertSame( $expected, sanitize_file_name( $test ) ); } } function test_replaces_any_number_of_hyphens_with_one_hyphen() { - $this->assertEquals( 'a-t-t', sanitize_file_name( 'a----t----t' ) ); + $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t' ) ); } function test_trims_trailing_hyphens() { - $this->assertEquals( 'a-t-t', sanitize_file_name( 'a----t----t----' ) ); + $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t----' ) ); } function test_replaces_any_amount_of_whitespace_with_one_hyphen() { - $this->assertEquals( 'a-t', sanitize_file_name( 'a t' ) ); - $this->assertEquals( 'a-t', sanitize_file_name( "a \n\n\nt" ) ); + $this->assertSame( 'a-t', sanitize_file_name( 'a t' ) ); + $this->assertSame( 'a-t', sanitize_file_name( "a \n\n\nt" ) ); } /** * @ticket 16226 */ function test_replaces_percent_sign() { - $this->assertEquals( 'a22b.jpg', sanitize_file_name( 'a%22b.jpg' ) ); + $this->assertSame( 'a22b.jpg', sanitize_file_name( 'a%22b.jpg' ) ); } function test_replaces_unnamed_file_extensions() { // Test filenames with both supported and unsupported extensions. - $this->assertEquals( 'unnamed-file.exe', sanitize_file_name( '_.exe' ) ); - $this->assertEquals( 'unnamed-file.jpg', sanitize_file_name( '_.jpg' ) ); + $this->assertSame( 'unnamed-file.exe', sanitize_file_name( '_.exe' ) ); + $this->assertSame( 'unnamed-file.jpg', sanitize_file_name( '_.jpg' ) ); } function test_replaces_unnamed_file_extensionless() { // Test a filenames that becomes extensionless. - $this->assertEquals( 'no-extension', sanitize_file_name( '_.no-extension' ) ); + $this->assertSame( 'no-extension', sanitize_file_name( '_.no-extension' ) ); } /** * @dataProvider data_wp_filenames */ function test_replaces_invalid_utf8_characters( $input, $expected ) { - $this->assertEquals( $expected, sanitize_file_name( $input ) ); + $this->assertSame( $expected, sanitize_file_name( $input ) ); } function data_wp_filenames() { diff --git a/tests/phpunit/tests/formatting/SanitizeMimeType.php b/tests/phpunit/tests/formatting/SanitizeMimeType.php index e8475ff6cf..45c8ec611f 100644 --- a/tests/phpunit/tests/formatting/SanitizeMimeType.php +++ b/tests/phpunit/tests/formatting/SanitizeMimeType.php @@ -35,7 +35,7 @@ class Tests_Formatting_SanitizeMimeType extends WP_UnitTestCase { ); foreach ( $inputs as $input ) { - $this->assertEquals( $input, sanitize_mime_type( $input ) ); + $this->assertSame( $input, sanitize_mime_type( $input ) ); } } } diff --git a/tests/phpunit/tests/formatting/SanitizeOrderby.php b/tests/phpunit/tests/formatting/SanitizeOrderby.php index 371d63b52e..95d2bed15e 100644 --- a/tests/phpunit/tests/formatting/SanitizeOrderby.php +++ b/tests/phpunit/tests/formatting/SanitizeOrderby.php @@ -10,7 +10,7 @@ class Tests_Formatting_SanitizeOrderby extends WP_UnitTestCase { * @dataProvider valid_orderbys */ function test_valid( $orderby ) { - $this->assertEquals( $orderby, sanitize_sql_orderby( $orderby ) ); + $this->assertSame( $orderby, sanitize_sql_orderby( $orderby ) ); } function valid_orderbys() { return array( diff --git a/tests/phpunit/tests/formatting/SanitizeTextField.php b/tests/phpunit/tests/formatting/SanitizeTextField.php index 441f52491b..00c19faa17 100644 --- a/tests/phpunit/tests/formatting/SanitizeTextField.php +++ b/tests/phpunit/tests/formatting/SanitizeTextField.php @@ -136,8 +136,8 @@ class Tests_Formatting_SanitizeTextField extends WP_UnitTestCase { $expected_oneline = $expected; $expected_multiline = $expected; } - $this->assertEquals( $expected_oneline, sanitize_text_field( $string ) ); - $this->assertEqualsIgnoreEOL( $expected_multiline, sanitize_textarea_field( $string ) ); + $this->assertSame( $expected_oneline, sanitize_text_field( $string ) ); + $this->assertSameIgnoreEOL( $expected_multiline, sanitize_textarea_field( $string ) ); } } diff --git a/tests/phpunit/tests/formatting/SanitizeTitle.php b/tests/phpunit/tests/formatting/SanitizeTitle.php index e536e14b40..a389d580ba 100644 --- a/tests/phpunit/tests/formatting/SanitizeTitle.php +++ b/tests/phpunit/tests/formatting/SanitizeTitle.php @@ -7,12 +7,12 @@ class Tests_Formatting_SanitizeTitle extends WP_UnitTestCase { function test_strips_html() { $input = 'Captain <strong>Awesome</strong>'; $expected = 'captain-awesome'; - $this->assertEquals( $expected, sanitize_title( $input ) ); + $this->assertSame( $expected, sanitize_title( $input ) ); } function test_titles_sanitized_to_nothing_are_replaced_with_optional_fallback() { $input = '<strong></strong>'; $fallback = 'Captain Awesome'; - $this->assertEquals( $fallback, sanitize_title( $input, $fallback ) ); + $this->assertSame( $fallback, sanitize_title( $input, $fallback ) ); } } diff --git a/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php b/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php index 4fcce5bb39..e105afca15 100644 --- a/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php +++ b/tests/phpunit/tests/formatting/SanitizeTitleWithDashes.php @@ -7,144 +7,144 @@ class Tests_Formatting_SanitizeTitleWithDashes extends WP_UnitTestCase { function test_strips_html() { $input = 'Captain <strong>Awesome</strong>'; $expected = 'captain-awesome'; - $this->assertEquals( $expected, sanitize_title( $input ) ); + $this->assertSame( $expected, sanitize_title( $input ) ); } function test_strips_unencoded_percent_signs() { - $this->assertEquals( 'fran%c3%a7ois', sanitize_title_with_dashes( 'fran%c3%a7%ois' ) ); + $this->assertSame( 'fran%c3%a7ois', sanitize_title_with_dashes( 'fran%c3%a7%ois' ) ); } function test_makes_title_lowercase() { - $this->assertEquals( 'abc', sanitize_title_with_dashes( 'ABC' ) ); + $this->assertSame( 'abc', sanitize_title_with_dashes( 'ABC' ) ); } function test_replaces_any_amount_of_whitespace_with_one_hyphen() { - $this->assertEquals( 'a-t', sanitize_title_with_dashes( 'a t' ) ); - $this->assertEquals( 'a-t', sanitize_title_with_dashes( "a \n\n\nt" ) ); + $this->assertSame( 'a-t', sanitize_title_with_dashes( 'a t' ) ); + $this->assertSame( 'a-t', sanitize_title_with_dashes( "a \n\n\nt" ) ); } function test_replaces_any_number_of_hyphens_with_one_hyphen() { - $this->assertEquals( 'a-t-t', sanitize_title_with_dashes( 'a----t----t' ) ); + $this->assertSame( 'a-t-t', sanitize_title_with_dashes( 'a----t----t' ) ); } function test_trims_trailing_hyphens() { - $this->assertEquals( 'a-t-t', sanitize_title_with_dashes( 'a----t----t----' ) ); + $this->assertSame( 'a-t-t', sanitize_title_with_dashes( 'a----t----t----' ) ); } function test_handles_non_entity_ampersands() { - $this->assertEquals( 'penn-teller-bull', sanitize_title_with_dashes( 'penn & teller bull' ) ); + $this->assertSame( 'penn-teller-bull', sanitize_title_with_dashes( 'penn & teller bull' ) ); } public function test_strips_nbsp_ndash_and_amp() { - $this->assertEquals( 'no-entities-here', sanitize_title_with_dashes( 'No   Entities – Here &' ) ); + $this->assertSame( 'no-entities-here', sanitize_title_with_dashes( 'No   Entities – Here &' ) ); } public function test_strips_encoded_ampersand() { - $this->assertEquals( 'one-two', sanitize_title_with_dashes( 'One & Two', '', 'save' ) ); + $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One & Two', '', 'save' ) ); } public function test_strips_url_encoded_ampersand() { - $this->assertEquals( 'one-two', sanitize_title_with_dashes( 'One { Two;', '', 'save' ) ); + $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One { Two;', '', 'save' ) ); } public function test_strips_trademark_symbol() { - $this->assertEquals( 'one-two', sanitize_title_with_dashes( 'One Two™;', '', 'save' ) ); + $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One Two™;', '', 'save' ) ); } public function test_strips_unencoded_ampersand_followed_by_encoded_ampersand() { - $this->assertEquals( 'one-two', sanitize_title_with_dashes( 'One && Two;', '', 'save' ) ); + $this->assertSame( 'one-two', sanitize_title_with_dashes( 'One && Two;', '', 'save' ) ); } public function test_strips_unencoded_ampersand_when_not_surrounded_by_spaces() { - $this->assertEquals( 'onetwo', sanitize_title_with_dashes( 'One&Two', '', 'save' ) ); + $this->assertSame( 'onetwo', sanitize_title_with_dashes( 'One&Two', '', 'save' ) ); } function test_replaces_nbsp() { - $this->assertEquals( 'dont-break-the-space', sanitize_title_with_dashes( "don't break the space", '', 'save' ) ); + $this->assertSame( 'dont-break-the-space', sanitize_title_with_dashes( "don't break the space", '', 'save' ) ); } /** * @ticket 31790 */ function test_replaces_nbsp_entities() { - $this->assertEquals( 'dont-break-the-space', sanitize_title_with_dashes( "don't break the space", '', 'save' ) ); + $this->assertSame( 'dont-break-the-space', sanitize_title_with_dashes( "don't break the space", '', 'save' ) ); } function test_replaces_ndash_mdash() { - $this->assertEquals( 'do-the-dash', sanitize_title_with_dashes( 'Do – the Dash', '', 'save' ) ); - $this->assertEquals( 'do-the-dash', sanitize_title_with_dashes( 'Do the — Dash', '', 'save' ) ); + $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do – the Dash', '', 'save' ) ); + $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do the — Dash', '', 'save' ) ); } /** * @ticket 31790 */ function test_replaces_ndash_mdash_entities() { - $this->assertEquals( 'do-the-dash', sanitize_title_with_dashes( 'Do – the – Dash', '', 'save' ) ); - $this->assertEquals( 'do-the-dash', sanitize_title_with_dashes( 'Do — the — Dash', '', 'save' ) ); + $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do – the – Dash', '', 'save' ) ); + $this->assertSame( 'do-the-dash', sanitize_title_with_dashes( 'Do — the — Dash', '', 'save' ) ); } function test_replaces_iexcel_iquest() { - $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( 'Just ¡a Slug', '', 'save' ) ); - $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( 'Just a Slug¿', '', 'save' ) ); + $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just ¡a Slug', '', 'save' ) ); + $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just a Slug¿', '', 'save' ) ); } function test_replaces_angle_quotes() { - $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( '‹Just a Slug›', '', 'save' ) ); - $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( '«Just a Slug»', '', 'save' ) ); + $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '‹Just a Slug›', '', 'save' ) ); + $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '«Just a Slug»', '', 'save' ) ); } function test_replaces_curly_quotes() { - $this->assertEquals( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its “Curly Joe”', '', 'save' ) ); - $this->assertEquals( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its ‘Curly Joe’', '', 'save' ) ); - $this->assertEquals( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its „Curly Joe“', '', 'save' ) ); - $this->assertEquals( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its ‚Curly Joe‛', '', 'save' ) ); - $this->assertEquals( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its „Curly Joe‟', '', 'save' ) ); + $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its “Curly Joe”', '', 'save' ) ); + $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its ‘Curly Joe’', '', 'save' ) ); + $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its „Curly Joe“', '', 'save' ) ); + $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its ‚Curly Joe‛', '', 'save' ) ); + $this->assertSame( 'hey-its-curly-joe', sanitize_title_with_dashes( 'Hey its „Curly Joe‟', '', 'save' ) ); } /** * @ticket 49791 */ function test_replaces_bullet() { - $this->assertEquals( 'fancy-title-amazing', sanitize_title_with_dashes( 'Fancy Title • Amazing', '', 'save' ) ); + $this->assertSame( 'fancy-title-amazing', sanitize_title_with_dashes( 'Fancy Title • Amazing', '', 'save' ) ); } function test_replaces_copy_reg_deg_trade() { - $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( 'Just © a Slug', '', 'save' ) ); - $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( '® Just a Slug', '', 'save' ) ); - $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( 'Just a ° Slug', '', 'save' ) ); - $this->assertEquals( 'just-a-slug', sanitize_title_with_dashes( 'Just ™ a Slug', '', 'save' ) ); + $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just © a Slug', '', 'save' ) ); + $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( '® Just a Slug', '', 'save' ) ); + $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just a ° Slug', '', 'save' ) ); + $this->assertSame( 'just-a-slug', sanitize_title_with_dashes( 'Just ™ a Slug', '', 'save' ) ); } /** * @ticket 10792 */ function test_replaces_forward_slash() { - $this->assertEquals( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon/McCartney', '', 'save' ) ); - $this->assertEquals( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon//McCartney', '', 'save' ) ); - $this->assertEquals( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon///McCartney', '', 'save' ) ); - $this->assertEquals( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon/-McCartney', '', 'save' ) ); - $this->assertEquals( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( '//songs by Lennon/McCartney', '', 'save' ) ); + $this->assertSame( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon/McCartney', '', 'save' ) ); + $this->assertSame( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon//McCartney', '', 'save' ) ); + $this->assertSame( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon///McCartney', '', 'save' ) ); + $this->assertSame( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( 'songs by Lennon/-McCartney', '', 'save' ) ); + $this->assertSame( 'songs-by-lennon-mccartney', sanitize_title_with_dashes( '//songs by Lennon/McCartney', '', 'save' ) ); } /** * @ticket 19820 */ function test_replaces_multiply_sign() { - $this->assertEquals( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ) ); + $this->assertSame( '6x7-is-42', sanitize_title_with_dashes( '6×7 is 42', '', 'save' ) ); } /** * @ticket 20772 */ function test_replaces_standalone_diacritic() { - $this->assertEquals( 'aaaa', sanitize_title_with_dashes( 'āáǎà', '', 'save' ) ); + $this->assertSame( 'aaaa', sanitize_title_with_dashes( 'āáǎà', '', 'save' ) ); } /** * @ticket 22395 */ function test_replaces_acute_accents() { - $this->assertEquals( 'aaaa', sanitize_title_with_dashes( 'ááa´aˊ', '', 'save' ) ); + $this->assertSame( 'aaaa', sanitize_title_with_dashes( 'ááa´aˊ', '', 'save' ) ); } } diff --git a/tests/phpunit/tests/formatting/SanitizeTrackbackUrls.php b/tests/phpunit/tests/formatting/SanitizeTrackbackUrls.php index b70f71bb43..d790cdcc16 100644 --- a/tests/phpunit/tests/formatting/SanitizeTrackbackUrls.php +++ b/tests/phpunit/tests/formatting/SanitizeTrackbackUrls.php @@ -9,7 +9,7 @@ class Tests_Formatting_SanitizeTrackbackUrls extends WP_UnitTestCase { * @dataProvider breaks */ function test_sanitize_trackback_urls_with_multiple_urls( $break ) { - $this->assertEquals( "http://example.com\nhttp://example.org", sanitize_trackback_urls( "http://example.com{$break}http://example.org" ) ); + $this->assertSame( "http://example.com\nhttp://example.org", sanitize_trackback_urls( "http://example.com{$break}http://example.org" ) ); } function breaks() { diff --git a/tests/phpunit/tests/formatting/SanitizeUser.php b/tests/phpunit/tests/formatting/SanitizeUser.php index b4e051c678..43533c6642 100644 --- a/tests/phpunit/tests/formatting/SanitizeUser.php +++ b/tests/phpunit/tests/formatting/SanitizeUser.php @@ -7,7 +7,7 @@ class Tests_Formatting_SanitizeUser extends WP_UnitTestCase { function test_strips_html() { $input = 'Captain <strong>Awesome</strong>'; $expected = is_multisite() ? 'captain awesome' : 'Captain Awesome'; - $this->assertEquals( $expected, sanitize_user( $input ) ); + $this->assertSame( $expected, sanitize_user( $input ) ); } public function test_strips_encoded_ampersand() { @@ -18,7 +18,7 @@ class Tests_Formatting_SanitizeUser extends WP_UnitTestCase { $expected = strtolower( $expected ); } - $this->assertEquals( $expected, sanitize_user( 'AT&T' ) ); + $this->assertSame( $expected, sanitize_user( 'AT&T' ) ); } public function test_strips_encoded_ampersand_when_followed_by_semicolon() { @@ -29,14 +29,14 @@ class Tests_Formatting_SanitizeUser extends WP_UnitTestCase { $expected = strtolower( $expected ); } - $this->assertEquals( $expected, sanitize_user( 'AT&T Test;' ) ); + $this->assertSame( $expected, sanitize_user( 'AT&T Test;' ) ); } function test_strips_percent_encoded_octets() { $expected = is_multisite() ? 'franois' : 'Franois'; - $this->assertEquals( $expected, sanitize_user( 'Fran%c3%a7ois' ) ); + $this->assertSame( $expected, sanitize_user( 'Fran%c3%a7ois' ) ); } function test_optional_strict_mode_reduces_to_safe_ascii_subset() { - $this->assertEquals( 'abc', sanitize_user( '()~ab~ˆcˆ!', true ) ); + $this->assertSame( 'abc', sanitize_user( '()~ab~ˆcˆ!', true ) ); } } diff --git a/tests/phpunit/tests/formatting/Slashit.php b/tests/phpunit/tests/formatting/Slashit.php index 876d7fda22..9f25694405 100644 --- a/tests/phpunit/tests/formatting/Slashit.php +++ b/tests/phpunit/tests/formatting/Slashit.php @@ -5,50 +5,50 @@ */ class Tests_Formatting_Slashit extends WP_UnitTestCase { function test_backslashes_middle_numbers() { - $this->assertEquals( "\\a-!9\\a943\\b\\c", backslashit( 'a-!9a943bc' ) ); + $this->assertSame( "\\a-!9\\a943\\b\\c", backslashit( 'a-!9a943bc' ) ); } function test_backslashes_alphas() { - $this->assertEquals( "\\a943\\b\\c", backslashit( 'a943bc' ) ); + $this->assertSame( "\\a943\\b\\c", backslashit( 'a943bc' ) ); } function test_double_backslashes_leading_numbers() { - $this->assertEquals( '\\\\95', backslashit( '95' ) ); + $this->assertSame( '\\\\95', backslashit( '95' ) ); } function test_removes_trailing_slashes() { - $this->assertEquals( 'a', untrailingslashit( 'a/' ) ); - $this->assertEquals( 'a', untrailingslashit( 'a////' ) ); + $this->assertSame( 'a', untrailingslashit( 'a/' ) ); + $this->assertSame( 'a', untrailingslashit( 'a////' ) ); } /** * @ticket 22267 */ function test_removes_trailing_backslashes() { - $this->assertEquals( 'a', untrailingslashit( 'a\\' ) ); - $this->assertEquals( 'a', untrailingslashit( 'a\\\\\\\\' ) ); + $this->assertSame( 'a', untrailingslashit( 'a\\' ) ); + $this->assertSame( 'a', untrailingslashit( 'a\\\\\\\\' ) ); } /** * @ticket 22267 */ function test_removes_trailing_mixed_slashes() { - $this->assertEquals( 'a', untrailingslashit( 'a/\\' ) ); - $this->assertEquals( 'a', untrailingslashit( 'a\\/\\///\\\\//' ) ); + $this->assertSame( 'a', untrailingslashit( 'a/\\' ) ); + $this->assertSame( 'a', untrailingslashit( 'a\\/\\///\\\\//' ) ); } function test_adds_trailing_slash() { - $this->assertEquals( 'a/', trailingslashit( 'a' ) ); + $this->assertSame( 'a/', trailingslashit( 'a' ) ); } function test_does_not_add_trailing_slash_if_one_exists() { - $this->assertEquals( 'a/', trailingslashit( 'a/' ) ); + $this->assertSame( 'a/', trailingslashit( 'a/' ) ); } /** * @ticket 22267 */ function test_converts_trailing_backslash_to_slash_if_one_exists() { - $this->assertEquals( 'a/', trailingslashit( 'a\\' ) ); + $this->assertSame( 'a/', trailingslashit( 'a\\' ) ); } } diff --git a/tests/phpunit/tests/formatting/Smilies.php b/tests/phpunit/tests/formatting/Smilies.php index 29d6b7dfa9..f5394d4268 100644 --- a/tests/phpunit/tests/formatting/Smilies.php +++ b/tests/phpunit/tests/formatting/Smilies.php @@ -54,12 +54,12 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { smilies_init(); - $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) ); + $this->assertSame( $converted_txt, convert_smilies( $in_txt ) ); // Standard smilies, use_smilies: OFF. update_option( 'use_smilies', 0 ); - $this->assertEquals( $in_txt, convert_smilies( $in_txt ) ); + $this->assertSame( $in_txt, convert_smilies( $in_txt ) ); } /** @@ -112,12 +112,12 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { smilies_init(); - $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) ); + $this->assertSame( $converted_txt, convert_smilies( $in_txt ) ); // Standard smilies, use_smilies: OFF. update_option( 'use_smilies', 0 ); - $this->assertEquals( $in_txt, convert_smilies( $in_txt ) ); + $this->assertSame( $in_txt, convert_smilies( $in_txt ) ); $wpsmiliestrans = $trans_orig; // Reset original translations array. } @@ -153,7 +153,7 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { update_option( 'use_smilies', 1 ); smilies_init(); - $this->assertEquals( $exp_str, convert_smilies( $in_str ) ); + $this->assertSame( $exp_str, convert_smilies( $in_str ) ); // Standard smilies, use_smilies: OFF. update_option( 'use_smilies', 0 ); @@ -205,12 +205,12 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { update_option( 'use_smilies', 1 ); smilies_init(); - $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) ); + $this->assertSame( $converted_txt, convert_smilies( $in_txt ) ); // Custom smilies, use_smilies: OFF. update_option( 'use_smilies', 0 ); - $this->assertEquals( $in_txt, convert_smilies( $in_txt ) ); + $this->assertSame( $in_txt, convert_smilies( $in_txt ) ); } /** @@ -260,12 +260,12 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { smilies_init(); - $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) ); + $this->assertSame( $converted_txt, convert_smilies( $in_txt ) ); // Standard smilies, use_smilies: OFF. update_option( 'use_smilies', 0 ); - $this->assertEquals( $in_txt, convert_smilies( $in_txt ) ); + $this->assertSame( $in_txt, convert_smilies( $in_txt ) ); $wpsmiliestrans = $orig_trans; // Reset original translations array. } @@ -305,7 +305,7 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { smilies_init(); - $this->assertEquals( $converted_txt, convert_smilies( $in_txt ) ); + $this->assertSame( $converted_txt, convert_smilies( $in_txt ) ); // Standard smilies, use_smilies: OFF. update_option( 'use_smilies', 0 ); @@ -323,7 +323,7 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { $txt = ':oops: I did it again'; - $this->assertEquals( $txt, convert_smilies( $txt ) ); + $this->assertSame( $txt, convert_smilies( $txt ) ); } /** @@ -339,7 +339,7 @@ class Tests_Formatting_Smilies extends WP_UnitTestCase { $txt = 'You played with my <3'; $expected_txt = 'You played with my \xe2\x9d\xa4'; - $this->assertEquals( $expected_txt, convert_smilies( $txt ) ); + $this->assertSame( $expected_txt, convert_smilies( $txt ) ); } diff --git a/tests/phpunit/tests/formatting/StripSlashesDeep.php b/tests/phpunit/tests/formatting/StripSlashesDeep.php index b27f6422e7..a401a99f79 100644 --- a/tests/phpunit/tests/formatting/StripSlashesDeep.php +++ b/tests/phpunit/tests/formatting/StripSlashesDeep.php @@ -10,10 +10,10 @@ class Tests_Formatting_StripSlashesDeep extends WP_UnitTestCase { */ function test_preserves_original_datatype() { - $this->assertEquals( true, stripslashes_deep( true ) ); - $this->assertEquals( false, stripslashes_deep( false ) ); - $this->assertEquals( 4, stripslashes_deep( 4 ) ); - $this->assertEquals( 'foo', stripslashes_deep( 'foo' ) ); + $this->assertTrue( stripslashes_deep( true ) ); + $this->assertFalse( stripslashes_deep( false ) ); + $this->assertSame( 4, stripslashes_deep( 4 ) ); + $this->assertSame( 'foo', stripslashes_deep( 'foo' ) ); $arr = array( 'a' => true, 'b' => false, @@ -21,23 +21,23 @@ class Tests_Formatting_StripSlashesDeep extends WP_UnitTestCase { 'd' => 'foo', ); $arr['e'] = $arr; // Add a sub-array. - $this->assertEquals( $arr, stripslashes_deep( $arr ) ); // Keyed array. - $this->assertEquals( array_values( $arr ), stripslashes_deep( array_values( $arr ) ) ); // Non-keyed. + $this->assertSame( $arr, stripslashes_deep( $arr ) ); // Keyed array. + $this->assertSame( array_values( $arr ), stripslashes_deep( array_values( $arr ) ) ); // Non-keyed. $obj = new stdClass; foreach ( $arr as $k => $v ) { $obj->$k = $v; } - $this->assertEquals( $obj, stripslashes_deep( $obj ) ); + $this->assertSame( $obj, stripslashes_deep( $obj ) ); } function test_strips_slashes() { $old = "I can\'t see, isn\'t that it?"; $new = "I can't see, isn't that it?"; - $this->assertEquals( $new, stripslashes_deep( $old ) ); - $this->assertEquals( $new, stripslashes_deep( "I can\\'t see, isn\\'t that it?" ) ); - $this->assertEquals( array( 'a' => $new ), stripslashes_deep( array( 'a' => $old ) ) ); // Keyed array. - $this->assertEquals( array( $new ), stripslashes_deep( array( $old ) ) ); // Non-keyed. + $this->assertSame( $new, stripslashes_deep( $old ) ); + $this->assertSame( $new, stripslashes_deep( "I can\\'t see, isn\\'t that it?" ) ); + $this->assertSame( array( 'a' => $new ), stripslashes_deep( array( 'a' => $old ) ) ); // Keyed array. + $this->assertSame( array( $new ), stripslashes_deep( array( $old ) ) ); // Non-keyed. $obj_old = new stdClass; $obj_old->a = $old; @@ -48,7 +48,7 @@ class Tests_Formatting_StripSlashesDeep extends WP_UnitTestCase { function test_permits_escaped_slash() { $txt = "I can't see, isn\'t that it?"; - $this->assertEquals( $txt, stripslashes_deep( "I can\'t see, isn\\\'t that it?" ) ); - $this->assertEquals( $txt, stripslashes_deep( "I can\'t see, isn\\\\\'t that it?" ) ); + $this->assertSame( $txt, stripslashes_deep( "I can\'t see, isn\\\'t that it?" ) ); + $this->assertSame( $txt, stripslashes_deep( "I can\'t see, isn\\\\\'t that it?" ) ); } } diff --git a/tests/phpunit/tests/formatting/URLShorten.php b/tests/phpunit/tests/formatting/URLShorten.php index dde9ce9655..a1f1942809 100644 --- a/tests/phpunit/tests/formatting/URLShorten.php +++ b/tests/phpunit/tests/formatting/URLShorten.php @@ -14,10 +14,10 @@ class Tests_Formatting_URLShorten extends WP_UnitTestCase { 'http://wordpress.org/about/philosophy/#decisions' => 'wordpress.org/about/philosophy/#…', // Shorten to 32 if > 35 after cleaning. ); foreach ( $tests as $k => $v ) { - $this->assertEquals( $v, url_shorten( $k ) ); + $this->assertSame( $v, url_shorten( $k ) ); } // Shorten to 31 if > 34 after cleaning. - $this->assertEquals( 'wordpress.org/about/philosophy/#…', url_shorten( 'http://wordpress.org/about/philosophy/#decisions' ), 31 ); + $this->assertSame( 'wordpress.org/about/philosophy/#…', url_shorten( 'http://wordpress.org/about/philosophy/#decisions' ), 31 ); } } diff --git a/tests/phpunit/tests/formatting/UrlencodeDeep.php b/tests/phpunit/tests/formatting/UrlencodeDeep.php index 1c36403a19..27c0c750bb 100644 --- a/tests/phpunit/tests/formatting/UrlencodeDeep.php +++ b/tests/phpunit/tests/formatting/UrlencodeDeep.php @@ -28,7 +28,7 @@ class Tests_Formatting_UrlencodeDeep extends WP_UnitTestCase { * @param string $expected */ public function test_urlencode_deep_should_encode_individual_value( $actual, $expected ) { - $this->assertEquals( $expected, urlencode_deep( $actual ) ); + $this->assertSame( $expected, urlencode_deep( $actual ) ); } /** @@ -40,7 +40,7 @@ class Tests_Formatting_UrlencodeDeep extends WP_UnitTestCase { $actual = wp_list_pluck( $data, 0 ); $expected = wp_list_pluck( $data, 1 ); - $this->assertEquals( $expected, urlencode_deep( $actual ) ); + $this->assertSame( $expected, urlencode_deep( $actual ) ); } } diff --git a/tests/phpunit/tests/formatting/Utf8UriEncode.php b/tests/phpunit/tests/formatting/Utf8UriEncode.php index 43c925c5fa..a3538e0397 100644 --- a/tests/phpunit/tests/formatting/Utf8UriEncode.php +++ b/tests/phpunit/tests/formatting/Utf8UriEncode.php @@ -12,7 +12,7 @@ class Tests_Formatting_Utf8UriEncode extends WP_UnitTestCase { * @dataProvider data */ function test_percent_encodes_non_reserved_characters( $utf8, $urlencoded ) { - $this->assertEquals( $urlencoded, utf8_uri_encode( $utf8 ) ); + $this->assertSame( $urlencoded, utf8_uri_encode( $utf8 ) ); } /** diff --git a/tests/phpunit/tests/formatting/WPBasename.php b/tests/phpunit/tests/formatting/WPBasename.php index 780d2c7473..a664e399c0 100644 --- a/tests/phpunit/tests/formatting/WPBasename.php +++ b/tests/phpunit/tests/formatting/WPBasename.php @@ -6,14 +6,14 @@ class Tests_Formatting_WP_Basename extends WP_UnitTestCase { function test_wp_basename_unix() { - $this->assertEquals( + $this->assertSame( 'file', wp_basename( '/home/test/file' ) ); } function test_wp_basename_unix_utf8_support() { - $this->assertEquals( + $this->assertSame( 'žluťoučký kůň.txt', wp_basename( '/test/žluťoučký kůň.txt' ) ); @@ -23,7 +23,7 @@ class Tests_Formatting_WP_Basename extends WP_UnitTestCase { * @ticket 22138 */ function test_wp_basename_windows() { - $this->assertEquals( + $this->assertSame( 'file.txt', wp_basename( 'C:\Documents and Settings\User\file.txt' ) ); @@ -33,7 +33,7 @@ class Tests_Formatting_WP_Basename extends WP_UnitTestCase { * @ticket 22138 */ function test_wp_basename_windows_utf8_support() { - $this->assertEquals( + $this->assertSame( 'щипцы.txt', wp_basename( 'C:\test\щипцы.txt' ) ); diff --git a/tests/phpunit/tests/formatting/WPMakeLinkRelative.php b/tests/phpunit/tests/formatting/WPMakeLinkRelative.php index 8aee571b91..da6099302b 100644 --- a/tests/phpunit/tests/formatting/WPMakeLinkRelative.php +++ b/tests/phpunit/tests/formatting/WPMakeLinkRelative.php @@ -8,13 +8,13 @@ class Tests_Formatting_WPMakeLinkRelative extends WP_UnitTestCase { public function test_wp_make_link_relative_with_http_scheme() { $link = 'http://example.com/this-is-a-test-http-url/'; $relative_link = wp_make_link_relative( $link ); - $this->assertEquals( '/this-is-a-test-http-url/', $relative_link ); + $this->assertSame( '/this-is-a-test-http-url/', $relative_link ); } public function test_wp_make_link_relative_with_https_scheme() { $link = 'https://example.com/this-is-a-test-https-url/'; $relative_link = wp_make_link_relative( $link ); - $this->assertEquals( '/this-is-a-test-https-url/', $relative_link ); + $this->assertSame( '/this-is-a-test-https-url/', $relative_link ); } /** @@ -23,7 +23,7 @@ class Tests_Formatting_WPMakeLinkRelative extends WP_UnitTestCase { public function test_wp_make_link_relative_with_no_scheme() { $link = '//example.com/this-is-a-test-schemeless-url/'; $relative_link = wp_make_link_relative( $link ); - $this->assertEquals( '/this-is-a-test-schemeless-url/', $relative_link ); + $this->assertSame( '/this-is-a-test-schemeless-url/', $relative_link ); } /** @@ -32,7 +32,7 @@ class Tests_Formatting_WPMakeLinkRelative extends WP_UnitTestCase { public function test_wp_make_link_relative_should_retain_URL_param_that_is_also_a_URL() { $link = 'https://example.com/this-is-a-test/?redirect=https://example.org/a-different-test-post/'; $relative_link = wp_make_link_relative( $link ); - $this->assertEquals( '/this-is-a-test/?redirect=https://example.org/a-different-test-post/', $relative_link ); + $this->assertSame( '/this-is-a-test/?redirect=https://example.org/a-different-test-post/', $relative_link ); } /** @@ -41,7 +41,7 @@ class Tests_Formatting_WPMakeLinkRelative extends WP_UnitTestCase { function test_wp_make_link_relative_with_no_path() { $link = 'http://example.com'; $relative_link = wp_make_link_relative( $link ); - $this->assertEquals( '', $relative_link ); + $this->assertSame( '', $relative_link ); } } diff --git a/tests/phpunit/tests/formatting/WPRelNoFollow.php b/tests/phpunit/tests/formatting/WPRelNoFollow.php index 187bb5997b..10385cade7 100644 --- a/tests/phpunit/tests/formatting/WPRelNoFollow.php +++ b/tests/phpunit/tests/formatting/WPRelNoFollow.php @@ -11,7 +11,7 @@ class Tests_Rel_No_Follow extends WP_UnitTestCase { public function test_add_no_follow() { $content = '<p>This is some cool <a href="/">Code</a></p>'; $expected = '<p>This is some cool <a href=\"/\" rel=\"nofollow\">Code</a></p>'; - $this->assertEquals( $expected, wp_rel_nofollow( $content ) ); + $this->assertSame( $expected, wp_rel_nofollow( $content ) ); } /** @@ -20,7 +20,7 @@ class Tests_Rel_No_Follow extends WP_UnitTestCase { public function test_convert_no_follow() { $content = '<p>This is some cool <a href="/" rel="weird">Code</a></p>'; $expected = '<p>This is some cool <a href=\"/\" rel=\"weird nofollow\">Code</a></p>'; - $this->assertEquals( $expected, wp_rel_nofollow( $content ) ); + $this->assertSame( $expected, wp_rel_nofollow( $content ) ); } /** @@ -28,7 +28,7 @@ class Tests_Rel_No_Follow extends WP_UnitTestCase { * @dataProvider data_wp_rel_nofollow */ public function test_wp_rel_nofollow( $input, $output ) { - return $this->assertEquals( wp_slash( $output ), wp_rel_nofollow( $input ) ); + return $this->assertSame( wp_slash( $output ), wp_rel_nofollow( $input ) ); } public function data_wp_rel_nofollow() { @@ -78,6 +78,6 @@ class Tests_Rel_No_Follow extends WP_UnitTestCase { public function test_append_no_follow_with_valueless_attribute() { $content = '<p>This is some cool <a href="demo.com" download rel="hola">Code</a></p>'; $expected = '<p>This is some cool <a href=\"demo.com\" download rel=\"hola nofollow\">Code</a></p>'; - $this->assertEquals( $expected, wp_rel_nofollow( $content ) ); + $this->assertSame( $expected, wp_rel_nofollow( $content ) ); } } diff --git a/tests/phpunit/tests/formatting/WPRelUgc.php b/tests/phpunit/tests/formatting/WPRelUgc.php index 515eebb736..85470155a1 100644 --- a/tests/phpunit/tests/formatting/WPRelUgc.php +++ b/tests/phpunit/tests/formatting/WPRelUgc.php @@ -11,7 +11,7 @@ class Tests_Rel_Ugc extends WP_UnitTestCase { public function test_add_ugc() { $content = '<p>This is some cool <a href="/">Code</a></p>'; $expected = '<p>This is some cool <a href=\"/\" rel=\"nofollow ugc\">Code</a></p>'; - $this->assertEquals( $expected, wp_rel_ugc( $content ) ); + $this->assertSame( $expected, wp_rel_ugc( $content ) ); } /** @@ -20,7 +20,7 @@ class Tests_Rel_Ugc extends WP_UnitTestCase { public function test_convert_ugc() { $content = '<p>This is some cool <a href="/" rel="weird">Code</a></p>'; $expected = '<p>This is some cool <a href=\"/\" rel=\"weird nofollow ugc\">Code</a></p>'; - $this->assertEquals( $expected, wp_rel_ugc( $content ) ); + $this->assertSame( $expected, wp_rel_ugc( $content ) ); } /** @@ -28,7 +28,7 @@ class Tests_Rel_Ugc extends WP_UnitTestCase { * @dataProvider data_wp_rel_ugc */ public function test_wp_rel_ugc( $input, $output ) { - return $this->assertEquals( wp_slash( $output ), wp_rel_ugc( $input ) ); + return $this->assertSame( wp_slash( $output ), wp_rel_ugc( $input ) ); } public function data_wp_rel_ugc() { @@ -78,6 +78,6 @@ class Tests_Rel_Ugc extends WP_UnitTestCase { public function test_append_ugc_with_valueless_attribute() { $content = '<p>This is some cool <a href="demo.com" download rel="hola">Code</a></p>'; $expected = '<p>This is some cool <a href=\"demo.com\" download rel=\"hola nofollow ugc\">Code</a></p>'; - $this->assertEquals( $expected, wp_rel_ugc( $content ) ); + $this->assertSame( $expected, wp_rel_ugc( $content ) ); } } diff --git a/tests/phpunit/tests/formatting/WPSlash.php b/tests/phpunit/tests/formatting/WPSlash.php index 296dc9c28b..4b0d206c06 100644 --- a/tests/phpunit/tests/formatting/WPSlash.php +++ b/tests/phpunit/tests/formatting/WPSlash.php @@ -57,10 +57,10 @@ class Tests_Formatting_WPSlash extends WP_UnitTestCase { function test_adds_slashes() { $old = "I can't see, isn't that it?"; $new = "I can\'t see, isn\'t that it?"; - $this->assertEquals( $new, wp_slash( $old ) ); - $this->assertEquals( "I can\\\\\'t see, isn\\\\\'t that it?", wp_slash( $new ) ); - $this->assertEquals( array( 'a' => $new ), wp_slash( array( 'a' => $old ) ) ); // Keyed array. - $this->assertEquals( array( $new ), wp_slash( array( $old ) ) ); // Non-keyed. + $this->assertSame( $new, wp_slash( $old ) ); + $this->assertSame( "I can\\\\\'t see, isn\\\\\'t that it?", wp_slash( $new ) ); + $this->assertSame( array( 'a' => $new ), wp_slash( array( 'a' => $old ) ) ); // Keyed array. + $this->assertSame( array( $new ), wp_slash( array( $old ) ) ); // Non-keyed. } /** @@ -68,10 +68,10 @@ class Tests_Formatting_WPSlash extends WP_UnitTestCase { */ function test_preserves_original_datatype() { - $this->assertEquals( true, wp_slash( true ) ); - $this->assertEquals( false, wp_slash( false ) ); - $this->assertEquals( 4, wp_slash( 4 ) ); - $this->assertEquals( 'foo', wp_slash( 'foo' ) ); + $this->assertTrue( wp_slash( true ) ); + $this->assertFalse( wp_slash( false ) ); + $this->assertSame( 4, wp_slash( 4 ) ); + $this->assertSame( 'foo', wp_slash( 'foo' ) ); $arr = array( 'a' => true, 'b' => false, @@ -79,14 +79,14 @@ class Tests_Formatting_WPSlash extends WP_UnitTestCase { 'd' => 'foo', ); $arr['e'] = $arr; // Add a sub-array. - $this->assertEquals( $arr, wp_slash( $arr ) ); // Keyed array. - $this->assertEquals( array_values( $arr ), wp_slash( array_values( $arr ) ) ); // Non-keyed. + $this->assertSame( $arr, wp_slash( $arr ) ); // Keyed array. + $this->assertSame( array_values( $arr ), wp_slash( array_values( $arr ) ) ); // Non-keyed. $obj = new stdClass; foreach ( $arr as $k => $v ) { $obj->$k = $v; } - $this->assertEquals( $obj, wp_slash( $obj ) ); + $this->assertSame( $obj, wp_slash( $obj ) ); } /** @@ -95,9 +95,9 @@ class Tests_Formatting_WPSlash extends WP_UnitTestCase { function test_add_even_more_slashes() { $old = 'single\\slash double\\\\slash triple\\\\\\slash'; $new = 'single\\\\slash double\\\\\\\\slash triple\\\\\\\\\\\\slash'; - $this->assertEquals( $new, wp_slash( $old ) ); - $this->assertEquals( array( 'a' => $new ), wp_slash( array( 'a' => $old ) ) ); // Keyed array. - $this->assertEquals( array( $new ), wp_slash( array( $old ) ) ); // Non-keyed. + $this->assertSame( $new, wp_slash( $old ) ); + $this->assertSame( array( 'a' => $new ), wp_slash( array( 'a' => $old ) ) ); // Keyed array. + $this->assertSame( array( $new ), wp_slash( array( $old ) ) ); // Non-keyed. } } diff --git a/tests/phpunit/tests/formatting/WPSpecialchars.php b/tests/phpunit/tests/formatting/WPSpecialchars.php index 2f3e9cea26..7cc131da04 100644 --- a/tests/phpunit/tests/formatting/WPSpecialchars.php +++ b/tests/phpunit/tests/formatting/WPSpecialchars.php @@ -6,10 +6,10 @@ class Tests_Formatting_WPSpecialchars extends WP_UnitTestCase { function test_wp_specialchars_basics() { $html = '&<hello world>'; - $this->assertEquals( $html, _wp_specialchars( $html ) ); + $this->assertSame( $html, _wp_specialchars( $html ) ); $double = '&amp;&lt;hello world&gt;'; - $this->assertEquals( $double, _wp_specialchars( $html, ENT_NOQUOTES, false, true ) ); + $this->assertSame( $double, _wp_specialchars( $html, ENT_NOQUOTES, false, true ) ); } function test_allowed_entity_names() { @@ -22,7 +22,7 @@ class Tests_Formatting_WPSpecialchars extends WP_UnitTestCase { continue; } $ent = '&' . $ent . ';'; - $this->assertEquals( $ent, _wp_specialchars( $ent ) ); + $this->assertSame( $ent, _wp_specialchars( $ent ) ); } } @@ -32,16 +32,16 @@ class Tests_Formatting_WPSpecialchars extends WP_UnitTestCase { foreach ( $ents as $ent ) { $escaped = '&' . $ent . ';'; $ent = '&' . $ent . ';'; - $this->assertEquals( $escaped, _wp_specialchars( $ent ) ); + $this->assertSame( $escaped, _wp_specialchars( $ent ) ); } } function test_optionally_escapes_quotes() { $source = "\"'hello!'\""; - $this->assertEquals( '"'hello!'"', _wp_specialchars( $source, 'single' ) ); - $this->assertEquals( ""'hello!'"", _wp_specialchars( $source, 'double' ) ); - $this->assertEquals( '"'hello!'"', _wp_specialchars( $source, true ) ); - $this->assertEquals( $source, _wp_specialchars( $source ) ); + $this->assertSame( '"'hello!'"', _wp_specialchars( $source, 'single' ) ); + $this->assertSame( ""'hello!'"", _wp_specialchars( $source, 'double' ) ); + $this->assertSame( '"'hello!'"', _wp_specialchars( $source, true ) ); + $this->assertSame( $source, _wp_specialchars( $source ) ); } /** @@ -51,7 +51,7 @@ class Tests_Formatting_WPSpecialchars extends WP_UnitTestCase { * @dataProvider data_double_encoding */ function test_double_encoding( $input, $output ) { - return $this->assertEquals( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, true ) ); + return $this->assertSame( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, true ) ); } function data_double_encoding() { @@ -78,7 +78,7 @@ class Tests_Formatting_WPSpecialchars extends WP_UnitTestCase { * @dataProvider data_no_double_encoding */ function test_no_double_encoding( $input, $output ) { - return $this->assertEquals( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, false ) ); + return $this->assertSame( $output, _wp_specialchars( $input, ENT_NOQUOTES, false, false ) ); } function data_no_double_encoding() { diff --git a/tests/phpunit/tests/formatting/WPStripAllTags.php b/tests/phpunit/tests/formatting/WPStripAllTags.php index 3ef538a34f..8656af2695 100644 --- a/tests/phpunit/tests/formatting/WPStripAllTags.php +++ b/tests/phpunit/tests/formatting/WPStripAllTags.php @@ -9,25 +9,25 @@ class Tests_Formatting_WPStripAllTags extends WP_UnitTestCase { function test_wp_strip_all_tags() { $text = 'lorem<br />ipsum'; - $this->assertEquals( 'loremipsum', wp_strip_all_tags( $text ) ); + $this->assertSame( 'loremipsum', wp_strip_all_tags( $text ) ); $text = "lorem<br />\nipsum"; - $this->assertEquals( "lorem\nipsum", wp_strip_all_tags( $text ) ); + $this->assertSame( "lorem\nipsum", wp_strip_all_tags( $text ) ); // Test removing breaks is working. $text = 'lorem<br />ipsum'; - $this->assertEquals( 'loremipsum', wp_strip_all_tags( $text, true ) ); + $this->assertSame( 'loremipsum', wp_strip_all_tags( $text, true ) ); // Test script / style tag's contents is removed. $text = 'lorem<script>alert(document.cookie)</script>ipsum'; - $this->assertEquals( 'loremipsum', wp_strip_all_tags( $text ) ); + $this->assertSame( 'loremipsum', wp_strip_all_tags( $text ) ); $text = "lorem<style>* { display: 'none' }</style>ipsum"; - $this->assertEquals( 'loremipsum', wp_strip_all_tags( $text ) ); + $this->assertSame( 'loremipsum', wp_strip_all_tags( $text ) ); // Test "marlformed" markup of contents. $text = "lorem<style>* { display: 'none' }<script>alert( document.cookie )</script></style>ipsum"; - $this->assertEquals( 'loremipsum', wp_strip_all_tags( $text ) ); + $this->assertSame( 'loremipsum', wp_strip_all_tags( $text ) ); } } diff --git a/tests/phpunit/tests/formatting/WPTargetedLinkRel.php b/tests/phpunit/tests/formatting/WPTargetedLinkRel.php index 7f461ec87a..bc58dfe9cc 100644 --- a/tests/phpunit/tests/formatting/WPTargetedLinkRel.php +++ b/tests/phpunit/tests/formatting/WPTargetedLinkRel.php @@ -9,61 +9,61 @@ class Tests_Targeted_Link_Rel extends WP_UnitTestCase { public function test_add_to_links_with_target_blank() { $content = '<p>Links: <a href="/" target="_blank">No rel</a></p>'; $expected = '<p>Links: <a href="/" target="_blank" rel="noopener noreferrer">No rel</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } public function test_add_to_links_with_target_foo() { $content = '<p>Links: <a href="/" target="foo">No rel</a></p>'; $expected = '<p>Links: <a href="/" target="foo" rel="noopener noreferrer">No rel</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } public function test_target_as_first_attribute() { $content = '<p>Links: <a target="_blank" href="#">No rel</a></p>'; $expected = '<p>Links: <a target="_blank" href="#" rel="noopener noreferrer">No rel</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } public function test_add_to_existing_rel() { $content = '<p>Links: <a href="/" rel="existing values" target="_blank">Existing rel</a></p>'; $expected = '<p>Links: <a href="/" rel="existing values noopener noreferrer" target="_blank">Existing rel</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } public function test_no_duplicate_values_added() { $content = '<p>Links: <a href="/" rel="existing noopener values" target="_blank">Existing rel</a></p>'; $expected = '<p>Links: <a href="/" rel="existing noopener values noreferrer" target="_blank">Existing rel</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } public function test_rel_with_single_quote_delimiter() { $content = '<p>Links: <a href="/" rel=\'existing values\' target="_blank">Existing rel</a></p>'; $expected = '<p>Links: <a href="/" rel="existing values noopener noreferrer" target="_blank">Existing rel</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } public function test_rel_with_no_delimiter() { $content = '<p>Links: <a href="/" rel=existing target="_blank">Existing rel</a></p>'; $expected = '<p>Links: <a href="/" rel="existing noopener noreferrer" target="_blank">Existing rel</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } public function test_rel_value_spaced_and_no_delimiter() { $content = '<p>Links: <a href="/" rel = existing target="_blank">Existing rel</a></p>'; $expected = '<p>Links: <a href="/" rel="existing noopener noreferrer" target="_blank">Existing rel</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } public function test_escaped_quotes() { $content = '<p>Links: <a href=\"/\" rel=\"existing values\" target=\"_blank\">Existing rel</a></p>'; $expected = '<p>Links: <a href=\"/\" rel=\"existing values noopener noreferrer\" target=\"_blank\">Existing rel</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } public function test_ignore_links_with_no_target() { $content = '<p>Links: <a href="/" target="_blank">Change me</a> <a href="/">Do not change me</a></p>'; $expected = '<p>Links: <a href="/" target="_blank" rel="noopener noreferrer">Change me</a> <a href="/">Do not change me</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } /** @@ -75,7 +75,7 @@ class Tests_Targeted_Link_Rel extends WP_UnitTestCase { add_filter( 'wp_targeted_link_rel', '__return_empty_string' ); $content = '<p>Links: <a href="/" target="_blank">Do not change me</a></p>'; $expected = '<p>Links: <a href="/" target="_blank">Do not change me</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } /** @@ -93,7 +93,7 @@ class Tests_Targeted_Link_Rel extends WP_UnitTestCase { ) ); - $this->assertEquals( $expected, $post->post_content ); + $this->assertSame( $expected, $post->post_content ); } /** @@ -104,7 +104,7 @@ class Tests_Targeted_Link_Rel extends WP_UnitTestCase { public function test_wp_targeted_link_rel_should_preserve_json() { $content = '<p>Links: <a href=\"\/\" target=\"_blank\">No rel<\/a><\/p>'; $expected = '<p>Links: <a href=\"\/\" target=\"_blank\" rel=\"noopener noreferrer\">No rel<\/a><\/p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } /** @@ -115,7 +115,7 @@ class Tests_Targeted_Link_Rel extends WP_UnitTestCase { public function test_wp_targeted_link_rel_skips_style_and_scripts() { $content = '<style><a href="/" target=a></style><p>Links: <script>console.log("<a href=\'/\' target=a>hi</a>");</script><script>alert(1);</script>here <a href="/" target=_blank>aq</a></p><script>console.log("<a href=\'last\' target=\'_blank\'")</script>'; $expected = '<style><a href="/" target=a></style><p>Links: <script>console.log("<a href=\'/\' target=a>hi</a>");</script><script>alert(1);</script>here <a href="/" target="_blank" rel="noopener noreferrer">aq</a></p><script>console.log("<a href=\'last\' target=\'_blank\'")</script>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } /** @@ -126,13 +126,13 @@ class Tests_Targeted_Link_Rel extends WP_UnitTestCase { public function test_ignore_entirely_serialized_content() { $content = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}'; $expected = 'a:1:{s:4:"html";s:52:"<p>Links: <a href="/" target="_blank">No Rel</a></p>";}'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } public function test_wp_targeted_link_rel_tab_separated_values_are_split() { $content = "<p>Links: <a href=\"/\" target=\"_blank\" rel=\"ugc\t\tnoopener\t\">No rel</a></p>"; $expected = '<p>Links: <a href="/" target="_blank" rel="ugc noopener noreferrer">No rel</a></p>'; - $this->assertEquals( $expected, wp_targeted_link_rel( $content ) ); + $this->assertSame( $expected, wp_targeted_link_rel( $content ) ); } } diff --git a/tests/phpunit/tests/formatting/WPTexturize.php b/tests/phpunit/tests/formatting/WPTexturize.php index 853e0db6fe..fda1fa9730 100644 --- a/tests/phpunit/tests/formatting/WPTexturize.php +++ b/tests/phpunit/tests/formatting/WPTexturize.php @@ -5,30 +5,30 @@ */ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { function test_dashes() { - $this->assertEquals( 'Hey — boo?', wptexturize( 'Hey -- boo?' ) ); - $this->assertEquals( '<a href="http://xx--xx">Hey — boo?</a>', wptexturize( '<a href="http://xx--xx">Hey -- boo?</a>' ) ); + $this->assertSame( 'Hey — boo?', wptexturize( 'Hey -- boo?' ) ); + $this->assertSame( '<a href="http://xx--xx">Hey — boo?</a>', wptexturize( '<a href="http://xx--xx">Hey -- boo?</a>' ) ); } function test_disable() { - $this->assertEquals( '<pre>---&</pre>', wptexturize( '<pre>---&</pre>' ) ); - $this->assertEquals( '<pre><code></code>--&</pre>', wptexturize( '<pre><code></code>--&</pre>' ) ); + $this->assertSame( '<pre>---&</pre>', wptexturize( '<pre>---&</pre>' ) ); + $this->assertSame( '<pre><code></code>--&</pre>', wptexturize( '<pre><code></code>--&</pre>' ) ); - $this->assertEquals( '<code>---&</code>', wptexturize( '<code>---&</code>' ) ); - $this->assertEquals( '<kbd>---&</kbd>', wptexturize( '<kbd>---&</kbd>' ) ); - $this->assertEquals( '<style>---&</style>', wptexturize( '<style>---&</style>' ) ); - $this->assertEquals( '<script>---&</script>', wptexturize( '<script>---&</script>' ) ); - $this->assertEquals( '<tt>---&</tt>', wptexturize( '<tt>---&</tt>' ) ); + $this->assertSame( '<code>---&</code>', wptexturize( '<code>---&</code>' ) ); + $this->assertSame( '<kbd>---&</kbd>', wptexturize( '<kbd>---&</kbd>' ) ); + $this->assertSame( '<style>---&</style>', wptexturize( '<style>---&</style>' ) ); + $this->assertSame( '<script>---&</script>', wptexturize( '<script>---&</script>' ) ); + $this->assertSame( '<tt>---&</tt>', wptexturize( '<tt>---&</tt>' ) ); - $this->assertEquals( '<code>href="baba"</code> “baba”', wptexturize( '<code>href="baba"</code> "baba"' ) ); + $this->assertSame( '<code>href="baba"</code> “baba”', wptexturize( '<code>href="baba"</code> "baba"' ) ); $enabled_tags_inside_code = '<code>curl -s <a href="http://x/">baba</a> | grep sfive | cut -d "\"" -f 10 > topmp3.txt</code>'; - $this->assertEquals( $enabled_tags_inside_code, wptexturize( $enabled_tags_inside_code ) ); + $this->assertSame( $enabled_tags_inside_code, wptexturize( $enabled_tags_inside_code ) ); $double_nest = '<pre>"baba"<code>"baba"<pre></pre></code>"baba"</pre>'; - $this->assertEquals( $double_nest, wptexturize( $double_nest ) ); + $this->assertSame( $double_nest, wptexturize( $double_nest ) ); $invalid_nest = '<pre></code>"baba"</pre>'; - $this->assertEquals( $invalid_nest, wptexturize( $invalid_nest ) ); + $this->assertSame( $invalid_nest, wptexturize( $invalid_nest ) ); } @@ -36,38 +36,38 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @ticket 1418 */ function test_bracketed_quotes_1418() { - $this->assertEquals( '(“test”)', wptexturize( '("test")' ) ); - $this->assertEquals( '(‘test’)', wptexturize( "('test')" ) ); - $this->assertEquals( '(’twas)', wptexturize( "('twas)" ) ); + $this->assertSame( '(“test”)', wptexturize( '("test")' ) ); + $this->assertSame( '(‘test’)', wptexturize( "('test')" ) ); + $this->assertSame( '(’twas)', wptexturize( "('twas)" ) ); } /** * @ticket 3810 */ function test_bracketed_quotes_3810() { - $this->assertEquals( 'A dog (“Hubertus”) was sent out.', wptexturize( 'A dog ("Hubertus") was sent out.' ) ); + $this->assertSame( 'A dog (“Hubertus”) was sent out.', wptexturize( 'A dog ("Hubertus") was sent out.' ) ); } /** * @ticket 4539 */ function test_basic_quotes() { - $this->assertEquals( 'test’s', wptexturize( 'test\'s' ) ); + $this->assertSame( 'test’s', wptexturize( 'test\'s' ) ); - $this->assertEquals( '‘quoted’', wptexturize( '\'quoted\'' ) ); - $this->assertEquals( '“quoted”', wptexturize( '"quoted"' ) ); + $this->assertSame( '‘quoted’', wptexturize( '\'quoted\'' ) ); + $this->assertSame( '“quoted”', wptexturize( '"quoted"' ) ); - $this->assertEquals( 'space before ‘quoted’ space after', wptexturize( 'space before \'quoted\' space after' ) ); - $this->assertEquals( 'space before “quoted” space after', wptexturize( 'space before "quoted" space after' ) ); + $this->assertSame( 'space before ‘quoted’ space after', wptexturize( 'space before \'quoted\' space after' ) ); + $this->assertSame( 'space before “quoted” space after', wptexturize( 'space before "quoted" space after' ) ); - $this->assertEquals( '(‘quoted’)', wptexturize( '(\'quoted\')' ) ); - $this->assertEquals( '{“quoted”}', wptexturize( '{"quoted"}' ) ); + $this->assertSame( '(‘quoted’)', wptexturize( '(\'quoted\')' ) ); + $this->assertSame( '{“quoted”}', wptexturize( '{"quoted"}' ) ); - $this->assertEquals( '‘qu(ot)ed’', wptexturize( '\'qu(ot)ed\'' ) ); - $this->assertEquals( '“qu{ot}ed”', wptexturize( '"qu{ot}ed"' ) ); + $this->assertSame( '‘qu(ot)ed’', wptexturize( '\'qu(ot)ed\'' ) ); + $this->assertSame( '“qu{ot}ed”', wptexturize( '"qu{ot}ed"' ) ); - $this->assertEquals( ' ‘test’s quoted’ ', wptexturize( ' \'test\'s quoted\' ' ) ); - $this->assertEquals( ' “test’s quoted” ', wptexturize( ' "test\'s quoted" ' ) ); + $this->assertSame( ' ‘test’s quoted’ ', wptexturize( ' \'test\'s quoted\' ' ) ); + $this->assertSame( ' “test’s quoted” ', wptexturize( ' "test\'s quoted" ' ) ); } /** @@ -75,7 +75,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @ticket 15241 */ function test_full_sentences_with_unmatched_single_quotes() { - $this->assertEquals( + $this->assertSame( 'That means every moment you’re working on something without it being in the public it’s actually dying.', wptexturize( "That means every moment you're working on something without it being in the public it's actually dying." ) ); @@ -85,64 +85,64 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @ticket 4539 */ function test_quotes() { - $this->assertEquals( '“Quoted String”', wptexturize( '"Quoted String"' ) ); - // $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a>”', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"' ) ); - // $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link and a period</a>”.', wptexturize( 'Here is "<a href="http://example.com">a test with a link and a period</a>".' ) ); - $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a>” and a space.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>" and a space.' ) ); - $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a> and some text quoted”', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a> and some text quoted"' ) ); - // $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a>”, and a comma.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>", and a comma.' ) ); - // $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a>”; and a semi-colon.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"; and a semi-colon.' ) ); - // $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a>”- and a dash.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"- and a dash.' ) ); - // $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a>”… and ellipses.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"... and ellipses.' ) ); - // $this->assertEquals( 'Here is “a test <a href="http://example.com">with a link</a>”.', wptexturize( 'Here is "a test <a href="http://example.com">with a link</a>".' ) ); - // $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a>”and a work stuck to the end.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"and a work stuck to the end.' ) ); - $this->assertEquals( 'A test with a finishing number, “like 23”.', wptexturize( 'A test with a finishing number, "like 23".' ) ); - $this->assertEquals( 'A test with a number, “like 62”, is nice to have.', wptexturize( 'A test with a number, "like 62", is nice to have.' ) ); + $this->assertSame( '“Quoted String”', wptexturize( '"Quoted String"' ) ); + // $this->assertSame( 'Here is “<a href="http://example.com">a test with a link</a>”', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"' ) ); + // $this->assertSame( 'Here is “<a href="http://example.com">a test with a link and a period</a>”.', wptexturize( 'Here is "<a href="http://example.com">a test with a link and a period</a>".' ) ); + $this->assertSame( 'Here is “<a href="http://example.com">a test with a link</a>” and a space.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>" and a space.' ) ); + $this->assertSame( 'Here is “<a href="http://example.com">a test with a link</a> and some text quoted”', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a> and some text quoted"' ) ); + // $this->assertSame( 'Here is “<a href="http://example.com">a test with a link</a>”, and a comma.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>", and a comma.' ) ); + // $this->assertSame( 'Here is “<a href="http://example.com">a test with a link</a>”; and a semi-colon.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"; and a semi-colon.' ) ); + // $this->assertSame( 'Here is “<a href="http://example.com">a test with a link</a>”- and a dash.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"- and a dash.' ) ); + // $this->assertSame( 'Here is “<a href="http://example.com">a test with a link</a>”… and ellipses.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"... and ellipses.' ) ); + // $this->assertSame( 'Here is “a test <a href="http://example.com">with a link</a>”.', wptexturize( 'Here is "a test <a href="http://example.com">with a link</a>".' ) ); + // $this->assertSame( 'Here is “<a href="http://example.com">a test with a link</a>”and a work stuck to the end.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"and a work stuck to the end.' ) ); + $this->assertSame( 'A test with a finishing number, “like 23”.', wptexturize( 'A test with a finishing number, "like 23".' ) ); + $this->assertSame( 'A test with a number, “like 62”, is nice to have.', wptexturize( 'A test with a number, "like 62", is nice to have.' ) ); } /** * @ticket 4539 */ function test_quotes_before_s() { - $this->assertEquals( 'test’s', wptexturize( "test's" ) ); - $this->assertEquals( '‘test’s', wptexturize( "'test's" ) ); - $this->assertEquals( '‘test’s’', wptexturize( "'test's'" ) ); - $this->assertEquals( '‘string’', wptexturize( "'string'" ) ); - $this->assertEquals( '‘string’s’', wptexturize( "'string's'" ) ); + $this->assertSame( 'test’s', wptexturize( "test's" ) ); + $this->assertSame( '‘test’s', wptexturize( "'test's" ) ); + $this->assertSame( '‘test’s’', wptexturize( "'test's'" ) ); + $this->assertSame( '‘string’', wptexturize( "'string'" ) ); + $this->assertSame( '‘string’s’', wptexturize( "'string's'" ) ); } /** * @ticket 4539 */ function test_quotes_before_numbers() { - $this->assertEquals( 'Class of ’99', wptexturize( "Class of '99" ) ); - $this->assertEquals( 'Class of ’99’s', wptexturize( "Class of '99's" ) ); - $this->assertEquals( '‘Class of ’99’', wptexturize( "'Class of '99'" ) ); - $this->assertEquals( '‘Class of ’99’ ', wptexturize( "'Class of '99' " ) ); - $this->assertEquals( '‘Class of ’99’.', wptexturize( "'Class of '99'." ) ); - $this->assertEquals( '‘Class of ’99’, she said', wptexturize( "'Class of '99', she said" ) ); - $this->assertEquals( '‘Class of ’99’:', wptexturize( "'Class of '99':" ) ); - $this->assertEquals( '‘Class of ’99’;', wptexturize( "'Class of '99';" ) ); - $this->assertEquals( '‘Class of ’99’!', wptexturize( "'Class of '99'!" ) ); - $this->assertEquals( '‘Class of ’99’?', wptexturize( "'Class of '99'?" ) ); - $this->assertEquals( '‘Class of ’99’s’', wptexturize( "'Class of '99's'" ) ); - $this->assertEquals( '‘Class of ’99’s’', wptexturize( "'Class of '99’s'" ) ); - $this->assertEquals( '“Class of 99”', wptexturize( '"Class of 99"' ) ); - $this->assertEquals( '“Class of ’99”', wptexturize( "\"Class of '99\"" ) ); - $this->assertEquals( '{“Class of ’99”}', wptexturize( "{\"Class of '99\"}" ) ); - $this->assertEquals( ' “Class of ’99” ', wptexturize( " \"Class of '99\" " ) ); - $this->assertEquals( ' “Class of ’99”.', wptexturize( " \"Class of '99\"." ) ); - $this->assertEquals( ' “Class of ’99”, she said', wptexturize( " \"Class of '99\", she said" ) ); - $this->assertEquals( ' “Class of ’99”:', wptexturize( " \"Class of '99\":" ) ); - $this->assertEquals( ' “Class of ’99”;', wptexturize( " \"Class of '99\";" ) ); - $this->assertEquals( ' “Class of ’99”!', wptexturize( " \"Class of '99\"!" ) ); - $this->assertEquals( ' “Class of ’99”?', wptexturize( " \"Class of '99\"?" ) ); + $this->assertSame( 'Class of ’99', wptexturize( "Class of '99" ) ); + $this->assertSame( 'Class of ’99’s', wptexturize( "Class of '99's" ) ); + $this->assertSame( '‘Class of ’99’', wptexturize( "'Class of '99'" ) ); + $this->assertSame( '‘Class of ’99’ ', wptexturize( "'Class of '99' " ) ); + $this->assertSame( '‘Class of ’99’.', wptexturize( "'Class of '99'." ) ); + $this->assertSame( '‘Class of ’99’, she said', wptexturize( "'Class of '99', she said" ) ); + $this->assertSame( '‘Class of ’99’:', wptexturize( "'Class of '99':" ) ); + $this->assertSame( '‘Class of ’99’;', wptexturize( "'Class of '99';" ) ); + $this->assertSame( '‘Class of ’99’!', wptexturize( "'Class of '99'!" ) ); + $this->assertSame( '‘Class of ’99’?', wptexturize( "'Class of '99'?" ) ); + $this->assertSame( '‘Class of ’99’s’', wptexturize( "'Class of '99's'" ) ); + $this->assertSame( '‘Class of ’99’s’', wptexturize( "'Class of '99’s'" ) ); + $this->assertSame( '“Class of 99”', wptexturize( '"Class of 99"' ) ); + $this->assertSame( '“Class of ’99”', wptexturize( "\"Class of '99\"" ) ); + $this->assertSame( '{“Class of ’99”}', wptexturize( "{\"Class of '99\"}" ) ); + $this->assertSame( ' “Class of ’99” ', wptexturize( " \"Class of '99\" " ) ); + $this->assertSame( ' “Class of ’99”.', wptexturize( " \"Class of '99\"." ) ); + $this->assertSame( ' “Class of ’99”, she said', wptexturize( " \"Class of '99\", she said" ) ); + $this->assertSame( ' “Class of ’99”:', wptexturize( " \"Class of '99\":" ) ); + $this->assertSame( ' “Class of ’99”;', wptexturize( " \"Class of '99\";" ) ); + $this->assertSame( ' “Class of ’99”!', wptexturize( " \"Class of '99\"!" ) ); + $this->assertSame( ' “Class of ’99”?', wptexturize( " \"Class of '99\"?" ) ); // Not a quotation, may be between two other quotations. - $this->assertEquals( '}”Class of ’99″{', wptexturize( "}\"Class of '99\"{" ) ); + $this->assertSame( '}”Class of ’99″{', wptexturize( "}\"Class of '99\"{" ) ); } function test_quotes_after_numbers() { - $this->assertEquals( 'Class of ’99', wptexturize( "Class of '99" ) ); + $this->assertSame( 'Class of ’99', wptexturize( "Class of '99" ) ); } /** @@ -150,43 +150,43 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @ticket 15241 */ function test_other_html() { - $this->assertEquals( '‘<strong>', wptexturize( "'<strong>" ) ); - // $this->assertEquals( '‘<strong>Quoted Text</strong>’,', wptexturize( "'<strong>Quoted Text</strong>'," ) ); - // $this->assertEquals( '“<strong>Quoted Text</strong>”,', wptexturize( '"<strong>Quoted Text</strong>",' ) ); + $this->assertSame( '‘<strong>', wptexturize( "'<strong>" ) ); + // $this->assertSame( '‘<strong>Quoted Text</strong>’,', wptexturize( "'<strong>Quoted Text</strong>'," ) ); + // $this->assertSame( '“<strong>Quoted Text</strong>”,', wptexturize( '"<strong>Quoted Text</strong>",' ) ); } function test_x() { - $this->assertEquals( '14×24', wptexturize( '14x24' ) ); + $this->assertSame( '14×24', wptexturize( '14x24' ) ); } function test_minutes_seconds() { - $this->assertEquals( '9′', wptexturize( '9\'' ) ); - $this->assertEquals( '9″', wptexturize( '9"' ) ); + $this->assertSame( '9′', wptexturize( '9\'' ) ); + $this->assertSame( '9″', wptexturize( '9"' ) ); - $this->assertEquals( 'a 9′ b', wptexturize( 'a 9\' b' ) ); - $this->assertEquals( 'a 9″ b', wptexturize( 'a 9" b' ) ); + $this->assertSame( 'a 9′ b', wptexturize( 'a 9\' b' ) ); + $this->assertSame( 'a 9″ b', wptexturize( 'a 9" b' ) ); - $this->assertEquals( '“a 9′ b”', wptexturize( '"a 9\' b"' ) ); - $this->assertEquals( '‘a 9″ b’', wptexturize( "'a 9\" b'" ) ); + $this->assertSame( '“a 9′ b”', wptexturize( '"a 9\' b"' ) ); + $this->assertSame( '‘a 9″ b’', wptexturize( "'a 9\" b'" ) ); } /** * @ticket 8775 */ function test_wptexturize_quotes_around_numbers() { - $this->assertEquals( '“12345”', wptexturize( '"12345"' ) ); - $this->assertEquals( '‘12345’', wptexturize( '\'12345\'' ) ); - $this->assertEquals( '“a 9′ plus a ‘9’, maybe a 9′ ‘9’”', wptexturize( '"a 9\' plus a \'9\', maybe a 9\' \'9\'"' ) ); - $this->assertEquals( '<p>’99<br />‘123’<br />’tis<br />‘s’</p>', wptexturize( '<p>\'99<br />\'123\'<br />\'tis<br />\'s\'</p>' ) ); + $this->assertSame( '“12345”', wptexturize( '"12345"' ) ); + $this->assertSame( '‘12345’', wptexturize( '\'12345\'' ) ); + $this->assertSame( '“a 9′ plus a ‘9’, maybe a 9′ ‘9’”', wptexturize( '"a 9\' plus a \'9\', maybe a 9\' \'9\'"' ) ); + $this->assertSame( '<p>’99<br />‘123’<br />’tis<br />‘s’</p>', wptexturize( '<p>\'99<br />\'123\'<br />\'tis<br />\'s\'</p>' ) ); } /** * @ticket 8912 */ function test_wptexturize_html_comments() { - $this->assertEquals( '<!--[if !IE]>--><!--<![endif]-->', wptexturize( '<!--[if !IE]>--><!--<![endif]-->' ) ); - $this->assertEquals( '<!--[if !IE]>"a 9\' plus a \'9\', maybe a 9\' \'9\' "<![endif]-->', wptexturize( '<!--[if !IE]>"a 9\' plus a \'9\', maybe a 9\' \'9\' "<![endif]-->' ) ); - $this->assertEquals( '<ul><li>Hello.</li><!--<li>Goodbye.</li>--></ul>', wptexturize( '<ul><li>Hello.</li><!--<li>Goodbye.</li>--></ul>' ) ); + $this->assertSame( '<!--[if !IE]>--><!--<![endif]-->', wptexturize( '<!--[if !IE]>--><!--<![endif]-->' ) ); + $this->assertSame( '<!--[if !IE]>"a 9\' plus a \'9\', maybe a 9\' \'9\' "<![endif]-->', wptexturize( '<!--[if !IE]>"a 9\' plus a \'9\', maybe a 9\' \'9\' "<![endif]-->' ) ); + $this->assertSame( '<ul><li>Hello.</li><!--<li>Goodbye.</li>--></ul>', wptexturize( '<ul><li>Hello.</li><!--<li>Goodbye.</li>--></ul>' ) ); } /** @@ -194,15 +194,15 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @ticket 15241 */ function test_entity_quote_cuddling() { - $this->assertEquals( ' “Testing”', wptexturize( ' "Testing"' ) ); - // $this->assertEquals( '&“Testing”', wptexturize( '&"Testing"' ) ); + $this->assertSame( ' “Testing”', wptexturize( ' "Testing"' ) ); + // $this->assertSame( '&“Testing”', wptexturize( '&"Testing"' ) ); } /** * @ticket 22823 */ function test_apostrophes_before_primes() { - $this->assertEquals( 'WordPress 3.5’s release date', wptexturize( "WordPress 3.5's release date" ) ); + $this->assertSame( 'WordPress 3.5’s release date', wptexturize( "WordPress 3.5's release date" ) ); } /** @@ -211,34 +211,34 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { function test_spaces_around_hyphens() { $nbsp = "\xC2\xA0"; - $this->assertEquals( ' – ', wptexturize( ' - ' ) ); - $this->assertEquals( ' – ', wptexturize( ' - ' ) ); - $this->assertEquals( ' – ', wptexturize( ' - ' ) ); - $this->assertEquals( ' – ', wptexturize( ' - ' ) ); - $this->assertEquals( "$nbsp–$nbsp", wptexturize( "$nbsp-$nbsp" ) ); - $this->assertEquals( " –$nbsp", wptexturize( " -$nbsp" ) ); - $this->assertEquals( "$nbsp– ", wptexturize( "$nbsp- " ) ); + $this->assertSame( ' – ', wptexturize( ' - ' ) ); + $this->assertSame( ' – ', wptexturize( ' - ' ) ); + $this->assertSame( ' – ', wptexturize( ' - ' ) ); + $this->assertSame( ' – ', wptexturize( ' - ' ) ); + $this->assertSame( "$nbsp–$nbsp", wptexturize( "$nbsp-$nbsp" ) ); + $this->assertSame( " –$nbsp", wptexturize( " -$nbsp" ) ); + $this->assertSame( "$nbsp– ", wptexturize( "$nbsp- " ) ); - $this->assertEquals( ' — ', wptexturize( ' -- ' ) ); - $this->assertEquals( ' — ', wptexturize( ' -- ' ) ); - $this->assertEquals( ' — ', wptexturize( ' -- ' ) ); - $this->assertEquals( ' — ', wptexturize( ' -- ' ) ); - $this->assertEquals( "$nbsp—$nbsp", wptexturize( "$nbsp--$nbsp" ) ); - $this->assertEquals( " —$nbsp", wptexturize( " --$nbsp" ) ); - $this->assertEquals( "$nbsp— ", wptexturize( "$nbsp-- " ) ); + $this->assertSame( ' — ', wptexturize( ' -- ' ) ); + $this->assertSame( ' — ', wptexturize( ' -- ' ) ); + $this->assertSame( ' — ', wptexturize( ' -- ' ) ); + $this->assertSame( ' — ', wptexturize( ' -- ' ) ); + $this->assertSame( "$nbsp—$nbsp", wptexturize( "$nbsp--$nbsp" ) ); + $this->assertSame( " —$nbsp", wptexturize( " --$nbsp" ) ); + $this->assertSame( "$nbsp— ", wptexturize( "$nbsp-- " ) ); } /** * @ticket 31030 */ function test_hyphens_at_start_and_end() { - $this->assertEquals( '– ', wptexturize( '- ' ) ); - $this->assertEquals( '– –', wptexturize( '- -' ) ); - $this->assertEquals( ' –', wptexturize( ' -' ) ); + $this->assertSame( '– ', wptexturize( '- ' ) ); + $this->assertSame( '– –', wptexturize( '- -' ) ); + $this->assertSame( ' –', wptexturize( ' -' ) ); - $this->assertEquals( '— ', wptexturize( '-- ' ) ); - $this->assertEquals( '— —', wptexturize( '-- --' ) ); - $this->assertEquals( ' —', wptexturize( ' --' ) ); + $this->assertSame( '— ', wptexturize( '-- ' ) ); + $this->assertSame( '— —', wptexturize( '-- --' ) ); + $this->assertSame( ' —', wptexturize( ' --' ) ); } /** @@ -266,7 +266,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_spaces_around_quotes */ function test_spaces_around_quotes( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_spaces_around_quotes() { @@ -322,7 +322,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_apos_before_digits */ function test_apos_before_digits( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_apos_before_digits() { @@ -363,7 +363,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_opening_single_quote */ function test_opening_single_quote( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_opening_single_quote() { @@ -492,7 +492,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_double_prime */ function test_double_prime( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_double_prime() { @@ -525,7 +525,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_single_prime */ function test_single_prime( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_single_prime() { @@ -558,7 +558,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_contractions */ function test_contractions( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_contractions() { @@ -599,7 +599,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_opening_quote */ function test_opening_quote( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_opening_quote() { @@ -676,7 +676,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_closing_quote */ function test_closing_quote( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_closing_quote() { @@ -765,7 +765,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_closing_single_quote */ function test_closing_single_quote( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_closing_single_quote() { @@ -855,7 +855,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_multiplication */ function test_multiplication( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_multiplication() { @@ -905,7 +905,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_ampersand */ function test_ampersand( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_ampersand() { @@ -970,7 +970,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_cockney */ function test_cockney( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_cockney() { @@ -1031,7 +1031,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_smart_dashes */ function test_smart_dashes( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_smart_dashes() { @@ -1084,7 +1084,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_misc_static_replacements */ function test_misc_static_replacements( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_misc_static_replacements() { @@ -1139,7 +1139,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_quoted_numbers */ function test_quoted_numbers( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_quoted_numbers() { @@ -1190,7 +1190,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_quotes_and_dashes */ function test_quotes_and_dashes( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_quotes_and_dashes() { @@ -1253,7 +1253,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_tag_avoidance */ function test_tag_avoidance( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_tag_avoidance() { @@ -1476,7 +1476,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_year_abbr */ function test_year_abbr( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_year_abbr() { @@ -1572,7 +1572,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { remove_filter( 'gettext_with_context', array( $this, 'filter_translate' ), 10, 4 ); wptexturize( 'reset', true ); - return $this->assertEquals( $output, $result ); + return $this->assertSame( $output, $result ); } function filter_translate( $translations, $text, $context, $domain ) { @@ -1792,7 +1792,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_element_stack */ function test_element_stack( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_element_stack() { @@ -1845,7 +1845,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { function test_unregistered_shortcodes( $input, $output ) { add_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 ); - $output = $this->assertEquals( $output, wptexturize( $input ) ); + $output = $this->assertSame( $output, wptexturize( $input ) ); remove_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 ); return $output; @@ -1928,7 +1928,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase { * @dataProvider data_primes_vs_quotes */ function test_primes_vs_quotes( $input, $output ) { - return $this->assertEquals( $output, wptexturize( $input ) ); + return $this->assertSame( $output, wptexturize( $input ) ); } function data_primes_vs_quotes() { @@ -1997,7 +1997,7 @@ String with a number followed by a single quote ‘Expendables 3’ vest remove_filter( 'gettext_with_context', array( $this, 'filter_translate2' ), 10, 4 ); wptexturize( 'reset', true ); - return $this->assertEquals( $output, $result ); + return $this->assertSame( $output, $result ); } function filter_translate2( $translations, $text, $context, $domain ) { @@ -2103,7 +2103,7 @@ String with a number followed by a single quote !q1!Expendables 3!q1! vestibulum * @ticket 35864 */ function test_trailing_less_than() { - $this->assertEquals( 'F–oo<', wptexturize( 'F--oo<', true ) ); + $this->assertSame( 'F–oo<', wptexturize( 'F--oo<', true ) ); } function data_whole_posts() { diff --git a/tests/phpunit/tests/formatting/WPTrimWords.php b/tests/phpunit/tests/formatting/WPTrimWords.php index 125bbcb9d2..10a4dd2dc9 100644 --- a/tests/phpunit/tests/formatting/WPTrimWords.php +++ b/tests/phpunit/tests/formatting/WPTrimWords.php @@ -16,23 +16,23 @@ class Tests_Formatting_WPTrimWords extends WP_UnitTestCase { function test_trims_to_55_by_default() { $trimmed = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce varius lacinia vehicula. Etiam sapien risus, ultricies ac posuere eu, convallis sit amet augue. Pellentesque urna massa, lacinia vel iaculis eget, bibendum in mauris. Aenean eleifend pulvinar ligula, a convallis eros gravida non. Suspendisse potenti. Pellentesque et odio tortor. In vulputate pellentesque libero, sed dapibus velit…'; - $this->assertEquals( $trimmed, wp_trim_words( $this->long_text ) ); + $this->assertSame( $trimmed, wp_trim_words( $this->long_text ) ); } function test_trims_to_10() { $trimmed = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce varius…'; - $this->assertEquals( $trimmed, wp_trim_words( $this->long_text, 10 ) ); + $this->assertSame( $trimmed, wp_trim_words( $this->long_text, 10 ) ); } function test_trims_to_5_and_uses_custom_more() { $trimmed = 'Lorem ipsum dolor sit amet,[...] Read on!'; - $this->assertEquals( $trimmed, wp_trim_words( $this->long_text, 5, '[...] Read on!' ) ); + $this->assertSame( $trimmed, wp_trim_words( $this->long_text, 5, '[...] Read on!' ) ); } function test_strips_tags_before_trimming() { $text = 'This text contains a <a href="http://wordpress.org"> link </a> to WordPress.org!'; $trimmed = 'This text contains a link…'; - $this->assertEquals( $trimmed, wp_trim_words( $text, 5 ) ); + $this->assertSame( $trimmed, wp_trim_words( $text, 5 ) ); } /** @@ -42,15 +42,15 @@ class Tests_Formatting_WPTrimWords extends WP_UnitTestCase { $trimmed = 'This text contains. It should go.'; $text = 'This text contains<script>alert(" Javascript");</script>. It should go.'; - $this->assertEquals( $trimmed, wp_trim_words( $text ) ); + $this->assertSame( $trimmed, wp_trim_words( $text ) ); $text = 'This text contains<style>#css { width:expression(alert("css")) }</style>. It should go.'; - $this->assertEquals( $trimmed, wp_trim_words( $text ) ); + $this->assertSame( $trimmed, wp_trim_words( $text ) ); } function test_doesnt_trim_short_text() { $text = 'This is some short text.'; - $this->assertEquals( $text, wp_trim_words( $text ) ); + $this->assertSame( $text, wp_trim_words( $text ) ); } /** @@ -61,7 +61,7 @@ class Tests_Formatting_WPTrimWords extends WP_UnitTestCase { $expected = substr( $this->long_text, 0, 20 ) . '…'; $actual = wp_trim_words( $this->long_text, 20 ); restore_previous_locale(); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** @@ -73,16 +73,16 @@ class Tests_Formatting_WPTrimWords extends WP_UnitTestCase { $expected = str_repeat( 'あ', 19 ) . '…'; $actual = wp_trim_words( $text, 19 ); restore_previous_locale(); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** * @ticket 47867 */ function test_works_with_non_numeric_num_words() { - $this->assertEquals( '', wp_trim_words( $this->long_text, '', '' ) ); - $this->assertEquals( '', wp_trim_words( $this->long_text, 'abc', '' ) ); - $this->assertEquals( '', wp_trim_words( $this->long_text, null, '' ) ); - $this->assertEquals( 'Lorem ipsum dolor', wp_trim_words( $this->long_text, '3', '' ) ); + $this->assertSame( '', wp_trim_words( $this->long_text, '', '' ) ); + $this->assertSame( '', wp_trim_words( $this->long_text, 'abc', '' ) ); + $this->assertSame( '', wp_trim_words( $this->long_text, null, '' ) ); + $this->assertSame( 'Lorem ipsum dolor', wp_trim_words( $this->long_text, '3', '' ) ); } } diff --git a/tests/phpunit/tests/formatting/WpHtmlEditPre.php b/tests/phpunit/tests/formatting/WpHtmlEditPre.php index dc39ddf050..fceabbe8db 100644 --- a/tests/phpunit/tests/formatting/WpHtmlEditPre.php +++ b/tests/phpunit/tests/formatting/WpHtmlEditPre.php @@ -17,7 +17,7 @@ class Tests_Formatting_WpHtmlEditPre extends WP_UnitTestCase { function test_wp_htmledit_pre_charset_iso_8859_1() { add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) ); $iso8859_1 = 'Fran' . chr( 135 ) . 'ais'; - $this->assertEquals( $iso8859_1, wp_htmledit_pre( $iso8859_1 ) ); + $this->assertSame( $iso8859_1, wp_htmledit_pre( $iso8859_1 ) ); remove_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) ); } @@ -31,7 +31,7 @@ class Tests_Formatting_WpHtmlEditPre extends WP_UnitTestCase { function test_wp_htmledit_pre_charset_utf_8() { add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) ); $utf8 = 'Fran' . chr( 195 ) . chr( 167 ) . 'ais'; - $this->assertEquals( $utf8, wp_htmledit_pre( $utf8 ) ); + $this->assertSame( $utf8, wp_htmledit_pre( $utf8 ) ); remove_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) ); } } diff --git a/tests/phpunit/tests/formatting/WpHtmlSplit.php b/tests/phpunit/tests/formatting/WpHtmlSplit.php index adf3203827..a9baa7cb8c 100644 --- a/tests/phpunit/tests/formatting/WpHtmlSplit.php +++ b/tests/phpunit/tests/formatting/WpHtmlSplit.php @@ -11,7 +11,7 @@ class Tests_Formatting_WpHtmlSplit extends WP_UnitTestCase { * @dataProvider data_basic_features */ function test_basic_features( $input, $output ) { - return $this->assertEquals( $output, wp_html_split( $input ) ); + return $this->assertSame( $output, wp_html_split( $input ) ); } function data_basic_features() { diff --git a/tests/phpunit/tests/formatting/WpReplaceInHtmlTags.php b/tests/phpunit/tests/formatting/WpReplaceInHtmlTags.php index 7a6291047f..764a0cc178 100644 --- a/tests/phpunit/tests/formatting/WpReplaceInHtmlTags.php +++ b/tests/phpunit/tests/formatting/WpReplaceInHtmlTags.php @@ -10,7 +10,7 @@ class Tests_Formatting_WpReplaceInTags extends WP_UnitTestCase { * @dataProvider data_wp_replace_in_html_tags */ function test_wp_replace_in_html_tags( $input, $output ) { - return $this->assertEquals( $output, wp_replace_in_html_tags( $input, array( "\n" => ' ' ) ) ); + return $this->assertSame( $output, wp_replace_in_html_tags( $input, array( "\n" => ' ' ) ) ); } function data_wp_replace_in_html_tags() { diff --git a/tests/phpunit/tests/formatting/WpRichEditPre.php b/tests/phpunit/tests/formatting/WpRichEditPre.php index d5c2a072cb..79ed8b1bc6 100644 --- a/tests/phpunit/tests/formatting/WpRichEditPre.php +++ b/tests/phpunit/tests/formatting/WpRichEditPre.php @@ -17,7 +17,7 @@ class Tests_Formatting_WpRichEditPre extends WP_UnitTestCase { function test_wp_richedit_pre_charset_iso_8859_1() { add_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) ); $iso8859_1 = 'Fran' . chr( 135 ) . 'ais'; - $this->assertEquals( '<p>' . $iso8859_1 . "</p>\n", wp_richedit_pre( $iso8859_1 ) ); + $this->assertSame( '<p>' . $iso8859_1 . "</p>\n", wp_richedit_pre( $iso8859_1 ) ); remove_filter( 'pre_option_blog_charset', array( $this, '_charset_iso_8859_1' ) ); } @@ -31,7 +31,7 @@ class Tests_Formatting_WpRichEditPre extends WP_UnitTestCase { function test_wp_richedit_pre_charset_utf_8() { add_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) ); $utf8 = 'Fran' . chr( 195 ) . chr( 167 ) . 'ais'; - $this->assertEquals( '<p>' . $utf8 . "</p>\n", wp_richedit_pre( $utf8 ) ); + $this->assertSame( '<p>' . $utf8 . "</p>\n", wp_richedit_pre( $utf8 ) ); remove_filter( 'pre_option_blog_charset', array( $this, '_charset_utf_8' ) ); } } diff --git a/tests/phpunit/tests/formatting/Zeroise.php b/tests/phpunit/tests/formatting/Zeroise.php index 212d006918..0f9fd8dad4 100644 --- a/tests/phpunit/tests/formatting/Zeroise.php +++ b/tests/phpunit/tests/formatting/Zeroise.php @@ -5,10 +5,10 @@ */ class Tests_Formatting_Zeroise extends WP_UnitTestCase { function test_pads_with_leading_zeroes() { - $this->assertEquals( '00005', zeroise( 5, 5 ) ); + $this->assertSame( '00005', zeroise( 5, 5 ) ); } function test_does_nothing_if_input_is_already_longer() { - $this->assertEquals( '5000000', zeroise( 5000000, 2 ) ); + $this->assertSame( '5000000', zeroise( 5000000, 2 ) ); } } diff --git a/tests/phpunit/tests/formatting/balanceTags.php b/tests/phpunit/tests/formatting/balanceTags.php index b5dedb11f4..c39e30f29e 100644 --- a/tests/phpunit/tests/formatting/balanceTags.php +++ b/tests/phpunit/tests/formatting/balanceTags.php @@ -154,7 +154,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { function test_detects_traditional_tag_names( $tag ) { $normalized = strtolower( $tag ); - $this->assertEquals( "<$normalized>inside</$normalized>", balanceTags( "<$tag>inside", true ) ); + $this->assertSame( "<$normalized>inside</$normalized>", balanceTags( "<$tag>inside", true ) ); } /** @@ -162,7 +162,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @dataProvider supported_custom_element_tag_names */ function test_detects_supported_custom_element_tag_names( $tag ) { - $this->assertEquals( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) ); + $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) ); } /** @@ -170,7 +170,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @dataProvider invalid_tag_names */ function test_ignores_invalid_tag_names( $input, $output ) { - $this->assertEquals( $output, balanceTags( $input, true ) ); + $this->assertSame( $output, balanceTags( $input, true ) ); } /** @@ -178,7 +178,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @dataProvider unsupported_valid_tag_names */ function test_ignores_unsupported_custom_tag_names( $tag ) { - $this->assertEquals( "<$tag>inside", balanceTags( "<$tag>inside", true ) ); + $this->assertSame( "<$tag>inside", balanceTags( "<$tag>inside", true ) ); } /** @@ -186,7 +186,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @dataProvider supported_invalid_tag_names */ function test_detects_supported_invalid_tag_names( $tag ) { - $this->assertEquals( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) ); + $this->assertSame( "<$tag>inside</$tag>", balanceTags( "<$tag>inside", true ) ); } /** @@ -196,7 +196,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @dataProvider single_tags */ function test_selfcloses_unclosed_known_single_tags( $tag ) { - $this->assertEquals( "<$tag />", balanceTags( "<$tag>", true ) ); + $this->assertSame( "<$tag />", balanceTags( "<$tag>", true ) ); } /** @@ -207,7 +207,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @dataProvider single_tags */ function test_selfcloses_known_single_tags_having_closing_tag( $tag ) { - $this->assertEquals( "<$tag />", balanceTags( "<$tag></$tag>", true ) ); + $this->assertSame( "<$tag />", balanceTags( "<$tag></$tag>", true ) ); } /** @@ -232,7 +232,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); foreach ( $inputs as $key => $input ) { - $this->assertEquals( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); + $this->assertSame( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); } } @@ -247,7 +247,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); foreach ( $inputs as $key => $input ) { - $this->assertEquals( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); + $this->assertSame( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); } } @@ -260,7 +260,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); foreach ( $inputs as $key => $input ) { - $this->assertEquals( $inputs[ $key ], balanceTags( $inputs[ $key ], true ) ); + $this->assertSame( $inputs[ $key ], balanceTags( $inputs[ $key ], true ) ); } } @@ -280,7 +280,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); foreach ( $inputs as $key => $input ) { - $this->assertEquals( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); + $this->assertSame( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); } } @@ -294,7 +294,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); foreach ( $inputs as $key => $input ) { - $this->assertEquals( $inputs[ $key ], balanceTags( $inputs[ $key ], true ) ); + $this->assertSame( $inputs[ $key ], balanceTags( $inputs[ $key ], true ) ); } } @@ -303,7 +303,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { */ function test_allows_immediately_nested_object_tags() { $object = '<object id="obj1"><param name="param1"/><object id="obj2"><param name="param2"/></object></object>'; - $this->assertEquals( $object, balanceTags( $object, true ) ); + $this->assertSame( $object, balanceTags( $object, true ) ); } function test_balances_nested_non_nestable_tags() { @@ -317,7 +317,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); foreach ( $inputs as $key => $input ) { - $this->assertEquals( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); + $this->assertSame( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); } } @@ -332,7 +332,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); foreach ( $inputs as $key => $input ) { - $this->assertEquals( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); + $this->assertSame( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); } } @@ -353,7 +353,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); foreach ( $inputs as $key => $input ) { - $this->assertEquals( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); + $this->assertSame( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); } } @@ -372,7 +372,7 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { ); foreach ( $inputs as $key => $input ) { - $this->assertEquals( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); + $this->assertSame( $expected[ $key ], balanceTags( $inputs[ $key ], true ) ); } } @@ -438,6 +438,6 @@ class Tests_Formatting_BalanceTags extends WP_UnitTestCase { * @param string $expected Expected. */ public function test_custom_elements( $source, $expected ) { - $this->assertEquals( $expected, balanceTags( $source, true ) ); + $this->assertSame( $expected, balanceTags( $source, true ) ); } } diff --git a/tests/phpunit/tests/formatting/date.php b/tests/phpunit/tests/formatting/date.php index fce5494f87..ac87159996 100644 --- a/tests/phpunit/tests/formatting/date.php +++ b/tests/phpunit/tests/formatting/date.php @@ -15,7 +15,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { update_option( 'timezone_string', 'Europe/London' ); $local = '2012-01-01 12:34:56'; $gmt = $local; - $this->assertEquals( $local, get_date_from_gmt( $gmt ) ); + $this->assertSame( $local, get_date_from_gmt( $gmt ) ); } /** @@ -27,7 +27,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { update_option( 'timezone_string', 'Europe/London' ); $gmt = '2012-06-01 12:34:56'; $local = '2012-06-01 13:34:56'; - $this->assertEquals( $local, get_date_from_gmt( $gmt ) ); + $this->assertSame( $local, get_date_from_gmt( $gmt ) ); } /** @@ -37,7 +37,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { update_option( 'timezone_string', 'Europe/London' ); $local = '2012-01-01 12:34:56'; $gmt = $local; - $this->assertEquals( $gmt, get_gmt_from_date( $local ) ); + $this->assertSame( $gmt, get_gmt_from_date( $local ) ); } /** @@ -47,7 +47,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { update_option( 'timezone_string', 'Europe/London' ); $local = '2012-06-01 12:34:56'; $gmt = '2012-06-01 11:34:56'; - $this->assertEquals( $gmt, get_gmt_from_date( $local ) ); + $this->assertSame( $gmt, get_gmt_from_date( $local ) ); } /** @@ -56,7 +56,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { function test_get_date_and_time_from_gmt_no_timezone() { $local = '2012-01-01 12:34:56'; $gmt = $local; - $this->assertEquals( $gmt, get_date_from_gmt( $local ) ); + $this->assertSame( $gmt, get_date_from_gmt( $local ) ); } /** @@ -65,7 +65,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { function test_get_gmt_from_date_no_timezone() { $gmt = '2012-12-01 00:00:00'; $date = '2012-12-01'; - $this->assertEquals( $gmt, get_gmt_from_date( $date ) ); + $this->assertSame( $gmt, get_gmt_from_date( $date ) ); } /** @@ -75,7 +75,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { update_option( 'timezone_string', 'Europe/London' ); $local = '2012-12-01'; $gmt = '2012-12-01 00:00:00'; - $this->assertEquals( $gmt, get_gmt_from_date( $local ) ); + $this->assertSame( $gmt, get_gmt_from_date( $local ) ); } /** @@ -110,7 +110,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { $utc = $local->setTimezone( new DateTimeZone( 'UTC' ) ); $mysql_local = $local->format( 'Y-m-d H:i:s' ); - $this->assertEquals( $utc->format( DATE_RFC3339 ), get_gmt_from_date( $mysql_local, DATE_RFC3339 ) ); + $this->assertSame( $utc->format( DATE_RFC3339 ), get_gmt_from_date( $mysql_local, DATE_RFC3339 ) ); } /** @@ -126,7 +126,7 @@ class Tests_Formatting_Date extends WP_UnitTestCase { $utc = $local->setTimezone( new DateTimeZone( 'UTC' ) ); $mysql_utc = $utc->format( 'Y-m-d H:i:s' ); - $this->assertEquals( $local->format( DATE_RFC3339 ), get_date_from_gmt( $mysql_utc, DATE_RFC3339 ) ); + $this->assertSame( $local->format( DATE_RFC3339 ), get_date_from_gmt( $mysql_utc, DATE_RFC3339 ) ); } /** @@ -144,45 +144,45 @@ class Tests_Formatting_Date extends WP_UnitTestCase { $local = new DateTimeImmutable( 'now', wp_timezone() ); $utc = $local->setTimezone( new DateTimeZone( 'UTC' ) ); - $this->assertEquals( + $this->assertSame( $local->format( 'Y-m-d H:i:s' ), iso8601_to_datetime( $local->format( $format ) ), 'Local time from local time.' ); - $this->assertEquals( + $this->assertSame( $utc->format( 'Y-m-d H:i:s' ), iso8601_to_datetime( $local->format( $format ), 'gmt' ), 'UTC time from local time.' ); - $this->assertEquals( + $this->assertSame( $local->format( 'Y-m-d H:i:s' ), iso8601_to_datetime( $local->format( $format_no_tz ) ), 'Local time from local time w/o timezone.' ); - $this->assertEquals( + $this->assertSame( $utc->format( 'Y-m-d H:i:s' ), iso8601_to_datetime( $local->format( $format_no_tz ), 'gmt' ), 'UTC time from local time w/o timezone.' ); - $this->assertEquals( + $this->assertSame( $local->format( 'Y-m-d H:i:s' ), iso8601_to_datetime( $utc->format( $format ) ), 'Local time from UTC time.' ); - $this->assertEquals( + $this->assertSame( $utc->format( 'Y-m-d H:i:s' ), iso8601_to_datetime( $utc->format( $format ), 'gmt' ), 'UTC time from UTC time.' ); - $this->assertEquals( + $this->assertSame( $local->format( 'Y-m-d H:i:s' ), iso8601_to_datetime( $utc->format( $format_no_tz ) . 'Z' ), 'Local time from UTC w/ Z timezone.' ); - $this->assertEquals( + $this->assertSame( $utc->format( 'Y-m-d H:i:s' ), iso8601_to_datetime( $utc->format( $format_no_tz ) . 'Z', 'gmt' ), 'UTC time from UTC w/ Z timezone.' diff --git a/tests/phpunit/tests/formatting/ent2ncr.php b/tests/phpunit/tests/formatting/ent2ncr.php index ea9b8da073..ba84e6d2e0 100644 --- a/tests/phpunit/tests/formatting/ent2ncr.php +++ b/tests/phpunit/tests/formatting/ent2ncr.php @@ -10,7 +10,7 @@ class Tests_Formatting_Ent2NCR extends WP_UnitTestCase { function test_converts_named_entities_to_numeric_character_references( $entity, $ncr ) { $entity = '&' . $entity . ';'; $ncr = '&#' . $ncr . ';'; - $this->assertEquals( $ncr, ent2ncr( $entity ), $entity ); + $this->assertSame( $ncr, ent2ncr( $entity ), $entity ); } /** diff --git a/tests/phpunit/tests/formatting/isoDescrambler.php b/tests/phpunit/tests/formatting/isoDescrambler.php index 32a717b948..c1133c4bcf 100644 --- a/tests/phpunit/tests/formatting/isoDescrambler.php +++ b/tests/phpunit/tests/formatting/isoDescrambler.php @@ -9,6 +9,6 @@ class Test_WP_ISO_Descrambler extends WP_UnitTestCase { * =?iso-8859-1?q?this=20is=20some=20text?= */ function test_decodes_iso_8859_1_rfc2047_q_encoding() { - $this->assertEquals( 'this is some text', wp_iso_descrambler( '=?iso-8859-1?q?this=20is=20some=20text?=' ) ); + $this->assertSame( 'this is some text', wp_iso_descrambler( '=?iso-8859-1?q?this=20is=20some=20text?=' ) ); } } diff --git a/tests/phpunit/tests/formatting/redirect.php b/tests/phpunit/tests/formatting/redirect.php index c79e1433eb..93aaee3d5f 100644 --- a/tests/phpunit/tests/formatting/redirect.php +++ b/tests/phpunit/tests/formatting/redirect.php @@ -46,34 +46,34 @@ class Tests_Formatting_Redirect extends WP_UnitTestCase { } function test_wp_sanitize_redirect() { - $this->assertEquals( 'http://example.com/watchthelinefeedgo', wp_sanitize_redirect( 'http://example.com/watchthelinefeed%0Ago' ) ); - $this->assertEquals( 'http://example.com/watchthelinefeedgo', wp_sanitize_redirect( 'http://example.com/watchthelinefeed%0ago' ) ); - $this->assertEquals( 'http://example.com/watchthecarriagereturngo', wp_sanitize_redirect( 'http://example.com/watchthecarriagereturn%0Dgo' ) ); - $this->assertEquals( 'http://example.com/watchthecarriagereturngo', wp_sanitize_redirect( 'http://example.com/watchthecarriagereturn%0dgo' ) ); - $this->assertEquals( 'http://example.com/watchtheallowedcharacters-~+_.?#=&;,/:%!*stay', wp_sanitize_redirect( 'http://example.com/watchtheallowedcharacters-~+_.?#=&;,/:%!*stay' ) ); - $this->assertEquals( 'http://example.com/watchtheutf8convert%F0%9D%8C%86', wp_sanitize_redirect( "http://example.com/watchtheutf8convert\xf0\x9d\x8c\x86" ) ); + $this->assertSame( 'http://example.com/watchthelinefeedgo', wp_sanitize_redirect( 'http://example.com/watchthelinefeed%0Ago' ) ); + $this->assertSame( 'http://example.com/watchthelinefeedgo', wp_sanitize_redirect( 'http://example.com/watchthelinefeed%0ago' ) ); + $this->assertSame( 'http://example.com/watchthecarriagereturngo', wp_sanitize_redirect( 'http://example.com/watchthecarriagereturn%0Dgo' ) ); + $this->assertSame( 'http://example.com/watchthecarriagereturngo', wp_sanitize_redirect( 'http://example.com/watchthecarriagereturn%0dgo' ) ); + $this->assertSame( 'http://example.com/watchtheallowedcharacters-~+_.?#=&;,/:%!*stay', wp_sanitize_redirect( 'http://example.com/watchtheallowedcharacters-~+_.?#=&;,/:%!*stay' ) ); + $this->assertSame( 'http://example.com/watchtheutf8convert%F0%9D%8C%86', wp_sanitize_redirect( "http://example.com/watchtheutf8convert\xf0\x9d\x8c\x86" ) ); // Nesting checks. - $this->assertEquals( 'http://example.com/watchthecarriagereturngo', wp_sanitize_redirect( 'http://example.com/watchthecarriagereturn%0%0ddgo' ) ); - $this->assertEquals( 'http://example.com/watchthecarriagereturngo', wp_sanitize_redirect( 'http://example.com/watchthecarriagereturn%0%0DDgo' ) ); - $this->assertEquals( 'http://example.com/whyisthisintheurl/?param[1]=foo', wp_sanitize_redirect( 'http://example.com/whyisthisintheurl/?param[1]=foo' ) ); - $this->assertEquals( 'http://[2606:2800:220:6d:26bf:1447:aa7]/', wp_sanitize_redirect( 'http://[2606:2800:220:6d:26bf:1447:aa7]/' ) ); - $this->assertEquals( 'http://example.com/search.php?search=(amistillhere)', wp_sanitize_redirect( 'http://example.com/search.php?search=(amistillhere)' ) ); - $this->assertEquals( 'http://example.com/@username', wp_sanitize_redirect( 'http://example.com/@username' ) ); + $this->assertSame( 'http://example.com/watchthecarriagereturngo', wp_sanitize_redirect( 'http://example.com/watchthecarriagereturn%0%0ddgo' ) ); + $this->assertSame( 'http://example.com/watchthecarriagereturngo', wp_sanitize_redirect( 'http://example.com/watchthecarriagereturn%0%0DDgo' ) ); + $this->assertSame( 'http://example.com/whyisthisintheurl/?param[1]=foo', wp_sanitize_redirect( 'http://example.com/whyisthisintheurl/?param[1]=foo' ) ); + $this->assertSame( 'http://[2606:2800:220:6d:26bf:1447:aa7]/', wp_sanitize_redirect( 'http://[2606:2800:220:6d:26bf:1447:aa7]/' ) ); + $this->assertSame( 'http://example.com/search.php?search=(amistillhere)', wp_sanitize_redirect( 'http://example.com/search.php?search=(amistillhere)' ) ); + $this->assertSame( 'http://example.com/@username', wp_sanitize_redirect( 'http://example.com/@username' ) ); } /** * @group 36998 */ function test_wp_sanitize_redirect_should_encode_spaces() { - $this->assertEquals( 'http://example.com/test%20spaces', wp_sanitize_redirect( 'http://example.com/test%20spaces' ) ); - $this->assertEquals( 'http://example.com/test%20spaces%20in%20url', wp_sanitize_redirect( 'http://example.com/test spaces in url' ) ); + $this->assertSame( 'http://example.com/test%20spaces', wp_sanitize_redirect( 'http://example.com/test%20spaces' ) ); + $this->assertSame( 'http://example.com/test%20spaces%20in%20url', wp_sanitize_redirect( 'http://example.com/test spaces in url' ) ); } /** * @dataProvider valid_url_provider */ function test_wp_validate_redirect_valid_url( $url, $expected ) { - $this->assertEquals( $expected, wp_validate_redirect( $url ) ); + $this->assertSame( $expected, wp_validate_redirect( $url ) ); } /** @@ -183,7 +183,7 @@ class Tests_Formatting_Redirect extends WP_UnitTestCase { // Set the global to current URI. $_SERVER['REQUEST_URI'] = $current_uri; - $this->assertEquals( $expected, wp_validate_redirect( $url, false ) ); + $this->assertSame( $expected, wp_validate_redirect( $url, false ) ); // Delete or reset the global as required. if ( $unset ) { diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index ad7ba280d9..6099901aed 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -9,7 +9,7 @@ class Tests_Functions extends WP_UnitTestCase { $x->_baba = 5; $x->yZ = 'baba'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase $x->a = array( 5, 111, 'x' ); - $this->assertEquals( + $this->assertSame( array( '_baba' => 5, 'yZ' => 'baba', @@ -18,19 +18,19 @@ class Tests_Functions extends WP_UnitTestCase { wp_parse_args( $x ) ); $y = new MockClass; - $this->assertEquals( array(), wp_parse_args( $y ) ); + $this->assertSame( array(), wp_parse_args( $y ) ); } function test_wp_parse_args_array() { // Arrays. $a = array(); - $this->assertEquals( array(), wp_parse_args( $a ) ); + $this->assertSame( array(), wp_parse_args( $a ) ); $b = array( '_baba' => 5, 'yZ' => 'baba', 'a' => array( 5, 111, 'x' ), ); - $this->assertEquals( + $this->assertSame( array( '_baba' => 5, 'yZ' => 'baba', @@ -46,7 +46,7 @@ class Tests_Functions extends WP_UnitTestCase { $x->yZ = 'baba'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase $x->a = array( 5, 111, 'x' ); $d = array( 'pu' => 'bu' ); - $this->assertEquals( + $this->assertSame( array( 'pu' => 'bu', '_baba' => 5, @@ -56,7 +56,7 @@ class Tests_Functions extends WP_UnitTestCase { wp_parse_args( $x, $d ) ); $e = array( '_baba' => 6 ); - $this->assertEquals( + $this->assertSame( array( '_baba' => 5, 'yZ' => 'baba', @@ -69,10 +69,10 @@ class Tests_Functions extends WP_UnitTestCase { function test_wp_parse_args_other() { $b = true; wp_parse_str( $b, $s ); - $this->assertEquals( $s, wp_parse_args( $b ) ); + $this->assertSame( $s, wp_parse_args( $b ) ); $q = 'x=5&_baba=dudu&'; wp_parse_str( $q, $ss ); - $this->assertEquals( $ss, wp_parse_args( $q ) ); + $this->assertSame( $ss, wp_parse_args( $q ) ); } /** @@ -136,7 +136,7 @@ class Tests_Functions extends WP_UnitTestCase { * @dataProvider data_wp_normalize_path */ function test_wp_normalize_path( $path, $expected ) { - $this->assertEquals( $expected, wp_normalize_path( $path ) ); + $this->assertSame( $expected, wp_normalize_path( $path ) ); } function data_wp_normalize_path() { @@ -168,32 +168,32 @@ class Tests_Functions extends WP_UnitTestCase { $testdir = DIR_TESTDATA . '/images/'; // Sanity check. - $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcdefg.png' ), 'Sanitiy check failed' ); + $this->assertSame( 'abcdefg.png', wp_unique_filename( $testdir, 'abcdefg.png' ), 'Sanitiy check failed' ); // Check number is appended for file already exists. $this->assertFileExists( $testdir . 'test-image.png', 'Test image does not exist' ); - $this->assertEquals( 'test-image-1.png', wp_unique_filename( $testdir, 'test-image.png' ), 'Number not appended correctly' ); + $this->assertSame( 'test-image-1.png', wp_unique_filename( $testdir, 'test-image.png' ), 'Number not appended correctly' ); $this->assertFileNotExists( $testdir . 'test-image-1.png' ); // Check special chars. - $this->assertEquals( 'testtest-image.png', wp_unique_filename( $testdir, 'testtést-imagé.png' ), 'Filename with special chars failed' ); + $this->assertSame( 'testtest-image.png', wp_unique_filename( $testdir, 'testtést-imagé.png' ), 'Filename with special chars failed' ); // Check special chars with potential conflicting name. - $this->assertEquals( 'test-image-1.png', wp_unique_filename( $testdir, 'tést-imagé.png' ), 'Filename with special chars failed' ); + $this->assertSame( 'test-image-1.png', wp_unique_filename( $testdir, 'tést-imagé.png' ), 'Filename with special chars failed' ); // Check with single quotes in name (somehow). - $this->assertEquals( 'abcdefgh.png', wp_unique_filename( $testdir, "abcdefg'h.png" ), 'File with quote failed' ); + $this->assertSame( 'abcdefgh.png', wp_unique_filename( $testdir, "abcdefg'h.png" ), 'File with quote failed' ); // Check with double quotes in name (somehow). - $this->assertEquals( 'abcdefgh.png', wp_unique_filename( $testdir, 'abcdefg"h.png' ), 'File with quote failed' ); + $this->assertSame( 'abcdefgh.png', wp_unique_filename( $testdir, 'abcdefg"h.png' ), 'File with quote failed' ); // Test crazy name (useful for regression tests). - $this->assertEquals( '12af34567890@..^_qwerty-fghjkl-zx.png', wp_unique_filename( $testdir, '12%af34567890#~!@#$..%^&*()|_+qwerty fgh`jkl zx<>?:"{}[]="\'/?.png' ), 'Failed crazy file name' ); + $this->assertSame( '12af34567890@..^_qwerty-fghjkl-zx.png', wp_unique_filename( $testdir, '12%af34567890#~!@#$..%^&*()|_+qwerty fgh`jkl zx<>?:"{}[]="\'/?.png' ), 'Failed crazy file name' ); // Test slashes in names. - $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\fg.png' ), 'Slash not removed' ); - $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\fg.png' ), 'Double slashed not removed' ); - $this->assertEquals( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\\fg.png' ), 'Tripple slashed not removed' ); + $this->assertSame( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\fg.png' ), 'Slash not removed' ); + $this->assertSame( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\fg.png' ), 'Double slashed not removed' ); + $this->assertSame( 'abcdefg.png', wp_unique_filename( $testdir, 'abcde\\\fg.png' ), 'Tripple slashed not removed' ); } /** @@ -205,12 +205,12 @@ class Tests_Functions extends WP_UnitTestCase { add_filter( 'upload_dir', array( $this, 'upload_dir_patch_basedir' ) ); // Test collision with "dimension-like" original filename. - $this->assertEquals( 'one-blue-pixel-100x100-1.png', wp_unique_filename( $testdir, 'one-blue-pixel-100x100.png' ) ); + $this->assertSame( 'one-blue-pixel-100x100-1.png', wp_unique_filename( $testdir, 'one-blue-pixel-100x100.png' ) ); // Test collision with existing sub-size filename. // Existing files: one-blue-pixel-100x100.png, one-blue-pixel-1-100x100.png. - $this->assertEquals( 'one-blue-pixel-2.png', wp_unique_filename( $testdir, 'one-blue-pixel.png' ) ); + $this->assertSame( 'one-blue-pixel-2.png', wp_unique_filename( $testdir, 'one-blue-pixel.png' ) ); // Same as above with upper case extension. - $this->assertEquals( 'one-blue-pixel-2.png', wp_unique_filename( $testdir, 'one-blue-pixel.PNG' ) ); + $this->assertSame( 'one-blue-pixel-2.png', wp_unique_filename( $testdir, 'one-blue-pixel.PNG' ) ); remove_filter( 'upload_dir', array( $this, 'upload_dir_patch_basedir' ) ); } @@ -368,9 +368,9 @@ class Tests_Functions extends WP_UnitTestCase { foreach ( $urls as $url ) { $_SERVER['REQUEST_URI'] = 'nothing'; - $this->assertEquals( "$url?foo=1", add_query_arg( 'foo', '1', $url ) ); - $this->assertEquals( "$url?foo=1", add_query_arg( array( 'foo' => '1' ), $url ) ); - $this->assertEquals( + $this->assertSame( "$url?foo=1", add_query_arg( 'foo', '1', $url ) ); + $this->assertSame( "$url?foo=1", add_query_arg( array( 'foo' => '1' ), $url ) ); + $this->assertSame( "$url?foo=2", add_query_arg( array( @@ -380,7 +380,7 @@ class Tests_Functions extends WP_UnitTestCase { $url ) ); - $this->assertEquals( + $this->assertSame( "$url?foo=1&bar=2", add_query_arg( array( @@ -393,9 +393,9 @@ class Tests_Functions extends WP_UnitTestCase { $_SERVER['REQUEST_URI'] = $url; - $this->assertEquals( "$url?foo=1", add_query_arg( 'foo', '1' ) ); - $this->assertEquals( "$url?foo=1", add_query_arg( array( 'foo' => '1' ) ) ); - $this->assertEquals( + $this->assertSame( "$url?foo=1", add_query_arg( 'foo', '1' ) ); + $this->assertSame( "$url?foo=1", add_query_arg( array( 'foo' => '1' ) ) ); + $this->assertSame( "$url?foo=2", add_query_arg( array( @@ -404,7 +404,7 @@ class Tests_Functions extends WP_UnitTestCase { ) ) ); - $this->assertEquals( + $this->assertSame( "$url?foo=1&bar=2", add_query_arg( array( @@ -419,9 +419,9 @@ class Tests_Functions extends WP_UnitTestCase { $_SERVER['REQUEST_URI'] = 'nothing'; $url = str_replace( '#frag', '', $frag_url ); - $this->assertEquals( "$url?foo=1#frag", add_query_arg( 'foo', '1', $frag_url ) ); - $this->assertEquals( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ), $frag_url ) ); - $this->assertEquals( + $this->assertSame( "$url?foo=1#frag", add_query_arg( 'foo', '1', $frag_url ) ); + $this->assertSame( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ), $frag_url ) ); + $this->assertSame( "$url?foo=2#frag", add_query_arg( array( @@ -431,7 +431,7 @@ class Tests_Functions extends WP_UnitTestCase { $frag_url ) ); - $this->assertEquals( + $this->assertSame( "$url?foo=1&bar=2#frag", add_query_arg( array( @@ -444,9 +444,9 @@ class Tests_Functions extends WP_UnitTestCase { $_SERVER['REQUEST_URI'] = $frag_url; - $this->assertEquals( "$url?foo=1#frag", add_query_arg( 'foo', '1' ) ); - $this->assertEquals( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ) ) ); - $this->assertEquals( + $this->assertSame( "$url?foo=1#frag", add_query_arg( 'foo', '1' ) ); + $this->assertSame( "$url?foo=1#frag", add_query_arg( array( 'foo' => '1' ) ) ); + $this->assertSame( "$url?foo=2#frag", add_query_arg( array( @@ -455,7 +455,7 @@ class Tests_Functions extends WP_UnitTestCase { ) ) ); - $this->assertEquals( + $this->assertSame( "$url?foo=1&bar=2#frag", add_query_arg( array( @@ -481,9 +481,9 @@ class Tests_Functions extends WP_UnitTestCase { foreach ( $qs_urls as $url ) { $_SERVER['REQUEST_URI'] = 'nothing'; - $this->assertEquals( "$url&foo=1", add_query_arg( 'foo', '1', $url ) ); - $this->assertEquals( "$url&foo=1", add_query_arg( array( 'foo' => '1' ), $url ) ); - $this->assertEquals( + $this->assertSame( "$url&foo=1", add_query_arg( 'foo', '1', $url ) ); + $this->assertSame( "$url&foo=1", add_query_arg( array( 'foo' => '1' ), $url ) ); + $this->assertSame( "$url&foo=2", add_query_arg( array( @@ -493,7 +493,7 @@ class Tests_Functions extends WP_UnitTestCase { $url ) ); - $this->assertEquals( + $this->assertSame( "$url&foo=1&bar=2", add_query_arg( array( @@ -506,9 +506,9 @@ class Tests_Functions extends WP_UnitTestCase { $_SERVER['REQUEST_URI'] = $url; - $this->assertEquals( "$url&foo=1", add_query_arg( 'foo', '1' ) ); - $this->assertEquals( "$url&foo=1", add_query_arg( array( 'foo' => '1' ) ) ); - $this->assertEquals( + $this->assertSame( "$url&foo=1", add_query_arg( 'foo', '1' ) ); + $this->assertSame( "$url&foo=1", add_query_arg( array( 'foo' => '1' ) ) ); + $this->assertSame( "$url&foo=2", add_query_arg( array( @@ -517,7 +517,7 @@ class Tests_Functions extends WP_UnitTestCase { ) ) ); - $this->assertEquals( + $this->assertSame( "$url&foo=1&bar=2", add_query_arg( array( @@ -536,7 +536,7 @@ class Tests_Functions extends WP_UnitTestCase { */ function test_add_query_arg_numeric_keys() { $url = add_query_arg( array( 'foo' => 'bar' ), '1=1' ); - $this->assertEquals( '1=1&foo=bar', $url ); + $this->assertSame( '1=1&foo=bar', $url ); $url = add_query_arg( array( @@ -545,10 +545,10 @@ class Tests_Functions extends WP_UnitTestCase { ), '1=1' ); - $this->assertEquals( '1=2&foo=bar', $url ); + $this->assertSame( '1=2&foo=bar', $url ); $url = add_query_arg( array( '1' => '2' ), 'foo=bar' ); - $this->assertEquals( 'foo=bar&1=2', $url ); + $this->assertSame( 'foo=bar&1=2', $url ); } /** @@ -600,7 +600,7 @@ class Tests_Functions extends WP_UnitTestCase { $mimes2 = wp_get_mime_types(); $this->assertInternalType( 'array', $mimes2 ); $this->assertNotEmpty( $mimes2 ); - $this->assertEquals( $mimes2, $mimes ); + $this->assertSame( $mimes2, $mimes ); } /** @@ -610,32 +610,32 @@ class Tests_Functions extends WP_UnitTestCase { $orig_blog_charset = get_option( 'blog_charset' ); update_option( 'blog_charset', 'utf8' ); - $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) ); + $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'utf-8' ); - $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) ); + $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'UTF8' ); - $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) ); + $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'UTF-8' ); - $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) ); + $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'ISO-8859-1' ); - $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) ); + $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'ISO8859-1' ); - $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) ); + $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'iso8859-1' ); - $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) ); + $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'iso-8859-1' ); - $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) ); + $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) ); // Arbitrary strings are passed through. update_option( 'blog_charset', 'foobarbaz' ); - $this->assertEquals( 'foobarbaz', get_option( 'blog_charset' ) ); + $this->assertSame( 'foobarbaz', get_option( 'blog_charset' ) ); update_option( 'blog_charset', $orig_blog_charset ); } @@ -706,7 +706,7 @@ class Tests_Functions extends WP_UnitTestCase { $_SERVER['HTTP_USER_AGENT'] = $user_agent; $actual = _device_can_upload(); unset( $_SERVER['HTTP_USER_AGENT'] ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function data_device_can_upload() { @@ -888,14 +888,14 @@ class Tests_Functions extends WP_UnitTestCase { $this->assertNotEmpty( $urls ); $this->assertInternalType( 'array', $urls ); $this->assertCount( count( $original_urls ), $urls ); - $this->assertEquals( $original_urls, $urls ); + $this->assertSame( $original_urls, $urls ); $exploded = array_values( array_filter( array_map( 'trim', explode( "\n", $blob ) ) ) ); // wp_extract_urls() calls html_entity_decode(). $decoded = array_map( 'html_entity_decode', $exploded ); - $this->assertEquals( $decoded, $urls ); - $this->assertEquals( $original_urls, $decoded ); + $this->assertSame( $decoded, $urls ); + $this->assertSame( $original_urls, $decoded ); $blob = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html et dolore magna aliqua. @@ -909,7 +909,7 @@ class Tests_Functions extends WP_UnitTestCase { $this->assertNotEmpty( $urls ); $this->assertInternalType( 'array', $urls ); $this->assertCount( 8, $urls ); - $this->assertEquals( array_slice( $original_urls, 0, 8 ), $urls ); + $this->assertSame( array_slice( $original_urls, 0, 8 ), $urls ); $blob = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore <a href="http://woo.com/1,2,3,4,5,6/-1-2-3-4-/woo.html">343462^</a> et dolore magna aliqua. @@ -923,21 +923,21 @@ class Tests_Functions extends WP_UnitTestCase { $this->assertNotEmpty( $urls ); $this->assertInternalType( 'array', $urls ); $this->assertCount( 8, $urls ); - $this->assertEquals( array_slice( $original_urls, 0, 8 ), $urls ); + $this->assertSame( array_slice( $original_urls, 0, 8 ), $urls ); } /** * @ticket 28786 */ function test_wp_json_encode() { - $this->assertEquals( wp_json_encode( 'a' ), '"a"' ); + $this->assertSame( wp_json_encode( 'a' ), '"a"' ); } /** * @ticket 28786 */ function test_wp_json_encode_utf8() { - $this->assertEquals( wp_json_encode( '这' ), '"\u8fd9"' ); + $this->assertSame( wp_json_encode( '这' ), '"\u8fd9"' ); } /** @@ -958,9 +958,9 @@ class Tests_Functions extends WP_UnitTestCase { $eucjp = mb_convert_encoding( 'aあb', 'EUC-JP', 'UTF-8' ); $utf8 = mb_convert_encoding( $eucjp, 'UTF-8', 'EUC-JP' ); - $this->assertEquals( 'aあb', $utf8 ); + $this->assertSame( 'aあb', $utf8 ); - $this->assertEquals( '"a\u3042b"', wp_json_encode( $eucjp ) ); + $this->assertSame( '"a\u3042b"', wp_json_encode( $eucjp ) ); mb_detect_order( $old_charsets ); } @@ -983,9 +983,9 @@ class Tests_Functions extends WP_UnitTestCase { $eucjp = mb_convert_encoding( 'aあb', 'EUC-JP', 'UTF-8' ); $utf8 = mb_convert_encoding( $eucjp, 'UTF-8', 'EUC-JP' ); - $this->assertEquals( 'aあb', $utf8 ); + $this->assertSame( 'aあb', $utf8 ); - $this->assertEquals( '["c","a\u3042b"]', wp_json_encode( array( 'c', $eucjp ) ) ); + $this->assertSame( '["c","a\u3042b"]', wp_json_encode( array( 'c', $eucjp ) ) ); mb_detect_order( $old_charsets ); } @@ -994,7 +994,7 @@ class Tests_Functions extends WP_UnitTestCase { * @ticket 28786 */ function test_wp_json_encode_array() { - $this->assertEquals( wp_json_encode( array( 'a' ) ), '["a"]' ); + $this->assertSame( wp_json_encode( array( 'a' ) ), '["a"]' ); } /** @@ -1003,7 +1003,7 @@ class Tests_Functions extends WP_UnitTestCase { function test_wp_json_encode_object() { $object = new stdClass; $object->a = 'b'; - $this->assertEquals( wp_json_encode( $object ), '{"a":"b"}' ); + $this->assertSame( wp_json_encode( $object ), '{"a":"b"}' ); } /** @@ -1028,7 +1028,7 @@ class Tests_Functions extends WP_UnitTestCase { $this->assertTrue( is_string( $date_return ), 'The date return must be a string' ); $this->assertNotEmpty( $date_return, 'The date return could not be an empty string' ); - $this->assertEquals( $expected, $date_return, 'The date does not match' ); + $this->assertSame( $expected, $date_return, 'The date does not match' ); $this->assertEquals( new DateTime( $expected ), new DateTime( $date_return ), 'The date is not the same after the call method' ); } @@ -1069,8 +1069,8 @@ class Tests_Functions extends WP_UnitTestCase { foreach ( $extensions as $type => $extension_list ) { foreach ( $extension_list as $extension ) { - $this->assertEquals( $type, wp_ext2type( $extension ) ); - $this->assertEquals( $type, wp_ext2type( strtoupper( $extension ) ) ); + $this->assertSame( $type, wp_ext2type( $extension ) ); + $this->assertSame( $type, wp_ext2type( strtoupper( $extension ) ) ); } } @@ -1095,7 +1095,7 @@ class Tests_Functions extends WP_UnitTestCase { $ini_limit_after = ini_get( 'memory_limit' ); $this->assertSame( $ini_limit_before, $ini_limit_after ); - $this->assertSame( false, $raised_limit ); + $this->assertFalse( $raised_limit ); $this->assertEquals( WP_MAX_MEMORY_LIMIT, $ini_limit_after ); } @@ -1114,7 +1114,7 @@ class Tests_Functions extends WP_UnitTestCase { } $unique_uuids = array_unique( $uuids ); - $this->assertEquals( $uuids, $unique_uuids ); + $this->assertSame( $uuids, $unique_uuids ); } /** @@ -1183,7 +1183,7 @@ class Tests_Functions extends WP_UnitTestCase { $this->assertTrue( is_numeric( $id ) ); $ids[] = $id; } - $this->assertEquals( $ids, array_unique( $ids ) ); + $this->assertSame( $ids, array_unique( $ids ) ); // Test with prefix. $ids = array(); @@ -1192,7 +1192,7 @@ class Tests_Functions extends WP_UnitTestCase { $this->assertRegExp( '/^foo-\d+$/', $id ); $ids[] = $id; } - $this->assertEquals( $ids, array_unique( $ids ) ); + $this->assertSame( $ids, array_unique( $ids ) ); } /** @@ -1204,7 +1204,7 @@ class Tests_Functions extends WP_UnitTestCase { $this->markTestSkipped( 'The exif PHP extension is not loaded.' ); } - $this->assertEquals( $expected, wp_get_image_mime( $file ) ); + $this->assertSame( $expected, wp_get_image_mime( $file ) ); } /** @@ -1216,7 +1216,7 @@ class Tests_Functions extends WP_UnitTestCase { $this->markTestSkipped( 'The fileinfo PHP extension is not loaded.' ); } - $this->assertEquals( $expected, wp_check_filetype_and_ext( $file, $filename ) ); + $this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) ); } /** @@ -1238,7 +1238,7 @@ class Tests_Functions extends WP_UnitTestCase { ); add_filter( 'upload_mimes', array( $this, '_filter_mime_types_svg' ) ); - $this->assertEquals( $expected, wp_check_filetype_and_ext( $file, $filename ) ); + $this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) ); // Cleanup. remove_filter( 'upload_mimes', array( $this, '_test_add_mime_types_svg' ) ); @@ -1263,7 +1263,7 @@ class Tests_Functions extends WP_UnitTestCase { ); add_filter( 'upload_mimes', array( $this, '_filter_mime_types_woff' ) ); - $this->assertEquals( $expected, wp_check_filetype_and_ext( $file, $filename ) ); + $this->assertSame( $expected, wp_check_filetype_and_ext( $file, $filename ) ); // Cleanup. remove_filter( 'upload_mimes', array( $this, '_test_add_mime_types_woff' ) ); diff --git a/tests/phpunit/tests/functions/allowedProtocols.php b/tests/phpunit/tests/functions/allowedProtocols.php index 6ac0ec0f2f..9caf236074 100644 --- a/tests/phpunit/tests/functions/allowedProtocols.php +++ b/tests/phpunit/tests/functions/allowedProtocols.php @@ -29,8 +29,8 @@ class Tests_Functions_AllowedProtocols extends WP_UnitTestCase { * @param string Example URL. */ function test_allowed_protocols( $protocol, $url ) { - $this->assertEquals( $url, esc_url( $url, $protocol ) ); - $this->assertEquals( $url, esc_url( $url, wp_allowed_protocols() ) ); + $this->assertSame( $url, esc_url( $url, $protocol ) ); + $this->assertSame( $url, esc_url( $url, wp_allowed_protocols() ) ); } /** diff --git a/tests/phpunit/tests/functions/anonymization.php b/tests/phpunit/tests/functions/anonymization.php index 231df96035..786b4cd238 100644 --- a/tests/phpunit/tests/functions/anonymization.php +++ b/tests/phpunit/tests/functions/anonymization.php @@ -36,7 +36,7 @@ class Tests_Functions_Anonymization extends WP_UnitTestCase { /* Todo test ipv6_fallback mode if keeping it.*/ - $this->assertEquals( $expected_result, $actual_result ); + $this->assertSame( $expected_result, $actual_result ); } /** @@ -226,7 +226,7 @@ class Tests_Functions_Anonymization extends WP_UnitTestCase { * Test date anonymization of `wp_privacy_anonymize_data()`. */ public function test_anonymize_date() { - $this->assertEquals( '0000-00-00 00:00:00', wp_privacy_anonymize_data( 'date', '2003-12-25 12:34:56' ) ); + $this->assertSame( '0000-00-00 00:00:00', wp_privacy_anonymize_data( 'date', '2003-12-25 12:34:56' ) ); } /** @@ -234,7 +234,7 @@ class Tests_Functions_Anonymization extends WP_UnitTestCase { */ public function test_anonymize_text() { $text = __( 'Four score and seven years ago' ); - $this->assertEquals( '[deleted]', wp_privacy_anonymize_data( 'text', $text ) ); + $this->assertSame( '[deleted]', wp_privacy_anonymize_data( 'text', $text ) ); } /** @@ -242,7 +242,7 @@ class Tests_Functions_Anonymization extends WP_UnitTestCase { */ public function test_anonymize_long_text() { $text = __( 'Four score and seven years ago' ); - $this->assertEquals( 'This content was deleted by the author.', wp_privacy_anonymize_data( 'longtext', $text ) ); + $this->assertSame( 'This content was deleted by the author.', wp_privacy_anonymize_data( 'longtext', $text ) ); } /** diff --git a/tests/phpunit/tests/functions/canonicalCharset.php b/tests/phpunit/tests/functions/canonicalCharset.php index bd128b769e..ac89b1ec08 100644 --- a/tests/phpunit/tests/functions/canonicalCharset.php +++ b/tests/phpunit/tests/functions/canonicalCharset.php @@ -9,43 +9,43 @@ class Tests_Functions_CanonicalCharset extends WP_UnitTestCase { public function test_utf_8_lower() { - $this->assertEquals( 'UTF-8', _canonical_charset( 'utf-8' ) ); + $this->assertSame( 'UTF-8', _canonical_charset( 'utf-8' ) ); } public function test_utf_8_upper() { - $this->assertEquals( 'UTF-8', _canonical_charset( 'UTF-8' ) ); + $this->assertSame( 'UTF-8', _canonical_charset( 'UTF-8' ) ); } public function test_utf_8_mixxed() { - $this->assertEquals( 'UTF-8', _canonical_charset( 'Utf-8' ) ); + $this->assertSame( 'UTF-8', _canonical_charset( 'Utf-8' ) ); } public function test_utf_8() { - $this->assertEquals( 'UTF-8', _canonical_charset( 'UTF8' ) ); + $this->assertSame( 'UTF-8', _canonical_charset( 'UTF8' ) ); } public function test_iso_lower() { - $this->assertEquals( 'ISO-8859-1', _canonical_charset( 'iso-8859-1' ) ); + $this->assertSame( 'ISO-8859-1', _canonical_charset( 'iso-8859-1' ) ); } public function test_iso_upper() { - $this->assertEquals( 'ISO-8859-1', _canonical_charset( 'ISO-8859-1' ) ); + $this->assertSame( 'ISO-8859-1', _canonical_charset( 'ISO-8859-1' ) ); } public function test_iso_mixxed() { - $this->assertEquals( 'ISO-8859-1', _canonical_charset( 'Iso8859-1' ) ); + $this->assertSame( 'ISO-8859-1', _canonical_charset( 'Iso8859-1' ) ); } public function test_iso() { - $this->assertEquals( 'ISO-8859-1', _canonical_charset( 'ISO8859-1' ) ); + $this->assertSame( 'ISO-8859-1', _canonical_charset( 'ISO8859-1' ) ); } public function test_random() { - $this->assertEquals( 'random', _canonical_charset( 'random' ) ); + $this->assertSame( 'random', _canonical_charset( 'random' ) ); } public function test_empty() { - $this->assertEquals( '', _canonical_charset( '' ) ); + $this->assertSame( '', _canonical_charset( '' ) ); } /** @@ -55,32 +55,32 @@ class Tests_Functions_CanonicalCharset extends WP_UnitTestCase { $orig_blog_charset = get_option( 'blog_charset' ); update_option( 'blog_charset', 'utf8' ); - $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) ); + $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'utf-8' ); - $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) ); + $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'UTF8' ); - $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) ); + $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'UTF-8' ); - $this->assertEquals( 'UTF-8', get_option( 'blog_charset' ) ); + $this->assertSame( 'UTF-8', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'ISO-8859-1' ); - $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) ); + $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'ISO8859-1' ); - $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) ); + $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'iso8859-1' ); - $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) ); + $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) ); update_option( 'blog_charset', 'iso-8859-1' ); - $this->assertEquals( 'ISO-8859-1', get_option( 'blog_charset' ) ); + $this->assertSame( 'ISO-8859-1', get_option( 'blog_charset' ) ); // Arbitrary strings are passed through. update_option( 'blog_charset', 'foobarbaz' ); - $this->assertEquals( 'foobarbaz', get_option( 'blog_charset' ) ); + $this->assertSame( 'foobarbaz', get_option( 'blog_charset' ) ); update_option( 'blog_charset', $orig_blog_charset ); } diff --git a/tests/phpunit/tests/functions/cleanupHeaderComment.php b/tests/phpunit/tests/functions/cleanupHeaderComment.php index 9bc0d73cd5..d7557c8813 100644 --- a/tests/phpunit/tests/functions/cleanupHeaderComment.php +++ b/tests/phpunit/tests/functions/cleanupHeaderComment.php @@ -17,7 +17,7 @@ class Tests_Functions_CleanupHeaderComment extends WP_UnitTestCase { * @param string $expected */ public function test_cleanup_header_comment( $test_string, $expected ) { - $this->assertEqualsIgnoreEOL( $expected, _cleanup_header_comment( $test_string ) ); + $this->assertSameIgnoreEOL( $expected, _cleanup_header_comment( $test_string ) ); } /** diff --git a/tests/phpunit/tests/functions/getWeekstartend.php b/tests/phpunit/tests/functions/getWeekstartend.php index 978f49eee7..ee76275be6 100644 --- a/tests/phpunit/tests/functions/getWeekstartend.php +++ b/tests/phpunit/tests/functions/getWeekstartend.php @@ -11,7 +11,7 @@ class Tests_Functions_GetWeekstartend extends WP_UnitTestCase { 'end' => 1455494399, ); - $this->assertEquals( $expected, get_weekstartend( '2016-02-12' ) ); + $this->assertSame( $expected, get_weekstartend( '2016-02-12' ) ); } public function test_start_of_week_sunday() { @@ -20,7 +20,7 @@ class Tests_Functions_GetWeekstartend extends WP_UnitTestCase { 'end' => 1455407999, ); - $this->assertEquals( $expected, get_weekstartend( '2016-02-12', 0 ) ); + $this->assertSame( $expected, get_weekstartend( '2016-02-12', 0 ) ); } public function test_start_of_week_should_fall_back_on_start_of_week_option() { @@ -31,7 +31,7 @@ class Tests_Functions_GetWeekstartend extends WP_UnitTestCase { 'end' => 1455580799, ); - $this->assertEquals( $expected, get_weekstartend( '2016-02-12' ) ); + $this->assertSame( $expected, get_weekstartend( '2016-02-12' ) ); } public function test_start_of_week_should_fall_back_on_sunday_when_option_is_missing() { @@ -42,6 +42,6 @@ class Tests_Functions_GetWeekstartend extends WP_UnitTestCase { 'end' => 1455407999, ); - $this->assertEquals( $expected, get_weekstartend( '2016-02-12' ) ); + $this->assertSame( $expected, get_weekstartend( '2016-02-12' ) ); } } diff --git a/tests/phpunit/tests/functions/numberFormatI18n.php b/tests/phpunit/tests/functions/numberFormatI18n.php index db10ff50a8..803b8ec02c 100644 --- a/tests/phpunit/tests/functions/numberFormatI18n.php +++ b/tests/phpunit/tests/functions/numberFormatI18n.php @@ -16,8 +16,8 @@ class Tests_Functions_NumberFormatI18n extends WP_UnitTestCase { $GLOBALS['wp_locale'] = $locale; - $this->assertEquals( '123,457', $actual_1 ); - $this->assertEquals( '123,456.7890', $actual_2 ); + $this->assertSame( '123,457', $actual_1 ); + $this->assertSame( '123,456.7890', $actual_2 ); } public function test_should_respect_number_format_of_locale() { @@ -33,17 +33,17 @@ class Tests_Functions_NumberFormatI18n extends WP_UnitTestCase { $GLOBALS['wp_locale']->number_format['decimal_point'] = $decimal_point; $GLOBALS['wp_locale']->number_format['thousands_sep'] = $thousands_sep; - $this->assertEquals( '123^457', $actual_1 ); - $this->assertEquals( '123^456@7890', $actual_2 ); + $this->assertSame( '123^457', $actual_1 ); + $this->assertSame( '123^456@7890', $actual_2 ); } public function test_should_default_to_en_us_format() { - $this->assertEquals( '123,457', number_format_i18n( 123456.789, 0 ) ); - $this->assertEquals( '123,456.7890', number_format_i18n( 123456.789, 4 ) ); + $this->assertSame( '123,457', number_format_i18n( 123456.789, 0 ) ); + $this->assertSame( '123,456.7890', number_format_i18n( 123456.789, 4 ) ); } public function test_should_handle_negative_precision() { - $this->assertEquals( '123,457', number_format_i18n( 123456.789, 0 ) ); - $this->assertEquals( '123,456.7890', number_format_i18n( 123456.789, -4 ) ); + $this->assertSame( '123,457', number_format_i18n( 123456.789, 0 ) ); + $this->assertSame( '123,456.7890', number_format_i18n( 123456.789, -4 ) ); } } diff --git a/tests/phpunit/tests/functions/removeQueryArg.php b/tests/phpunit/tests/functions/removeQueryArg.php index b55f903d98..3d53f881e0 100644 --- a/tests/phpunit/tests/functions/removeQueryArg.php +++ b/tests/phpunit/tests/functions/removeQueryArg.php @@ -11,7 +11,7 @@ class Tests_Functions_RemoveQueryArg extends WP_UnitTestCase { $actual = remove_query_arg( $keys_to_remove, $url ); $this->assertNotEmpty( $actual ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } public function remove_query_arg_provider() { diff --git a/tests/phpunit/tests/functions/wpGetArchives.php b/tests/phpunit/tests/functions/wpGetArchives.php index 7eaf356b06..35d011921d 100644 --- a/tests/phpunit/tests/functions/wpGetArchives.php +++ b/tests/phpunit/tests/functions/wpGetArchives.php @@ -31,12 +31,12 @@ class Tests_Functions_wpGetArchives extends WP_UnitTestCase { function test_wp_get_archives_default() { $expected['default'] = "<li><a href='" . $this->month_url . "'>" . gmdate( 'F Y' ) . '</a></li>'; - $this->assertEquals( $expected['default'], trim( wp_get_archives( array( 'echo' => false ) ) ) ); + $this->assertSame( $expected['default'], trim( wp_get_archives( array( 'echo' => false ) ) ) ); } function test_wp_get_archives_type() { $expected['type'] = "<li><a href='" . $this->year_url . "'>" . gmdate( 'Y' ) . '</a></li>'; - $this->assertEquals( + $this->assertSame( $expected['type'], trim( wp_get_archives( @@ -71,7 +71,7 @@ class Tests_Functions_wpGetArchives extends WP_UnitTestCase { <li><a href='$link4'>$title4</a></li> <li><a href='$link5'>$title5</a></li> EOF; - $this->assertEqualsIgnoreEOL( + $this->assertSameIgnoreEOL( $expected['limit'], trim( wp_get_archives( @@ -87,7 +87,7 @@ EOF; function test_wp_get_archives_format() { $expected['format'] = "<option value='" . $this->month_url . "'> " . gmdate( 'F Y' ) . ' </option>'; - $this->assertEquals( + $this->assertSame( $expected['format'], trim( wp_get_archives( @@ -102,7 +102,7 @@ EOF; function test_wp_get_archives_before_and_after() { $expected['before_and_after'] = "<div><a href='" . $this->month_url . "'>" . gmdate( 'F Y' ) . '</a></div>'; - $this->assertEquals( + $this->assertSame( $expected['before_and_after'], trim( wp_get_archives( @@ -119,7 +119,7 @@ EOF; function test_wp_get_archives_show_post_count() { $expected['show_post_count'] = "<li><a href='" . $this->month_url . "'>" . gmdate( 'F Y' ) . '</a> (8)</li>'; - $this->assertEquals( + $this->assertSame( $expected['show_post_count'], trim( wp_get_archives( @@ -153,7 +153,7 @@ EOF; <li><a href='{$oct_url}'>October 2012</a></li> <li><a href='{$this->month_url}'>$date_full</a></li> EOF; - $this->assertEqualsIgnoreEOL( + $this->assertSameIgnoreEOL( $expected['order_asc'], trim( wp_get_archives( @@ -169,7 +169,7 @@ EOF; <li><a href='{$this->month_url}'>$date_full</a></li> <li><a href='{$oct_url}'>October 2012</a></li> EOF; - $this->assertEqualsIgnoreEOL( + $this->assertSameIgnoreEOL( $expected['order_desc'], trim( wp_get_archives( @@ -204,6 +204,6 @@ EOF; 'post_type' => 'taco', ) ); - $this->assertEquals( $expected, trim( $archives ) ); + $this->assertSame( $expected, trim( $archives ) ); } } diff --git a/tests/phpunit/tests/functions/wpListFilter.php b/tests/phpunit/tests/functions/wpListFilter.php index 4708cea16f..e347308804 100644 --- a/tests/phpunit/tests/functions/wpListFilter.php +++ b/tests/phpunit/tests/functions/wpListFilter.php @@ -49,7 +49,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { ), 'AND' ); - $this->assertEquals( 2, count( $list ) ); + $this->assertSame( 2, count( $list ) ); $this->assertArrayHasKey( 'foo', $list ); $this->assertArrayHasKey( 'bar', $list ); } @@ -63,7 +63,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { ), 'OR' ); - $this->assertEquals( 3, count( $list ) ); + $this->assertSame( 3, count( $list ) ); $this->assertArrayHasKey( 'foo', $list ); $this->assertArrayHasKey( 'bar', $list ); $this->assertArrayHasKey( 'baz', $list ); @@ -78,7 +78,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { ), 'NOT' ); - $this->assertEquals( 1, count( $list ) ); + $this->assertSame( 1, count( $list ) ); $this->assertArrayHasKey( 'baz', $list ); } @@ -92,7 +92,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { 'AND', 'name' ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'foo', 'bar' => 'bar', @@ -111,7 +111,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { 'OR', 'name' ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'foo', 'bar' => 'bar', @@ -130,12 +130,12 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { 'NOT', 'name' ); - $this->assertEquals( array( 'baz' => 'baz' ), $list ); + $this->assertSame( array( 'baz' => 'baz' ), $list ); } function test_wp_list_pluck() { $list = wp_list_pluck( $this->object_list, 'name' ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'foo', 'bar' => 'bar', @@ -145,7 +145,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { ); $list = wp_list_pluck( $this->array_list, 'name' ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'foo', 'bar' => 'bar', @@ -160,7 +160,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { */ function test_wp_list_pluck_index_key() { $list = wp_list_pluck( $this->array_list, 'name', 'id' ); - $this->assertEquals( + $this->assertSame( array( 'f' => 'foo', 'b' => 'bar', @@ -175,7 +175,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { */ function test_wp_list_pluck_object_index_key() { $list = wp_list_pluck( $this->object_list, 'name', 'id' ); - $this->assertEquals( + $this->assertSame( array( 'f' => 'foo', 'b' => 'bar', @@ -190,7 +190,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { */ function test_wp_list_pluck_missing_index_key() { $list = wp_list_pluck( $this->array_list, 'name', 'nonexistent' ); - $this->assertEquals( + $this->assertSame( array( 0 => 'foo', 1 => 'bar', @@ -207,7 +207,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { $array_list = $this->array_list; unset( $array_list['bar']['id'] ); $list = wp_list_pluck( $array_list, 'name', 'id' ); - $this->assertEquals( + $this->assertSame( array( 'f' => 'foo', 0 => 'bar', @@ -224,7 +224,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { $mixed_list = $this->array_list; $mixed_list['bar'] = (object) $mixed_list['bar']; $list = wp_list_pluck( $mixed_list, 'name', 'id' ); - $this->assertEquals( + $this->assertSame( array( 'f' => 'foo', 'b' => 'bar', @@ -247,7 +247,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { $this->assertInstanceOf( 'stdClass', $ref_list[1] ); $list = wp_list_pluck( $ref_list, 'name' ); - $this->assertEquals( + $this->assertSame( array( 'foo', 'bar', @@ -272,7 +272,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { $this->assertInstanceOf( 'stdClass', $ref_list[1] ); $list = wp_list_pluck( $ref_list, 'name', 'id' ); - $this->assertEquals( + $this->assertSame( array( 'f' => 'foo', 'b' => 'bar', @@ -286,13 +286,13 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { function test_filter_object_list_nested_array_and() { $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'AND' ); - $this->assertEquals( 1, count( $list ) ); + $this->assertSame( 1, count( $list ) ); $this->assertArrayHasKey( 'baz', $list ); } function test_filter_object_list_nested_array_not() { $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'red' ) ), 'NOT' ); - $this->assertEquals( 2, count( $list ) ); + $this->assertSame( 2, count( $list ) ); $this->assertArrayHasKey( 'bar', $list ); $this->assertArrayHasKey( 'baz', $list ); } @@ -306,26 +306,26 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { ), 'OR' ); - $this->assertEquals( 2, count( $list ) ); + $this->assertSame( 2, count( $list ) ); $this->assertArrayHasKey( 'foo', $list ); $this->assertArrayHasKey( 'baz', $list ); } function test_filter_object_list_nested_array_or_singular() { $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'OR' ); - $this->assertEquals( 1, count( $list ) ); + $this->assertSame( 1, count( $list ) ); $this->assertArrayHasKey( 'baz', $list ); } function test_filter_object_list_nested_array_and_field() { $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'AND', 'name' ); - $this->assertEquals( array( 'baz' => 'baz' ), $list ); + $this->assertSame( array( 'baz' => 'baz' ), $list ); } function test_filter_object_list_nested_array_not_field() { $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'green' ) ), 'NOT', 'name' ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'foo', 'baz' => 'baz', @@ -344,7 +344,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { 'OR', 'name' ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'foo', 'baz' => 'baz', diff --git a/tests/phpunit/tests/functions/wpListUtil.php b/tests/phpunit/tests/functions/wpListUtil.php index d6a014357c..6368b87d05 100644 --- a/tests/phpunit/tests/functions/wpListUtil.php +++ b/tests/phpunit/tests/functions/wpListUtil.php @@ -691,7 +691,7 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase { * @param string $order Either 'ASC' or 'DESC'. */ public function test_wp_list_sort( $list, $orderby, $order, $expected ) { - $this->assertEquals( $expected, wp_list_sort( $list, $orderby, $order ) ); + $this->assertSame( $expected, wp_list_sort( $list, $orderby, $order ) ); } public function data_test_wp_list_sort_preserve_keys() { @@ -1016,7 +1016,7 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase { * @param string $order Either 'ASC' or 'DESC'. */ public function test_wp_list_sort_preserve_keys( $list, $orderby, $order, $expected ) { - $this->assertEquals( $expected, wp_list_sort( $list, $orderby, $order, true ) ); + $this->assertSame( $expected, wp_list_sort( $list, $orderby, $order, true ) ); } public function test_wp_list_util_get_input() { diff --git a/tests/phpunit/tests/functions/wpRemoteFopen.php b/tests/phpunit/tests/functions/wpRemoteFopen.php index 3d52b82ba1..ce3d8f37dd 100644 --- a/tests/phpunit/tests/functions/wpRemoteFopen.php +++ b/tests/phpunit/tests/functions/wpRemoteFopen.php @@ -29,6 +29,6 @@ class Tests_Functions_wpRemoteFopen extends WP_UnitTestCase { $response = wp_remote_fopen( $url ); $this->assertInternalType( 'string', $response ); - $this->assertEquals( 40148, strlen( $response ) ); + $this->assertSame( 40148, strlen( $response ) ); } } diff --git a/tests/phpunit/tests/general/archives.php b/tests/phpunit/tests/general/archives.php index f32bb6bcbc..88cfbd8311 100644 --- a/tests/phpunit/tests/general/archives.php +++ b/tests/phpunit/tests/general/archives.php @@ -32,7 +32,7 @@ class Tests_General_Archives extends WP_UnitTestCase { $this->assertInternalType( 'string', $result ); $time1 = wp_cache_get( 'last_changed', 'posts' ); $this->assertNotEmpty( $time1 ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); $num_queries = $wpdb->num_queries; @@ -44,8 +44,8 @@ class Tests_General_Archives extends WP_UnitTestCase { ) ); $this->assertInternalType( 'string', $result ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); // Change args, resulting in a different query string. Cache is not primed, expect 1 query. $result = wp_get_archives( @@ -56,8 +56,8 @@ class Tests_General_Archives extends WP_UnitTestCase { ) ); $this->assertInternalType( 'string', $result ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); $num_queries = $wpdb->num_queries; @@ -70,8 +70,8 @@ class Tests_General_Archives extends WP_UnitTestCase { ) ); $this->assertInternalType( 'string', $result ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); $num_queries = $wpdb->num_queries; @@ -83,8 +83,8 @@ class Tests_General_Archives extends WP_UnitTestCase { ) ); $this->assertInternalType( 'string', $result ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); $num_queries = $wpdb->num_queries; @@ -96,8 +96,8 @@ class Tests_General_Archives extends WP_UnitTestCase { ) ); $this->assertInternalType( 'string', $result ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); // Change type. Cache is not primed, expect 1 query. $result = wp_get_archives( @@ -107,8 +107,8 @@ class Tests_General_Archives extends WP_UnitTestCase { ) ); $this->assertInternalType( 'string', $result ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); $num_queries = $wpdb->num_queries; @@ -120,8 +120,8 @@ class Tests_General_Archives extends WP_UnitTestCase { ) ); $this->assertInternalType( 'string', $result ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); // Change type. Cache is not primed, expect 1 query. $result = wp_get_archives( @@ -131,8 +131,8 @@ class Tests_General_Archives extends WP_UnitTestCase { ) ); $this->assertInternalType( 'string', $result ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); $num_queries = $wpdb->num_queries; @@ -144,8 +144,8 @@ class Tests_General_Archives extends WP_UnitTestCase { ) ); $this->assertInternalType( 'string', $result ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); // Change type. Cache is not primed, expect 1 query. $result = wp_get_archives( @@ -155,8 +155,8 @@ class Tests_General_Archives extends WP_UnitTestCase { ) ); $this->assertInternalType( 'string', $result ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); $num_queries = $wpdb->num_queries; @@ -168,7 +168,7 @@ class Tests_General_Archives extends WP_UnitTestCase { ) ); $this->assertInternalType( 'string', $result ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); } } diff --git a/tests/phpunit/tests/general/document-title.php b/tests/phpunit/tests/general/document-title.php index 826a14a7cd..a15f926ea9 100644 --- a/tests/phpunit/tests/general/document-title.php +++ b/tests/phpunit/tests/general/document-title.php @@ -80,7 +80,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase { add_filter( 'pre_get_document_title', array( $this, '_short_circuit_title' ) ); - $this->assertEquals( 'A Wild Title', wp_get_document_title() ); + $this->assertSame( 'A Wild Title', wp_get_document_title() ); } function _short_circuit_title( $title ) { @@ -101,12 +101,12 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase { add_filter( 'document_title_parts', array( $this, '_front_page_title_parts' ) ); $this->go_to( '/' ); - $this->assertEquals( sprintf( '%s – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( '%s – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); update_option( 'show_on_front', 'posts' ); $this->go_to( '/' ); - $this->assertEquals( sprintf( '%s – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( '%s – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); } function _front_page_title_parts( $parts ) { @@ -129,7 +129,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase { // Show page name on home page if it's not the front page. $this->go_to( get_permalink( $blog_page_id ) ); - $this->assertEquals( sprintf( 'blog-page – %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( 'blog-page – %s', $this->blog_name ), wp_get_document_title() ); } function test_paged_title() { @@ -137,7 +137,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase { add_filter( 'document_title_parts', array( $this, '_paged_title_parts' ) ); - $this->assertEquals( sprintf( '%s – Page 4 – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( '%s – Page 4 – Just another WordPress site', $this->blog_name ), wp_get_document_title() ); } function _paged_title_parts( $parts ) { @@ -154,7 +154,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase { add_filter( 'document_title_parts', array( $this, '_singular_title_parts' ) ); - $this->assertEquals( sprintf( 'test_title – %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( 'test_title – %s', $this->blog_name ), wp_get_document_title() ); } function _singular_title_parts( $parts ) { @@ -168,19 +168,19 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase { function test_category_title() { $this->go_to( '?cat=' . self::$category_id ); - $this->assertEquals( sprintf( 'test_category – %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( 'test_category – %s', $this->blog_name ), wp_get_document_title() ); } function test_search_title() { $this->go_to( '?s=test_title' ); - $this->assertEquals( sprintf( 'Search Results for “test_title” – %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( 'Search Results for “test_title” – %s', $this->blog_name ), wp_get_document_title() ); } function test_author_title() { $this->go_to( '?author=' . self::$author_id ); - $this->assertEquals( sprintf( 'test_author – %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( 'test_author – %s', $this->blog_name ), wp_get_document_title() ); } function test_post_type_archive_title() { @@ -203,31 +203,31 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase { $this->go_to( '?post_type=cpt' ); - $this->assertEquals( sprintf( 'test_cpt – %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( 'test_cpt – %s', $this->blog_name ), wp_get_document_title() ); } function test_year_title() { $this->go_to( '?year=2015' ); - $this->assertEquals( sprintf( '2015 – %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( '2015 – %s', $this->blog_name ), wp_get_document_title() ); } function test_month_title() { $this->go_to( '?monthnum=09' ); - $this->assertEquals( sprintf( 'September 2015 – %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( 'September 2015 – %s', $this->blog_name ), wp_get_document_title() ); } function test_day_title() { $this->go_to( '?day=22' ); - $this->assertEquals( sprintf( 'September 22, 2015 – %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( 'September 22, 2015 – %s', $this->blog_name ), wp_get_document_title() ); } function test_404_title() { $this->go_to( '?m=404' ); - $this->assertEquals( sprintf( 'Page not found – %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( 'Page not found – %s', $this->blog_name ), wp_get_document_title() ); } function test_paged_post_title() { @@ -235,7 +235,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase { add_filter( 'title_tag_parts', array( $this, '_paged_post_title_parts' ) ); - $this->assertEquals( sprintf( 'test_title – Page 4 – %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( 'test_title – Page 4 – %s', $this->blog_name ), wp_get_document_title() ); } function _paged_post_title_parts( $parts ) { @@ -252,7 +252,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase { add_filter( 'document_title_parts', array( $this, '_rearrange_title_parts' ) ); - $this->assertEquals( sprintf( '%s – test_title', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( '%s – test_title', $this->blog_name ), wp_get_document_title() ); } function _rearrange_title_parts( $parts ) { @@ -269,7 +269,7 @@ class Tests_General_DocumentTitle extends WP_UnitTestCase { add_filter( 'document_title_separator', array( $this, '_change_title_separator' ) ); - $this->assertEquals( sprintf( 'test_title %%%% %s', $this->blog_name ), wp_get_document_title() ); + $this->assertSame( sprintf( 'test_title %%%% %s', $this->blog_name ), wp_get_document_title() ); } function _change_title_separator( $sep ) { diff --git a/tests/phpunit/tests/general/paginateLinks.php b/tests/phpunit/tests/general/paginateLinks.php index 95692a0524..be6ce5b2ea 100644 --- a/tests/phpunit/tests/general/paginateLinks.php +++ b/tests/phpunit/tests/general/paginateLinks.php @@ -25,7 +25,7 @@ class Tests_Paginate_Links extends WP_UnitTestCase { EXPECTED; $links = paginate_links( array( 'total' => 50 ) ); - $this->assertEqualsIgnoreEOL( $expected, $links ); + $this->assertSameIgnoreEOL( $expected, $links ); } function test_format() { @@ -48,7 +48,7 @@ EXPECTED; 'format' => 'page/%#%/', ) ); - $this->assertEqualsIgnoreEOL( $expected, $links ); + $this->assertSameIgnoreEOL( $expected, $links ); } function test_prev_next_false() { @@ -73,7 +73,7 @@ EXPECTED; 'current' => 2, ) ); - $this->assertEqualsIgnoreEOL( $expected, $links ); + $this->assertSameIgnoreEOL( $expected, $links ); } function test_prev_next_true() { @@ -100,7 +100,7 @@ EXPECTED; 'current' => 2, ) ); - $this->assertEqualsIgnoreEOL( $expected, $links ); + $this->assertSameIgnoreEOL( $expected, $links ); } function increment_i18n_count() { @@ -125,7 +125,7 @@ EXPECTED; ); // The links should be: // < Previous 1 ... 49 50 51 ... 100 Next > - $this->assertEquals( 5, $this->i18n_count ); + $this->assertSame( 5, $this->i18n_count ); remove_filter( 'number_format_i18n', array( $this, 'increment_i18n_count' ) ); } @@ -170,8 +170,8 @@ EXPECTED; $href = $tag->attributes->getNamedItem( 'href' )->value; $class = $tag->attributes->getNamedItem( 'class' )->value; - $this->assertEquals( $attributes['href'], $href ); - $this->assertEquals( $attributes['class'], $class ); + $this->assertSame( $attributes['href'], $href ); + $this->assertSame( $attributes['class'], $class ); } // Current page: 1. @@ -190,14 +190,14 @@ EXPECTED; $this->assertNotNull( $tag ); $class = $tag->attributes->getNamedItem( 'class' )->value; - $this->assertEquals( 'page-numbers current', $class ); + $this->assertSame( 'page-numbers current', $class ); $document->loadHTML( $links[1] ); $tag = $document->getElementsByTagName( 'a' )->item( 0 ); $this->assertNotNull( $tag ); $href = $tag->attributes->getNamedItem( 'href' )->value; - $this->assertEquals( get_pagenum_link( 2 ), $href ); + $this->assertSame( get_pagenum_link( 2 ), $href ); } function add_query_arg( $url ) { @@ -244,7 +244,7 @@ EXPECTED; $this->assertNotNull( $tag ); $href = $tag->attributes->getNamedItem( 'href' )->value; - $this->assertEquals( $expected_href, $href ); + $this->assertSame( $expected_href, $href ); } } @@ -284,7 +284,7 @@ EXPECTED; $this->assertNotNull( $tag ); $href = $tag->attributes->getNamedItem( 'href' )->value; - $this->assertEquals( $expected_href, $href ); + $this->assertSame( $expected_href, $href ); } } diff --git a/tests/phpunit/tests/general/resourceHints.php b/tests/phpunit/tests/general/resourceHints.php index 624256f54c..d3d10cbecb 100644 --- a/tests/phpunit/tests/general/resourceHints.php +++ b/tests/phpunit/tests/general/resourceHints.php @@ -50,7 +50,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase { remove_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_domains' ) ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function _add_dns_prefetch_domains( $hints, $method ) { @@ -82,7 +82,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase { remove_filter( 'wp_resource_hints', array( $this, '_add_preconnect_domains' ) ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function _add_preconnect_domains( $hints, $method ) { @@ -109,7 +109,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase { remove_filter( 'wp_resource_hints', array( $this, '_add_prerender_urls' ) ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function _add_prerender_urls( $hints, $method ) { @@ -133,7 +133,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase { remove_filter( 'wp_resource_hints', array( $this, '_add_dns_prefetch_long_urls' ) ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function _add_dns_prefetch_long_urls( $hints, $method ) { @@ -159,7 +159,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase { wp_dequeue_style( 'googlefonts' ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } @@ -178,7 +178,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase { wp_dequeue_style( 'googlefonts' ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function test_dns_prefetch_scripts_does_not_included_registered_only() { @@ -191,7 +191,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase { wp_deregister_script( 'jquery-elsewhere' ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); $this->assertNotContains( $unexpected, $actual ); } @@ -205,7 +205,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase { wp_deregister_script( 'test-script' ); $actual = get_echo( 'wp_resource_hints' ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** @@ -218,13 +218,13 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase { add_filter( 'wp_resource_hints', array( $this, '_add_malformed_url_errant_colon' ), 10, 2 ); $actual = get_echo( 'wp_resource_hints' ); remove_filter( 'wp_resource_hints', array( $this, '_add_malformed_url_errant_colon' ) ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); // Unsupported Scheme. add_filter( 'wp_resource_hints', array( $this, '_add_malformed_url_unsupported_scheme' ), 10, 2 ); $actual = get_echo( 'wp_resource_hints' ); remove_filter( 'wp_resource_hints', array( $this, '_add_malformed_url_unsupported_scheme' ) ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function _add_malformed_url_errant_colon( $hints, $method ) { @@ -259,7 +259,7 @@ class Tests_WP_Resource_Hints extends WP_UnitTestCase { remove_filter( 'wp_resource_hints', array( $this, '_add_url_with_attributes' ) ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function _add_url_with_attributes( $hints, $method ) { diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php index e6c3d104f9..096cf8bce8 100644 --- a/tests/phpunit/tests/general/template.php +++ b/tests/phpunit/tests/general/template.php @@ -38,7 +38,7 @@ class Tests_General_Template extends WP_UnitTestCase { $this->assertEmpty( get_site_icon_url() ); $this->_set_site_icon(); - $this->assertEquals( $this->site_icon_url, get_site_icon_url() ); + $this->assertSame( $this->site_icon_url, get_site_icon_url() ); $this->_remove_site_icon(); $this->assertEmpty( get_site_icon_url() ); @@ -323,7 +323,7 @@ class Tests_General_Template extends WP_UnitTestCase { restore_current_blog(); $expected_custom_logo = '<a href="' . $home_url . '" class="custom-logo-link" rel="home">' . $image . '</a>'; - $this->assertEquals( $expected_custom_logo, get_custom_logo( $blog_id ) ); + $this->assertSame( $expected_custom_logo, get_custom_logo( $blog_id ) ); } /** @@ -554,8 +554,8 @@ class Tests_General_Template extends WP_UnitTestCase { * @dataProvider data_selected_and_checked_with_equal_values */ function test_selected_and_checked_with_equal_values( $selected, $current ) { - $this->assertEquals( " selected='selected'", selected( $selected, $current, false ) ); - $this->assertEquals( " checked='checked'", checked( $selected, $current, false ) ); + $this->assertSame( " selected='selected'", selected( $selected, $current, false ) ); + $this->assertSame( " checked='checked'", checked( $selected, $current, false ) ); } function data_selected_and_checked_with_equal_values() { @@ -578,8 +578,8 @@ class Tests_General_Template extends WP_UnitTestCase { * @dataProvider data_selected_and_checked_with_non_equal_values */ function test_selected_and_checked_with_non_equal_values( $selected, $current ) { - $this->assertEquals( '', selected( $selected, $current, false ) ); - $this->assertEquals( '', checked( $selected, $current, false ) ); + $this->assertSame( '', selected( $selected, $current, false ) ); + $this->assertSame( '', checked( $selected, $current, false ) ); } function data_selected_and_checked_with_non_equal_values() { diff --git a/tests/phpunit/tests/general/wpError.php b/tests/phpunit/tests/general/wpError.php index 72a575fbf7..1a7e36c1d8 100644 --- a/tests/phpunit/tests/general/wpError.php +++ b/tests/phpunit/tests/general/wpError.php @@ -60,7 +60,7 @@ class Tests_WP_Error extends WP_UnitTestCase { public function test_WP_Error_with_code_and_empty_message_and_empty_data_should_add_error_but_not_associated_data() { $wp_error = new WP_Error( 'code' ); - $this->assertSame( null, $wp_error->get_error_data( 'code' ) ); + $this->assertNull( $wp_error->get_error_data( 'code' ) ); } public function test_WP_Error_with_code_and_empty_message_and_non_empty_data_should_add_error_with_empty_message_and_that_stored_data() { @@ -272,7 +272,7 @@ class Tests_WP_Error extends WP_UnitTestCase { * @covers ::get_error_data */ public function test_get_error_data_with_empty_code_and_no_errors_should_evaluate_as_null() { - $this->assertSame( null, $this->wp_error->get_error_data() ); + $this->assertNull( $this->wp_error->get_error_data() ); } /** @@ -281,7 +281,7 @@ class Tests_WP_Error extends WP_UnitTestCase { public function test_get_error_data_with_empty_code_one_error_no_data_should_evaluate_as_null() { $this->wp_error->add( 'code', 'message' ); - $this->assertSame( null, $this->wp_error->get_error_data() ); + $this->assertNull( $this->wp_error->get_error_data() ); } /** @@ -291,7 +291,7 @@ class Tests_WP_Error extends WP_UnitTestCase { $this->wp_error->add( 'code', 'message' ); $this->wp_error->add( 'code2', 'message2' ); - $this->assertSame( null, $this->wp_error->get_error_data() ); + $this->assertNull( $this->wp_error->get_error_data() ); } /** @@ -330,7 +330,7 @@ class Tests_WP_Error extends WP_UnitTestCase { * @covers ::get_error_data */ public function test_get_error_data_with_code_and_no_errors_should_evaluate_as_null() { - $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) ); + $this->assertNull( $this->wp_error->get_error_data( 'code' ) ); } /** @@ -339,7 +339,7 @@ class Tests_WP_Error extends WP_UnitTestCase { public function test_get_error_data_with_code_and_one_error_with_no_data_should_evaluate_as_null() { $this->wp_error->add( 'code', 'message' ); - $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) ); + $this->assertNull( $this->wp_error->get_error_data( 'code' ) ); } /** @@ -450,7 +450,7 @@ class Tests_WP_Error extends WP_UnitTestCase { public function test_add_with_code_empty_message_empty_data_should_not_add_error_data() { $this->wp_error->add( 'code', '' ); - $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) ); + $this->assertNull( $this->wp_error->get_error_data( 'code' ) ); } /** @@ -468,7 +468,7 @@ class Tests_WP_Error extends WP_UnitTestCase { public function test_add_with_code_and_message_and_empty_data_should_not_alter_stored_data() { $this->wp_error->add( 'code', 'message' ); - $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) ); + $this->assertNull( $this->wp_error->get_error_data( 'code' ) ); } /** diff --git a/tests/phpunit/tests/hooks/addFilter.php b/tests/phpunit/tests/hooks/addFilter.php index 5e9c0e75e3..2c134ef333 100644 --- a/tests/phpunit/tests/hooks/addFilter.php +++ b/tests/phpunit/tests/hooks/addFilter.php @@ -20,8 +20,8 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase { $hook->add_filter( $tag, $callback, $priority, $accepted_args ); $function_index = _wp_filter_build_unique_id( $tag, $callback, $priority ); - $this->assertEquals( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] ); - $this->assertEquals( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] ); + $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] ); + $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] ); } public function test_add_filter_with_object() { @@ -35,8 +35,8 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase { $hook->add_filter( $tag, $callback, $priority, $accepted_args ); $function_index = _wp_filter_build_unique_id( $tag, $callback, $priority ); - $this->assertEquals( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] ); - $this->assertEquals( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] ); + $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] ); + $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] ); } public function test_add_filter_with_static_method() { @@ -49,8 +49,8 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase { $hook->add_filter( $tag, $callback, $priority, $accepted_args ); $function_index = _wp_filter_build_unique_id( $tag, $callback, $priority ); - $this->assertEquals( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] ); - $this->assertEquals( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] ); + $this->assertSame( $callback, $hook->callbacks[ $priority ][ $function_index ]['function'] ); + $this->assertSame( $accepted_args, $hook->callbacks[ $priority ][ $function_index ]['accepted_args'] ); } public function test_add_two_filters_with_same_priority() { @@ -124,7 +124,7 @@ class Tests_WP_Hook_Add_Filter extends WP_UnitTestCase { $hook->add_filter( $tag, array( $b, 'action' ), 5, 1 ); $hook->add_filter( $tag, array( $c, 'action' ), 8, 1 ); - $this->assertEquals( array( 5, 8, 10 ), array_keys( $hook->callbacks ) ); + $this->assertSame( array( 5, 8, 10 ), array_keys( $hook->callbacks ) ); } public function test_remove_and_add() { diff --git a/tests/phpunit/tests/hooks/applyFilters.php b/tests/phpunit/tests/hooks/applyFilters.php index 1879cbf70b..a50f21bf38 100644 --- a/tests/phpunit/tests/hooks/applyFilters.php +++ b/tests/phpunit/tests/hooks/applyFilters.php @@ -20,8 +20,8 @@ class Tests_WP_Hook_Apply_Filters extends WP_UnitTestCase { $returned = $hook->apply_filters( $arg, array( $arg ) ); - $this->assertEquals( $returned, $arg ); - $this->assertEquals( 1, $a->get_call_count() ); + $this->assertSame( $returned, $arg ); + $this->assertSame( 1, $a->get_call_count() ); } public function test_apply_filters_with_multiple_calls() { @@ -38,8 +38,8 @@ class Tests_WP_Hook_Apply_Filters extends WP_UnitTestCase { $returned_one = $hook->apply_filters( $arg, array( $arg ) ); $returned_two = $hook->apply_filters( $returned_one, array( $returned_one ) ); - $this->assertEquals( $returned_two, $arg ); - $this->assertEquals( 2, $a->get_call_count() ); + $this->assertSame( $returned_two, $arg ); + $this->assertSame( 2, $a->get_call_count() ); } } diff --git a/tests/phpunit/tests/hooks/doAction.php b/tests/phpunit/tests/hooks/doAction.php index 34f90eae3a..542edf14ac 100644 --- a/tests/phpunit/tests/hooks/doAction.php +++ b/tests/phpunit/tests/hooks/doAction.php @@ -27,7 +27,7 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase { $hook->add_filter( $tag, $callback, $priority, $accepted_args ); $hook->do_action( array( $arg ) ); - $this->assertEquals( 1, $a->get_call_count() ); + $this->assertSame( 1, $a->get_call_count() ); } public function test_do_action_with_multiple_calls() { @@ -43,7 +43,7 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase { $hook->do_action( array( $arg ) ); $hook->do_action( array( $arg ) ); - $this->assertEquals( 2, $a->get_call_count() ); + $this->assertSame( 2, $a->get_call_count() ); } public function test_do_action_with_multiple_callbacks_on_same_priority() { @@ -61,8 +61,8 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase { $hook->add_filter( $tag, $callback_two, $priority, $accepted_args ); $hook->do_action( array( $arg ) ); - $this->assertEquals( 1, $a->get_call_count() ); - $this->assertEquals( 1, $a->get_call_count() ); + $this->assertSame( 1, $a->get_call_count() ); + $this->assertSame( 1, $a->get_call_count() ); } public function test_do_action_with_multiple_callbacks_on_different_priorities() { @@ -80,8 +80,8 @@ class Tests_WP_Hook_Do_Action extends WP_UnitTestCase { $hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args ); $hook->do_action( array( $arg ) ); - $this->assertEquals( 1, $a->get_call_count() ); - $this->assertEquals( 1, $a->get_call_count() ); + $this->assertSame( 1, $a->get_call_count() ); + $this->assertSame( 1, $a->get_call_count() ); } public function test_do_action_with_no_accepted_args() { diff --git a/tests/phpunit/tests/hooks/doAllHook.php b/tests/phpunit/tests/hooks/doAllHook.php index abaf92525b..d848b5ab16 100644 --- a/tests/phpunit/tests/hooks/doAllHook.php +++ b/tests/phpunit/tests/hooks/doAllHook.php @@ -21,6 +21,6 @@ class Tests_WP_Hook_Do_All_Hook extends WP_UnitTestCase { $hook->do_all_hook( $args ); $hook->do_all_hook( $args ); - $this->assertEquals( 2, $a->get_call_count() ); + $this->assertSame( 2, $a->get_call_count() ); } } diff --git a/tests/phpunit/tests/hooks/hasFilter.php b/tests/phpunit/tests/hooks/hasFilter.php index 61b79861c3..bf63ee6e06 100644 --- a/tests/phpunit/tests/hooks/hasFilter.php +++ b/tests/phpunit/tests/hooks/hasFilter.php @@ -16,7 +16,7 @@ class Tests_WP_Hook_Has_Filter extends WP_UnitTestCase { $hook->add_filter( $tag, $callback, $priority, $accepted_args ); - $this->assertEquals( $priority, $hook->has_filter( $tag, $callback ) ); + $this->assertSame( $priority, $hook->has_filter( $tag, $callback ) ); } public function test_has_filter_with_object() { @@ -29,7 +29,7 @@ class Tests_WP_Hook_Has_Filter extends WP_UnitTestCase { $hook->add_filter( $tag, $callback, $priority, $accepted_args ); - $this->assertEquals( $priority, $hook->has_filter( $tag, $callback ) ); + $this->assertSame( $priority, $hook->has_filter( $tag, $callback ) ); } public function test_has_filter_with_static_method() { @@ -41,7 +41,7 @@ class Tests_WP_Hook_Has_Filter extends WP_UnitTestCase { $hook->add_filter( $tag, $callback, $priority, $accepted_args ); - $this->assertEquals( $priority, $hook->has_filter( $tag, $callback ) ); + $this->assertSame( $priority, $hook->has_filter( $tag, $callback ) ); } public function test_has_filter_without_callback() { diff --git a/tests/phpunit/tests/hooks/preinitHooks.php b/tests/phpunit/tests/hooks/preinitHooks.php index 8211a16b3b..7eb5efe5cc 100644 --- a/tests/phpunit/tests/hooks/preinitHooks.php +++ b/tests/phpunit/tests/hooks/preinitHooks.php @@ -33,7 +33,7 @@ class Tests_WP_Hook_Preinit_Hooks extends WP_UnitTestCase { $hooks = WP_Hook::build_preinitialized_hooks( $filters ); - $this->assertEquals( $priority1, $hooks[ $tag1 ]->has_filter( $tag1, '__return_false' ) ); - $this->assertEquals( $priority2, $hooks[ $tag2 ]->has_filter( $tag2, '__return_null' ) ); + $this->assertSame( $priority1, $hooks[ $tag1 ]->has_filter( $tag1, '__return_false' ) ); + $this->assertSame( $priority2, $hooks[ $tag2 ]->has_filter( $tag2, '__return_null' ) ); } } diff --git a/tests/phpunit/tests/hooks/removeAllFilters.php b/tests/phpunit/tests/hooks/removeAllFilters.php index 9a0f013d0f..1437c57248 100644 --- a/tests/phpunit/tests/hooks/removeAllFilters.php +++ b/tests/phpunit/tests/hooks/removeAllFilters.php @@ -36,6 +36,6 @@ class Tests_WP_Hook_Remove_All_Filters extends WP_UnitTestCase { $this->assertFalse( $hook->has_filter( $tag, $callback_one ) ); $this->assertTrue( $hook->has_filters() ); - $this->assertEquals( $priority + 1, $hook->has_filter( $tag, $callback_two ) ); + $this->assertSame( $priority + 1, $hook->has_filter( $tag, $callback_two ) ); } } diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index d438056126..fdc78ffe3c 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -57,7 +57,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( 200, (int) $res['response']['code'] ); + $this->assertSame( 200, (int) $res['response']['code'] ); } function test_redirect_on_302() { @@ -66,7 +66,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( 200, (int) $res['response']['code'] ); + $this->assertSame( 200, (int) $res['response']['code'] ); } /** @@ -78,7 +78,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( 301, (int) $res['response']['code'] ); + $this->assertSame( 301, (int) $res['response']['code'] ); } /** @@ -90,7 +90,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( 302, (int) $res['response']['code'] ); + $this->assertSame( 302, (int) $res['response']['code'] ); } function test_redirections_equal() { @@ -99,7 +99,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( 200, (int) $res['response']['code'] ); + $this->assertSame( 200, (int) $res['response']['code'] ); } function test_no_head_redirections() { @@ -108,7 +108,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( 302, (int) $res['response']['code'] ); + $this->assertSame( 302, (int) $res['response']['code'] ); } /** @@ -126,7 +126,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( 200, (int) $res['response']['code'] ); + $this->assertSame( 200, (int) $res['response']['code'] ); } function test_redirections_greater() { @@ -162,7 +162,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( 302, (int) $res['response']['code'] ); + $this->assertSame( 302, (int) $res['response']['code'] ); } /** @@ -176,7 +176,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( 'PASS', $res['body'] ); + $this->assertSame( 'PASS', $res['body'] ); } /** @@ -197,7 +197,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { ); $this->skipTestOnTimeout( $res ); - $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); + $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); $this->assertTrue( ! empty( $res['headers']['location'] ) ); } @@ -252,9 +252,9 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( '', $res['body'] ); // The body should be empty. + $this->assertSame( '', $res['body'] ); // The body should be empty. $this->assertEquals( $size, $res['headers']['content-length'] ); // Check the headers are returned (and the size is the same). - $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters. + $this->assertSame( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters. $this->assertStringStartsWith( get_temp_dir(), $res['filename'] ); // Check it's saving within the temp directory. } @@ -281,7 +281,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters. + $this->assertSame( $size, $filesize ); // Check that the file is written to disk correctly without any extra characters. } @@ -304,7 +304,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $this->skipTestOnTimeout( $res ); $this->assertNotWPError( $res ); - $this->assertEquals( $size, strlen( $res['body'] ) ); + $this->assertSame( $size, strlen( $res['body'] ) ); } /** @@ -320,7 +320,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $res = wp_remote_post( add_query_arg( 'response_code', $response_code, $url ), array( 'timeout' => 30 ) ); $this->skipTestOnTimeout( $res ); - $this->assertEquals( $method, wp_remote_retrieve_body( $res ) ); + $this->assertSame( $method, wp_remote_retrieve_body( $res ) ); } public function data_post_redirect_to_method_300() { @@ -367,7 +367,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $res = wp_remote_get( $url, $args ); $this->skipTestOnTimeout( $res ); - $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); + $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); } @@ -409,7 +409,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $res = wp_remote_get( $url, array( 'timeout' => 30 ) ); $this->skipTestOnTimeout( $res ); - $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); + $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); } @@ -424,7 +424,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $res = wp_remote_get( $url ); $this->skipTestOnTimeout( $res ); - $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); + $this->assertSame( 'PASS', wp_remote_retrieve_body( $res ) ); } /** diff --git a/tests/phpunit/tests/http/functions.php b/tests/phpunit/tests/http/functions.php index de272d9a0e..d28936fde6 100644 --- a/tests/phpunit/tests/http/functions.php +++ b/tests/phpunit/tests/http/functions.php @@ -25,9 +25,9 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { $this->assertInternalType( 'array', $response ); - $this->assertEquals( 'image/jpeg', $headers['content-type'] ); - $this->assertEquals( '40148', $headers['content-length'] ); - $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) ); + $this->assertSame( 'image/jpeg', $headers['content-type'] ); + $this->assertSame( '40148', $headers['content-length'] ); + $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } function test_head_redirect() { @@ -36,7 +36,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { $response = wp_remote_head( $url ); $this->skipTestOnTimeout( $response ); - $this->assertEquals( '301', wp_remote_retrieve_response_code( $response ) ); + $this->assertSame( 301, wp_remote_retrieve_response_code( $response ) ); } function test_head_404() { @@ -44,7 +44,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { $response = wp_remote_head( $url ); $this->skipTestOnTimeout( $response ); - $this->assertEquals( '404', wp_remote_retrieve_response_code( $response ) ); + $this->assertSame( 404, wp_remote_retrieve_response_code( $response ) ); } function test_get_request() { @@ -59,9 +59,9 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { $this->assertInternalType( 'array', $response ); // Should return the same headers as a HEAD request. - $this->assertEquals( 'image/jpeg', $headers['content-type'] ); - $this->assertEquals( '40148', $headers['content-length'] ); - $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) ); + $this->assertSame( 'image/jpeg', $headers['content-type'] ); + $this->assertSame( '40148', $headers['content-length'] ); + $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } function test_get_redirect() { @@ -75,9 +75,9 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { $headers = wp_remote_retrieve_headers( $response ); // Should return the same headers as a HEAD request. - $this->assertEquals( 'image/jpeg', $headers['content-type'] ); - $this->assertEquals( '40148', $headers['content-length'] ); - $this->assertEquals( '200', wp_remote_retrieve_response_code( $response ) ); + $this->assertSame( 'image/jpeg', $headers['content-type'] ); + $this->assertSame( '40148', $headers['content-length'] ); + $this->assertSame( 200, wp_remote_retrieve_response_code( $response ) ); } function test_get_redirect_limit_exceeded() { @@ -196,7 +196,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { // Check the host_only flag in the resulting WP_Http_Cookie. $cookie = wp_remote_retrieve_cookie( $response, 'test' ); - $this->assertEquals( $cookie->domain, 'wordpress.org' ); + $this->assertSame( $cookie->domain, 'wordpress.org' ); $this->assertFalse( $cookie->host_only, 'host-only flag not set' ); // Regurgitate (Requests_Cookie -> WP_Http_Cookie -> Requests_Cookie). diff --git a/tests/phpunit/tests/http/http.php b/tests/phpunit/tests/http/http.php index f18e6b719f..4986f1719b 100644 --- a/tests/phpunit/tests/http/http.php +++ b/tests/phpunit/tests/http/http.php @@ -13,7 +13,7 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase { */ function test_make_absolute_url( $relative_url, $absolute_url, $expected ) { $actual = WP_Http::make_absolute_url( $relative_url, $absolute_url ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function make_absolute_url_testcases() { @@ -72,7 +72,7 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase { */ function test_wp_parse_url( $url, $expected ) { $actual = wp_parse_url( $url ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function parse_url_testcases() { @@ -183,7 +183,7 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase { */ function test_wp_parse_url_with_default_component() { $actual = wp_parse_url( self::FULL_TEST_URL, -1 ); - $this->assertEquals( + $this->assertSame( array( 'scheme' => 'http', 'host' => 'host.name', @@ -271,7 +271,7 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase { // This primes the `$wp_header_to_desc` global: get_status_header_desc( 200 ); - $this->assertEquals( array_keys( $wp_header_to_desc ), array_values( $constants ) ); + $this->assertSame( array_keys( $wp_header_to_desc ), array_values( $constants ) ); } diff --git a/tests/phpunit/tests/http/remoteRetrieveHeaders.php b/tests/phpunit/tests/http/remoteRetrieveHeaders.php index 4551df7c54..1d4e42f2e9 100644 --- a/tests/phpunit/tests/http/remoteRetrieveHeaders.php +++ b/tests/phpunit/tests/http/remoteRetrieveHeaders.php @@ -13,7 +13,7 @@ class Tests_HTTP_RemoteRetrieveHeaders extends WP_UnitTestCase { $response = array( 'headers' => $headers ); $result = wp_remote_retrieve_headers( $response ); - $this->assertEquals( $headers, $result ); + $this->assertSame( $headers, $result ); } /** @@ -23,7 +23,7 @@ class Tests_HTTP_RemoteRetrieveHeaders extends WP_UnitTestCase { $response = new WP_Error( 'Some error' ); $result = wp_remote_retrieve_headers( $response ); - $this->assertEquals( array(), $result ); + $this->assertSame( array(), $result ); } /** @@ -33,6 +33,6 @@ class Tests_HTTP_RemoteRetrieveHeaders extends WP_UnitTestCase { $response = array( 'no_headers' => 'set' ); $result = wp_remote_retrieve_headers( $response ); - $this->assertEquals( array(), $result ); + $this->assertSame( array(), $result ); } } diff --git a/tests/phpunit/tests/image/base.php b/tests/phpunit/tests/image/base.php index 3c32052b63..8392c548a0 100644 --- a/tests/phpunit/tests/image/base.php +++ b/tests/phpunit/tests/image/base.php @@ -48,7 +48,7 @@ abstract class WP_Image_UnitTestCase extends WP_UnitTestCase { $colors = imagecolorsforindex( $im, $rgb ); - $this->assertEquals( $alpha, $colors['alpha'] ); + $this->assertSame( $alpha, $colors['alpha'] ); } /** @@ -62,7 +62,7 @@ abstract class WP_Image_UnitTestCase extends WP_UnitTestCase { $im = new Imagick( $image_path ); $pixel = $im->getImagePixelColor( $point[0], $point[1] ); $color = $pixel->getColorValue( imagick::COLOR_ALPHA ); - $this->assertEquals( $expected, $color ); + $this->assertSame( $expected, $color ); } /** @@ -85,7 +85,7 @@ abstract class WP_Image_UnitTestCase extends WP_UnitTestCase { $detected_height = $image_size[1]; } - $this->assertEquals( $width, $detected_width ); - $this->assertEquals( $height, $detected_height ); + $this->assertSame( $width, $detected_width ); + $this->assertSame( $height, $detected_height ); } } diff --git a/tests/phpunit/tests/image/dimensions.php b/tests/phpunit/tests/image/dimensions.php index 2dd75808f8..bbab2d3b39 100644 --- a/tests/phpunit/tests/image/dimensions.php +++ b/tests/phpunit/tests/image/dimensions.php @@ -10,72 +10,72 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { // Landscape: resize 640x480 to fit 400x400: 400x300. $out = image_resize_dimensions( 640, 480, 400, 400, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out ); // Portrait: resize 480x640 to fit 400x400: 300x400. $out = image_resize_dimensions( 480, 640, 400, 400, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); } function test_400x0_no_crop() { // Landscape: resize 640x480 to fit 400w: 400x300. $out = image_resize_dimensions( 640, 480, 400, 0, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out ); // Portrait: resize 480x640 to fit 400w: 400x533. $out = image_resize_dimensions( 480, 640, 400, 0, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out ); } function test_0x400_no_crop() { // Landscape: resize 640x480 to fit 400h: 533x400. $out = image_resize_dimensions( 640, 480, 0, 400, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 533, 400, 640, 480 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 533, 400, 640, 480 ), $out ); // Portrait: resize 480x640 to fit 400h: 300x400. $out = image_resize_dimensions( 480, 640, 0, 400, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); } function test_800x800_no_crop() { // Landscape: resize 640x480 to fit 800x800. $out = image_resize_dimensions( 640, 480, 800, 800, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( false, $out ); + $this->assertFalse( $out ); // Portrait: resize 480x640 to fit 800x800. $out = image_resize_dimensions( 480, 640, 800, 800, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( false, $out ); + $this->assertFalse( $out ); } function test_800x0_no_crop() { // Landscape: resize 640x480 to fit 800w. $out = image_resize_dimensions( 640, 480, 800, 0, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( false, $out ); + $this->assertFalse( $out ); // Portrait: resize 480x640 to fit 800w. $out = image_resize_dimensions( 480, 640, 800, 0, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( false, $out ); + $this->assertFalse( $out ); } function test_0x800_no_crop() { // Landscape: resize 640x480 to fit 800h. $out = image_resize_dimensions( 640, 480, 0, 800, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( false, $out ); + $this->assertFalse( $out ); // Portrait: resize 480x640 to fit 800h. $out = image_resize_dimensions( 480, 640, 0, 800, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( false, $out ); + $this->assertFalse( $out ); } // Cropped versions. @@ -84,48 +84,48 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { // Landscape: crop 640x480 to fit 400x400: 400x400 taken from a 480x480 crop at (80. 0). $out = image_resize_dimensions( 640, 480, 400, 400, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 80, 0, 400, 400, 480, 480 ), $out ); + $this->assertSame( array( 0, 0, 80, 0, 400, 400, 480, 480 ), $out ); // Portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop at (0. 80). $out = image_resize_dimensions( 480, 640, 400, 400, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 80, 400, 400, 480, 480 ), $out ); + $this->assertSame( array( 0, 0, 0, 80, 400, 400, 480, 480 ), $out ); } function test_400x0_crop() { // Landscape: resize 640x480 to fit 400w: 400x300. $out = image_resize_dimensions( 640, 480, 400, 0, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 400, 300, 640, 480 ), $out ); // Portrait: resize 480x640 to fit 400w: 400x533. $out = image_resize_dimensions( 480, 640, 400, 0, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out ); } function test_0x400_crop() { // Landscape: resize 640x480 to fit 400h: 533x400. $out = image_resize_dimensions( 640, 480, 0, 400, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 533, 400, 640, 480 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 533, 400, 640, 480 ), $out ); // Portrait: resize 480x640 to fit 400h: 300x400. $out = image_resize_dimensions( 480, 640, 0, 400, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); } function test_400x500_crop() { // Landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop at (80. 0). $out = image_resize_dimensions( 640, 480, 400, 500, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 120, 0, 400, 480, 400, 480 ), $out ); + $this->assertSame( array( 0, 0, 120, 0, 400, 480, 400, 480 ), $out ); // Portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop at (0. 80). $out = image_resize_dimensions( 480, 640, 400, 500, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 20, 400, 500, 480, 600 ), $out ); + $this->assertSame( array( 0, 0, 0, 20, 400, 500, 480, 600 ), $out ); } function test_640x480() { @@ -143,12 +143,12 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { // Crop 640x480 to fit 640x480 (no change). $out = image_resize_dimensions( 640, 480, 640, 480, true ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 640, 480, 640, 480 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 640, 480, 640, 480 ), $out ); // Resize 640x480 to fit 640x480 (no change). $out = image_resize_dimensions( 640, 480, 640, 480, false ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 640, 480, 640, 480 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 640, 480, 640, 480 ), $out ); remove_filter( 'wp_image_resize_identical_dimensions', '__return_true' ); } @@ -161,25 +161,25 @@ class Tests_Image_Dimensions extends WP_UnitTestCase { // src_x = 0 (left), src_y = 0 (top). $out = image_resize_dimensions( 640, 480, 400, 500, array( 'left', 'top' ) ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 400, 480, 400, 480 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 400, 480, 400, 480 ), $out ); // Portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop. // src_x = 0 (left), src_y = 0 (top). $out = image_resize_dimensions( 480, 640, 400, 500, array( 'left', 'top' ) ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 0, 400, 500, 480, 600 ), $out ); + $this->assertSame( array( 0, 0, 0, 0, 400, 500, 480, 600 ), $out ); // Landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop. // src_x = 240 (left), src_y = 0 (due to landscape crop). $out = image_resize_dimensions( 640, 480, 400, 500, array( 'right', 'bottom' ) ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 240, 0, 400, 480, 400, 480 ), $out ); + $this->assertSame( array( 0, 0, 240, 0, 400, 480, 400, 480 ), $out ); // Portrait: resize 480x640 to fit 400x400: 400x400 taken from a 480x480 crop. // src_x = 0 (due to portrait crop), src_y = 40 (bottom). $out = image_resize_dimensions( 480, 640, 400, 500, array( 'right', 'bottom' ) ); // dst_x, dst_y, src_x, src_y, dst_w, dst_h, src_w, src_h. - $this->assertEquals( array( 0, 0, 0, 40, 400, 500, 480, 600 ), $out ); + $this->assertSame( array( 0, 0, 0, 40, 400, 500, 480, 600 ), $out ); } } diff --git a/tests/phpunit/tests/image/editor.php b/tests/phpunit/tests/image/editor.php index f602915331..34e2b29fd4 100644 --- a/tests/phpunit/tests/image/editor.php +++ b/tests/phpunit/tests/image/editor.php @@ -74,20 +74,20 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase { $editor->set_mime_type( 'image/jpeg' ); // Ensure mime-specific filters act properly. // Check default value. - $this->assertEquals( 82, $editor->get_quality() ); + $this->assertSame( 82, $editor->get_quality() ); // Ensure the quality filters do not have precedence if created after editor instantiation. $func_100_percent = array( $this, 'return_integer_100' ); add_filter( 'wp_editor_set_quality', $func_100_percent ); - $this->assertEquals( 82, $editor->get_quality() ); + $this->assertSame( 82, $editor->get_quality() ); $func_95_percent = array( $this, 'return_integer_95' ); add_filter( 'jpeg_quality', $func_95_percent ); - $this->assertEquals( 82, $editor->get_quality() ); + $this->assertSame( 82, $editor->get_quality() ); // Ensure set_quality() works and overrides the filters. $this->assertTrue( $editor->set_quality( 75 ) ); - $this->assertEquals( 75, $editor->get_quality() ); + $this->assertSame( 75, $editor->get_quality() ); // Get a new editor to clear default quality state. unset( $editor ); @@ -95,7 +95,7 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase { $editor->set_mime_type( 'image/jpeg' ); // Ensure mime-specific filters act properly. // Ensure jpeg_quality filter applies if it exists before editor instantiation. - $this->assertEquals( 95, $editor->get_quality() ); + $this->assertSame( 95, $editor->get_quality() ); // Get a new editor to clear jpeg_quality state. remove_filter( 'jpeg_quality', $func_95_percent ); @@ -103,7 +103,7 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase { $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); // Ensure wp_editor_set_quality filter applies if it exists before editor instantiation. - $this->assertEquals( 100, $editor->get_quality() ); + $this->assertSame( 100, $editor->get_quality() ); // Clean up. remove_filter( 'wp_editor_set_quality', $func_100_percent ); @@ -130,19 +130,19 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase { ); // Test with no parameters. - $this->assertEquals( 'canola-100x50.jpg', wp_basename( $editor->generate_filename() ) ); + $this->assertSame( 'canola-100x50.jpg', wp_basename( $editor->generate_filename() ) ); // Test with a suffix only. - $this->assertEquals( 'canola-new.jpg', wp_basename( $editor->generate_filename( 'new' ) ) ); + $this->assertSame( 'canola-new.jpg', wp_basename( $editor->generate_filename( 'new' ) ) ); // Test with a destination dir only. - $this->assertEquals( trailingslashit( realpath( get_temp_dir() ) ), trailingslashit( realpath( dirname( $editor->generate_filename( null, get_temp_dir() ) ) ) ) ); + $this->assertSame( trailingslashit( realpath( get_temp_dir() ) ), trailingslashit( realpath( dirname( $editor->generate_filename( null, get_temp_dir() ) ) ) ) ); // Test with a suffix only. - $this->assertEquals( 'canola-100x50.png', wp_basename( $editor->generate_filename( null, null, 'png' ) ) ); + $this->assertSame( 'canola-100x50.png', wp_basename( $editor->generate_filename( null, null, 'png' ) ) ); // Combo! - $this->assertEquals( trailingslashit( realpath( get_temp_dir() ) ) . 'canola-new.png', $editor->generate_filename( 'new', realpath( get_temp_dir() ), 'png' ) ); + $this->assertSame( trailingslashit( realpath( get_temp_dir() ) ) . 'canola-new.png', $editor->generate_filename( 'new', realpath( get_temp_dir() ), 'png' ) ); } /** @@ -166,7 +166,7 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase { $property->setAccessible( true ); $property->setValue( $editor, $size ); - $this->assertEquals( $size, $editor->get_size() ); + $this->assertSame( $size, $editor->get_size() ); } /** @@ -189,6 +189,6 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase { $property->setAccessible( true ); $property->setValue( $editor, $size ); - $this->assertEquals( '100x50', $editor->get_suffix() ); + $this->assertSame( '100x50', $editor->get_suffix() ); } } diff --git a/tests/phpunit/tests/image/editorGd.php b/tests/phpunit/tests/image/editorGd.php index 0c9ddd650b..480d66f0ac 100644 --- a/tests/phpunit/tests/image/editorGd.php +++ b/tests/phpunit/tests/image/editorGd.php @@ -34,20 +34,20 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { public function test_supports_mime_type_jpeg() { $gd_image_editor = new WP_Image_Editor_GD( null ); - $expected = imagetypes() & IMG_JPG; - $this->assertEquals( $expected, $gd_image_editor->supports_mime_type( 'image/jpeg' ) ); + $expected = (bool) ( imagetypes() & IMG_JPG ); + $this->assertSame( $expected, $gd_image_editor->supports_mime_type( 'image/jpeg' ) ); } public function test_supports_mime_type_png() { $gd_image_editor = new WP_Image_Editor_GD( null ); - $expected = imagetypes() & IMG_PNG; - $this->assertEquals( $expected, $gd_image_editor->supports_mime_type( 'image/png' ) ); + $expected = (bool) ( imagetypes() & IMG_PNG ); + $this->assertSame( $expected, $gd_image_editor->supports_mime_type( 'image/png' ) ); } public function test_supports_mime_type_gif() { $gd_image_editor = new WP_Image_Editor_GD( null ); - $expected = imagetypes() & IMG_GIF; - $this->assertEquals( $expected, $gd_image_editor->supports_mime_type( 'image/gif' ) ); + $expected = (bool) ( imagetypes() & IMG_GIF ); + $this->assertSame( $expected, $gd_image_editor->supports_mime_type( 'image/gif' ) ); } /** @@ -61,7 +61,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { $gd_image_editor->resize( 100, 50 ); - $this->assertEquals( + $this->assertSame( array( 'width' => 75, 'height' => 50, @@ -98,7 +98,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { ), ); - $this->assertEquals( $expected_array, $resized ); + $this->assertSame( $expected_array, $resized ); // Now, verify real dimensions are as expected. $image_path = DIR_TESTDATA . '/images/' . $resized[0]['file']; @@ -370,7 +370,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { ); $this->assertNotNull( $resized ); - $this->assertEquals( $expected_array, $resized ); + $this->assertSame( $expected_array, $resized ); foreach ( $resized as $key => $image_data ) { $image_path = DIR_TESTDATA . '/images/' . $image_data['file']; @@ -395,7 +395,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { $gd_image_editor->resize( 100, 50, true ); - $this->assertEquals( + $this->assertSame( array( 'width' => 100, 'height' => 50, @@ -415,7 +415,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { $gd_image_editor->crop( 0, 0, 50, 50 ); - $this->assertEquals( + $this->assertSame( array( 'width' => 50, 'height' => 50, @@ -440,7 +440,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { $gd_image_editor->rotate( 180 ); - $this->assertEquals( $color_top_left, imagecolorat( $property->getValue( $gd_image_editor ), 99, 99 ) ); + $this->assertSame( $color_top_left, imagecolorat( $property->getValue( $gd_image_editor ), 99, 99 ) ); } /** @@ -459,7 +459,7 @@ class Tests_Image_Editor_GD extends WP_Image_UnitTestCase { $gd_image_editor->flip( true, false ); - $this->assertEquals( $color_top_left, imagecolorat( $property->getValue( $gd_image_editor ), 0, 99 ) ); + $this->assertSame( $color_top_left, imagecolorat( $property->getValue( $gd_image_editor ), 0, 99 ) ); } /** diff --git a/tests/phpunit/tests/image/editorImagick.php b/tests/phpunit/tests/image/editorImagick.php index 812b112b77..a358c654af 100644 --- a/tests/phpunit/tests/image/editorImagick.php +++ b/tests/phpunit/tests/image/editorImagick.php @@ -54,7 +54,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { $imagick_image_editor->resize( 100, 50 ); - $this->assertEquals( + $this->assertSame( array( 'width' => 75, 'height' => 50, @@ -91,7 +91,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { ), ); - $this->assertEquals( $expected_array, $resized ); + $this->assertSame( $expected_array, $resized ); // Now, verify real dimensions are as expected. $image_path = DIR_TESTDATA . '/images/' . $resized[0]['file']; @@ -363,7 +363,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { ); $this->assertNotNull( $resized ); - $this->assertEquals( $expected_array, $resized ); + $this->assertSame( $expected_array, $resized ); foreach ( $resized as $key => $image_data ) { $image_path = DIR_TESTDATA . '/images/' . $image_data['file']; @@ -388,7 +388,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { $imagick_image_editor->resize( 100, 50, true ); - $this->assertEquals( + $this->assertSame( array( 'width' => 100, 'height' => 50, @@ -408,7 +408,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { $imagick_image_editor->crop( 0, 0, 50, 50 ); - $this->assertEquals( + $this->assertSame( array( 'width' => 50, 'height' => 50, @@ -433,7 +433,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { $imagick_image_editor->rotate( 180 ); - $this->assertEquals( $color_top_left, $property->getValue( $imagick_image_editor )->getImagePixelColor( 99, 99 )->getColor() ); + $this->assertSame( $color_top_left, $property->getValue( $imagick_image_editor )->getImagePixelColor( 99, 99 )->getColor() ); } /** @@ -452,7 +452,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { $imagick_image_editor->flip( true, false ); - $this->assertEquals( $color_top_left, $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 99 )->getColor() ); + $this->assertSame( $color_top_left, $property->getValue( $imagick_image_editor )->getImagePixelColor( 0, 99 )->getColor() ); } /** @@ -558,7 +558,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { $data = wp_read_image_metadata( $file ); // The orientation value 3 is equivalent to rotated upside down (180 degrees). - $this->assertEquals( 3, intval( $data['orientation'] ), 'Orientation value read from does not match image file Exif data: ' . $file ); + $this->assertSame( 3, intval( $data['orientation'] ), 'Orientation value read from does not match image file Exif data: ' . $file ); $temp_file = wp_tempnam( $file ); $image = wp_get_image_editor( $file ); @@ -570,7 +570,7 @@ class Tests_Image_Editor_Imagick extends WP_Image_UnitTestCase { $data = wp_read_image_metadata( $ret['path'] ); // Make sure the image is no longer in The Upside Down Exif orientation. - $this->assertEquals( 1, intval( $data['orientation'] ), 'Orientation Exif data was not updated after rotating image: ' . $file ); + $this->assertSame( 1, intval( $data['orientation'] ), 'Orientation Exif data was not updated after rotating image: ' . $file ); // Remove both the generated file ending in .tmp and tmp.jpg due to wp_tempnam(). unlink( $temp_file ); diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index d6ea84e598..9c81ed6d93 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -186,7 +186,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { $ret = wp_save_image_file( $file, $img, $mime_type, 1 ); $this->assertNotEmpty( $ret ); $this->assertNotWPError( $ret ); - $this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) ); + $this->assertSame( $mime_type, $this->get_mime_type( $ret['path'] ) ); // Clean up. unlink( $file ); @@ -228,7 +228,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { // Make assertions. $this->assertNotEmpty( $ret ); $this->assertNotWPError( $ret ); - $this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) ); + $this->assertSame( $mime_type, $this->get_mime_type( $ret['path'] ) ); // Clean up. unlink( $file ); @@ -283,7 +283,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { $ret = $img->save( trailingslashit( $temp ) . $file ); $this->assertNotEmpty( $ret ); $this->assertNotWPError( $ret ); - $this->assertEquals( $mime_type, $this->get_mime_type( $ret['path'] ) ); + $this->assertSame( $mime_type, $this->get_mime_type( $ret['path'] ) ); unlink( $ret['path'] ); } @@ -319,7 +319,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { $loaded = $editor->load(); $this->assertInstanceOf( 'WP_Error', $loaded ); - $this->assertEquals( 'error_loading_image', $loaded->get_error_code() ); + $this->assertSame( 'error_loading_image', $loaded->get_error_code() ); } } @@ -341,8 +341,8 @@ class Tests_Image_Functions extends WP_UnitTestCase { $this->assertFileExists( $file ); $image = wp_get_image_editor( $file ); $size = $image->get_size(); - $this->assertEquals( 100, $size['height'] ); - $this->assertEquals( 100, $size['width'] ); + $this->assertSame( 100, $size['height'] ); + $this->assertSame( 100, $size['width'] ); unlink( $file ); } @@ -376,8 +376,8 @@ class Tests_Image_Functions extends WP_UnitTestCase { $this->assertFileExists( $file ); $image = wp_get_image_editor( $file ); $size = $image->get_size(); - $this->assertEquals( 100, $size['height'] ); - $this->assertEquals( 100, $size['width'] ); + $this->assertSame( 100, $size['height'] ); + $this->assertSame( 100, $size['width'] ); unlink( $file ); } diff --git a/tests/phpunit/tests/image/header.php b/tests/phpunit/tests/image/header.php index 1a619cdc6d..d378dddb2d 100644 --- a/tests/phpunit/tests/image/header.php +++ b/tests/phpunit/tests/image/header.php @@ -28,8 +28,8 @@ class Tests_Image_Header extends WP_UnitTestCase { 'height' => 1200, ) ); - $this->assertEquals( 1200, $dimensions['dst_width'] ); - $this->assertEquals( 230, $dimensions['dst_height'] ); + $this->assertSame( 1200, $dimensions['dst_width'] ); + $this->assertSame( 230, $dimensions['dst_height'] ); } @@ -48,8 +48,8 @@ class Tests_Image_Header extends WP_UnitTestCase { 'height' => 1200, ) ); - $this->assertEquals( 1200, $dimensions['dst_width'] ); - $this->assertEquals( 230, $dimensions['dst_height'] ); + $this->assertSame( 1200, $dimensions['dst_width'] ); + $this->assertSame( 230, $dimensions['dst_height'] ); } @@ -68,8 +68,8 @@ class Tests_Image_Header extends WP_UnitTestCase { 'height' => 1200, ) ); - $this->assertEquals( 1200, $dimensions['dst_width'] ); - $this->assertEquals( 900, $dimensions['dst_height'] ); + $this->assertSame( 1200, $dimensions['dst_width'] ); + $this->assertSame( 900, $dimensions['dst_height'] ); } @@ -88,8 +88,8 @@ class Tests_Image_Header extends WP_UnitTestCase { 'height' => 1200, ) ); - $this->assertEquals( 1500, $dimensions['dst_width'] ); // Max width. - $this->assertEquals( 230, $dimensions['dst_height'] ); + $this->assertSame( 1500, $dimensions['dst_width'] ); // Max width. + $this->assertSame( 230, $dimensions['dst_height'] ); } @@ -108,8 +108,8 @@ class Tests_Image_Header extends WP_UnitTestCase { 'height' => 1200, ) ); - $this->assertEquals( 1600, $dimensions['dst_width'] ); - $this->assertEquals( 1200, $dimensions['dst_height'] ); + $this->assertSame( 1600, $dimensions['dst_width'] ); + $this->assertSame( 1200, $dimensions['dst_height'] ); } @@ -126,10 +126,10 @@ class Tests_Image_Header extends WP_UnitTestCase { $cropped = 'foo-cropped.png'; $object = $this->custom_image_header->create_attachment_object( $cropped, $id ); - $this->assertEquals( 'foo-cropped.png', $object['post_title'] ); - $this->assertEquals( 'http://localhost/' . $cropped, $object['guid'] ); - $this->assertEquals( 'custom-header', $object['context'] ); - $this->assertEquals( 'image/jpeg', $object['post_mime_type'] ); + $this->assertSame( 'foo-cropped.png', $object['post_title'] ); + $this->assertSame( 'http://localhost/' . $cropped, $object['guid'] ); + $this->assertSame( 'custom-header', $object['context'] ); + $this->assertSame( 'image/jpeg', $object['post_mime_type'] ); } function test_insert_cropped_attachment() { diff --git a/tests/phpunit/tests/image/intermediateSize.php b/tests/phpunit/tests/image/intermediateSize.php index c7d8307afc..c2ac785058 100644 --- a/tests/phpunit/tests/image/intermediateSize.php +++ b/tests/phpunit/tests/image/intermediateSize.php @@ -56,9 +56,9 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 75, true ); $this->assertInternalType( 'array', $image ); - $this->assertEquals( 100, $image['width'] ); - $this->assertEquals( 75, $image['height'] ); - $this->assertEquals( 'image/jpeg', $image['mime-type'] ); + $this->assertSame( 100, $image['width'] ); + $this->assertSame( 75, $image['height'] ); + $this->assertSame( 'image/jpeg', $image['mime-type'] ); $this->assertFalse( isset( $image['path'] ) ); diff --git a/tests/phpunit/tests/image/meta.php b/tests/phpunit/tests/image/meta.php index 81d9d8e180..13f1b5abbd 100644 --- a/tests/phpunit/tests/image/meta.php +++ b/tests/phpunit/tests/image/meta.php @@ -22,32 +22,32 @@ class Tests_Image_Meta extends WP_UnitTestCase { $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2004-07-22-DSC_0008.jpg' ); $this->assertEquals( 6.3, $out['aperture'] ); - $this->assertEquals( '', $out['credit'] ); - $this->assertEquals( 'NIKON D70', $out['camera'] ); - $this->assertEquals( '', $out['caption'] ); + $this->assertSame( '', $out['credit'] ); + $this->assertSame( 'NIKON D70', $out['camera'] ); + $this->assertSame( '', $out['caption'] ); $this->assertEquals( strtotime( '2004-07-22 17:14:59' ), $out['created_timestamp'] ); - $this->assertEquals( '', $out['copyright'] ); + $this->assertSame( '', $out['copyright'] ); $this->assertEquals( 27, $out['focal_length'] ); $this->assertEquals( 400, $out['iso'] ); $this->assertEquals( 1 / 40, $out['shutter_speed'] ); - $this->assertEquals( '', $out['title'] ); + $this->assertSame( '', $out['title'] ); } function test_exif_d70_mf() { // Exif from a Nikon D70 - manual focus lens, so some data is unavailable. $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG' ); - $this->assertEquals( 0, $out['aperture'] ); - $this->assertEquals( '', $out['credit'] ); - $this->assertEquals( 'NIKON D70', $out['camera'] ); - $this->assertEquals( '', $out['caption'] ); + $this->assertSame( '0', $out['aperture'] ); + $this->assertSame( '', $out['credit'] ); + $this->assertSame( 'NIKON D70', $out['camera'] ); + $this->assertSame( '', $out['caption'] ); $this->assertEquals( strtotime( '2007-06-17 21:18:00' ), $out['created_timestamp'] ); - $this->assertEquals( '', $out['copyright'] ); + $this->assertSame( '', $out['copyright'] ); $this->assertEquals( 0, $out['focal_length'] ); $this->assertEquals( 0, $out['iso'] ); // Interesting - a Nikon bug? $this->assertEquals( 1 / 500, $out['shutter_speed'] ); - $this->assertEquals( '', $out['title'] ); - // $this->assertEquals( array( 'Flowers' ), $out['keywords'] ); + $this->assertSame( '', $out['title'] ); + // $this->assertSame( array( 'Flowers' ), $out['keywords'] ); } function test_exif_d70_iptc() { @@ -55,15 +55,15 @@ class Tests_Image_Meta extends WP_UnitTestCase { $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2004-07-22-DSC_0007.jpg' ); $this->assertEquals( 6.3, $out['aperture'] ); - $this->assertEquals( 'IPTC Creator', $out['credit'] ); - $this->assertEquals( 'NIKON D70', $out['camera'] ); - $this->assertEquals( 'IPTC Caption', $out['caption'] ); + $this->assertSame( 'IPTC Creator', $out['credit'] ); + $this->assertSame( 'NIKON D70', $out['camera'] ); + $this->assertSame( 'IPTC Caption', $out['caption'] ); $this->assertEquals( strtotime( '2004-07-22 17:14:35' ), $out['created_timestamp'] ); - $this->assertEquals( 'IPTC Copyright', $out['copyright'] ); + $this->assertSame( 'IPTC Copyright', $out['copyright'] ); $this->assertEquals( 18, $out['focal_length'] ); $this->assertEquals( 200, $out['iso'] ); $this->assertEquals( 1 / 25, $out['shutter_speed'] ); - $this->assertEquals( 'IPTC Headline', $out['title'] ); + $this->assertSame( 'IPTC Headline', $out['title'] ); } function test_exif_fuji() { @@ -71,15 +71,15 @@ class Tests_Image_Meta extends WP_UnitTestCase { $out = wp_read_image_metadata( DIR_TESTDATA . '/images/a2-small.jpg' ); $this->assertEquals( 4.5, $out['aperture'] ); - $this->assertEquals( '', $out['credit'] ); - $this->assertEquals( 'FinePix S5600', $out['camera'] ); - $this->assertEquals( '', $out['caption'] ); + $this->assertSame( '', $out['credit'] ); + $this->assertSame( 'FinePix S5600', $out['camera'] ); + $this->assertSame( '', $out['caption'] ); $this->assertEquals( strtotime( '2007-09-03 10:17:03' ), $out['created_timestamp'] ); - $this->assertEquals( '', $out['copyright'] ); + $this->assertSame( '', $out['copyright'] ); $this->assertEquals( 6.3, $out['focal_length'] ); $this->assertEquals( 64, $out['iso'] ); $this->assertEquals( 1 / 320, $out['shutter_speed'] ); - $this->assertEquals( '', $out['title'] ); + $this->assertSame( '', $out['title'] ); } @@ -92,15 +92,15 @@ class Tests_Image_Meta extends WP_UnitTestCase { $out = wp_read_image_metadata( DIR_TESTDATA . '/images/waffles.jpg' ); $this->assertEquals( 0, $out['aperture'] ); - $this->assertEquals( '', $out['credit'] ); - $this->assertEquals( '', $out['camera'] ); - $this->assertEquals( '', $out['caption'] ); + $this->assertSame( '', $out['credit'] ); + $this->assertSame( '', $out['camera'] ); + $this->assertSame( '', $out['caption'] ); $this->assertEquals( 0, $out['created_timestamp'] ); - $this->assertEquals( '', $out['copyright'] ); + $this->assertSame( '', $out['copyright'] ); $this->assertEquals( 0, $out['focal_length'] ); $this->assertEquals( 0, $out['iso'] ); $this->assertEquals( 0, $out['shutter_speed'] ); - $this->assertEquals( '', $out['title'] ); + $this->assertSame( '', $out['title'] ); } function test_exif_no_data() { @@ -108,15 +108,15 @@ class Tests_Image_Meta extends WP_UnitTestCase { $out = wp_read_image_metadata( DIR_TESTDATA . '/images/canola.jpg' ); $this->assertEquals( 0, $out['aperture'] ); - $this->assertEquals( '', $out['credit'] ); - $this->assertEquals( '', $out['camera'] ); - $this->assertEquals( '', $out['caption'] ); + $this->assertSame( '', $out['credit'] ); + $this->assertSame( '', $out['camera'] ); + $this->assertSame( '', $out['caption'] ); $this->assertEquals( 0, $out['created_timestamp'] ); - $this->assertEquals( '', $out['copyright'] ); + $this->assertSame( '', $out['copyright'] ); $this->assertEquals( 0, $out['focal_length'] ); $this->assertEquals( 0, $out['iso'] ); $this->assertEquals( 0, $out['shutter_speed'] ); - $this->assertEquals( '', $out['title'] ); + $this->assertSame( '', $out['title'] ); } /** @@ -126,7 +126,7 @@ class Tests_Image_Meta extends WP_UnitTestCase { // Trilingual UTF-8 text in the ITPC caption-abstract field. $out = wp_read_image_metadata( DIR_TESTDATA . '/images/test-image-iptc.jpg' ); - $this->assertEquals( 'This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $out['caption'] ); + $this->assertSame( 'This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $out['caption'] ); } /** @@ -144,18 +144,18 @@ class Tests_Image_Meta extends WP_UnitTestCase { public function test_exif_keywords() { $out = wp_read_image_metadata( DIR_TESTDATA . '/images/33772.jpg' ); - $this->assertEquals( '8', $out['aperture'] ); - $this->assertEquals( 'Photoshop Author', $out['credit'] ); - $this->assertEquals( 'DMC-LX2', $out['camera'] ); - $this->assertEquals( 'Photoshop Description', $out['caption'] ); + $this->assertSame( '8', $out['aperture'] ); + $this->assertSame( 'Photoshop Author', $out['credit'] ); + $this->assertSame( 'DMC-LX2', $out['camera'] ); + $this->assertSame( 'Photoshop Description', $out['caption'] ); $this->assertEquals( 1306315327, $out['created_timestamp'] ); - $this->assertEquals( 'Photoshop Copyrright Notice', $out['copyright'] ); - $this->assertEquals( '6.3', $out['focal_length'] ); - $this->assertEquals( '100', $out['iso'] ); - $this->assertEquals( '0.0025', $out['shutter_speed'] ); - $this->assertEquals( 'Photoshop Document Ttitle', $out['title'] ); + $this->assertSame( 'Photoshop Copyrright Notice', $out['copyright'] ); + $this->assertSame( '6.3', $out['focal_length'] ); + $this->assertSame( '100', $out['iso'] ); + $this->assertSame( '0.0025', $out['shutter_speed'] ); + $this->assertSame( 'Photoshop Document Ttitle', $out['title'] ); $this->assertEquals( 1, $out['orientation'] ); - $this->assertEquals( array( 'beach', 'baywatch', 'LA', 'sunset' ), $out['keywords'] ); + $this->assertSame( array( 'beach', 'baywatch', 'LA', 'sunset' ), $out['keywords'] ); } } diff --git a/tests/phpunit/tests/image/resize.php b/tests/phpunit/tests/image/resize.php index c03916af2a..05f9806bf5 100644 --- a/tests/phpunit/tests/image/resize.php +++ b/tests/phpunit/tests/image/resize.php @@ -29,11 +29,11 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase function test_resize_jpg() { $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 25, 25 ); - $this->assertEquals( 'test-image-25x25.jpg', wp_basename( $image ) ); + $this->assertSame( 'test-image-25x25.jpg', wp_basename( $image ) ); list($w, $h, $type) = getimagesize( $image ); - $this->assertEquals( 25, $w ); - $this->assertEquals( 25, $h ); - $this->assertEquals( IMAGETYPE_JPEG, $type ); + $this->assertSame( 25, $w ); + $this->assertSame( 25, $h ); + $this->assertSame( IMAGETYPE_JPEG, $type ); unlink( $image ); } @@ -45,11 +45,11 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase $this->fail( sprintf( 'No PNG support in the editor engine %s on this system', $this->editor_engine ) ); } - $this->assertEquals( 'test-image-25x25.png', wp_basename( $image ) ); + $this->assertSame( 'test-image-25x25.png', wp_basename( $image ) ); list($w, $h, $type) = getimagesize( $image ); - $this->assertEquals( 25, $w ); - $this->assertEquals( 25, $h ); - $this->assertEquals( IMAGETYPE_PNG, $type ); + $this->assertSame( 25, $w ); + $this->assertSame( 25, $h ); + $this->assertSame( IMAGETYPE_PNG, $type ); unlink( $image ); } @@ -61,11 +61,11 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase $this->fail( sprintf( 'No GIF support in the editor engine %s on this system', $this->editor_engine ) ); } - $this->assertEquals( 'test-image-25x25.gif', wp_basename( $image ) ); + $this->assertSame( 'test-image-25x25.gif', wp_basename( $image ) ); list($w, $h, $type) = getimagesize( $image ); - $this->assertEquals( 25, $w ); - $this->assertEquals( 25, $h ); - $this->assertEquals( IMAGETYPE_GIF, $type ); + $this->assertSame( 25, $w ); + $this->assertSame( 25, $h ); + $this->assertSame( IMAGETYPE_GIF, $type ); unlink( $image ); } @@ -75,17 +75,17 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 100, 100 ); $this->assertInstanceOf( 'WP_Error', $image ); - $this->assertEquals( 'error_getting_dimensions', $image->get_error_code() ); + $this->assertSame( 'error_getting_dimensions', $image->get_error_code() ); } function test_resize_thumb_128x96() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 96 ); - $this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', wp_basename( $image ) ); + $this->assertSame( '2007-06-17DSC_4173-64x96.jpg', wp_basename( $image ) ); list($w, $h, $type) = getimagesize( $image ); - $this->assertEquals( 64, $w ); - $this->assertEquals( 96, $h ); - $this->assertEquals( IMAGETYPE_JPEG, $type ); + $this->assertSame( 64, $w ); + $this->assertSame( 96, $h ); + $this->assertSame( IMAGETYPE_JPEG, $type ); unlink( $image ); } @@ -93,11 +93,11 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase function test_resize_thumb_128x0() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 0 ); - $this->assertEquals( '2007-06-17DSC_4173-128x193.jpg', wp_basename( $image ) ); + $this->assertSame( '2007-06-17DSC_4173-128x193.jpg', wp_basename( $image ) ); list($w, $h, $type) = getimagesize( $image ); - $this->assertEquals( 128, $w ); - $this->assertEquals( 193, $h ); - $this->assertEquals( IMAGETYPE_JPEG, $type ); + $this->assertSame( 128, $w ); + $this->assertSame( 193, $h ); + $this->assertSame( IMAGETYPE_JPEG, $type ); unlink( $image ); } @@ -105,11 +105,11 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase function test_resize_thumb_0x96() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 0, 96 ); - $this->assertEquals( '2007-06-17DSC_4173-64x96.jpg', wp_basename( $image ) ); + $this->assertSame( '2007-06-17DSC_4173-64x96.jpg', wp_basename( $image ) ); list($w, $h, $type) = getimagesize( $image ); - $this->assertEquals( 64, $w ); - $this->assertEquals( 96, $h ); - $this->assertEquals( IMAGETYPE_JPEG, $type ); + $this->assertSame( 64, $w ); + $this->assertSame( 96, $h ); + $this->assertSame( IMAGETYPE_JPEG, $type ); unlink( $image ); } @@ -117,11 +117,11 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase function test_resize_thumb_150x150_crop() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 150, true ); - $this->assertEquals( '2007-06-17DSC_4173-150x150.jpg', wp_basename( $image ) ); + $this->assertSame( '2007-06-17DSC_4173-150x150.jpg', wp_basename( $image ) ); list($w, $h, $type) = getimagesize( $image ); - $this->assertEquals( 150, $w ); - $this->assertEquals( 150, $h ); - $this->assertEquals( IMAGETYPE_JPEG, $type ); + $this->assertSame( 150, $w ); + $this->assertSame( 150, $h ); + $this->assertSame( IMAGETYPE_JPEG, $type ); unlink( $image ); } @@ -129,11 +129,11 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase function test_resize_thumb_150x100_crop() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 100, true ); - $this->assertEquals( '2007-06-17DSC_4173-150x100.jpg', wp_basename( $image ) ); + $this->assertSame( '2007-06-17DSC_4173-150x100.jpg', wp_basename( $image ) ); list($w, $h, $type) = getimagesize( $image ); - $this->assertEquals( 150, $w ); - $this->assertEquals( 100, $h ); - $this->assertEquals( IMAGETYPE_JPEG, $type ); + $this->assertSame( 150, $w ); + $this->assertSame( 100, $h ); + $this->assertSame( IMAGETYPE_JPEG, $type ); unlink( $image ); } @@ -141,11 +141,11 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase function test_resize_thumb_50x150_crop() { $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 50, 150, true ); - $this->assertEquals( '2007-06-17DSC_4173-50x150.jpg', wp_basename( $image ) ); + $this->assertSame( '2007-06-17DSC_4173-50x150.jpg', wp_basename( $image ) ); list($w, $h, $type) = getimagesize( $image ); - $this->assertEquals( 50, $w ); - $this->assertEquals( 150, $h ); - $this->assertEquals( IMAGETYPE_JPEG, $type ); + $this->assertSame( 50, $w ); + $this->assertSame( 150, $h ); + $this->assertSame( IMAGETYPE_JPEG, $type ); unlink( $image ); } @@ -159,7 +159,7 @@ abstract class WP_Tests_Image_Resize_UnitTestCase extends WP_Image_UnitTestCase $image = $this->resize_helper( DIR_TESTDATA . '/images/test-non-existent-image.jpg', 25, 25 ); $this->assertInstanceOf( 'WP_Error', $image ); - $this->assertEquals( 'error_loading_image', $image->get_error_code() ); + $this->assertSame( 'error_loading_image', $image->get_error_code() ); } /** diff --git a/tests/phpunit/tests/image/resizeGd.php b/tests/phpunit/tests/image/resizeGd.php index 51bbb8e193..fc39c9f7f6 100644 --- a/tests/phpunit/tests/image/resizeGd.php +++ b/tests/phpunit/tests/image/resizeGd.php @@ -33,7 +33,7 @@ class Test_Image_Resize_GD extends WP_Tests_Image_Resize_UnitTestCase { $image = $this->resize_helper( DIR_TESTDATA . '/export/crazy-cdata.xml', 25, 25 ); $this->assertInstanceOf( 'WP_Error', $image ); - $this->assertEquals( 'invalid_image', $image->get_error_code() ); + $this->assertSame( 'invalid_image', $image->get_error_code() ); } } diff --git a/tests/phpunit/tests/image/siteIcon.php b/tests/phpunit/tests/image/siteIcon.php index c55bdc7e4b..595a1a5f21 100644 --- a/tests/phpunit/tests/image/siteIcon.php +++ b/tests/phpunit/tests/image/siteIcon.php @@ -36,7 +36,7 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { $sizes[] = 'site_icon-' . $size; } - $this->assertEquals( $sizes, $image_sizes ); + $this->assertSame( $sizes, $image_sizes ); } function test_intermediate_image_sizes_with_filter() { @@ -52,7 +52,7 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { $this->assertContains( 'site_icon-321', $image_sizes ); // All icon sizes should be part of the array, including sizes added through the filter. - $this->assertEquals( $sizes, $image_sizes ); + $this->assertSame( $sizes, $image_sizes ); // Remove custom size. unset( $this->wp_site_icon->site_icon_sizes[ array_search( 321, $this->wp_site_icon->site_icon_sizes, true ) ] ); @@ -72,7 +72,7 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { ); } - $this->assertEquals( $sizes, $image_sizes ); + $this->assertSame( $sizes, $image_sizes ); } function test_additional_sizes_with_filter() { @@ -92,7 +92,7 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { $this->assertArrayHasKey( 'site_icon-321', $image_sizes ); // All icon sizes should be part of the array, including sizes added through the filter. - $this->assertEquals( $sizes, $image_sizes ); + $this->assertSame( $sizes, $image_sizes ); // Remove custom size. unset( $this->wp_site_icon->site_icon_sizes[ array_search( 321, $this->wp_site_icon->site_icon_sizes, true ) ] ); @@ -105,11 +105,11 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { $object = $this->wp_site_icon->create_attachment_object( $cropped, $attachment_id ); - $this->assertEquals( $object['post_title'], 'cropped-test-image.jpg' ); - $this->assertEquals( $object['context'], 'site-icon' ); - $this->assertEquals( $object['post_mime_type'], 'image/jpeg' ); - $this->assertEquals( $object['post_content'], $cropped ); - $this->assertEquals( $object['guid'], $cropped ); + $this->assertSame( $object['post_title'], 'cropped-test-image.jpg' ); + $this->assertSame( $object['context'], 'site-icon' ); + $this->assertSame( $object['post_mime_type'], 'image/jpeg' ); + $this->assertSame( $object['post_content'], $cropped ); + $this->assertSame( $object['guid'], $cropped ); } function test_insert_cropped_attachment() { diff --git a/tests/phpunit/tests/import/import.php b/tests/phpunit/tests/import/import.php index 1454bed8be..0dfb60b369 100644 --- a/tests/phpunit/tests/import/import.php +++ b/tests/phpunit/tests/import/import.php @@ -51,27 +51,27 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { // Ensure that authors were imported correctly. $user_count = count_users(); - $this->assertEquals( 3, $user_count['total_users'] ); + $this->assertSame( 3, $user_count['total_users'] ); $admin = get_user_by( 'login', 'admin' ); - $this->assertEquals( 'admin', $admin->user_login ); - $this->assertEquals( 'local@host.null', $admin->user_email ); + $this->assertSame( 'admin', $admin->user_login ); + $this->assertSame( 'local@host.null', $admin->user_email ); $editor = get_user_by( 'login', 'editor' ); - $this->assertEquals( 'editor', $editor->user_login ); - $this->assertEquals( 'editor@example.org', $editor->user_email ); - $this->assertEquals( 'FirstName', $editor->user_firstname ); - $this->assertEquals( 'LastName', $editor->user_lastname ); + $this->assertSame( 'editor', $editor->user_login ); + $this->assertSame( 'editor@example.org', $editor->user_email ); + $this->assertSame( 'FirstName', $editor->user_firstname ); + $this->assertSame( 'LastName', $editor->user_lastname ); $author = get_user_by( 'login', 'author' ); - $this->assertEquals( 'author', $author->user_login ); - $this->assertEquals( 'author@example.org', $author->user_email ); + $this->assertSame( 'author', $author->user_login ); + $this->assertSame( 'author@example.org', $author->user_email ); // Check that terms were imported correctly. $this->assertEquals( 30, wp_count_terms( array( 'taxonomy' => 'category' ) ) ); $this->assertEquals( 3, wp_count_terms( array( 'taxonomy' => 'post_tag' ) ) ); $foo = get_term_by( 'slug', 'foo', 'category' ); - $this->assertEquals( 0, $foo->parent ); + $this->assertSame( 0, $foo->parent ); $bar = get_term_by( 'slug', 'bar', 'category' ); $foo_bar = get_term_by( 'slug', 'foo-bar', 'category' ); - $this->assertEquals( $bar->term_id, $foo_bar->parent ); + $this->assertSame( $bar->term_id, $foo_bar->parent ); // Check that posts/pages were imported correctly. $post_count = wp_count_posts( 'post' ); @@ -91,120 +91,120 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { 'orderby' => 'ID', ) ); - $this->assertEquals( 11, count( $posts ) ); + $this->assertSame( 11, count( $posts ) ); $post = $posts[0]; - $this->assertEquals( 'Many Categories', $post->post_title ); - $this->assertEquals( 'many-categories', $post->post_name ); + $this->assertSame( 'Many Categories', $post->post_title ); + $this->assertSame( 'many-categories', $post->post_name ); $this->assertEquals( $admin->ID, $post->post_author ); - $this->assertEquals( 'post', $post->post_type ); - $this->assertEquals( 'publish', $post->post_status ); - $this->assertEquals( 0, $post->post_parent ); + $this->assertSame( 'post', $post->post_type ); + $this->assertSame( 'publish', $post->post_status ); + $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID ); - $this->assertEquals( 27, count( $cats ) ); + $this->assertSame( 27, count( $cats ) ); $post = $posts[1]; - $this->assertEquals( 'Non-standard post format', $post->post_title ); - $this->assertEquals( 'non-standard-post-format', $post->post_name ); + $this->assertSame( 'Non-standard post format', $post->post_title ); + $this->assertSame( 'non-standard-post-format', $post->post_name ); $this->assertEquals( $admin->ID, $post->post_author ); - $this->assertEquals( 'post', $post->post_type ); - $this->assertEquals( 'publish', $post->post_status ); - $this->assertEquals( 0, $post->post_parent ); + $this->assertSame( 'post', $post->post_type ); + $this->assertSame( 'publish', $post->post_status ); + $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID ); - $this->assertEquals( 1, count( $cats ) ); + $this->assertSame( 1, count( $cats ) ); $this->assertTrue( has_post_format( 'aside', $post->ID ) ); $post = $posts[2]; - $this->assertEquals( 'Top-level Foo', $post->post_title ); - $this->assertEquals( 'top-level-foo', $post->post_name ); + $this->assertSame( 'Top-level Foo', $post->post_title ); + $this->assertSame( 'top-level-foo', $post->post_name ); $this->assertEquals( $admin->ID, $post->post_author ); - $this->assertEquals( 'post', $post->post_type ); - $this->assertEquals( 'publish', $post->post_status ); - $this->assertEquals( 0, $post->post_parent ); + $this->assertSame( 'post', $post->post_type ); + $this->assertSame( 'publish', $post->post_status ); + $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) ); - $this->assertEquals( 1, count( $cats ) ); - $this->assertEquals( 'foo', $cats[0]->slug ); + $this->assertSame( 1, count( $cats ) ); + $this->assertSame( 'foo', $cats[0]->slug ); $post = $posts[3]; - $this->assertEquals( 'Foo-child', $post->post_title ); - $this->assertEquals( 'foo-child', $post->post_name ); + $this->assertSame( 'Foo-child', $post->post_title ); + $this->assertSame( 'foo-child', $post->post_name ); $this->assertEquals( $editor->ID, $post->post_author ); - $this->assertEquals( 'post', $post->post_type ); - $this->assertEquals( 'publish', $post->post_status ); - $this->assertEquals( 0, $post->post_parent ); + $this->assertSame( 'post', $post->post_type ); + $this->assertSame( 'publish', $post->post_status ); + $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) ); - $this->assertEquals( 1, count( $cats ) ); - $this->assertEquals( 'foo-bar', $cats[0]->slug ); + $this->assertSame( 1, count( $cats ) ); + $this->assertSame( 'foo-bar', $cats[0]->slug ); $post = $posts[4]; - $this->assertEquals( 'Private Post', $post->post_title ); - $this->assertEquals( 'private-post', $post->post_name ); + $this->assertSame( 'Private Post', $post->post_title ); + $this->assertSame( 'private-post', $post->post_name ); $this->assertEquals( $admin->ID, $post->post_author ); - $this->assertEquals( 'post', $post->post_type ); - $this->assertEquals( 'private', $post->post_status ); - $this->assertEquals( 0, $post->post_parent ); + $this->assertSame( 'post', $post->post_type ); + $this->assertSame( 'private', $post->post_status ); + $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID ); - $this->assertEquals( 1, count( $cats ) ); + $this->assertSame( 1, count( $cats ) ); $tags = wp_get_post_tags( $post->ID ); - $this->assertEquals( 3, count( $tags ) ); - $this->assertEquals( 'tag1', $tags[0]->slug ); - $this->assertEquals( 'tag2', $tags[1]->slug ); - $this->assertEquals( 'tag3', $tags[2]->slug ); + $this->assertSame( 3, count( $tags ) ); + $this->assertSame( 'tag1', $tags[0]->slug ); + $this->assertSame( 'tag2', $tags[1]->slug ); + $this->assertSame( 'tag3', $tags[2]->slug ); $post = $posts[5]; - $this->assertEquals( '1-col page', $post->post_title ); - $this->assertEquals( '1-col-page', $post->post_name ); + $this->assertSame( '1-col page', $post->post_title ); + $this->assertSame( '1-col-page', $post->post_name ); $this->assertEquals( $admin->ID, $post->post_author ); - $this->assertEquals( 'page', $post->post_type ); - $this->assertEquals( 'publish', $post->post_status ); - $this->assertEquals( 0, $post->post_parent ); - $this->assertEquals( 'onecolumn-page.php', get_post_meta( $post->ID, '_wp_page_template', true ) ); + $this->assertSame( 'page', $post->post_type ); + $this->assertSame( 'publish', $post->post_status ); + $this->assertSame( 0, $post->post_parent ); + $this->assertSame( 'onecolumn-page.php', get_post_meta( $post->ID, '_wp_page_template', true ) ); $post = $posts[6]; - $this->assertEquals( 'Draft Page', $post->post_title ); - $this->assertEquals( '', $post->post_name ); + $this->assertSame( 'Draft Page', $post->post_title ); + $this->assertSame( '', $post->post_name ); $this->assertEquals( $admin->ID, $post->post_author ); - $this->assertEquals( 'page', $post->post_type ); - $this->assertEquals( 'draft', $post->post_status ); - $this->assertEquals( 0, $post->post_parent ); - $this->assertEquals( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) ); + $this->assertSame( 'page', $post->post_type ); + $this->assertSame( 'draft', $post->post_status ); + $this->assertSame( 0, $post->post_parent ); + $this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) ); $post = $posts[7]; - $this->assertEquals( 'Parent Page', $post->post_title ); - $this->assertEquals( 'parent-page', $post->post_name ); + $this->assertSame( 'Parent Page', $post->post_title ); + $this->assertSame( 'parent-page', $post->post_name ); $this->assertEquals( $admin->ID, $post->post_author ); - $this->assertEquals( 'page', $post->post_type ); - $this->assertEquals( 'publish', $post->post_status ); - $this->assertEquals( 0, $post->post_parent ); - $this->assertEquals( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) ); + $this->assertSame( 'page', $post->post_type ); + $this->assertSame( 'publish', $post->post_status ); + $this->assertSame( 0, $post->post_parent ); + $this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) ); $post = $posts[8]; - $this->assertEquals( 'Child Page', $post->post_title ); - $this->assertEquals( 'child-page', $post->post_name ); + $this->assertSame( 'Child Page', $post->post_title ); + $this->assertSame( 'child-page', $post->post_name ); $this->assertEquals( $admin->ID, $post->post_author ); - $this->assertEquals( 'page', $post->post_type ); - $this->assertEquals( 'publish', $post->post_status ); - $this->assertEquals( $posts[7]->ID, $post->post_parent ); - $this->assertEquals( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) ); + $this->assertSame( 'page', $post->post_type ); + $this->assertSame( 'publish', $post->post_status ); + $this->assertSame( $posts[7]->ID, $post->post_parent ); + $this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) ); $post = $posts[9]; - $this->assertEquals( 'Sample Page', $post->post_title ); - $this->assertEquals( 'sample-page', $post->post_name ); + $this->assertSame( 'Sample Page', $post->post_title ); + $this->assertSame( 'sample-page', $post->post_name ); $this->assertEquals( $admin->ID, $post->post_author ); - $this->assertEquals( 'page', $post->post_type ); - $this->assertEquals( 'publish', $post->post_status ); - $this->assertEquals( 0, $post->post_parent ); - $this->assertEquals( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) ); + $this->assertSame( 'page', $post->post_type ); + $this->assertSame( 'publish', $post->post_status ); + $this->assertSame( 0, $post->post_parent ); + $this->assertSame( 'default', get_post_meta( $post->ID, '_wp_page_template', true ) ); $post = $posts[10]; - $this->assertEquals( 'Hello world!', $post->post_title ); - $this->assertEquals( 'hello-world', $post->post_name ); + $this->assertSame( 'Hello world!', $post->post_title ); + $this->assertSame( 'hello-world', $post->post_name ); $this->assertEquals( $author->ID, $post->post_author ); - $this->assertEquals( 'post', $post->post_type ); - $this->assertEquals( 'publish', $post->post_status ); - $this->assertEquals( 0, $post->post_parent ); + $this->assertSame( 'post', $post->post_type ); + $this->assertSame( 'publish', $post->post_status ); + $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID ); - $this->assertEquals( 1, count( $cats ) ); + $this->assertSame( 1, count( $cats ) ); } function test_double_import() { @@ -217,26 +217,26 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { $this->_import_wp( DIR_TESTDATA . '/export/small-export.xml', $authors ); $user_count = count_users(); - $this->assertEquals( 3, $user_count['total_users'] ); + $this->assertSame( 3, $user_count['total_users'] ); $admin = get_user_by( 'login', 'admin' ); - $this->assertEquals( 'admin', $admin->user_login ); - $this->assertEquals( 'local@host.null', $admin->user_email ); + $this->assertSame( 'admin', $admin->user_login ); + $this->assertSame( 'local@host.null', $admin->user_email ); $editor = get_user_by( 'login', 'editor' ); - $this->assertEquals( 'editor', $editor->user_login ); - $this->assertEquals( 'editor@example.org', $editor->user_email ); - $this->assertEquals( 'FirstName', $editor->user_firstname ); - $this->assertEquals( 'LastName', $editor->user_lastname ); + $this->assertSame( 'editor', $editor->user_login ); + $this->assertSame( 'editor@example.org', $editor->user_email ); + $this->assertSame( 'FirstName', $editor->user_firstname ); + $this->assertSame( 'LastName', $editor->user_lastname ); $author = get_user_by( 'login', 'author' ); - $this->assertEquals( 'author', $author->user_login ); - $this->assertEquals( 'author@example.org', $author->user_email ); + $this->assertSame( 'author', $author->user_login ); + $this->assertSame( 'author@example.org', $author->user_email ); $this->assertEquals( 30, wp_count_terms( array( 'taxonomy' => 'category' ) ) ); $this->assertEquals( 3, wp_count_terms( array( 'taxonomy' => 'post_tag' ) ) ); $foo = get_term_by( 'slug', 'foo', 'category' ); - $this->assertEquals( 0, $foo->parent ); + $this->assertSame( 0, $foo->parent ); $bar = get_term_by( 'slug', 'bar', 'category' ); $foo_bar = get_term_by( 'slug', 'foo-bar', 'category' ); - $this->assertEquals( $bar->term_id, $foo_bar->parent ); + $this->assertSame( $bar->term_id, $foo_bar->parent ); $post_count = wp_count_posts( 'post' ); $this->assertEquals( 5, $post_count->publish ); @@ -258,7 +258,7 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { 'ABC1' => array( 'ABC1' ), 'def1' => array( 'def1' ), ); - $this->assertEquals( + $this->assertSame( array( 'ABC1' => array( 'ABC1' ), 'abc2' => array( 'abc2' ), diff --git a/tests/phpunit/tests/import/parser.php b/tests/phpunit/tests/import/parser.php index af27b0b29e..82214c110d 100644 --- a/tests/phpunit/tests/import/parser.php +++ b/tests/phpunit/tests/import/parser.php @@ -32,7 +32,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { $parser = new $p; $result = $parser->parse( $file ); $this->assertWPError( $result ); - $this->assertEquals( 'There was an error when reading this WXR file', $result->get_error_message() ); + $this->assertSame( 'There was an error when reading this WXR file', $result->get_error_message() ); } } @@ -45,7 +45,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { $parser = new $p; $result = $parser->parse( $file ); $this->assertWPError( $result ); - $this->assertEquals( 'This does not appear to be a WXR file, missing/invalid WXR version number', $result->get_error_message() ); + $this->assertSame( 'This does not appear to be a WXR file, missing/invalid WXR version number', $result->get_error_message() ); } } } @@ -59,7 +59,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { $result = $parser->parse( $file ); $this->assertTrue( is_array( $result ), $message ); - $this->assertEquals( 'http://localhost/', $result['base_url'], $message ); + $this->assertSame( 'http://localhost/', $result['base_url'], $message ); $this->assertEquals( array( 'author_id' => 2, @@ -106,9 +106,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { $message ); - $this->assertEquals( 2, count( $result['posts'] ), $message ); - $this->assertEquals( 19, count( $result['posts'][0] ), $message ); - $this->assertEquals( 18, count( $result['posts'][1] ), $message ); + $this->assertSame( 2, count( $result['posts'] ), $message ); + $this->assertSame( 19, count( $result['posts'][0] ), $message ); + $this->assertSame( 18, count( $result['posts'][1] ), $message ); $this->assertEquals( array( array( @@ -130,7 +130,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { $result['posts'][0]['terms'], $message ); - $this->assertEquals( + $this->assertSame( array( array( 'key' => '_wp_page_template', @@ -152,17 +152,17 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { $result = $parser->parse( $file ); $this->assertTrue( is_array( $result ), $message ); - $this->assertEquals( 'http://localhost/', $result['base_url'], $message ); - $this->assertEquals( $result['categories'][0]['category_nicename'], 'alpha', $message ); - $this->assertEquals( $result['categories'][0]['cat_name'], 'alpha', $message ); - $this->assertEquals( $result['categories'][0]['category_parent'], '', $message ); - $this->assertEquals( $result['categories'][0]['category_description'], 'The alpha category', $message ); - $this->assertEquals( $result['tags'][0]['tag_slug'], 'chicken', $message ); - $this->assertEquals( $result['tags'][0]['tag_name'], 'chicken', $message ); + $this->assertSame( 'http://localhost/', $result['base_url'], $message ); + $this->assertSame( $result['categories'][0]['category_nicename'], 'alpha', $message ); + $this->assertSame( $result['categories'][0]['cat_name'], 'alpha', $message ); + $this->assertSame( $result['categories'][0]['category_parent'], '', $message ); + $this->assertSame( $result['categories'][0]['category_description'], 'The alpha category', $message ); + $this->assertSame( $result['tags'][0]['tag_slug'], 'chicken', $message ); + $this->assertSame( $result['tags'][0]['tag_name'], 'chicken', $message ); - $this->assertEquals( 6, count( $result['posts'] ), $message ); - $this->assertEquals( 19, count( $result['posts'][0] ), $message ); - $this->assertEquals( 18, count( $result['posts'][1] ), $message ); + $this->assertSame( 6, count( $result['posts'] ), $message ); + $this->assertSame( 19, count( $result['posts'][0] ), $message ); + $this->assertSame( 18, count( $result['posts'][1] ), $message ); $this->assertEquals( array( @@ -218,7 +218,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { $message ); - $this->assertEquals( + $this->assertSame( array( array( 'key' => '_wp_page_template', @@ -246,7 +246,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { $result = $parser->parse( $file ); $post = $result['posts'][0]; - $this->assertEquals( 'Content with nested <![CDATA[ tags ]]> :)', $post['post_content'], $message ); + $this->assertSame( 'Content with nested <![CDATA[ tags ]]> :)', $post['post_content'], $message ); foreach ( $post['postmeta'] as $meta ) { switch ( $meta['key'] ) { case 'Plain string': @@ -261,7 +261,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { default: $this->fail( 'Unknown postmeta (' . $meta['key'] . ') was parsed out by' . $p ); } - $this->assertEquals( $value, $meta['value'], $message ); + $this->assertSame( $value, $meta['value'], $message ); } } } @@ -277,7 +277,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { $result = $parser->parse( $file ); $post = $result['posts'][0]; - $this->assertEquals( 'Content with nested <![CDATA[ tags ]]> :)', $post['post_content'] ); + $this->assertSame( 'Content with nested <![CDATA[ tags ]]> :)', $post['post_content'] ); foreach ( $post['postmeta'] as $meta ) { switch ( $meta['key'] ) { case 'Plain string': @@ -292,7 +292,7 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { default: $this->fail( 'Unknown postmeta (' . $meta['key'] . ') was parsed out by' . $p ); } - $this->assertEquals( $value, $meta['value'] ); + $this->assertSame( $value, $meta['value'] ); } } diff --git a/tests/phpunit/tests/import/postmeta.php b/tests/phpunit/tests/import/postmeta.php index d4d9c5c3a0..54a05743de 100644 --- a/tests/phpunit/tests/import/postmeta.php +++ b/tests/phpunit/tests/import/postmeta.php @@ -28,7 +28,7 @@ class Tests_Import_Postmeta extends WP_Import_UnitTestCase { $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-no-cdata.xml', array( 'johncoswell' => 'john' ) ); $expected['special_post_title'] = 'A special title'; $expected['is_calendar'] = ''; - $this->assertEquals( $expected, get_post_meta( 122, 'post-options', true ) ); + $this->assertSame( $expected, get_post_meta( 122, 'post-options', true ) ); } function test_utw_postmeta() { @@ -84,11 +84,11 @@ class Tests_Import_Postmeta extends WP_Import_UnitTestCase { $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-with-cdata.xml', array( 'johncoswell' => 'johncoswell' ) ); // HTML in the CDATA should work with old WordPress version. - $this->assertEquals( '<pre>some html</pre>', get_post_meta( 10, 'contains-html', true ) ); + $this->assertSame( '<pre>some html</pre>', get_post_meta( 10, 'contains-html', true ) ); // Serialised will only work with 3.0 onwards. $expected['special_post_title'] = 'A special title'; $expected['is_calendar'] = ''; - $this->assertEquals( $expected, get_post_meta( 10, 'post-options', true ) ); + $this->assertSame( $expected, get_post_meta( 10, 'post-options', true ) ); } /** @@ -97,6 +97,6 @@ class Tests_Import_Postmeta extends WP_Import_UnitTestCase { function test_serialized_postmeta_with_evil_stuff_in_cdata() { $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-with-cdata.xml', array( 'johncoswell' => 'johncoswell' ) ); // Evil content in the CDATA. - $this->assertEquals( '<wp:meta_value>evil</wp:meta_value>', get_post_meta( 10, 'evil', true ) ); + $this->assertSame( '<wp:meta_value>evil</wp:meta_value>', get_post_meta( 10, 'evil', true ) ); } } diff --git a/tests/phpunit/tests/includes/factory.php b/tests/phpunit/tests/includes/factory.php index 63f87ce619..8fd351e772 100644 --- a/tests/phpunit/tests/includes/factory.php +++ b/tests/phpunit/tests/includes/factory.php @@ -19,14 +19,14 @@ class TestFactoryFor extends WP_UnitTestCase { function test_get_object_by_id_gets_an_object_with_the_same_name() { $id = $this->category_factory->create( array( 'name' => 'Boo' ) ); $object = $this->category_factory->get_object_by_id( $id ); - $this->assertEquals( 'Boo', $object->name ); + $this->assertSame( 'Boo', $object->name ); } function test_the_taxonomy_argument_overrules_the_factory_taxonomy() { $term_factory = new WP_UnitTest_Factory_For_term( null, 'category' ); $id = $term_factory->create( array( 'taxonomy' => 'post_tag' ) ); $term = get_term( $id, 'post_tag' ); - $this->assertEquals( $id, $term->term_id ); + $this->assertSame( $id, $term->term_id ); } /** diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index 37753260e9..0a6527a56d 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -29,7 +29,7 @@ class Tests_Kses extends WP_UnitTestCase { foreach ( (array) $values as $value ) { $string = "<address $name='$value'>1 WordPress Avenue, The Internet.</address>"; $expect_string = "<address $name='" . str_replace( '; ', ';', trim( $value, ';' ) ) . "'>1 WordPress Avenue, The Internet.</address>"; - $this->assertEquals( $expect_string, wp_kses( $string, $allowedposttags ) ); + $this->assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); } } } @@ -63,7 +63,7 @@ class Tests_Kses extends WP_UnitTestCase { } $string = "<a $attr>I link this</a>"; $expect_string = "<a $expected_attr>I link this</a>"; - $this->assertEquals( $expect_string, wp_kses( $string, $allowedposttags ) ); + $this->assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); } } @@ -137,7 +137,7 @@ class Tests_Kses extends WP_UnitTestCase { foreach ( $attributes as $name => $value ) { $string = "<abbr $name='$value'>WP</abbr>"; $expect_string = "<abbr $name='" . trim( $value, ';' ) . "'>WP</abbr>"; - $this->assertEquals( $expect_string, wp_kses( $string, $allowedposttags ) ); + $this->assertSame( $expect_string, wp_kses( $string, $allowedposttags ) ); } } @@ -172,7 +172,7 @@ EOF; <a href="">CLICK ME</a> EOF; - $this->assertEquals( $expected, wp_kses( $content, $allowedposttags ) ); + $this->assertSame( $expected, wp_kses( $content, $allowedposttags ) ); } function test_wp_kses_bad_protocol() { @@ -211,25 +211,25 @@ EOF; if ( ! empty( $result ) && 'alert(1);' !== $result && 'alert(1)' !== $result ) { switch ( $k ) { case 6: - $this->assertEquals( 'javascript&#0000058alert(1);', $result ); + $this->assertSame( 'javascript&#0000058alert(1);', $result ); break; case 12: - $this->assertEquals( str_replace( '&', '&', $x ), $result ); + $this->assertSame( str_replace( '&', '&', $x ), $result ); break; case 22: - $this->assertEquals( 'javascript&#0000058alert(1);', $result ); + $this->assertSame( 'javascript&#0000058alert(1);', $result ); break; case 23: - $this->assertEquals( 'javascript&#0000058alert(1)//?:', $result ); + $this->assertSame( 'javascript&#0000058alert(1)//?:', $result ); break; case 24: - $this->assertEquals( 'feed:alert(1)', $result ); + $this->assertSame( 'feed:alert(1)', $result ); break; case 26: - $this->assertEquals( 'javascript&#58alert(1)', $result ); + $this->assertSame( 'javascript&#58alert(1)', $result ); break; case 27: - $this->assertEquals( 'javascript&#x3ax=1;alert(1)', $result ); + $this->assertSame( 'javascript&#x3ax=1;alert(1)', $result ); break; default: $this->fail( "wp_kses_bad_protocol failed on $k, $x. Result: $result" ); @@ -304,106 +304,106 @@ EOF; switch ( $attack->name ) { case 'XSS Locator': - $this->assertEquals( '\';alert(String.fromCharCode(88,83,83))//\\\';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//\\";alert(String.fromCharCode(88,83,83))//-->">\'>alert(String.fromCharCode(88,83,83))=&{}', $result ); + $this->assertSame( '\';alert(String.fromCharCode(88,83,83))//\\\';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//\\";alert(String.fromCharCode(88,83,83))//-->">\'>alert(String.fromCharCode(88,83,83))=&{}', $result ); break; case 'XSS Quick Test': - $this->assertEquals( '\'\';!--"=&{()}', $result ); + $this->assertSame( '\'\';!--"=&{()}', $result ); break; case 'SCRIPT w/Alert()': - $this->assertEquals( "alert('XSS')", $result ); + $this->assertSame( "alert('XSS')", $result ); break; case 'SCRIPT w/Char Code': - $this->assertEquals( 'alert(String.fromCharCode(88,83,83))', $result ); + $this->assertSame( 'alert(String.fromCharCode(88,83,83))', $result ); break; case 'IMG STYLE w/expression': - $this->assertEquals( 'exp/*', $result ); + $this->assertSame( 'exp/*', $result ); break; case 'List-style-image': - $this->assertEquals( 'li {list-style-image: url("javascript:alert(\'XSS\')");}XSS', $result ); + $this->assertSame( 'li {list-style-image: url("javascript:alert(\'XSS\')");}XSS', $result ); break; case 'STYLE': - $this->assertEquals( "alert('XSS');", $result ); + $this->assertSame( "alert('XSS');", $result ); break; case 'STYLE w/background-image': - $this->assertEquals( '.XSS{background-image:url("javascript:alert(\'XSS\')");}<A></A>', $result ); + $this->assertSame( '.XSS{background-image:url("javascript:alert(\'XSS\')");}<A></A>', $result ); break; case 'STYLE w/background': - $this->assertEquals( 'BODY{background:url("javascript:alert(\'XSS\')")}', $result ); + $this->assertSame( 'BODY{background:url("javascript:alert(\'XSS\')")}', $result ); break; case 'Remote Stylesheet 2': - $this->assertEquals( "@import'http://ha.ckers.org/xss.css';", $result ); + $this->assertSame( "@import'http://ha.ckers.org/xss.css';", $result ); break; case 'Remote Stylesheet 3': - $this->assertEquals( '<META HTTP-EQUIV="Link" Content="; REL=stylesheet">', $result ); + $this->assertSame( '<META HTTP-EQUIV="Link" Content="; REL=stylesheet">', $result ); break; case 'Remote Stylesheet 4': - $this->assertEquals( 'BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}', $result ); + $this->assertSame( 'BODY{-moz-binding:url("http://ha.ckers.org/xssmoz.xml#xss")}', $result ); break; case 'XML data island w/CDATA': - $this->assertEquals( '<![CDATA[]]>', $result ); + $this->assertSame( '<![CDATA[]]>', $result ); break; case 'XML data island w/comment': - $this->assertEquals( "<I><B><IMG SRC="javas<!-- -->cript:alert('XSS')\"></B></I>", $result ); + $this->assertSame( "<I><B><IMG SRC="javas<!-- -->cript:alert('XSS')\"></B></I>", $result ); break; case 'XML HTML+TIME': - $this->assertEquals( '<t:set attributeName="innerHTML" to="XSSalert(\'XSS\')">', $result ); + $this->assertSame( '<t:set attributeName="innerHTML" to="XSSalert(\'XSS\')">', $result ); break; case 'Commented-out Block': - $this->assertEquals( "<!--[if gte IE 4]>-->\nalert('XSS');", $result ); + $this->assertSame( "<!--[if gte IE 4]>-->\nalert('XSS');", $result ); break; case 'Cookie Manipulation': - $this->assertEquals( '<META HTTP-EQUIV="Set-Cookie" Content="USERID=alert(\'XSS\')">', $result ); + $this->assertSame( '<META HTTP-EQUIV="Set-Cookie" Content="USERID=alert(\'XSS\')">', $result ); break; case 'SSI': - $this->assertEquals( '<!--#exec cmd="/bin/echo '<!--#exec cmd="/bin/echo \'=http://ha.ckers.org/xss.js>\'"-->', $result ); + $this->assertSame( '<!--#exec cmd="/bin/echo '<!--#exec cmd="/bin/echo \'=http://ha.ckers.org/xss.js>\'"-->', $result ); break; case 'PHP': - $this->assertEquals( '<? echo('alert("XSS")\'); ?>', $result ); + $this->assertSame( '<? echo('alert("XSS")\'); ?>', $result ); break; case 'UTF-7 Encoding': - $this->assertEquals( '+ADw-SCRIPT+AD4-alert(\'XSS\');+ADw-/SCRIPT+AD4-', $result ); + $this->assertSame( '+ADw-SCRIPT+AD4-alert(\'XSS\');+ADw-/SCRIPT+AD4-', $result ); break; case 'Escaping JavaScript escapes': - $this->assertEquals( '\";alert(\'XSS\');//', $result ); + $this->assertSame( '\";alert(\'XSS\');//', $result ); break; case 'STYLE w/broken up JavaScript': - $this->assertEquals( '@im\port\'\ja\vasc\ript:alert("XSS")\';', $result ); + $this->assertSame( '@im\port\'\ja\vasc\ript:alert("XSS")\';', $result ); break; case 'Null Chars 2': - $this->assertEquals( '&alert("XSS")', $result ); + $this->assertSame( '&alert("XSS")', $result ); break; case 'No Closing Script Tag': - $this->assertEquals( '<SCRIPT SRC=http://ha.ckers.org/xss.js', $result ); + $this->assertSame( '<SCRIPT SRC=http://ha.ckers.org/xss.js', $result ); break; case 'Half-Open HTML/JavaScript': - $this->assertEquals( '<IMG SRC="javascript:alert('XSS')"', $result ); + $this->assertSame( '<IMG SRC="javascript:alert('XSS')"', $result ); break; case 'Double open angle brackets': - $this->assertEquals( '<IFRAME SRC=http://ha.ckers.org/scriptlet.html <', $result ); + $this->assertSame( '<IFRAME SRC=http://ha.ckers.org/scriptlet.html <', $result ); break; case 'Extraneous Open Brackets': - $this->assertEquals( '<alert("XSS");//<', $result ); + $this->assertSame( '<alert("XSS");//<', $result ); break; case 'Malformed IMG Tags': - $this->assertEquals( 'alert("XSS")">', $result ); + $this->assertSame( 'alert("XSS")">', $result ); break; case 'No Quotes/Semicolons': - $this->assertEquals( "a=/XSS/\nalert(a.source)", $result ); + $this->assertSame( "a=/XSS/\nalert(a.source)", $result ); break; case 'Evade Regex Filter 1': - $this->assertEquals( '" SRC="http://ha.ckers.org/xss.js">', $result ); + $this->assertSame( '" SRC="http://ha.ckers.org/xss.js">', $result ); break; case 'Evade Regex Filter 4': - $this->assertEquals( '\'" SRC="http://ha.ckers.org/xss.js">', $result ); + $this->assertSame( '\'" SRC="http://ha.ckers.org/xss.js">', $result ); break; case 'Evade Regex Filter 5': - $this->assertEquals( '` SRC="http://ha.ckers.org/xss.js">', $result ); + $this->assertSame( '` SRC="http://ha.ckers.org/xss.js">', $result ); break; case 'Filter Evasion 1': - $this->assertEquals( 'document.write("<SCRI");PT SRC="http://ha.ckers.org/xss.js">', $result ); + $this->assertSame( 'document.write("<SCRI");PT SRC="http://ha.ckers.org/xss.js">', $result ); break; case 'Filter Evasion 2': - $this->assertEquals( '\'>" SRC="http://ha.ckers.org/xss.js">', $result ); + $this->assertSame( '\'>" SRC="http://ha.ckers.org/xss.js">', $result ); break; default: $this->fail( 'KSES failed on ' . $attack->name . ': ' . $result ); @@ -425,7 +425,7 @@ EOF; public function test_wp_kses_allowed_html() { global $allowedposttags, $allowedtags, $allowedentitynames; - $this->assertEquals( $allowedposttags, wp_kses_allowed_html( 'post' ) ); + $this->assertSame( $allowedposttags, wp_kses_allowed_html( 'post' ) ); $tags = wp_kses_allowed_html( 'post' ); @@ -436,9 +436,9 @@ EOF; $this->assertTrue( $tag['title'] ); } - $this->assertEquals( $allowedtags, wp_kses_allowed_html( 'data' ) ); - $this->assertEquals( $allowedtags, wp_kses_allowed_html( '' ) ); - $this->assertEquals( $allowedtags, wp_kses_allowed_html() ); + $this->assertSame( $allowedtags, wp_kses_allowed_html( 'data' ) ); + $this->assertSame( $allowedtags, wp_kses_allowed_html( '' ) ); + $this->assertSame( $allowedtags, wp_kses_allowed_html() ); $tags = wp_kses_allowed_html( 'user_description' ); $this->assertTrue( $tags['a']['rel'] ); @@ -446,7 +446,7 @@ EOF; $tags = wp_kses_allowed_html(); $this->assertFalse( isset( $tags['a']['rel'] ) ); - $this->assertEquals( array(), wp_kses_allowed_html( 'strip' ) ); + $this->assertSame( array(), wp_kses_allowed_html( 'strip' ) ); $custom_tags = array( 'a' => array( @@ -458,16 +458,16 @@ EOF; ), ); - $this->assertEquals( $custom_tags, wp_kses_allowed_html( $custom_tags ) ); + $this->assertSame( $custom_tags, wp_kses_allowed_html( $custom_tags ) ); add_filter( 'wp_kses_allowed_html', array( $this, '_wp_kses_allowed_html_filter' ), 10, 2 ); - $this->assertEquals( array( 'a' => array( 'href' => true ) ), wp_kses_allowed_html( 'post' ) ); - $this->assertEquals( array( 'a' => array( 'href' => false ) ), wp_kses_allowed_html( 'data' ) ); + $this->assertSame( array( 'a' => array( 'href' => true ) ), wp_kses_allowed_html( 'post' ) ); + $this->assertSame( array( 'a' => array( 'href' => false ) ), wp_kses_allowed_html( 'data' ) ); remove_filter( 'wp_kses_allowed_html', array( $this, '_wp_kses_allowed_html_filter' ) ); - $this->assertEquals( $allowedposttags, wp_kses_allowed_html( 'post' ) ); - $this->assertEquals( $allowedtags, wp_kses_allowed_html( 'data' ) ); + $this->assertSame( $allowedposttags, wp_kses_allowed_html( 'post' ) ); + $this->assertSame( $allowedtags, wp_kses_allowed_html( 'data' ) ); } function test_hyphenated_tag() { @@ -480,23 +480,23 @@ EOF; $expect_stripped_string = 'Alot of hyphens.'; $expect_valid_string = '<hyphenated-tag attribute="value">Alot of hyphens.</hyphenated-tag>'; - $this->assertEquals( $expect_stripped_string, wp_kses_post( $string ) ); - $this->assertEquals( $expect_valid_string, wp_kses( $string, $custom_tags ) ); + $this->assertSame( $expect_stripped_string, wp_kses_post( $string ) ); + $this->assertSame( $expect_valid_string, wp_kses( $string, $custom_tags ) ); } /** * @ticket 26290 */ public function test_wp_kses_normalize_entities() { - $this->assertEquals( '♠', wp_kses_normalize_entities( '♠' ) ); + $this->assertSame( '♠', wp_kses_normalize_entities( '♠' ) ); - $this->assertEquals( '¹', wp_kses_normalize_entities( '¹' ) ); - $this->assertEquals( '²', wp_kses_normalize_entities( '²' ) ); - $this->assertEquals( '³', wp_kses_normalize_entities( '³' ) ); - $this->assertEquals( '¼', wp_kses_normalize_entities( '¼' ) ); - $this->assertEquals( '½', wp_kses_normalize_entities( '½' ) ); - $this->assertEquals( '¾', wp_kses_normalize_entities( '¾' ) ); - $this->assertEquals( '∴', wp_kses_normalize_entities( '∴' ) ); + $this->assertSame( '¹', wp_kses_normalize_entities( '¹' ) ); + $this->assertSame( '²', wp_kses_normalize_entities( '²' ) ); + $this->assertSame( '³', wp_kses_normalize_entities( '³' ) ); + $this->assertSame( '¼', wp_kses_normalize_entities( '¼' ) ); + $this->assertSame( '½', wp_kses_normalize_entities( '½' ) ); + $this->assertSame( '¾', wp_kses_normalize_entities( '¾' ) ); + $this->assertSame( '∴', wp_kses_normalize_entities( '∴' ) ); } /** @@ -508,7 +508,7 @@ EOF; function test_ctrl_removal( $input, $output ) { global $allowedposttags; - return $this->assertEquals( $output, wp_kses( $input, $allowedposttags ) ); + return $this->assertSame( $output, wp_kses( $input, $allowedposttags ) ); } function data_ctrl_removal() { @@ -545,7 +545,7 @@ EOF; function test_slash_zero_removal( $input, $output ) { global $allowedposttags; - return $this->assertEquals( $output, wp_kses( $input, $allowedposttags ) ); + return $this->assertSame( $output, wp_kses( $input, $allowedposttags ) ); } function data_slash_zero_removal() { @@ -595,7 +595,7 @@ EOF; * @dataProvider data_hair_parse */ function test_hair_parse( $input, $output ) { - return $this->assertEquals( $output, wp_kses_hair_parse( $input ) ); + return $this->assertSame( $output, wp_kses_hair_parse( $input ) ); } function data_hair_parse() { @@ -661,7 +661,7 @@ EOF; * @dataProvider data_attr_parse */ function test_attr_parse( $input, $output ) { - return $this->assertEquals( $output, wp_kses_attr_parse( $input ) ); + return $this->assertSame( $output, wp_kses_attr_parse( $input ) ); } function data_attr_parse() { @@ -719,7 +719,7 @@ EOF; * @dataProvider data_one_attr */ function test_one_attr( $element, $input, $output ) { - return $this->assertEquals( $output, wp_kses_one_attr( $input, $element ) ); + return $this->assertSame( $output, wp_kses_one_attr( $input, $element ) ); } function data_one_attr() { @@ -800,7 +800,7 @@ EOF; $input = '<p>This is <bdo dir="rtl">a BDO tag</bdo>. Weird, <bdo dir="ltr">right?</bdo></p>'; - $this->assertEquals( $input, wp_kses( $input, $allowedposttags ) ); + $this->assertSame( $input, wp_kses( $input, $allowedposttags ) ); } /** @@ -811,7 +811,7 @@ EOF; $input = '<ol reversed="reversed"><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>'; - $this->assertEquals( $input, wp_kses( $input, $allowedposttags ) ); + $this->assertSame( $input, wp_kses( $input, $allowedposttags ) ); } /** @@ -821,7 +821,7 @@ EOF; $element = 'foo'; $attribute = 'title="foo" class="bar"'; - $this->assertEquals( "<{$element}>", wp_kses_attr( $element, $attribute, array( 'foo' => array() ), array() ) ); + $this->assertSame( "<{$element}>", wp_kses_attr( $element, $attribute, array( 'foo' => array() ), array() ) ); } /** @@ -831,7 +831,7 @@ EOF; $element = 'foo'; $attribute = 'title="foo" class="bar"'; - $this->assertEquals( "<{$element}>", wp_kses_attr( $element, $attribute, array( 'foo' => true ), array() ) ); + $this->assertSame( "<{$element}>", wp_kses_attr( $element, $attribute, array( 'foo' => true ), array() ) ); } /** @@ -841,7 +841,7 @@ EOF; $element = 'foo'; $attribute = 'title="foo" class="bar"'; - $this->assertEquals( "<{$element} title=\"foo\">", wp_kses_attr( $element, $attribute, array( 'foo' => array( 'title' => true ) ), array() ) ); + $this->assertSame( "<{$element} title=\"foo\">", wp_kses_attr( $element, $attribute, array( 'foo' => array( 'title' => true ) ), array() ) ); } /** @@ -851,7 +851,7 @@ EOF; $element = 'foo'; $attribute = 'title="foo" class="bar"'; - $this->assertEquals( "<{$element}>", wp_kses_attr( $element, $attribute, array( 'foo' => false ), array() ) ); + $this->assertSame( "<{$element}>", wp_kses_attr( $element, $attribute, array( 'foo' => false ), array() ) ); } /** @@ -1057,7 +1057,7 @@ EOF; $test = '<div data-foo="foo" data-bar="bar" datainvalid="gone" data--invaild="gone" data-also-invaild-="gone" data-two-hyphens="remains">Pens and pencils</div>'; $expected = '<div data-foo="foo" data-bar="bar" data-two-hyphens="remains">Pens and pencils</div>'; - $this->assertEquals( $expected, wp_kses_post( $test ) ); + $this->assertSame( $expected, wp_kses_post( $test ) ); } /** diff --git a/tests/phpunit/tests/l10n.php b/tests/phpunit/tests/l10n.php index 7c8e492fc5..f39bdb8307 100644 --- a/tests/phpunit/tests/l10n.php +++ b/tests/phpunit/tests/l10n.php @@ -23,9 +23,9 @@ class Tests_L10n extends WP_UnitTestCase { $nooped_plural = _n_noop( '%s post', '%s posts', $text_domain ); $this->assertNotEmpty( $nooped_plural['domain'] ); - $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) ); - $this->assertEquals( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) ); - $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) ); + $this->assertSame( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) ); + $this->assertSame( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) ); + $this->assertSame( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) ); } /** @@ -37,18 +37,18 @@ class Tests_L10n extends WP_UnitTestCase { $this->assertNotEmpty( $nooped_plural['domain'] ); $this->assertNotEmpty( $nooped_plural['context'] ); - $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) ); - $this->assertEquals( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) ); - $this->assertEquals( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) ); + $this->assertSame( '%s posts', translate_nooped_plural( $nooped_plural, 0, $text_domain ) ); + $this->assertSame( '%s post', translate_nooped_plural( $nooped_plural, 1, $text_domain ) ); + $this->assertSame( '%s posts', translate_nooped_plural( $nooped_plural, 2, $text_domain ) ); } /** * @ticket 35073 */ function test_before_last_bar() { - $this->assertEquals( 'no-bar-at-all', before_last_bar( 'no-bar-at-all' ) ); - $this->assertEquals( 'before-last-bar', before_last_bar( 'before-last-bar|after-bar' ) ); - $this->assertEquals( 'first-before-bar|second-before-bar', before_last_bar( 'first-before-bar|second-before-bar|after-last-bar' ) ); + $this->assertSame( 'no-bar-at-all', before_last_bar( 'no-bar-at-all' ) ); + $this->assertSame( 'before-last-bar', before_last_bar( 'before-last-bar|after-bar' ) ); + $this->assertSame( 'first-before-bar|second-before-bar', before_last_bar( 'first-before-bar|second-before-bar|after-last-bar' ) ); } /** @@ -62,7 +62,7 @@ class Tests_L10n extends WP_UnitTestCase { $this->assertEmpty( $array ); $array = get_available_languages( DIR_TESTDATA . '/languages/' ); - $this->assertEquals( array( 'de_DE', 'en_GB', 'es_ES', 'ja_JP' ), $array ); + $this->assertSame( array( 'de_DE', 'en_GB', 'es_ES', 'ja_JP' ), $array ); } /** @@ -76,15 +76,15 @@ class Tests_L10n extends WP_UnitTestCase { $this->assertNotEmpty( $installed_translations['default']['en_GB'] ); $data_en_gb = $installed_translations['default']['en_GB']; - $this->assertEquals( '2016-10-26 00:01+0200', $data_en_gb['PO-Revision-Date'] ); - $this->assertEquals( 'Development (4.4.x)', $data_en_gb['Project-Id-Version'] ); - $this->assertEquals( 'Poedit 1.8.10', $data_en_gb['X-Generator'] ); + $this->assertSame( '2016-10-26 00:01+0200', $data_en_gb['PO-Revision-Date'] ); + $this->assertSame( 'Development (4.4.x)', $data_en_gb['Project-Id-Version'] ); + $this->assertSame( 'Poedit 1.8.10', $data_en_gb['X-Generator'] ); $this->assertNotEmpty( $installed_translations['admin']['es_ES'] ); $data_es_es = $installed_translations['admin']['es_ES']; - $this->assertEquals( '2016-10-25 18:29+0200', $data_es_es['PO-Revision-Date'] ); - $this->assertEquals( 'Administration', $data_es_es['Project-Id-Version'] ); - $this->assertEquals( 'Poedit 1.8.10', $data_es_es['X-Generator'] ); + $this->assertSame( '2016-10-25 18:29+0200', $data_es_es['PO-Revision-Date'] ); + $this->assertSame( 'Administration', $data_es_es['Project-Id-Version'] ); + $this->assertSame( 'Poedit 1.8.10', $data_es_es['X-Generator'] ); } /** diff --git a/tests/phpunit/tests/l10n/loadScriptTextdomain.php b/tests/phpunit/tests/l10n/loadScriptTextdomain.php index 310cc72bea..9f4e1012ba 100644 --- a/tests/phpunit/tests/l10n/loadScriptTextdomain.php +++ b/tests/phpunit/tests/l10n/loadScriptTextdomain.php @@ -32,18 +32,18 @@ class Tests_L10n_loadScriptTextdomain extends WP_UnitTestCase { $json_translations = file_get_contents( DIR_TESTDATA . '/languages/en_US-813e104eb47e13dd4cc5af844c618754.json' ); wp_enqueue_script( 'test-example-root', '/wp-includes/js/script.js', array(), null ); - $this->assertEquals( $json_translations, load_script_textdomain( 'test-example-root', 'default', DIR_TESTDATA . '/languages' ) ); + $this->assertSame( $json_translations, load_script_textdomain( 'test-example-root', 'default', DIR_TESTDATA . '/languages' ) ); // Assets on a CDN. add_filter( 'load_script_textdomain_relative_path', array( $this, 'relative_path_from_cdn' ), 10, 2 ); wp_enqueue_script( 'test-example-cdn', 'https://my-cdn.com/wordpress/wp-includes/js/script.js', array(), null ); - $this->assertEquals( $json_translations, load_script_textdomain( 'test-example-cdn', 'default', DIR_TESTDATA . '/languages' ) ); + $this->assertSame( $json_translations, load_script_textdomain( 'test-example-cdn', 'default', DIR_TESTDATA . '/languages' ) ); remove_filter( 'load_script_textdomain_relative_path', array( $this, 'relative_path_from_cdn' ) ); // Test for WordPress installs in a subdirectory. add_filter( 'site_url', array( $this, 'site_url_subdirectory' ) ); wp_enqueue_script( 'test-example-subdir', '/wp/wp-includes/js/script.js', array(), null ); - $this->assertEquals( $json_translations, load_script_textdomain( 'test-example-subdir', 'default', DIR_TESTDATA . '/languages' ) ); + $this->assertSame( $json_translations, load_script_textdomain( 'test-example-subdir', 'default', DIR_TESTDATA . '/languages' ) ); remove_filter( 'site_url', array( $this, 'site_url_subdirectory' ) ); } @@ -55,7 +55,7 @@ class Tests_L10n_loadScriptTextdomain extends WP_UnitTestCase { add_filter( 'plugins_url', array( $this, 'plugins_url_custom_domain' ) ); wp_enqueue_script( 'plugin-example-1', 'https://plugins.example.com/my-plugin/js/script.js', array(), null ); - $this->assertEquals( $json_translations, load_script_textdomain( 'plugin-example-1', 'internationalized-plugin', DIR_TESTDATA . '/languages' ) ); + $this->assertSame( $json_translations, load_script_textdomain( 'plugin-example-1', 'internationalized-plugin', DIR_TESTDATA . '/languages' ) ); remove_filter( 'plugins_url', array( $this, 'plugins_url_custom_domain' ) ); } @@ -67,7 +67,7 @@ class Tests_L10n_loadScriptTextdomain extends WP_UnitTestCase { add_filter( 'content_url', array( $this, 'content_url_custom_domain_with_no_path' ) ); wp_enqueue_script( 'plugin-example-2', 'https://content.example.com/plugins/my-plugin/js/script.js', array(), null ); - $this->assertEquals( $json_translations, load_script_textdomain( 'plugin-example-2', 'internationalized-plugin', DIR_TESTDATA . '/languages' ) ); + $this->assertSame( $json_translations, load_script_textdomain( 'plugin-example-2', 'internationalized-plugin', DIR_TESTDATA . '/languages' ) ); remove_filter( 'content_url', array( $this, 'content_url_custom_domain_with_no_path' ) ); } } diff --git a/tests/phpunit/tests/link.php b/tests/phpunit/tests/link.php index 263da2fe50..62f55fbd7d 100644 --- a/tests/phpunit/tests/link.php +++ b/tests/phpunit/tests/link.php @@ -21,7 +21,7 @@ class Tests_Link extends WP_UnitTestCase { $paged = get_pagenum_link( 2 ); remove_filter( 'home_url', array( $this, '_get_pagenum_link_cb' ) ); - $this->assertEquals( $paged, home_url( '/WooHoo/page/2/' ) ); + $this->assertSame( $paged, home_url( '/WooHoo/page/2/' ) ); $_SERVER['REQUEST_URI'] = $old_req_uri; } @@ -31,43 +31,43 @@ class Tests_Link extends WP_UnitTestCase { $post_id2 = self::factory()->post->create(); // Basic case. - $this->assertEquals( get_permalink( $post_id ), wp_get_shortlink( $post_id, 'post' ) ); + $this->assertSame( get_permalink( $post_id ), wp_get_shortlink( $post_id, 'post' ) ); unset( $GLOBALS['post'] ); // Global post is not set. - $this->assertEquals( '', wp_get_shortlink( 0, 'post' ) ); - $this->assertEquals( '', wp_get_shortlink( 0 ) ); - $this->assertEquals( '', wp_get_shortlink() ); + $this->assertSame( '', wp_get_shortlink( 0, 'post' ) ); + $this->assertSame( '', wp_get_shortlink( 0 ) ); + $this->assertSame( '', wp_get_shortlink() ); $GLOBALS['post'] = get_post( $post_id ); // Global post is set. - $this->assertEquals( get_permalink( $post_id ), wp_get_shortlink( 0, 'post' ) ); - $this->assertEquals( get_permalink( $post_id ), wp_get_shortlink( 0 ) ); - $this->assertEquals( get_permalink( $post_id ), wp_get_shortlink() ); + $this->assertSame( get_permalink( $post_id ), wp_get_shortlink( 0, 'post' ) ); + $this->assertSame( get_permalink( $post_id ), wp_get_shortlink( 0 ) ); + $this->assertSame( get_permalink( $post_id ), wp_get_shortlink() ); // Not the global post. - $this->assertEquals( get_permalink( $post_id2 ), wp_get_shortlink( $post_id2, 'post' ) ); + $this->assertSame( get_permalink( $post_id2 ), wp_get_shortlink( $post_id2, 'post' ) ); unset( $GLOBALS['post'] ); // Global post is not set, once again. - $this->assertEquals( '', wp_get_shortlink( 0, 'post' ) ); - $this->assertEquals( '', wp_get_shortlink( 0 ) ); - $this->assertEquals( '', wp_get_shortlink() ); + $this->assertSame( '', wp_get_shortlink( 0, 'post' ) ); + $this->assertSame( '', wp_get_shortlink( 0 ) ); + $this->assertSame( '', wp_get_shortlink() ); $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); // With a permalink structure set, get_permalink() will no longer match. $this->assertNotEquals( get_permalink( $post_id ), wp_get_shortlink( $post_id, 'post' ) ); - $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink( $post_id, 'post' ) ); + $this->assertSame( home_url( '?p=' . $post_id ), wp_get_shortlink( $post_id, 'post' ) ); // Global post and permalink structure are set. $GLOBALS['post'] = get_post( $post_id ); - $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink( 0, 'post' ) ); - $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink( 0 ) ); - $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink() ); + $this->assertSame( home_url( '?p=' . $post_id ), wp_get_shortlink( 0, 'post' ) ); + $this->assertSame( home_url( '?p=' . $post_id ), wp_get_shortlink( 0 ) ); + $this->assertSame( home_url( '?p=' . $post_id ), wp_get_shortlink() ); } function test_wp_get_shortlink_with_page() { @@ -75,11 +75,11 @@ class Tests_Link extends WP_UnitTestCase { // Basic case. // Don't test against get_permalink() since it uses ?page_id= for pages. - $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink( $post_id, 'post' ) ); + $this->assertSame( home_url( '?p=' . $post_id ), wp_get_shortlink( $post_id, 'post' ) ); $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); - $this->assertEquals( home_url( '?p=' . $post_id ), wp_get_shortlink( $post_id, 'post' ) ); + $this->assertSame( home_url( '?p=' . $post_id ), wp_get_shortlink( $post_id, 'post' ) ); } /** @@ -90,11 +90,11 @@ class Tests_Link extends WP_UnitTestCase { update_option( 'show_on_front', 'page' ); update_option( 'page_on_front', $post_id ); - $this->assertEquals( home_url( '/' ), wp_get_shortlink( $post_id, 'post' ) ); + $this->assertSame( home_url( '/' ), wp_get_shortlink( $post_id, 'post' ) ); $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); - $this->assertEquals( home_url( '/' ), wp_get_shortlink( $post_id, 'post' ) ); + $this->assertSame( home_url( '/' ), wp_get_shortlink( $post_id, 'post' ) ); } /** @@ -114,7 +114,7 @@ class Tests_Link extends WP_UnitTestCase { $non_pretty_permalink = add_query_arg( 'p', $p, trailingslashit( home_url() ) ); - $this->assertEquals( $non_pretty_permalink, get_permalink( $p ) ); + $this->assertSame( $non_pretty_permalink, get_permalink( $p ) ); } /** @@ -143,7 +143,7 @@ class Tests_Link extends WP_UnitTestCase { trailingslashit( home_url() ) ); - $this->assertEquals( $non_pretty_permalink, get_permalink( $p ) ); + $this->assertSame( $non_pretty_permalink, get_permalink( $p ) ); } /** diff --git a/tests/phpunit/tests/link/getAdjacentPost.php b/tests/phpunit/tests/link/getAdjacentPost.php index 97dbba38b9..2954732ef2 100644 --- a/tests/phpunit/tests/link/getAdjacentPost.php +++ b/tests/phpunit/tests/link/getAdjacentPost.php @@ -58,13 +58,13 @@ class Tests_Link_GetAdjacentPost extends WP_UnitTestCase { // Test category adjacency. $this->go_to( get_permalink( $post_one->ID ) ); - $this->assertEquals( '', get_adjacent_post( true, '', true, 'category' ) ); + $this->assertSame( '', get_adjacent_post( true, '', true, 'category' ) ); $this->assertEquals( $post_three, get_adjacent_post( true, '', false, 'category' ) ); // Test tag adjacency. $this->go_to( get_permalink( $post_two->ID ) ); - $this->assertEquals( '', get_adjacent_post( true, '', true, 'post_tag' ) ); + $this->assertSame( '', get_adjacent_post( true, '', true, 'post_tag' ) ); $this->assertEquals( $post_four, get_adjacent_post( true, '', false, 'post_tag' ) ); // Test normal boundary post. @@ -204,7 +204,7 @@ class Tests_Link_GetAdjacentPost extends WP_UnitTestCase { } // Should skip $p2, which belongs to $t. - $this->assertEquals( $p3, $found->ID ); + $this->assertSame( $p3, $found->ID ); } /** @@ -241,7 +241,7 @@ class Tests_Link_GetAdjacentPost extends WP_UnitTestCase { } // Should skip $p2, which belongs to $t. - $this->assertEquals( $p3, $found->ID ); + $this->assertSame( $p3, $found->ID ); } /** diff --git a/tests/phpunit/tests/link/getDashboardUrl.php b/tests/phpunit/tests/link/getDashboardUrl.php index 1b70e13a70..be051b3027 100644 --- a/tests/phpunit/tests/link/getDashboardUrl.php +++ b/tests/phpunit/tests/link/getDashboardUrl.php @@ -22,7 +22,7 @@ class Tests_Link_GetDashboardUrl extends WP_UnitTestCase { * @ticket 39065 */ public function test_get_dashboard_url_for_current_site_user() { - $this->assertEquals( admin_url(), get_dashboard_url( self::$user_id ) ); + $this->assertSame( admin_url(), get_dashboard_url( self::$user_id ) ); } /** @@ -33,7 +33,7 @@ class Tests_Link_GetDashboardUrl extends WP_UnitTestCase { $expected = is_multisite() ? user_admin_url() : admin_url(); - $this->assertEquals( $expected, get_dashboard_url( self::$user_id ) ); + $this->assertSame( $expected, get_dashboard_url( self::$user_id ) ); } /** @@ -50,7 +50,7 @@ class Tests_Link_GetDashboardUrl extends WP_UnitTestCase { revoke_super_admin( self::$user_id ); - $this->assertEquals( $expected, $result ); + $this->assertSame( $expected, $result ); } /** @@ -70,6 +70,6 @@ class Tests_Link_GetDashboardUrl extends WP_UnitTestCase { wp_delete_site( $site_id ); - $this->assertEquals( $expected, $result ); + $this->assertSame( $expected, $result ); } } diff --git a/tests/phpunit/tests/link/getPostCommentsFeedLink.php b/tests/phpunit/tests/link/getPostCommentsFeedLink.php index e96aa97af6..c905ff08cf 100644 --- a/tests/phpunit/tests/link/getPostCommentsFeedLink.php +++ b/tests/phpunit/tests/link/getPostCommentsFeedLink.php @@ -16,7 +16,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { home_url( '/' ) ); - $this->assertEquals( $expected, $link ); + $this->assertSame( $expected, $link ); } public function test_post_pretty_link() { @@ -27,7 +27,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { $link = get_post_comments_feed_link( $post_id ); $expected = get_permalink( $post_id ) . 'feed/'; - $this->assertEquals( $expected, $link ); + $this->assertSame( $expected, $link ); } public function test_attachment_link() { @@ -50,7 +50,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { home_url( '/' ) ); - $this->assertEquals( $expected, $link ); + $this->assertSame( $expected, $link ); } public function test_attachment_pretty_link() { @@ -76,7 +76,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { $link = get_post_comments_feed_link( $attachment_id ); $expected = get_permalink( $post_id ) . 'burrito/feed/'; - $this->assertEquals( $expected, $link ); + $this->assertSame( $expected, $link ); } public function test_attachment_no_name_pretty_link() { @@ -95,7 +95,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { $link = get_post_comments_feed_link( $attachment_id ); $expected = get_permalink( $post_id ) . 'attachment/' . $attachment_id . '/feed/'; - $this->assertEquals( $expected, $link ); + $this->assertSame( $expected, $link ); } public function test_unattached_link() { @@ -117,7 +117,7 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { home_url( '/' ) ); - $this->assertEquals( $expected, $link ); + $this->assertSame( $expected, $link ); } public function test_unattached_pretty_link() { @@ -135,6 +135,6 @@ class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase { $link = get_post_comments_feed_link( $attachment_id ); $expected = add_query_arg( 'attachment_id', $attachment_id, home_url( '/feed/' ) ); - $this->assertEquals( $expected, $link ); + $this->assertSame( $expected, $link ); } } diff --git a/tests/phpunit/tests/link/getPreviewPostLink.php b/tests/phpunit/tests/link/getPreviewPostLink.php index 79ea850af2..a689cb31f3 100644 --- a/tests/phpunit/tests/link/getPreviewPostLink.php +++ b/tests/phpunit/tests/link/getPreviewPostLink.php @@ -8,7 +8,7 @@ class Tests_Link_GetPreviewPostLink extends WP_UnitTestCase { public function test_get_preview_post_link() { $post = self::factory()->post->create(); - $this->assertEquals( add_query_arg( 'preview', 'true', get_permalink( $post ) ), get_preview_post_link( $post ) ); + $this->assertSame( add_query_arg( 'preview', 'true', get_permalink( $post ) ), get_preview_post_link( $post ) ); } public function test_get_preview_post_link_should_add_additional_query_vars() { @@ -23,7 +23,7 @@ class Tests_Link_GetPreviewPostLink extends WP_UnitTestCase { get_permalink( $post ) ); - $this->assertEquals( + $this->assertSame( $expected, get_preview_post_link( $post, @@ -40,7 +40,7 @@ class Tests_Link_GetPreviewPostLink extends WP_UnitTestCase { $expected = 'https://google.com/?foo=bar&bar=baz&preview=true'; - $this->assertEquals( + $this->assertSame( $expected, get_preview_post_link( $post, @@ -64,7 +64,7 @@ class Tests_Link_GetPreviewPostLink extends WP_UnitTestCase { $GLOBALS['post'] = $post; - $this->assertEquals( add_query_arg( 'preview', 'true', get_permalink( $post ) ), get_preview_post_link() ); + $this->assertSame( add_query_arg( 'preview', 'true', get_permalink( $post ) ), get_preview_post_link() ); } public function test_get_preview_post_link_should_return_empty_string_for_non_viewable_post_type() { diff --git a/tests/phpunit/tests/link/getPreviousCommentsLink.php b/tests/phpunit/tests/link/getPreviousCommentsLink.php index ff4c088dea..6872f90e89 100644 --- a/tests/phpunit/tests/link/getPreviousCommentsLink.php +++ b/tests/phpunit/tests/link/getPreviousCommentsLink.php @@ -28,10 +28,10 @@ class Tests_Link_GetPreviousCommentsLink extends WP_UnitTestCase { $cpage = get_query_var( 'cpage' ); set_query_var( 'cpage', '' ); - $link = get_previous_comments_link( 'Next', 5 ); + $link = get_previous_comments_link( 'Next' ); // Technically, it returns null here. - $this->assertEquals( '', $link ); + $this->assertNull( $link ); set_query_var( 'cpage', $cpage ); } diff --git a/tests/phpunit/tests/link/wpGetCanonicalURL.php b/tests/phpunit/tests/link/wpGetCanonicalURL.php index 2dedd63c1a..c6f0722db6 100644 --- a/tests/phpunit/tests/link/wpGetCanonicalURL.php +++ b/tests/phpunit/tests/link/wpGetCanonicalURL.php @@ -41,7 +41,7 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase { * Test for a page that is not the queried object. */ public function test_non_current_page() { - $this->assertEquals( get_permalink( self::$post_id ), wp_get_canonical_url( self::$post_id ) ); + $this->assertSame( get_permalink( self::$post_id ), wp_get_canonical_url( self::$post_id ) ); } /** @@ -65,7 +65,7 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase { get_permalink( self::$post_id ) ); - $this->assertEquals( $expected, wp_get_canonical_url( self::$post_id ) ); + $this->assertSame( $expected, wp_get_canonical_url( self::$post_id ) ); } /** @@ -87,7 +87,7 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase { $expected = trailingslashit( get_permalink( self::$post_id ) ) . user_trailingslashit( $page, 'single_paged' ); - $this->assertEquals( $expected, wp_get_canonical_url( self::$post_id ) ); + $this->assertSame( $expected, wp_get_canonical_url( self::$post_id ) ); } /** @@ -113,7 +113,7 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase { get_permalink( self::$post_id ) . '#comments' ); - $this->assertEquals( $expected, wp_get_canonical_url( self::$post_id ) ); + $this->assertSame( $expected, wp_get_canonical_url( self::$post_id ) ); } /** @@ -137,7 +137,7 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase { $expected = user_trailingslashit( trailingslashit( get_permalink( self::$post_id ) ) . $wp_rewrite->comments_pagination_base . '-' . $cpage, 'commentpaged' ) . '#comments'; - $this->assertEquals( $expected, wp_get_canonical_url( self::$post_id ) ); + $this->assertSame( $expected, wp_get_canonical_url( self::$post_id ) ); } /** @@ -148,7 +148,7 @@ class Tests_WpGetCanonicalURL extends WP_UnitTestCase { $canonical_url = wp_get_canonical_url( self::$post_id ); remove_filter( 'get_canonical_url', array( $this, 'canonical_url_filter' ) ); - $this->assertEquals( $this->canonical_url_filter(), $canonical_url ); + $this->assertSame( $this->canonical_url_filter(), $canonical_url ); } /** diff --git a/tests/phpunit/tests/locale.php b/tests/phpunit/tests/locale.php index 9790ca14bf..a51df0a5b4 100644 --- a/tests/phpunit/tests/locale.php +++ b/tests/phpunit/tests/locale.php @@ -16,13 +16,13 @@ class Tests_Locale extends WP_UnitTestCase { } public function test_get_weekday() { - $this->assertEquals( __( 'Sunday' ), $this->locale->get_weekday( 0 ) ); - $this->assertEquals( __( 'Monday' ), $this->locale->get_weekday( 1 ) ); - $this->assertEquals( __( 'Tuesday' ), $this->locale->get_weekday( 2 ) ); - $this->assertEquals( __( 'Wednesday' ), $this->locale->get_weekday( 3 ) ); - $this->assertEquals( __( 'Thursday' ), $this->locale->get_weekday( 4 ) ); - $this->assertEquals( __( 'Friday' ), $this->locale->get_weekday( 5 ) ); - $this->assertEquals( __( 'Saturday' ), $this->locale->get_weekday( 6 ) ); + $this->assertSame( __( 'Sunday' ), $this->locale->get_weekday( 0 ) ); + $this->assertSame( __( 'Monday' ), $this->locale->get_weekday( 1 ) ); + $this->assertSame( __( 'Tuesday' ), $this->locale->get_weekday( 2 ) ); + $this->assertSame( __( 'Wednesday' ), $this->locale->get_weekday( 3 ) ); + $this->assertSame( __( 'Thursday' ), $this->locale->get_weekday( 4 ) ); + $this->assertSame( __( 'Friday' ), $this->locale->get_weekday( 5 ) ); + $this->assertSame( __( 'Saturday' ), $this->locale->get_weekday( 6 ) ); } /** @@ -33,72 +33,72 @@ class Tests_Locale extends WP_UnitTestCase { } public function test_get_weekday_initial() { - $this->assertEquals( __( 'S' ), $this->locale->get_weekday_initial( __( 'Sunday' ) ) ); - $this->assertEquals( __( 'M' ), $this->locale->get_weekday_initial( __( 'Monday' ) ) ); - $this->assertEquals( __( 'T' ), $this->locale->get_weekday_initial( __( 'Tuesday' ) ) ); - $this->assertEquals( __( 'W' ), $this->locale->get_weekday_initial( __( 'Wednesday' ) ) ); - $this->assertEquals( __( 'T' ), $this->locale->get_weekday_initial( __( 'Thursday' ) ) ); - $this->assertEquals( __( 'F' ), $this->locale->get_weekday_initial( __( 'Friday' ) ) ); - $this->assertEquals( __( 'S' ), $this->locale->get_weekday_initial( __( 'Saturday' ) ) ); + $this->assertSame( __( 'S' ), $this->locale->get_weekday_initial( __( 'Sunday' ) ) ); + $this->assertSame( __( 'M' ), $this->locale->get_weekday_initial( __( 'Monday' ) ) ); + $this->assertSame( __( 'T' ), $this->locale->get_weekday_initial( __( 'Tuesday' ) ) ); + $this->assertSame( __( 'W' ), $this->locale->get_weekday_initial( __( 'Wednesday' ) ) ); + $this->assertSame( __( 'T' ), $this->locale->get_weekday_initial( __( 'Thursday' ) ) ); + $this->assertSame( __( 'F' ), $this->locale->get_weekday_initial( __( 'Friday' ) ) ); + $this->assertSame( __( 'S' ), $this->locale->get_weekday_initial( __( 'Saturday' ) ) ); } public function test_get_weekday_abbrev() { - $this->assertEquals( __( 'Sun' ), $this->locale->get_weekday_abbrev( __( 'Sunday' ) ) ); - $this->assertEquals( __( 'Mon' ), $this->locale->get_weekday_abbrev( __( 'Monday' ) ) ); - $this->assertEquals( __( 'Tue' ), $this->locale->get_weekday_abbrev( __( 'Tuesday' ) ) ); - $this->assertEquals( __( 'Wed' ), $this->locale->get_weekday_abbrev( __( 'Wednesday' ) ) ); - $this->assertEquals( __( 'Thu' ), $this->locale->get_weekday_abbrev( __( 'Thursday' ) ) ); - $this->assertEquals( __( 'Fri' ), $this->locale->get_weekday_abbrev( __( 'Friday' ) ) ); - $this->assertEquals( __( 'Sat' ), $this->locale->get_weekday_abbrev( __( 'Saturday' ) ) ); + $this->assertSame( __( 'Sun' ), $this->locale->get_weekday_abbrev( __( 'Sunday' ) ) ); + $this->assertSame( __( 'Mon' ), $this->locale->get_weekday_abbrev( __( 'Monday' ) ) ); + $this->assertSame( __( 'Tue' ), $this->locale->get_weekday_abbrev( __( 'Tuesday' ) ) ); + $this->assertSame( __( 'Wed' ), $this->locale->get_weekday_abbrev( __( 'Wednesday' ) ) ); + $this->assertSame( __( 'Thu' ), $this->locale->get_weekday_abbrev( __( 'Thursday' ) ) ); + $this->assertSame( __( 'Fri' ), $this->locale->get_weekday_abbrev( __( 'Friday' ) ) ); + $this->assertSame( __( 'Sat' ), $this->locale->get_weekday_abbrev( __( 'Saturday' ) ) ); } public function test_get_month() { - $this->assertEquals( __( 'January' ), $this->locale->get_month( 1 ) ); - $this->assertEquals( __( 'February' ), $this->locale->get_month( 2 ) ); - $this->assertEquals( __( 'March' ), $this->locale->get_month( 3 ) ); - $this->assertEquals( __( 'April' ), $this->locale->get_month( 4 ) ); - $this->assertEquals( __( 'May' ), $this->locale->get_month( 5 ) ); - $this->assertEquals( __( 'June' ), $this->locale->get_month( 6 ) ); - $this->assertEquals( __( 'July' ), $this->locale->get_month( 7 ) ); - $this->assertEquals( __( 'August' ), $this->locale->get_month( 8 ) ); - $this->assertEquals( __( 'September' ), $this->locale->get_month( 9 ) ); - $this->assertEquals( __( 'October' ), $this->locale->get_month( 10 ) ); - $this->assertEquals( __( 'November' ), $this->locale->get_month( 11 ) ); - $this->assertEquals( __( 'December' ), $this->locale->get_month( 12 ) ); + $this->assertSame( __( 'January' ), $this->locale->get_month( 1 ) ); + $this->assertSame( __( 'February' ), $this->locale->get_month( 2 ) ); + $this->assertSame( __( 'March' ), $this->locale->get_month( 3 ) ); + $this->assertSame( __( 'April' ), $this->locale->get_month( 4 ) ); + $this->assertSame( __( 'May' ), $this->locale->get_month( 5 ) ); + $this->assertSame( __( 'June' ), $this->locale->get_month( 6 ) ); + $this->assertSame( __( 'July' ), $this->locale->get_month( 7 ) ); + $this->assertSame( __( 'August' ), $this->locale->get_month( 8 ) ); + $this->assertSame( __( 'September' ), $this->locale->get_month( 9 ) ); + $this->assertSame( __( 'October' ), $this->locale->get_month( 10 ) ); + $this->assertSame( __( 'November' ), $this->locale->get_month( 11 ) ); + $this->assertSame( __( 'December' ), $this->locale->get_month( 12 ) ); } public function test_get_month_leading_zero() { - $this->assertEquals( __( 'January' ), $this->locale->get_month( '01' ) ); - $this->assertEquals( __( 'February' ), $this->locale->get_month( '02' ) ); - $this->assertEquals( __( 'March' ), $this->locale->get_month( '03' ) ); - $this->assertEquals( __( 'April' ), $this->locale->get_month( '04' ) ); - $this->assertEquals( __( 'May' ), $this->locale->get_month( '05' ) ); - $this->assertEquals( __( 'June' ), $this->locale->get_month( '06' ) ); - $this->assertEquals( __( 'July' ), $this->locale->get_month( '07' ) ); - $this->assertEquals( __( 'August' ), $this->locale->get_month( '08' ) ); - $this->assertEquals( __( 'September' ), $this->locale->get_month( '09' ) ); + $this->assertSame( __( 'January' ), $this->locale->get_month( '01' ) ); + $this->assertSame( __( 'February' ), $this->locale->get_month( '02' ) ); + $this->assertSame( __( 'March' ), $this->locale->get_month( '03' ) ); + $this->assertSame( __( 'April' ), $this->locale->get_month( '04' ) ); + $this->assertSame( __( 'May' ), $this->locale->get_month( '05' ) ); + $this->assertSame( __( 'June' ), $this->locale->get_month( '06' ) ); + $this->assertSame( __( 'July' ), $this->locale->get_month( '07' ) ); + $this->assertSame( __( 'August' ), $this->locale->get_month( '08' ) ); + $this->assertSame( __( 'September' ), $this->locale->get_month( '09' ) ); } public function test_get_month_abbrev() { - $this->assertEquals( __( 'Jan' ), $this->locale->get_month_abbrev( __( 'January' ) ) ); - $this->assertEquals( __( 'Feb' ), $this->locale->get_month_abbrev( __( 'February' ) ) ); - $this->assertEquals( __( 'Mar' ), $this->locale->get_month_abbrev( __( 'March' ) ) ); - $this->assertEquals( __( 'Apr' ), $this->locale->get_month_abbrev( __( 'April' ) ) ); - $this->assertEquals( __( 'May' ), $this->locale->get_month_abbrev( __( 'May' ) ) ); - $this->assertEquals( __( 'Jun' ), $this->locale->get_month_abbrev( __( 'June' ) ) ); - $this->assertEquals( __( 'Jul' ), $this->locale->get_month_abbrev( __( 'July' ) ) ); - $this->assertEquals( __( 'Aug' ), $this->locale->get_month_abbrev( __( 'August' ) ) ); - $this->assertEquals( __( 'Sep' ), $this->locale->get_month_abbrev( __( 'September' ) ) ); - $this->assertEquals( __( 'Oct' ), $this->locale->get_month_abbrev( __( 'October' ) ) ); - $this->assertEquals( __( 'Nov' ), $this->locale->get_month_abbrev( __( 'November' ) ) ); - $this->assertEquals( __( 'Dec' ), $this->locale->get_month_abbrev( __( 'December' ) ) ); + $this->assertSame( __( 'Jan' ), $this->locale->get_month_abbrev( __( 'January' ) ) ); + $this->assertSame( __( 'Feb' ), $this->locale->get_month_abbrev( __( 'February' ) ) ); + $this->assertSame( __( 'Mar' ), $this->locale->get_month_abbrev( __( 'March' ) ) ); + $this->assertSame( __( 'Apr' ), $this->locale->get_month_abbrev( __( 'April' ) ) ); + $this->assertSame( __( 'May' ), $this->locale->get_month_abbrev( __( 'May' ) ) ); + $this->assertSame( __( 'Jun' ), $this->locale->get_month_abbrev( __( 'June' ) ) ); + $this->assertSame( __( 'Jul' ), $this->locale->get_month_abbrev( __( 'July' ) ) ); + $this->assertSame( __( 'Aug' ), $this->locale->get_month_abbrev( __( 'August' ) ) ); + $this->assertSame( __( 'Sep' ), $this->locale->get_month_abbrev( __( 'September' ) ) ); + $this->assertSame( __( 'Oct' ), $this->locale->get_month_abbrev( __( 'October' ) ) ); + $this->assertSame( __( 'Nov' ), $this->locale->get_month_abbrev( __( 'November' ) ) ); + $this->assertSame( __( 'Dec' ), $this->locale->get_month_abbrev( __( 'December' ) ) ); } public function test_get_meridiem() { - $this->assertEquals( __( 'am' ), $this->locale->get_meridiem( 'am' ) ); - $this->assertEquals( __( 'AM' ), $this->locale->get_meridiem( 'AM' ) ); - $this->assertEquals( __( 'pm' ), $this->locale->get_meridiem( 'pm' ) ); - $this->assertEquals( __( 'PM' ), $this->locale->get_meridiem( 'PM' ) ); + $this->assertSame( __( 'am' ), $this->locale->get_meridiem( 'am' ) ); + $this->assertSame( __( 'AM' ), $this->locale->get_meridiem( 'AM' ) ); + $this->assertSame( __( 'pm' ), $this->locale->get_meridiem( 'pm' ) ); + $this->assertSame( __( 'PM' ), $this->locale->get_meridiem( 'PM' ) ); } public function test_is_rtl() { diff --git a/tests/phpunit/tests/mail.php b/tests/phpunit/tests/mail.php index f520e1e5a0..25d6fa3058 100644 --- a/tests/phpunit/tests/mail.php +++ b/tests/phpunit/tests/mail.php @@ -80,7 +80,7 @@ class Tests_Mail extends WP_UnitTestCase { $mailer = tests_retrieve_phpmailer_instance(); // We need some better assertions here but these catch the failure for now. - $this->assertEqualsIgnoreEOL( $body, $mailer->get_sent()->body ); + $this->assertSameIgnoreEOL( $body, $mailer->get_sent()->body ); $this->assertTrue( strpos( iconv_mime_decode_headers( ( $mailer->get_sent()->header ) )['Content-Type'][0], 'boundary="----=_Part_4892_25692638.1192452070893"' ) > 0 ); $this->assertTrue( strpos( $mailer->get_sent()->header, 'charset=' ) > 0 ); } @@ -106,13 +106,13 @@ class Tests_Mail extends WP_UnitTestCase { // Retrieve the mailer instance. $mailer = tests_retrieve_phpmailer_instance(); - $this->assertEquals( 'address@tld.com', $mailer->get_recipient( 'to' )->address ); - $this->assertEquals( 'Name', $mailer->get_recipient( 'to' )->name ); - $this->assertEquals( 'cc@cc.com', $mailer->get_recipient( 'cc' )->address ); - $this->assertEquals( 'The Carbon Guy', $mailer->get_recipient( 'cc' )->name ); - $this->assertEquals( 'bcc@bcc.com', $mailer->get_recipient( 'bcc' )->address ); - $this->assertEquals( 'The Blind Carbon Guy', $mailer->get_recipient( 'bcc' )->name ); - $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); + $this->assertSame( 'address@tld.com', $mailer->get_recipient( 'to' )->address ); + $this->assertSame( 'Name', $mailer->get_recipient( 'to' )->name ); + $this->assertSame( 'cc@cc.com', $mailer->get_recipient( 'cc' )->address ); + $this->assertSame( 'The Carbon Guy', $mailer->get_recipient( 'cc' )->name ); + $this->assertSame( 'bcc@bcc.com', $mailer->get_recipient( 'bcc' )->address ); + $this->assertSame( 'The Blind Carbon Guy', $mailer->get_recipient( 'bcc' )->name ); + $this->assertSameIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); } /** @@ -128,11 +128,11 @@ class Tests_Mail extends WP_UnitTestCase { // WordPress 3.2 and later correctly split the address into the two parts and send them separately to PHPMailer. // Earlier versions of PHPMailer were not touchy about the formatting of these arguments. $mailer = tests_retrieve_phpmailer_instance(); - $this->assertEquals( 'address@tld.com', $mailer->get_recipient( 'to' )->address ); - $this->assertEquals( 'Name', $mailer->get_recipient( 'to' )->name ); - $this->assertEquals( 'another_address@different-tld.com', $mailer->get_recipient( 'to', 0, 1 )->address ); - $this->assertEquals( 'Another Name', $mailer->get_recipient( 'to', 0, 1 )->name ); - $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); + $this->assertSame( 'address@tld.com', $mailer->get_recipient( 'to' )->address ); + $this->assertSame( 'Name', $mailer->get_recipient( 'to' )->name ); + $this->assertSame( 'another_address@different-tld.com', $mailer->get_recipient( 'to', 0, 1 )->address ); + $this->assertSame( 'Another Name', $mailer->get_recipient( 'to', 0, 1 )->name ); + $this->assertSameIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); } function test_wp_mail_multiple_to_addresses() { @@ -143,9 +143,9 @@ class Tests_Mail extends WP_UnitTestCase { wp_mail( $to, $subject, $message ); $mailer = tests_retrieve_phpmailer_instance(); - $this->assertEquals( 'address@tld.com', $mailer->get_recipient( 'to' )->address ); - $this->assertEquals( 'another_address@different-tld.com', $mailer->get_recipient( 'to', 0, 1 )->address ); - $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); + $this->assertSame( 'address@tld.com', $mailer->get_recipient( 'to' )->address ); + $this->assertSame( 'another_address@different-tld.com', $mailer->get_recipient( 'to', 0, 1 )->address ); + $this->assertSameIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); } /** @@ -159,8 +159,8 @@ class Tests_Mail extends WP_UnitTestCase { wp_mail( $to, $subject, $message ); $mailer = tests_retrieve_phpmailer_instance(); - $this->assertEquals( 'address@tld.com', $mailer->get_recipient( 'to' )->address ); - $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); + $this->assertSame( 'address@tld.com', $mailer->get_recipient( 'to' )->address ); + $this->assertSameIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); } /** @@ -286,7 +286,7 @@ class Tests_Mail extends WP_UnitTestCase { wp_mail( $to, $subject, $message, $headers ); $mailer = tests_retrieve_phpmailer_instance(); - $this->assertEquals( 1, substr_count( $mailer->get_sent()->header, $expected ) ); + $this->assertSame( 1, substr_count( $mailer->get_sent()->header, $expected ) ); } function wp_mail_quoted_printable( $mailer ) { @@ -354,7 +354,7 @@ class Tests_Mail extends WP_UnitTestCase { foreach ( $headers as $header => $value ) { $target_headers = preg_grep( "/^$header:/", $sent_headers ); - $this->assertEquals( $expected[ $header ], array_pop( $target_headers ) ); + $this->assertSame( $expected[ $header ], array_pop( $target_headers ) ); } } @@ -373,7 +373,7 @@ class Tests_Mail extends WP_UnitTestCase { $mailer = tests_retrieve_phpmailer_instance(); - $this->assertEquals( '', $mailer->Sender ); + $this->assertSame( '', $mailer->Sender ); } /** @@ -389,7 +389,7 @@ class Tests_Mail extends WP_UnitTestCase { wp_mail( $to, $subject, $message ); - $this->assertEquals( 1, $ma->get_call_count() ); + $this->assertSame( 1, $ma->get_call_count() ); $expected_error_data = array( 'to' => array( 'an_invalid_address' ), @@ -404,8 +404,8 @@ class Tests_Mail extends WP_UnitTestCase { $all_args = $ma->get_args(); $call_args = array_pop( $all_args ); - $this->assertEquals( 'wp_mail_failed', $call_args[0]->get_error_code() ); - $this->assertEquals( $expected_error_data, $call_args[0]->get_error_data() ); + $this->assertSame( 'wp_mail_failed', $call_args[0]->get_error_code() ); + $this->assertSame( $expected_error_data, $call_args[0]->get_error_data() ); } /** diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index 09f3003773..9131ab2cdb 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -48,8 +48,8 @@ CAP; function test_img_caption_shortcode_added() { global $shortcode_tags; - $this->assertEquals( 'img_caption_shortcode', $shortcode_tags['caption'] ); - $this->assertEquals( 'img_caption_shortcode', $shortcode_tags['wp_caption'] ); + $this->assertSame( 'img_caption_shortcode', $shortcode_tags['caption'] ); + $this->assertSame( 'img_caption_shortcode', $shortcode_tags['wp_caption'] ); } function test_img_caption_shortcode_with_empty_params() { @@ -62,7 +62,7 @@ CAP; */ function test_img_caption_shortcode_with_empty_params_but_content() { $result = img_caption_shortcode( array(), $this->caption ); - $this->assertEquals( $this->caption, $result ); + $this->assertSame( $this->caption, $result ); } /** @@ -72,7 +72,7 @@ CAP; add_filter( 'img_caption_shortcode', array( $this, '_return_alt_caption' ) ); $result = img_caption_shortcode( array(), $this->caption ); - $this->assertEquals( $this->alternate_caption, $result ); + $this->assertSame( $this->alternate_caption, $result ); } /** @@ -92,7 +92,7 @@ CAP; ), $this->caption ); - $this->assertEquals( $this->caption, $result ); + $this->assertSame( $this->caption, $result ); } /** @@ -117,7 +117,7 @@ CAP; ), $this->caption ); - $this->assertEquals( $this->caption, $result ); + $this->assertSame( $this->caption, $result ); } function test_img_caption_shortcode_with_old_format() { @@ -128,14 +128,14 @@ CAP; ) ); - $this->assertEquals( 2, preg_match_all( '/wp-caption/', $result, $_r ) ); - $this->assertEquals( 1, preg_match_all( '/alignnone/', $result, $_r ) ); - $this->assertEquals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); + $this->assertSame( 2, preg_match_all( '/wp-caption/', $result, $_r ) ); + $this->assertSame( 1, preg_match_all( '/alignnone/', $result, $_r ) ); + $this->assertSame( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); if ( current_theme_supports( 'html5', 'caption' ) ) { - $this->assertEquals( 1, preg_match_all( '/width: 20/', $result, $_r ) ); + $this->assertSame( 1, preg_match_all( '/width: 20/', $result, $_r ) ); } else { - $this->assertEquals( 1, preg_match_all( '/width: 30/', $result, $_r ) ); + $this->assertSame( 1, preg_match_all( '/width: 30/', $result, $_r ) ); } } @@ -148,9 +148,9 @@ CAP; 'align' => '&myAlignment', ) ); - $this->assertEquals( 1, preg_match_all( '/wp-caption &myAlignment/', $result, $_r ) ); - $this->assertEquals( 1, preg_match_all( '/id="myId"/', $result, $_r ) ); - $this->assertEquals( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); + $this->assertSame( 1, preg_match_all( '/wp-caption &myAlignment/', $result, $_r ) ); + $this->assertSame( 1, preg_match_all( '/id="myId"/', $result, $_r ) ); + $this->assertSame( 1, preg_match_all( "/{$this->caption}/", $result, $_r ) ); } function test_img_caption_shortcode_with_old_format_and_class() { @@ -161,7 +161,7 @@ CAP; 'caption' => $this->caption, ) ); - $this->assertEquals( 1, preg_match_all( '/wp-caption alignnone some-class another-class/', $result, $_r ) ); + $this->assertSame( 1, preg_match_all( '/wp-caption alignnone some-class another-class/', $result, $_r ) ); } @@ -174,7 +174,7 @@ CAP; ); $our_preg = preg_quote( $this->html_content ); - $this->assertEquals( 1, preg_match_all( "~{$our_preg}~", $result, $_r ) ); + $this->assertSame( 1, preg_match_all( "~{$our_preg}~", $result, $_r ) ); } function test_new_img_caption_shortcode_new_format() { @@ -185,8 +185,8 @@ CAP; $img_preg = preg_quote( $this->img_content ); $content_preg = preg_quote( $this->html_content ); - $this->assertEquals( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) ); - $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); + $this->assertSame( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) ); + $this->assertSame( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); } function test_new_img_caption_shortcode_new_format_and_linked_image() { @@ -198,8 +198,8 @@ CAP; $img_preg = preg_quote( $linked_image ); $content_preg = preg_quote( $this->html_content ); - $this->assertEquals( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) ); - $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); + $this->assertSame( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) ); + $this->assertSame( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); } function test_new_img_caption_shortcode_new_format_and_linked_image_with_newline() { @@ -211,8 +211,8 @@ CAP; $img_preg = preg_quote( $linked_image ); $content_preg = preg_quote( $this->html_content ); - $this->assertEquals( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) ); - $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); + $this->assertSame( 1, preg_match_all( "~{$img_preg}.*wp-caption-text~", $result, $_r ) ); + $this->assertSame( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); } /** @@ -227,7 +227,7 @@ CAP; $this->img_content . $this->html_content ); - $this->assertEquals( 1, preg_match_all( '/aria-describedby="caption-myId"/', $result, $_r ) ); + $this->assertSame( 1, preg_match_all( '/aria-describedby="caption-myId"/', $result, $_r ) ); } function test_add_remove_oembed_provider() { @@ -245,7 +245,7 @@ CAP; $content = ''; $result = $wp_embed->autoembed( $content ); - $this->assertEquals( $content, $result ); + $this->assertSame( $content, $result ); } /** @@ -267,7 +267,7 @@ http://some.other.link/</pre> EOF; $result = $wp_embed->autoembed( $content ); - $this->assertEquals( $content, $result ); + $this->assertSame( $content, $result ); } function data_autoembed() { @@ -333,7 +333,7 @@ https://w.org</a>', function test_autoembed( $content, $result = null ) { $wp_embed = new Test_Autoembed; - $this->assertEquals( $wp_embed->autoembed( $content ), $result ? $result : $content ); + $this->assertSame( $wp_embed->autoembed( $content ), $result ? $result : $content ); } function test_wp_prepare_attachment_for_js() { @@ -350,31 +350,31 @@ https://w.org</a>', $prepped = wp_prepare_attachment_for_js( $post ); $this->assertInternalType( 'array', $prepped ); - $this->assertEquals( 0, $prepped['uploadedTo'] ); - $this->assertEquals( '', $prepped['mime'] ); - $this->assertEquals( '', $prepped['type'] ); - $this->assertEquals( '', $prepped['subtype'] ); + $this->assertSame( 0, $prepped['uploadedTo'] ); + $this->assertSame( '', $prepped['mime'] ); + $this->assertSame( '', $prepped['type'] ); + $this->assertSame( '', $prepped['subtype'] ); // #21963, there will be a GUID always, so there will be a URL. $this->assertNotEquals( '', $prepped['url'] ); - $this->assertEquals( site_url( 'wp-includes/images/media/default.png' ), $prepped['icon'] ); + $this->assertSame( site_url( 'wp-includes/images/media/default.png' ), $prepped['icon'] ); // Fake a mime. $post->post_mime_type = 'image/jpeg'; $prepped = wp_prepare_attachment_for_js( $post ); - $this->assertEquals( 'image/jpeg', $prepped['mime'] ); - $this->assertEquals( 'image', $prepped['type'] ); - $this->assertEquals( 'jpeg', $prepped['subtype'] ); + $this->assertSame( 'image/jpeg', $prepped['mime'] ); + $this->assertSame( 'image', $prepped['type'] ); + $this->assertSame( 'jpeg', $prepped['subtype'] ); // Fake a mime without a slash. See #WP22532. $post->post_mime_type = 'image'; $prepped = wp_prepare_attachment_for_js( $post ); - $this->assertEquals( 'image', $prepped['mime'] ); - $this->assertEquals( 'image', $prepped['type'] ); - $this->assertEquals( '', $prepped['subtype'] ); + $this->assertSame( 'image', $prepped['mime'] ); + $this->assertSame( 'image', $prepped['type'] ); + $this->assertSame( '', $prepped['subtype'] ); // Test that if author is not found, we return "(no author)" as `display_name`. // The previously used test post contains no author, so we can reuse it. - $this->assertEquals( '(no author)', $prepped['authorName'] ); + $this->assertSame( '(no author)', $prepped['authorName'] ); // Test that if author has HTML entities in display_name, they're decoded correctly. $html_entity_author = self::factory()->user->create( @@ -384,7 +384,7 @@ https://w.org</a>', ); $post->post_author = $html_entity_author; $prepped = wp_prepare_attachment_for_js( $post ); - $this->assertEquals( 'You & Me', $prepped['authorName'] ); + $this->assertSame( 'You & Me', $prepped['authorName'] ); } /** @@ -428,15 +428,15 @@ https://w.org</a>', $tb = $gb * 1024; // Test if boundaries are correct. - $this->assertEquals( '1TB', wp_convert_bytes_to_hr( $tb ) ); - $this->assertEquals( '1GB', wp_convert_bytes_to_hr( $gb ) ); - $this->assertEquals( '1MB', wp_convert_bytes_to_hr( $mb ) ); - $this->assertEquals( '1KB', wp_convert_bytes_to_hr( $kb ) ); + $this->assertSame( '1TB', wp_convert_bytes_to_hr( $tb ) ); + $this->assertSame( '1GB', wp_convert_bytes_to_hr( $gb ) ); + $this->assertSame( '1MB', wp_convert_bytes_to_hr( $mb ) ); + $this->assertSame( '1KB', wp_convert_bytes_to_hr( $kb ) ); - $this->assertEquals( '1 TB', size_format( $tb ) ); - $this->assertEquals( '1 GB', size_format( $gb ) ); - $this->assertEquals( '1 MB', size_format( $mb ) ); - $this->assertEquals( '1 KB', size_format( $kb ) ); + $this->assertSame( '1 TB', size_format( $tb ) ); + $this->assertSame( '1 GB', size_format( $gb ) ); + $this->assertSame( '1 MB', size_format( $mb ) ); + $this->assertSame( '1 KB', size_format( $kb ) ); // Now some values around. $hr = wp_convert_bytes_to_hr( $tb + $tb / 2 + $mb ); @@ -452,8 +452,8 @@ https://w.org</a>', $this->assertEquals( 1022.99902344, (float) str_replace( ',', '.', $hr ), 'The values should be equal', 0.0001 ); // Edge. - $this->assertEquals( '-1B', wp_convert_bytes_to_hr( -1 ) ); - $this->assertEquals( '0B', wp_convert_bytes_to_hr( 0 ) ); + $this->assertSame( '-1B', wp_convert_bytes_to_hr( -1 ) ); + $this->assertSame( '0B', wp_convert_bytes_to_hr( 0 ) ); } /** @@ -522,7 +522,7 @@ https://w.org</a>', BLOB; $post_id = self::factory()->post->create( array( 'post_content' => $blob ) ); $srcs = get_post_galleries_images( $post_id ); - $this->assertEquals( $srcs, array( $ids1_srcs, $ids2_srcs ) ); + $this->assertSame( $srcs, array( $ids1_srcs, $ids2_srcs ) ); } /** @@ -672,7 +672,7 @@ BLOB; BLOB; $post_id = self::factory()->post->create( array( 'post_content' => $blob ) ); $srcs = get_post_gallery_images( $post_id ); - $this->assertEquals( $srcs, $ids1_srcs ); + $this->assertSame( $srcs, $ids1_srcs ); } function test_get_media_embedded_in_content() { @@ -721,22 +721,22 @@ CONTENT; $contents = array_values( compact( $types ) ); $matches = get_media_embedded_in_content( $content, 'audio' ); - $this->assertEquals( array( $audio ), $matches ); + $this->assertSame( array( $audio ), $matches ); $matches = get_media_embedded_in_content( $content, 'video' ); - $this->assertEquals( array( $video ), $matches ); + $this->assertSame( array( $video ), $matches ); $matches = get_media_embedded_in_content( $content, 'object' ); - $this->assertEquals( array( $object ), $matches ); + $this->assertSame( array( $object ), $matches ); $matches = get_media_embedded_in_content( $content, 'embed' ); - $this->assertEquals( array( $embed ), $matches ); + $this->assertSame( array( $embed ), $matches ); $matches = get_media_embedded_in_content( $content, 'iframe' ); - $this->assertEquals( array( $iframe ), $matches ); + $this->assertSame( array( $iframe ), $matches ); $matches = get_media_embedded_in_content( $content, $types ); - $this->assertEquals( $contents, $matches ); + $this->assertSame( $contents, $matches ); } function test_get_media_embedded_in_content_order() { @@ -753,11 +753,11 @@ VIDEO; $content = $audio . $video; $matches1 = get_media_embedded_in_content( $content, array( 'audio', 'video' ) ); - $this->assertEquals( array( $audio, $video ), $matches1 ); + $this->assertSame( array( $audio, $video ), $matches1 ); $reversed = $video . $audio; $matches2 = get_media_embedded_in_content( $reversed, array( 'audio', 'video' ) ); - $this->assertEquals( array( $video, $audio ), $matches2 ); + $this->assertSame( array( $video, $audio ), $matches2 ); } /** @@ -859,7 +859,7 @@ VIDEO; '<a href="http://domain.tld/wp-content/uploads/2013/12/xyz.mp4">' . "http://domain.tld/wp-content/uploads/2013/12/xyz.mp4</a></video></div>\n"; - $this->assertEquals( $expected, $content ); + $this->assertSame( $expected, $content ); } /** @@ -1016,8 +1016,8 @@ VIDEO; remove_image_size( 'test-size' ); $this->assertArrayHasKey( 'test-size', $sizes ); - $this->assertEquals( 200, $sizes['test-size']['width'] ); - $this->assertEquals( 600, $sizes['test-size']['height'] ); + $this->assertSame( 200, $sizes['test-size']['width'] ); + $this->assertSame( 600, $sizes['test-size']['height'] ); } /** @@ -1056,7 +1056,7 @@ VIDEO; ); $image_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path; - $this->assertEquals( $attachment_id, attachment_url_to_postid( $image_url ) ); + $this->assertSame( $attachment_id, attachment_url_to_postid( $image_url ) ); } /** @@ -1074,7 +1074,7 @@ VIDEO; ); $image_url = 'https://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path; - $this->assertEquals( $attachment_id, attachment_url_to_postid( $image_url ) ); + $this->assertSame( $attachment_id, attachment_url_to_postid( $image_url ) ); } /** @@ -1102,7 +1102,7 @@ VIDEO; ); $image_url = 'http://' . WP_TESTS_DOMAIN . '/wp-content/uploads/' . $image_path_upper_case; - $this->assertEquals( $attachment_id_upper_case, attachment_url_to_postid( $image_url ) ); + $this->assertSame( $attachment_id_upper_case, attachment_url_to_postid( $image_url ) ); } function test_attachment_url_to_postid_filtered() { @@ -1118,7 +1118,7 @@ VIDEO; add_filter( 'upload_dir', array( $this, '_upload_dir' ) ); $image_url = 'http://192.168.1.20.com/wp-content/uploads/' . $image_path; - $this->assertEquals( $attachment_id, attachment_url_to_postid( $image_url ) ); + $this->assertSame( $attachment_id, attachment_url_to_postid( $image_url ) ); remove_filter( 'upload_dir', array( $this, '_upload_dir' ) ); } @@ -1133,7 +1133,7 @@ VIDEO; function test_attachment_url_to_postid_with_empty_url() { $post_id = attachment_url_to_postid( '' ); $this->assertInternalType( 'int', $post_id ); - $this->assertEquals( 0, $post_id ); + $this->assertSame( 0, $post_id ); } /** @@ -1172,7 +1172,7 @@ VIDEO; // Clean up. wp_delete_attachment( $post_id ); - $this->assertEquals( 'This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $post->post_excerpt ); + $this->assertSame( 'This is a comment. / Это комментарий. / Βλέπετε ένα σχόλιο.', $post->post_excerpt ); } /** @@ -1211,7 +1211,7 @@ VIDEO; // Clean up. wp_delete_attachment( $post_id ); - $this->assertEquals( 'This is a test', $post->post_title ); + $this->assertSame( 'This is a test', $post->post_title ); } /** @@ -1228,7 +1228,7 @@ _my_function('data'); EOF; $result = $wp_embed->autoembed( $content ); - $this->assertEquals( $content, $result ); + $this->assertSame( $content, $result ); } /** @@ -1244,7 +1244,7 @@ my_function(); EOF; $result = $wp_embed->autoembed( $content ); - $this->assertEquals( $content, $result ); + $this->assertSame( $content, $result ); } @@ -1278,7 +1278,7 @@ Stop.</p> EOF; $result = apply_filters( 'the_content', $content ); - $this->assertEqualsIgnoreEOL( $expected, $result ); + $this->assertSameIgnoreEOL( $expected, $result ); } /** @@ -1307,7 +1307,7 @@ EOF; EOF; $result = $wp_embed->autoembed( $content ); - $this->assertEquals( $expected, $result ); + $this->assertSame( $expected, $result ); $content = <<<EOF <a href="https://www.example.com/?video=1">https://www.example.com/?video=1</a> @@ -1321,7 +1321,7 @@ do not break this'; EOF; $result = $wp_embed->autoembed( $content ); - $this->assertEquals( $content, $result ); + $this->assertSame( $content, $result ); remove_filter( 'embed_maybe_make_link', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 ); } @@ -1340,7 +1340,7 @@ EOF; $image[0] ); - $this->assertEquals( $expected, wp_get_attachment_image( self::$large_id ) ); + $this->assertSame( $expected, wp_get_attachment_image( self::$large_id ) ); } /** @@ -1360,7 +1360,7 @@ EOF; $image[0] ); - $this->assertEquals( $expected, wp_get_attachment_image( self::$large_id ) ); + $this->assertSame( $expected, wp_get_attachment_image( self::$large_id ) ); // Cleanup. update_post_meta( self::$large_id, '_wp_attachment_image_alt', '', true ); @@ -1384,7 +1384,7 @@ EOF; $image = wp_get_attachment_image_src( $attachment_id, 'thumbnail', false ); - $this->assertEquals( $image[0], wp_get_attachment_image_url( $attachment_id ) ); + $this->assertSame( $image[0], wp_get_attachment_image_url( $attachment_id ) ); } /** @@ -1408,7 +1408,7 @@ EOF; $this->assertFalse( wp_get_attachment_caption( $post_id ) ); - $this->assertEquals( $caption, wp_get_attachment_caption( $attachment_id ) ); + $this->assertSame( $caption, wp_get_attachment_caption( $attachment_id ) ); } /** @@ -1426,7 +1426,7 @@ EOF; ) ); - $this->assertEquals( '', wp_get_attachment_caption( $attachment_id ) ); + $this->assertSame( '', wp_get_attachment_caption( $attachment_id ) ); } /** @@ -2387,7 +2387,7 @@ EOF; $attachment_id = wp_insert_attachment( $data, '', 0, true ); $this->assertWPError( $attachment_id ); - $this->assertEquals( 'invalid_date', $attachment_id->get_error_code() ); + $this->assertSame( 'invalid_date', $attachment_id->get_error_code() ); $attachment_id = wp_insert_attachment( $data, '', 0 ); $this->assertSame( 0, $attachment_id ); @@ -2406,7 +2406,7 @@ EOF; ), ); - $this->assertEquals( 123, wp_get_media_creation_timestamp( $metadata ) ); + $this->assertSame( 123, wp_get_media_creation_timestamp( $metadata ) ); } /** @@ -2424,7 +2424,7 @@ EOF; ), ); - $this->assertEquals( 1450978809, wp_get_media_creation_timestamp( $metadata ) ); + $this->assertSame( 1450978809, wp_get_media_creation_timestamp( $metadata ) ); } /** @@ -2444,7 +2444,7 @@ EOF; ), ); - $this->assertEquals( 1450978805, wp_get_media_creation_timestamp( $metadata ) ); + $this->assertSame( 1450978805, wp_get_media_creation_timestamp( $metadata ) ); } /** @@ -2462,7 +2462,7 @@ EOF; ), ); - $this->assertEquals( 1265680539, wp_get_media_creation_timestamp( $metadata ) ); + $this->assertSame( 1265680539, wp_get_media_creation_timestamp( $metadata ) ); } /** @@ -2477,7 +2477,7 @@ EOF; $video = DIR_TESTDATA . '/uploads/small-video.mp4'; $metadata = wp_read_audio_metadata( $video ); - $this->assertEquals( 1269120551, $metadata['created_timestamp'] ); + $this->assertSame( 1269120551, $metadata['created_timestamp'] ); } /** @@ -2487,7 +2487,7 @@ EOF; $video = DIR_TESTDATA . '/uploads/small-video.mov'; $metadata = wp_read_video_metadata( $video ); - $this->assertEquals( 1269120551, $metadata['created_timestamp'] ); + $this->assertSame( 1269120551, $metadata['created_timestamp'] ); } /** @@ -2497,7 +2497,7 @@ EOF; $video = DIR_TESTDATA . '/uploads/small-video.mp4'; $metadata = wp_read_video_metadata( $video ); - $this->assertEquals( 1269120551, $metadata['created_timestamp'] ); + $this->assertSame( 1269120551, $metadata['created_timestamp'] ); } /** @@ -2507,7 +2507,7 @@ EOF; $video = DIR_TESTDATA . '/uploads/small-video.mkv'; $metadata = wp_read_video_metadata( $video ); - $this->assertEquals( 1269120551, $metadata['created_timestamp'] ); + $this->assertSame( 1269120551, $metadata['created_timestamp'] ); } /** @@ -2517,7 +2517,7 @@ EOF; $video = DIR_TESTDATA . '/uploads/small-video.webm'; $metadata = wp_read_video_metadata( $video ); - $this->assertEquals( 1269120551, $metadata['created_timestamp'] ); + $this->assertSame( 1269120551, $metadata['created_timestamp'] ); } /** @@ -2969,7 +2969,7 @@ EOF; 'link' => 'file', ) ); - $this->assertEquals( 2, substr_count( $actual, '.jpg' ) ); + $this->assertSame( 2, substr_count( $actual, '.jpg' ) ); // None: Does not link. $actual = gallery_shortcode( diff --git a/tests/phpunit/tests/menu/nav-menu.php b/tests/phpunit/tests/menu/nav-menu.php index 39e9ed4924..467b4ab930 100644 --- a/tests/phpunit/tests/menu/nav-menu.php +++ b/tests/phpunit/tests/menu/nav-menu.php @@ -44,7 +44,7 @@ class Tests_Nav_Menu_Theme_Change extends WP_UnitTestCase { $expected_nav_menu_locations = array( 'primary' => 1, ); - $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); + $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); } /** @@ -66,7 +66,7 @@ class Tests_Nav_Menu_Theme_Change extends WP_UnitTestCase { 'primary' => 1, 'secondary' => 2, ); - $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); + $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); } /** @@ -85,7 +85,7 @@ class Tests_Nav_Menu_Theme_Change extends WP_UnitTestCase { $new_next_theme_nav_menu_locations = wp_map_nav_menu_locations( $old_next_theme_nav_menu_locations, $prev_theme_nav_menu_locations ); $expected_nav_menu_locations = $prev_theme_nav_menu_locations; - $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); + $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); } /** @@ -109,7 +109,7 @@ class Tests_Nav_Menu_Theme_Change extends WP_UnitTestCase { $new_next_theme_nav_menu_locations = wp_map_nav_menu_locations( $old_next_theme_nav_menu_locations, $prev_theme_nav_menu_locations ); $expected_nav_menu_locations = wp_array_slice_assoc( $prev_theme_nav_menu_locations, array_keys( get_registered_nav_menus() ) ); - $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); + $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); } /** @@ -132,7 +132,7 @@ class Tests_Nav_Menu_Theme_Change extends WP_UnitTestCase { 'primary' => 1, 'secondary' => 2, ); - $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); + $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); } /** @@ -176,7 +176,7 @@ class Tests_Nav_Menu_Theme_Change extends WP_UnitTestCase { 'primary' => 1, 'main' => 2, ); - $this->assertEquals( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); + $this->assertSame( $expected_nav_menu_locations, $new_next_theme_nav_menu_locations ); } /** diff --git a/tests/phpunit/tests/menu/wpExpandNavMenuPostData.php b/tests/phpunit/tests/menu/wpExpandNavMenuPostData.php index 55b414876c..7d5c21fde8 100644 --- a/tests/phpunit/tests/menu/wpExpandNavMenuPostData.php +++ b/tests/phpunit/tests/menu/wpExpandNavMenuPostData.php @@ -25,7 +25,7 @@ class Tests_Menu_WpExpandNavMenuPostData extends WP_UnitTestCase { 'yesorno' => 'yes', ); - $this->assertEquals( $expected, $_POST ); + $this->assertSame( $expected, $_POST ); } public function test_multidimensional_nested_array_should_expand() { @@ -55,7 +55,7 @@ class Tests_Menu_WpExpandNavMenuPostData extends WP_UnitTestCase { ), ), ); - $this->assertEquals( $expected, $_POST ); + $this->assertSame( $expected, $_POST ); } public function test_multidimensional_nested_array_should_expand_and_merge() { @@ -100,6 +100,6 @@ class Tests_Menu_WpExpandNavMenuPostData extends WP_UnitTestCase { ), ); - $this->assertEquals( $expected, $_POST ); + $this->assertSame( $expected, $_POST ); } } diff --git a/tests/phpunit/tests/meta.php b/tests/phpunit/tests/meta.php index 30c154b982..d6869782f6 100644 --- a/tests/phpunit/tests/meta.php +++ b/tests/phpunit/tests/meta.php @@ -19,11 +19,11 @@ class Tests_Meta extends WP_UnitTestCase { function test_sanitize_meta() { $meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' ); - $this->assertEquals( 'unsanitized', $meta ); + $this->assertSame( 'unsanitized', $meta ); register_meta( 'post', 'some_meta', array( $this, '_meta_sanitize_cb' ) ); $meta = sanitize_meta( 'some_meta', 'unsanitized', 'post' ); - $this->assertEquals( 'sanitized', $meta ); + $this->assertSame( 'sanitized', $meta ); } function test_delete_metadata_by_mid() { @@ -48,23 +48,23 @@ class Tests_Meta extends WP_UnitTestCase { // Update the meta value. $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, 'meta_new_value' ) ); $meta = get_metadata_by_mid( 'user', $this->meta_id ); - $this->assertEquals( 'meta_new_value', $meta->meta_value ); + $this->assertSame( 'meta_new_value', $meta->meta_value ); // Update the meta value. $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, 'meta_new_value', 'meta_new_key' ) ); $meta = get_metadata_by_mid( 'user', $this->meta_id ); - $this->assertEquals( 'meta_new_key', $meta->meta_key ); + $this->assertSame( 'meta_new_key', $meta->meta_key ); // Update the key and value. $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, 'meta_value', 'meta_key' ) ); $meta = get_metadata_by_mid( 'user', $this->meta_id ); - $this->assertEquals( 'meta_key', $meta->meta_key ); - $this->assertEquals( 'meta_value', $meta->meta_value ); + $this->assertSame( 'meta_key', $meta->meta_key ); + $this->assertSame( 'meta_value', $meta->meta_value ); // Update the value that has to be serialized. $this->assertTrue( update_metadata_by_mid( 'user', $this->meta_id, array( 'first', 'second' ) ) ); $meta = get_metadata_by_mid( 'user', $this->meta_id ); - $this->assertEquals( array( 'first', 'second' ), $meta->meta_value ); + $this->assertSame( array( 'first', 'second' ), $meta->meta_value ); // Let's try some invalid meta data. $this->assertFalse( update_metadata_by_mid( 'user', 0, 'meta_value' ) ); @@ -137,13 +137,13 @@ class Tests_Meta extends WP_UnitTestCase { ) ); - $this->assertEquals( 1, count( $u ) ); + $this->assertSame( 1, count( $u ) ); // User found is not locally defined author (it's the admin). $this->assertNotEquals( $this->author->user_login, $u[0]->user_login ); // Test EXISTS and NOT EXISTS together, no users should be found. - $this->assertEquals( + $this->assertSame( 0, count( get_users( @@ -163,7 +163,7 @@ class Tests_Meta extends WP_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( 2, count( get_users( @@ -181,7 +181,7 @@ class Tests_Meta extends WP_UnitTestCase { delete_metadata( 'user', $this->author->ID, 'meta_key' ); - $this->assertEquals( + $this->assertSame( 2, count( get_users( @@ -208,24 +208,24 @@ class Tests_Meta extends WP_UnitTestCase { $this->assertFalse( delete_metadata( 'user', $this->author->ID, $key ) ); $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) ); $this->assertInternalType( 'int', add_metadata( 'user', $this->author->ID, $key, $value ) ); - $this->assertEquals( $expected, get_metadata( 'user', $this->author->ID, $key, true ) ); + $this->assertSame( $expected, get_metadata( 'user', $this->author->ID, $key, true ) ); $this->assertTrue( delete_metadata( 'user', $this->author->ID, $key ) ); $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) ); $this->assertInternalType( 'int', update_metadata( 'user', $this->author->ID, $key, $value ) ); - $this->assertEquals( $expected, get_metadata( 'user', $this->author->ID, $key, true ) ); + $this->assertSame( $expected, get_metadata( 'user', $this->author->ID, $key, true ) ); $this->assertTrue( update_metadata( 'user', $this->author->ID, $key, 'blah' ) ); - $this->assertEquals( 'blah', get_metadata( 'user', $this->author->ID, $key, true ) ); + $this->assertSame( 'blah', get_metadata( 'user', $this->author->ID, $key, true ) ); $this->assertTrue( delete_metadata( 'user', $this->author->ID, $key ) ); $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) ); $this->assertFalse( metadata_exists( 'user', $this->author->ID, $key ) ); // Test overslashing. $this->assertInternalType( 'int', add_metadata( 'user', $this->author->ID, $key, $value2 ) ); - $this->assertEquals( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) ); + $this->assertSame( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) ); $this->assertTrue( delete_metadata( 'user', $this->author->ID, $key ) ); $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) ); $this->assertInternalType( 'int', update_metadata( 'user', $this->author->ID, $key, $value2 ) ); - $this->assertEquals( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) ); + $this->assertSame( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) ); } /** @@ -252,8 +252,8 @@ class Tests_Meta extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $post_id2, $post_id1 ), $posts->posts ); - $this->assertEquals( 2, substr_count( $posts->request, 'CAST(' ) ); + $this->assertSame( array( $post_id2, $post_id1 ), $posts->posts ); + $this->assertSame( 2, substr_count( $posts->request, 'CAST(' ) ); // Make sure the newer meta_query syntax behaves in a consistent way. $posts = new WP_Query( @@ -273,8 +273,8 @@ class Tests_Meta extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $post_id2, $post_id1 ), $posts->posts ); - $this->assertEquals( 2, substr_count( $posts->request, 'CAST(' ) ); + $this->assertSame( array( $post_id2, $post_id1 ), $posts->posts ); + $this->assertSame( 2, substr_count( $posts->request, 'CAST(' ) ); // The legacy `meta_key` value should take precedence. $posts = new WP_Query( @@ -297,8 +297,8 @@ class Tests_Meta extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $post_id2, $post_id1 ), $posts->posts ); - $this->assertEquals( 2, substr_count( $posts->request, 'CAST(' ) ); + $this->assertSame( array( $post_id2, $post_id1 ), $posts->posts ); + $this->assertSame( 2, substr_count( $posts->request, 'CAST(' ) ); } function test_meta_cache_order_asc() { @@ -310,7 +310,7 @@ class Tests_Meta extends WP_UnitTestCase { foreach ( range( 1, 10 ) as $i ) { $meta = get_post_meta( $post_id, 'color' ); - $this->assertEquals( $meta, $colors ); + $this->assertSame( $meta, $colors ); if ( 0 === $i % 2 ) { wp_cache_delete( $post_id, 'post_meta' ); @@ -399,7 +399,7 @@ class Tests_Meta extends WP_UnitTestCase { add_metadata( 'user', $this->author->ID, 'foo', $data ); $found = get_metadata( 'user', $this->author->ID ); - $this->assertEquals( array( $value ), $found['foo'] ); + $this->assertSame( array( $value ), $found['foo'] ); } /** diff --git a/tests/phpunit/tests/meta/deleteMetadata.php b/tests/phpunit/tests/meta/deleteMetadata.php index 024ac5b526..a769d00559 100644 --- a/tests/phpunit/tests/meta/deleteMetadata.php +++ b/tests/phpunit/tests/meta/deleteMetadata.php @@ -156,7 +156,7 @@ class Tests_Meta_DeleteMetadata extends WP_UnitTestCase { } public function action_check_object_id_is_int( $meta_type, $object_id ) { - $this->assertEquals( + $this->assertSame( 'integer', gettype( $object_id ) ); diff --git a/tests/phpunit/tests/meta/query.php b/tests/phpunit/tests/meta/query.php index 417c59646f..b082ba72e2 100644 --- a/tests/phpunit/tests/meta/query.php +++ b/tests/phpunit/tests/meta/query.php @@ -10,12 +10,12 @@ class Tests_Meta_Query extends WP_UnitTestCase { public function test_empty_meta_query_param() { $query = new WP_Meta_Query(); - $this->assertSame( null, $query->relation ); + $this->assertNull( $query->relation ); } public function test_default_relation() { $query = new WP_Meta_Query( array( array( 'key' => 'abc' ) ) ); - $this->assertEquals( 'AND', $query->relation ); + $this->assertSame( 'AND', $query->relation ); } public function test_set_relation() { @@ -27,7 +27,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( 'AND', $query->relation ); + $this->assertSame( 'AND', $query->relation ); $query = new WP_Meta_Query( array( @@ -36,7 +36,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( 'OR', $query->relation ); + $this->assertSame( 'OR', $query->relation ); } /** @@ -74,7 +74,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { $sql = $query->get_sql( 'post', $wpdb->posts, 'ID' ); - $this->assertEquals( 1, substr_count( $sql['join'], 'INNER JOIN' ) ); + $this->assertSame( 1, substr_count( $sql['join'], 'INNER JOIN' ) ); // Also check mixing key and key => value. @@ -92,7 +92,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { $sql = $query->get_sql( 'post', $wpdb->posts, 'ID' ); - $this->assertEquals( 1, substr_count( $sql['join'], 'INNER JOIN' ) ); + $this->assertSame( 1, substr_count( $sql['join'], 'INNER JOIN' ) ); } /** @@ -120,17 +120,17 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'compare' => 'bar', 'value' => 'baz', ); - $this->assertEquals( $expected0, $query->queries[0] ); + $this->assertSame( $expected0, $query->queries[0] ); $expected1 = array( - 'relation' => 'OR', array( 'key' => 'foo1', 'compare' => 'baz1', 'value' => 'bar1', ), + 'relation' => 'OR', ); - $this->assertEquals( $expected1, $query->queries[1] ); + $this->assertSame( $expected1, $query->queries[1] ); } /** @@ -176,25 +176,25 @@ class Tests_Meta_Query extends WP_UnitTestCase { // Just meta_value. $expected = array( - 'relation' => 'OR', array( 'key' => 'abc', ), + 'relation' => 'OR', ); $query->parse_query_vars( array( 'meta_key' => 'abc', ) ); - $this->assertEquals( $expected, $query->queries ); + $this->assertSame( $expected, $query->queries ); // meta_key & meta_value. $expected = array( - 'relation' => 'OR', array( 'key' => 'abc', 'value' => 'def', ), + 'relation' => 'OR', ); $query->parse_query_vars( array( @@ -202,15 +202,15 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'meta_value' => 'def', ) ); - $this->assertEquals( $expected, $query->queries ); + $this->assertSame( $expected, $query->queries ); // meta_compare. $expected = array( - 'relation' => 'OR', array( 'key' => 'abc', 'compare' => '=>', ), + 'relation' => 'OR', ); $query->parse_query_vars( array( @@ -218,7 +218,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'meta_compare' => '=>', ) ); - $this->assertEquals( $expected, $query->queries ); + $this->assertSame( $expected, $query->queries ); } /** @@ -226,42 +226,42 @@ class Tests_Meta_Query extends WP_UnitTestCase { */ public function test_get_cast_for_type() { $query = new WP_Meta_Query(); - $this->assertEquals( 'BINARY', $query->get_cast_for_type( 'BINARY' ) ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'CHAR' ) ); - $this->assertEquals( 'DATE', $query->get_cast_for_type( 'DATE' ) ); - $this->assertEquals( 'DATETIME', $query->get_cast_for_type( 'DATETIME' ) ); - $this->assertEquals( 'SIGNED', $query->get_cast_for_type( 'SIGNED' ) ); - $this->assertEquals( 'UNSIGNED', $query->get_cast_for_type( 'UNSIGNED' ) ); - $this->assertEquals( 'TIME', $query->get_cast_for_type( 'TIME' ) ); - $this->assertEquals( 'SIGNED', $query->get_cast_for_type( 'NUMERIC' ) ); - $this->assertEquals( 'NUMERIC(10)', $query->get_cast_for_type( 'NUMERIC(10)' ) ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10)' ) ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10 )' ) ); - $this->assertEquals( 'NUMERIC(10, 5)', $query->get_cast_for_type( 'NUMERIC(10, 5)' ) ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC(10, 5)' ) ); - $this->assertEquals( 'NUMERIC(10,5)', $query->get_cast_for_type( 'NUMERIC(10,5)' ) ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10, 5 )' ) ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'NUMERIC(10, 5 )' ) ); - $this->assertEquals( 'DECIMAL', $query->get_cast_for_type( 'DECIMAL' ) ); - $this->assertEquals( 'DECIMAL(10)', $query->get_cast_for_type( 'DECIMAL(10)' ) ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL( 10 )' ) ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL( 10)' ) ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL(10 )' ) ); - $this->assertEquals( 'DECIMAL(10, 5)', $query->get_cast_for_type( 'DECIMAL(10, 5)' ) ); - $this->assertEquals( 'DECIMAL(10,5)', $query->get_cast_for_type( 'DECIMAL(10,5)' ) ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'DECIMAL(10, 5)' ) ); + $this->assertSame( 'BINARY', $query->get_cast_for_type( 'BINARY' ) ); + $this->assertSame( 'CHAR', $query->get_cast_for_type( 'CHAR' ) ); + $this->assertSame( 'DATE', $query->get_cast_for_type( 'DATE' ) ); + $this->assertSame( 'DATETIME', $query->get_cast_for_type( 'DATETIME' ) ); + $this->assertSame( 'SIGNED', $query->get_cast_for_type( 'SIGNED' ) ); + $this->assertSame( 'UNSIGNED', $query->get_cast_for_type( 'UNSIGNED' ) ); + $this->assertSame( 'TIME', $query->get_cast_for_type( 'TIME' ) ); + $this->assertSame( 'SIGNED', $query->get_cast_for_type( 'NUMERIC' ) ); + $this->assertSame( 'NUMERIC(10)', $query->get_cast_for_type( 'NUMERIC(10)' ) ); + $this->assertSame( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10)' ) ); + $this->assertSame( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10 )' ) ); + $this->assertSame( 'NUMERIC(10, 5)', $query->get_cast_for_type( 'NUMERIC(10, 5)' ) ); + $this->assertSame( 'CHAR', $query->get_cast_for_type( 'NUMERIC(10, 5)' ) ); + $this->assertSame( 'NUMERIC(10,5)', $query->get_cast_for_type( 'NUMERIC(10,5)' ) ); + $this->assertSame( 'CHAR', $query->get_cast_for_type( 'NUMERIC( 10, 5 )' ) ); + $this->assertSame( 'CHAR', $query->get_cast_for_type( 'NUMERIC(10, 5 )' ) ); + $this->assertSame( 'DECIMAL', $query->get_cast_for_type( 'DECIMAL' ) ); + $this->assertSame( 'DECIMAL(10)', $query->get_cast_for_type( 'DECIMAL(10)' ) ); + $this->assertSame( 'CHAR', $query->get_cast_for_type( 'DECIMAL( 10 )' ) ); + $this->assertSame( 'CHAR', $query->get_cast_for_type( 'DECIMAL( 10)' ) ); + $this->assertSame( 'CHAR', $query->get_cast_for_type( 'DECIMAL(10 )' ) ); + $this->assertSame( 'DECIMAL(10, 5)', $query->get_cast_for_type( 'DECIMAL(10, 5)' ) ); + $this->assertSame( 'DECIMAL(10,5)', $query->get_cast_for_type( 'DECIMAL(10,5)' ) ); + $this->assertSame( 'CHAR', $query->get_cast_for_type( 'DECIMAL(10, 5)' ) ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type() ); - $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'ANYTHING ELSE' ) ); + $this->assertSame( 'CHAR', $query->get_cast_for_type() ); + $this->assertSame( 'CHAR', $query->get_cast_for_type( 'ANYTHING ELSE' ) ); } public function test_sanitize_query_single_query() { $expected = array( - 'relation' => 'OR', array( 'key' => 'foo', 'value' => 'bar', ), + 'relation' => 'OR', ); $q = new WP_Meta_Query(); @@ -274,12 +274,11 @@ class Tests_Meta_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } public function test_sanitize_query_multiple_first_order_queries_relation_default() { $expected = array( - 'relation' => 'AND', array( 'key' => 'foo', 'value' => 'bar', @@ -288,6 +287,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'key' => 'foo2', 'value' => 'bar2', ), + 'relation' => 'AND', ); $q = new WP_Meta_Query(); @@ -304,12 +304,11 @@ class Tests_Meta_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } public function test_sanitize_query_multiple_first_order_queries_relation_or() { $expected = array( - 'relation' => 'OR', array( 'key' => 'foo', 'value' => 'bar', @@ -318,12 +317,12 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'key' => 'foo2', 'value' => 'bar2', ), + 'relation' => 'OR', ); $q = new WP_Meta_Query(); $found = $q->sanitize_query( array( - 'relation' => 'OR', array( 'key' => 'foo', 'value' => 'bar', @@ -332,15 +331,15 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'key' => 'foo2', 'value' => 'bar2', ), + 'relation' => 'OR', ) ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } public function test_sanitize_query_multiple_first_order_queries_relation_or_lowercase() { $expected = array( - 'relation' => 'OR', array( 'key' => 'foo', 'value' => 'bar', @@ -349,12 +348,12 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'key' => 'foo2', 'value' => 'bar2', ), + 'relation' => 'OR', ); $q = new WP_Meta_Query(); $found = $q->sanitize_query( array( - 'relation' => 'or', array( 'key' => 'foo', 'value' => 'bar', @@ -363,15 +362,15 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'key' => 'foo2', 'value' => 'bar2', ), + 'relation' => 'or', ) ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } public function test_sanitize_query_multiple_first_order_queries_invalid_relation() { $expected = array( - 'relation' => 'AND', array( 'key' => 'foo', 'value' => 'bar', @@ -380,12 +379,12 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'key' => 'foo2', 'value' => 'bar2', ), + 'relation' => 'AND', ); $q = new WP_Meta_Query(); $found = $q->sanitize_query( array( - 'relation' => 'FOO', array( 'key' => 'foo', 'value' => 'bar', @@ -394,17 +393,16 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'key' => 'foo2', 'value' => 'bar2', ), + 'relation' => 'FOO', ) ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } public function test_sanitize_query_single_query_which_is_a_nested_query() { $expected = array( - 'relation' => 'OR', array( - 'relation' => 'AND', array( 'key' => 'foo', 'value' => 'bar', @@ -413,7 +411,9 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'key' => 'foo2', 'value' => 'bar2', ), + 'relation' => 'AND', ), + 'relation' => 'OR', ); $q = new WP_Meta_Query(); @@ -432,14 +432,12 @@ class Tests_Meta_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } public function test_sanitize_query_multiple_nested_queries() { $expected = array( - 'relation' => 'OR', array( - 'relation' => 'AND', array( 'key' => 'foo', 'value' => 'bar', @@ -448,9 +446,9 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'key' => 'foo2', 'value' => 'bar2', ), + 'relation' => 'AND', ), array( - 'relation' => 'AND', array( 'key' => 'foo3', 'value' => 'bar3', @@ -459,13 +457,14 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'key' => 'foo4', 'value' => 'bar4', ), + 'relation' => 'AND', ), + 'relation' => 'OR', ); $q = new WP_Meta_Query(); $found = $q->sanitize_query( array( - 'relation' => 'OR', array( array( 'key' => 'foo', @@ -486,10 +485,11 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'value' => 'bar4', ), ), + 'relation' => 'OR', ) ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } /** @@ -528,7 +528,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this ); - $this->assertEquals( 3, substr_count( $sql['join'], 'JOIN' ) ); + $this->assertSame( 3, substr_count( $sql['join'], 'JOIN' ) ); } /** @@ -548,7 +548,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { ); $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this ); - $this->assertEquals( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_value = ''" ) ); + $this->assertSame( 1, substr_count( $sql['where'], "$wpdb->postmeta.meta_value = ''" ) ); } /** @@ -560,8 +560,6 @@ class Tests_Meta_Query extends WP_UnitTestCase { $query1 = new WP_Meta_Query( array( - 'relation' => 'OR', - // Empty 'compare'. array( 'key' => 'foo', @@ -589,6 +587,8 @@ class Tests_Meta_Query extends WP_UnitTestCase { array( 'value' => 'bar', ), + + 'relation' => 'OR', ) ); @@ -604,8 +604,6 @@ class Tests_Meta_Query extends WP_UnitTestCase { // 'AND' queries don't have key-only queries. $query2 = new WP_Meta_Query( array( - 'relation' => 'AND', - // Empty 'compare'. array( 'key' => 'foo', @@ -616,6 +614,8 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'key' => 'bar', 'compare' => '<', ), + + 'relation' => 'AND', ) ); @@ -887,7 +887,6 @@ class Tests_Meta_Query extends WP_UnitTestCase { $query = new WP_Meta_Query( array( - 'relation' => 'OR', array( 'key' => 'exclude', 'compare' => 'NOT EXISTS', @@ -897,6 +896,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'compare' => '!=', 'value' => '1', ), + 'relation' => 'OR', ) ); @@ -910,7 +910,6 @@ class Tests_Meta_Query extends WP_UnitTestCase { $query = new WP_Meta_Query( array( - 'relation' => 'OR', array( 'key' => 'exclude', 'compare' => '', @@ -920,6 +919,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'compare' => '!=', 'value' => '1', ), + 'relation' => 'OR', ) ); @@ -936,7 +936,6 @@ class Tests_Meta_Query extends WP_UnitTestCase { public function test_has_or_relation_should_return_false() { $q = new WP_Meta_Query( array( - 'relation' => 'AND', array( 'key' => 'foo', 'value' => 'bar', @@ -952,6 +951,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'value' => 'bar', ), ), + 'relation' => 'AND', ) ); @@ -964,7 +964,6 @@ class Tests_Meta_Query extends WP_UnitTestCase { public function test_has_or_relation_should_return_true_for_top_level_or() { $q = new WP_Meta_Query( array( - 'relation' => 'OR', array( 'key' => 'foo', 'value' => 'bar', @@ -980,6 +979,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'value' => 'bar', ), ), + 'relation' => 'OR', ) ); @@ -992,7 +992,6 @@ class Tests_Meta_Query extends WP_UnitTestCase { public function test_has_or_relation_should_return_true_for_nested_or() { $q = new WP_Meta_Query( array( - 'relation' => 'AND', array( 'key' => 'foo', 'value' => 'bar', @@ -1008,6 +1007,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { 'value' => 'bar', ), ), + 'relation' => 'AND', ) ); diff --git a/tests/phpunit/tests/meta/registerMeta.php b/tests/phpunit/tests/meta/registerMeta.php index 025a2a1e71..22c282c437 100644 --- a/tests/phpunit/tests/meta/registerMeta.php +++ b/tests/phpunit/tests/meta/registerMeta.php @@ -45,7 +45,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { remove_filter( 'auth_post_meta_flight_number', array( $this, '_old_auth_meta_cb' ) ); // The filter should have been added with a priority of 10. - $this->assertEquals( 10, $has_filter ); + $this->assertSame( 10, $has_filter ); } public function test_register_meta_back_compat_with_sanitize_callback_and_no_auth_callback_has_old_style_sanitize_filter() { @@ -53,7 +53,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { $has_filter = has_filter( 'sanitize_post_meta_flight_number', array( $this, '_old_sanitize_meta_cb' ) ); remove_filter( 'sanitize_post_meta_flight_number', array( $this, '_old_sanitize_meta_cb' ) ); - $this->assertEquals( 10, $has_filter ); + $this->assertSame( 10, $has_filter ); } public function test_register_meta_back_compat_with_auth_and_sanitize_callback_has_old_style_filters() { @@ -64,7 +64,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { remove_filter( 'auth_post_meta_flight_number', array( $this, '_old_auth_meta_cb' ) ); remove_filter( 'sanitize_post_meta_flight_number', array( $this, '_old_sanitize_meta_cb' ) ); - $this->assertEquals( + $this->assertSame( array( 'auth' => 10, 'sanitize' => 10, @@ -102,7 +102,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { ), ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } public function test_register_meta_with_term_object_type_populates_wp_meta_keys() { @@ -126,7 +126,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { ), ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } public function test_register_meta_with_deprecated_sanitize_callback_does_not_populate_wp_meta_keys() { @@ -137,7 +137,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { remove_filter( 'sanitize_post_meta_flight_number', array( $this, '_old_sanitize_meta_cb' ) ); remove_filter( 'auth_post_meta_flight_number', '__return_true' ); - $this->assertEquals( array(), $actual ); + $this->assertSame( array(), $actual ); } public function test_register_meta_with_deprecated_sanitize_callback_param_returns_false() { @@ -156,7 +156,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { remove_filter( 'sanitize_post_meta_flight_number', array( $this, '_old_sanitize_meta_cb' ) ); remove_filter( 'auth_post_meta_flight_number', '__return_true' ); - $this->assertEquals( 'old_sanitized_key old sanitized', $meta ); + $this->assertSame( 'old_sanitized_key old sanitized', $meta ); } public function test_register_meta_with_current_sanitize_callback_populates_wp_meta_keys() { @@ -179,7 +179,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { ), ), ); - $this->assertEquals( $actual, $expected ); + $this->assertSame( $actual, $expected ); } public function test_register_meta_with_current_sanitize_callback_returns_true() { @@ -195,7 +195,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { unregister_meta_key( 'post', 'new_sanitized_key' ); - $this->assertEquals( 'new_sanitized_key new sanitized', $meta ); + $this->assertSame( 'new_sanitized_key new sanitized', $meta ); } public function test_register_meta_unregistered_meta_key_removes_sanitize_filter() { @@ -221,7 +221,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { register_meta( 'post', 'registered_key', array() ); unregister_meta_key( 'post', 'registered_key' ); - $this->assertEquals( array(), $wp_meta_keys ); + $this->assertSame( array(), $wp_meta_keys ); } public function test_unregister_meta_key_with_invalid_key_returns_false() { @@ -260,7 +260,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { unregister_meta_key( 'post', 'registered_key1' ); - $this->assertEquals( 'I\'m just a field, take a good look at me', $meta_keys['registered_key1']['description'] ); + $this->assertSame( 'I\'m just a field, take a good look at me', $meta_keys['registered_key1']['description'] ); } public function test_get_registered_meta_keys_invalid_arg() { @@ -281,7 +281,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { unregister_meta_key( 'post', 'flight_number' ); - $this->assertEquals( 'Oceanic 815', $meta['flight_number'][0] ); + $this->assertSame( 'Oceanic 815', $meta['flight_number'][0] ); } public function test_get_registered_metadata_by_key() { @@ -292,7 +292,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { unregister_meta_key( 'post', 'flight_number' ); - $this->assertEquals( 'Oceanic 815', $meta[0] ); + $this->assertSame( 'Oceanic 815', $meta[0] ); } public function test_get_registered_metadata_by_key_single() { @@ -303,7 +303,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { unregister_meta_key( 'post', 'flight_number' ); - $this->assertEquals( 'Oceanic 815', $meta ); + $this->assertSame( 'Oceanic 815', $meta ); } public function test_get_registered_metadata_by_invalid_key() { @@ -352,7 +352,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { // Reset global so subsequent data tests do not get polluted. $wp_meta_keys = array(); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** @@ -405,7 +405,7 @@ class Tests_Meta_Register_Meta extends WP_UnitTestCase { // Reset global so subsequent data tests do not get polluted. $wp_meta_keys = array(); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** diff --git a/tests/phpunit/tests/meta/slashes.php b/tests/phpunit/tests/meta/slashes.php index d8ec881134..469b04765e 100644 --- a/tests/phpunit/tests/meta/slashes.php +++ b/tests/phpunit/tests/meta/slashes.php @@ -71,10 +71,10 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { edit_post(); $post = get_post( $id ); - $this->assertEquals( $this->slash_6, get_post_meta( $id, 'slash_test_0', true ) ); - $this->assertEquals( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) ); - $this->assertEquals( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) ); - $this->assertEquals( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( $this->slash_6, get_post_meta( $id, 'slash_test_0', true ) ); + $this->assertSame( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) ); + $this->assertSame( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) ); + $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) ); $_POST = array(); $_POST['post_ID'] = $id; @@ -101,9 +101,9 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { edit_post(); $post = get_post( $id ); - $this->assertEquals( $this->slash_2, get_post_meta( $id, 'slash_test_1', true ) ); - $this->assertEquals( $this->slash_4, get_post_meta( $id, 'slash_test_2', true ) ); - $this->assertEquals( $this->slash_5, get_post_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( $this->slash_2, get_post_meta( $id, 'slash_test_1', true ) ); + $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_2', true ) ); + $this->assertSame( $this->slash_5, get_post_meta( $id, 'slash_test_3', true ) ); } /** @@ -115,9 +115,9 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { add_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) ); add_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) ); - $this->assertEquals( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) ); - $this->assertEquals( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) ); - $this->assertEquals( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) ); + $this->assertSame( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) ); + $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) ); } /** @@ -129,9 +129,9 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { update_post_meta( $id, 'slash_test_2', addslashes( $this->slash_3 ) ); update_post_meta( $id, 'slash_test_3', addslashes( $this->slash_4 ) ); - $this->assertEquals( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) ); - $this->assertEquals( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) ); - $this->assertEquals( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( $this->slash_1, get_post_meta( $id, 'slash_test_1', true ) ); + $this->assertSame( $this->slash_3, get_post_meta( $id, 'slash_test_2', true ) ); + $this->assertSame( $this->slash_4, get_post_meta( $id, 'slash_test_3', true ) ); } /** @@ -144,17 +144,17 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { add_comment_meta( $id, 'slash_test_2', $this->slash_3 ); add_comment_meta( $id, 'slash_test_3', $this->slash_5 ); - $this->assertEquals( wp_unslash( $this->slash_1 ), get_comment_meta( $id, 'slash_test_1', true ) ); - $this->assertEquals( wp_unslash( $this->slash_3 ), get_comment_meta( $id, 'slash_test_2', true ) ); - $this->assertEquals( wp_unslash( $this->slash_5 ), get_comment_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $id, 'slash_test_3', true ) ); add_comment_meta( $id, 'slash_test_4', $this->slash_2 ); add_comment_meta( $id, 'slash_test_5', $this->slash_4 ); add_comment_meta( $id, 'slash_test_6', $this->slash_6 ); - $this->assertEquals( wp_unslash( $this->slash_2 ), get_comment_meta( $id, 'slash_test_4', true ) ); - $this->assertEquals( wp_unslash( $this->slash_4 ), get_comment_meta( $id, 'slash_test_5', true ) ); - $this->assertEquals( wp_unslash( $this->slash_6 ), get_comment_meta( $id, 'slash_test_6', true ) ); + $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $id, 'slash_test_4', true ) ); + $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $id, 'slash_test_5', true ) ); + $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $id, 'slash_test_6', true ) ); } /** @@ -171,17 +171,17 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { update_comment_meta( $id, 'slash_test_2', $this->slash_3 ); update_comment_meta( $id, 'slash_test_3', $this->slash_5 ); - $this->assertEquals( wp_unslash( $this->slash_1 ), get_comment_meta( $id, 'slash_test_1', true ) ); - $this->assertEquals( wp_unslash( $this->slash_3 ), get_comment_meta( $id, 'slash_test_2', true ) ); - $this->assertEquals( wp_unslash( $this->slash_5 ), get_comment_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_1 ), get_comment_meta( $id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_3 ), get_comment_meta( $id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_5 ), get_comment_meta( $id, 'slash_test_3', true ) ); update_comment_meta( $id, 'slash_test_1', $this->slash_2 ); update_comment_meta( $id, 'slash_test_2', $this->slash_4 ); update_comment_meta( $id, 'slash_test_3', $this->slash_6 ); - $this->assertEquals( wp_unslash( $this->slash_2 ), get_comment_meta( $id, 'slash_test_1', true ) ); - $this->assertEquals( wp_unslash( $this->slash_4 ), get_comment_meta( $id, 'slash_test_2', true ) ); - $this->assertEquals( wp_unslash( $this->slash_6 ), get_comment_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_2 ), get_comment_meta( $id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_4 ), get_comment_meta( $id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_6 ), get_comment_meta( $id, 'slash_test_3', true ) ); } /** @@ -194,17 +194,17 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { add_user_meta( $id, 'slash_test_2', $this->slash_3 ); add_user_meta( $id, 'slash_test_3', $this->slash_5 ); - $this->assertEquals( wp_unslash( $this->slash_1 ), get_user_meta( $id, 'slash_test_1', true ) ); - $this->assertEquals( wp_unslash( $this->slash_3 ), get_user_meta( $id, 'slash_test_2', true ) ); - $this->assertEquals( wp_unslash( $this->slash_5 ), get_user_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $id, 'slash_test_3', true ) ); add_user_meta( $id, 'slash_test_4', $this->slash_2 ); add_user_meta( $id, 'slash_test_5', $this->slash_4 ); add_user_meta( $id, 'slash_test_6', $this->slash_6 ); - $this->assertEquals( wp_unslash( $this->slash_2 ), get_user_meta( $id, 'slash_test_4', true ) ); - $this->assertEquals( wp_unslash( $this->slash_4 ), get_user_meta( $id, 'slash_test_5', true ) ); - $this->assertEquals( wp_unslash( $this->slash_6 ), get_user_meta( $id, 'slash_test_6', true ) ); + $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $id, 'slash_test_4', true ) ); + $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $id, 'slash_test_5', true ) ); + $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $id, 'slash_test_6', true ) ); } /** @@ -221,16 +221,16 @@ class Tests_Meta_Slashes extends WP_UnitTestCase { update_user_meta( $id, 'slash_test_2', $this->slash_3 ); update_user_meta( $id, 'slash_test_3', $this->slash_5 ); - $this->assertEquals( wp_unslash( $this->slash_1 ), get_user_meta( $id, 'slash_test_1', true ) ); - $this->assertEquals( wp_unslash( $this->slash_3 ), get_user_meta( $id, 'slash_test_2', true ) ); - $this->assertEquals( wp_unslash( $this->slash_5 ), get_user_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_1 ), get_user_meta( $id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_3 ), get_user_meta( $id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_5 ), get_user_meta( $id, 'slash_test_3', true ) ); update_user_meta( $id, 'slash_test_1', $this->slash_2 ); update_user_meta( $id, 'slash_test_2', $this->slash_4 ); update_user_meta( $id, 'slash_test_3', $this->slash_6 ); - $this->assertEquals( wp_unslash( $this->slash_2 ), get_user_meta( $id, 'slash_test_1', true ) ); - $this->assertEquals( wp_unslash( $this->slash_4 ), get_user_meta( $id, 'slash_test_2', true ) ); - $this->assertEquals( wp_unslash( $this->slash_6 ), get_user_meta( $id, 'slash_test_3', true ) ); + $this->assertSame( wp_unslash( $this->slash_2 ), get_user_meta( $id, 'slash_test_1', true ) ); + $this->assertSame( wp_unslash( $this->slash_4 ), get_user_meta( $id, 'slash_test_2', true ) ); + $this->assertSame( wp_unslash( $this->slash_6 ), get_user_meta( $id, 'slash_test_3', true ) ); } } diff --git a/tests/phpunit/tests/multisite.php b/tests/phpunit/tests/multisite.php index e4150a2b0e..e96f3d27ce 100644 --- a/tests/phpunit/tests/multisite.php +++ b/tests/phpunit/tests/multisite.php @@ -32,7 +32,7 @@ if ( is_multisite() ) : // Currently there is no wrapper function for the registration_log. $reg_blog = $wpdb->get_col( $wpdb->prepare( "SELECT email FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.blog_id = 1 AND IP LIKE %s", $ip ) ); - $this->assertEquals( $user->user_email, $reg_blog[ count( $reg_blog ) - 1 ] ); + $this->assertSame( $user->user_email, $reg_blog[ count( $reg_blog ) - 1 ] ); } /** @@ -88,7 +88,7 @@ if ( is_multisite() ) : $expected['all'] += 1; $expected['public'] += 1; - $this->assertEquals( $expected, $counts ); + $this->assertSame( $expected, $counts ); } } diff --git a/tests/phpunit/tests/multisite/bootstrap.php b/tests/phpunit/tests/multisite/bootstrap.php index 9b85114624..eabf78297b 100644 --- a/tests/phpunit/tests/multisite/bootstrap.php +++ b/tests/phpunit/tests/multisite/bootstrap.php @@ -125,7 +125,7 @@ if ( is_multisite() ) : */ function test_get_network_by_path( $expected_key, $domain, $path, $message ) { $network = get_network_by_path( $domain, $path ); - $this->assertEquals( self::$network_ids[ $expected_key ], $network->id, $message ); + $this->assertSame( self::$network_ids[ $expected_key ], $network->id, $message ); } public function data_get_network_by_path() { @@ -161,7 +161,7 @@ if ( is_multisite() ) : remove_filter( 'network_by_path_segments_count', '__return_zero' ); - $this->assertEquals( self::$network_ids[ $expected_key ], $network->id, $message ); + $this->assertSame( self::$network_ids[ $expected_key ], $network->id, $message ); } public function data_get_network_by_path_with_zero_path_segments() { @@ -186,7 +186,7 @@ if ( is_multisite() ) : $network = get_network_by_path( 'wordpress.org', '/one/b/' ); remove_filter( 'network_by_path_segments_count', array( $this, 'filter_network_path_segments' ) ); - $this->assertEquals( self::$network_ids['wordpress.org/one/'], $network->id ); + $this->assertSame( self::$network_ids['wordpress.org/one/'], $network->id ); } public function filter_network_path_segments() { diff --git a/tests/phpunit/tests/multisite/getBlogDetails.php b/tests/phpunit/tests/multisite/getBlogDetails.php index 51d980465c..f79b065725 100644 --- a/tests/phpunit/tests/multisite/getBlogDetails.php +++ b/tests/phpunit/tests/multisite/getBlogDetails.php @@ -125,7 +125,7 @@ if ( is_multisite() ) : } $site = get_blog_details( array( 'domain' => 'wordpress.org' ) ); - $this->assertEquals( self::$site_ids['wordpress.org/'], $site->blog_id ); + $this->assertSame( self::$site_ids['wordpress.org/'], $site->blog_id ); } public function test_get_blog_details_with_only_domain_in_fields_subdirectory() { diff --git a/tests/phpunit/tests/multisite/getIdFromBlogname.php b/tests/phpunit/tests/multisite/getIdFromBlogname.php index 1e50110018..3df68afe86 100644 --- a/tests/phpunit/tests/multisite/getIdFromBlogname.php +++ b/tests/phpunit/tests/multisite/getIdFromBlogname.php @@ -101,7 +101,7 @@ if ( is_multisite() ) : $result = get_id_from_blogname( 'foo' ); $current_site = $original_network; - $this->assertEquals( $expected, $result ); + $this->assertSame( $expected, $result ); } /** @@ -122,7 +122,7 @@ if ( is_multisite() ) : $result = get_id_from_blogname( 'foo' ); $current_site = $original_network; - $this->assertEquals( $expected, $result ); + $this->assertSame( $expected, $result ); } public function test_get_id_from_blogname_invalid_slug() { @@ -134,7 +134,7 @@ if ( is_multisite() ) : $result = get_id_from_blogname( 'bar' ); $current_site = $original_network; - $this->assertEquals( null, $result ); + $this->assertNull( $result ); } } diff --git a/tests/phpunit/tests/multisite/getSite.php b/tests/phpunit/tests/multisite/getSite.php index aeaa9ddf2e..1df45df9be 100644 --- a/tests/phpunit/tests/multisite/getSite.php +++ b/tests/phpunit/tests/multisite/getSite.php @@ -45,7 +45,7 @@ if ( is_multisite() ) : $site = get_site(); restore_current_blog(); - $this->assertEquals( self::$site_ids['wordpress.org/foo/'], $site->id ); + $this->assertSame( self::$site_ids['wordpress.org/foo/'], $site->id ); } } diff --git a/tests/phpunit/tests/multisite/getSpaceAllowed.php b/tests/phpunit/tests/multisite/getSpaceAllowed.php index e876658ba0..b534d391be 100644 --- a/tests/phpunit/tests/multisite/getSpaceAllowed.php +++ b/tests/phpunit/tests/multisite/getSpaceAllowed.php @@ -48,7 +48,7 @@ if ( is_multisite() ) : delete_option( 'blog_upload_space' ); delete_site_option( 'blog_upload_space' ); - $this->assertEquals( 100, get_space_allowed() ); + $this->assertSame( 100, get_space_allowed() ); } /** @@ -59,7 +59,7 @@ if ( is_multisite() ) : delete_site_option( 'blog_upload_space' ); update_site_option( 'blog_upload_space', 200 ); - $this->assertEquals( 200, get_space_allowed() ); + $this->assertSame( 200, get_space_allowed() ); } /** @@ -73,7 +73,7 @@ if ( is_multisite() ) : update_option( 'blog_upload_space', $site_option ); update_site_option( 'blog_upload_space', $network_option ); - $this->assertEquals( $expected, get_space_allowed() ); + $this->assertSame( $expected, get_space_allowed() ); } public function data_blog_upload_space() { @@ -108,7 +108,7 @@ if ( is_multisite() ) : $space_allowed = get_space_allowed(); remove_filter( 'get_space_allowed', array( $this, '_filter_space_allowed' ) ); - $this->assertEquals( 999, $space_allowed ); + $this->assertSame( 999, $space_allowed ); } public function _filter_space_allowed() { diff --git a/tests/phpunit/tests/multisite/getSpaceUsed.php b/tests/phpunit/tests/multisite/getSpaceUsed.php index 7d6d33304c..f3a4c93ecc 100644 --- a/tests/phpunit/tests/multisite/getSpaceUsed.php +++ b/tests/phpunit/tests/multisite/getSpaceUsed.php @@ -44,7 +44,7 @@ if ( is_multisite() ) : delete_transient( 'dirsize_cache' ); - $this->assertEquals( $size, get_space_used() ); + $this->assertSame( $size, get_space_used() ); $upload_dir = wp_upload_dir(); $this->remove_added_uploads(); $this->delete_folders( $upload_dir['basedir'] ); @@ -79,7 +79,7 @@ if ( is_multisite() ) : delete_transient( 'dirsize_cache' ); - $this->assertEquals( $space_used, get_space_used() ); + $this->assertSame( $space_used, get_space_used() ); // Switch back to the new site to remove the uploaded file. switch_to_blog( $blog_id ); @@ -92,7 +92,7 @@ if ( is_multisite() ) : function test_get_space_used_pre_get_spaced_used_filter() { add_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) ); - $this->assertEquals( 300, get_space_used() ); + $this->assertSame( 300, get_space_used() ); remove_filter( 'pre_get_space_used', array( $this, '_filter_space_used' ) ); } diff --git a/tests/phpunit/tests/multisite/ms-files-rewriting.php b/tests/phpunit/tests/multisite/ms-files-rewriting.php index 1d39234397..c7a8e7b8e3 100644 --- a/tests/phpunit/tests/multisite/ms-files-rewriting.php +++ b/tests/phpunit/tests/multisite/ms-files-rewriting.php @@ -40,18 +40,18 @@ if ( is_multisite() ) : $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); $blog_id2 = self::factory()->blog->create( array( 'user_id' => $user_id ) ); $info = wp_upload_dir(); - $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] ); - $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] ); - $this->assertEquals( gmstrftime( '/%Y/%m' ), $info['subdir'] ); - $this->assertEquals( '', $info['error'] ); + $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] ); + $this->assertSame( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] ); + $this->assertSame( gmstrftime( '/%Y/%m' ), $info['subdir'] ); + $this->assertFalse( $info['error'] ); switch_to_blog( $blog_id2 ); $info2 = wp_upload_dir(); $this->assertNotEquals( $info, $info2 ); - $this->assertEquals( get_option( 'siteurl' ) . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['url'] ); - $this->assertEquals( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['path'] ); - $this->assertEquals( gmstrftime( '/%Y/%m' ), $info2['subdir'] ); - $this->assertEquals( '', $info2['error'] ); + $this->assertSame( get_option( 'siteurl' ) . '/wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['url'] ); + $this->assertSame( ABSPATH . 'wp-content/blogs.dir/' . get_current_blog_id() . '/files/' . gmstrftime( '%Y/%m' ), $info2['path'] ); + $this->assertSame( gmstrftime( '/%Y/%m' ), $info2['subdir'] ); + $this->assertFalse( $info2['error'] ); restore_current_blog(); } diff --git a/tests/phpunit/tests/multisite/network.php b/tests/phpunit/tests/multisite/network.php index bfe220638b..ff7a2ff4b5 100644 --- a/tests/phpunit/tests/multisite/network.php +++ b/tests/phpunit/tests/multisite/network.php @@ -76,7 +76,7 @@ if ( is_multisite() ) : * By default, only one network exists and has a network ID of 1. */ function test_get_main_network_id_default() { - $this->assertEquals( 1, get_main_network_id() ); + $this->assertSame( 1, get_main_network_id() ); } /** @@ -86,7 +86,7 @@ if ( is_multisite() ) : function test_get_main_network_id_two_networks() { self::factory()->network->create(); - $this->assertEquals( 1, get_main_network_id() ); + $this->assertSame( 1, get_main_network_id() ); } /** @@ -100,7 +100,7 @@ if ( is_multisite() ) : $current_site->id = (int) $id; - $this->assertEquals( 1, get_main_network_id() ); + $this->assertSame( 1, get_main_network_id() ); } /** @@ -120,12 +120,12 @@ if ( is_multisite() ) : $main_network_id = get_main_network_id(); $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->site} SET id=1 WHERE id=%d", $temp_id ) ); - $this->assertEquals( self::$different_network_id, $main_network_id ); + $this->assertSame( self::$different_network_id, $main_network_id ); } function test_get_main_network_id_filtered() { add_filter( 'get_main_network_id', array( $this, '_get_main_network_id' ) ); - $this->assertEquals( 3, get_main_network_id() ); + $this->assertSame( 3, get_main_network_id() ); remove_filter( 'get_main_network_id', array( $this, '_get_main_network_id' ) ); } @@ -159,7 +159,7 @@ if ( is_multisite() ) : } wp_update_network_counts(); - $this->assertEquals( $site_count_start + 1, $actual ); + $this->assertSame( $site_count_start + 1, $actual ); } /** @@ -246,7 +246,7 @@ if ( is_multisite() ) : // No change, cache not refreshed. $count = get_user_count(); - $this->assertEquals( $start_count, $count ); + $this->assertSame( $start_count, $count ); wp_update_network_counts(); $start_count = get_user_count(); @@ -268,26 +268,26 @@ if ( is_multisite() ) : // Local activate, should be invisible for the network. activate_plugin( $path ); // Enable the plugin for the current site. $active_plugins = wp_get_active_network_plugins(); - $this->assertEquals( array(), $active_plugins ); + $this->assertSame( array(), $active_plugins ); add_action( 'deactivated_plugin', array( $this, '_helper_deactivate_hook' ) ); // Activate the plugin sitewide. activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network. $active_plugins = wp_get_active_network_plugins(); - $this->assertEquals( array( WP_PLUGIN_DIR . '/hello.php' ), $active_plugins ); + $this->assertSame( array( WP_PLUGIN_DIR . '/hello.php' ), $active_plugins ); // Deactivate the plugin. deactivate_plugins( $path ); $active_plugins = wp_get_active_network_plugins(); - $this->assertEquals( array(), $active_plugins ); + $this->assertSame( array(), $active_plugins ); - $this->assertEquals( 1, $this->plugin_hook_count ); // Testing actions and silent mode. + $this->assertSame( 1, $this->plugin_hook_count ); // Testing actions and silent mode. activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network. deactivate_plugins( $path, true ); // Silent mode. - $this->assertEquals( 1, $this->plugin_hook_count ); // Testing actions and silent mode. + $this->assertSame( 1, $this->plugin_hook_count ); // Testing actions and silent mode. } /** @@ -302,13 +302,13 @@ if ( is_multisite() ) : activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network. $active_plugins = wp_get_active_network_plugins(); $this->assertCount( 1, $active_plugins ); - $this->assertEquals( 1, $mock->get_call_count() ); + $this->assertSame( 1, $mock->get_call_count() ); // Should do nothing on the second try. activate_plugin( $path, '', true ); // Enable the plugin for all sites in the network. $active_plugins = wp_get_active_network_plugins(); $this->assertCount( 1, $active_plugins ); - $this->assertEquals( 1, $mock->get_call_count() ); + $this->assertSame( 1, $mock->get_call_count() ); remove_action( 'activate_' . $path, array( $mock, 'action' ) ); } @@ -337,7 +337,7 @@ if ( is_multisite() ) : self::factory()->user->create( array( 'role' => 'administrator' ) ); $count = get_user_count(); // No change, cache not refreshed. - $this->assertEquals( $start_count, $count ); + $this->assertSame( $start_count, $count ); wp_update_network_counts(); // Magic happens here. @@ -392,7 +392,7 @@ if ( is_multisite() ) : wp_update_network_site_counts(); $result = get_blog_count(); - $this->assertEquals( $expected, $result ); + $this->assertSame( $expected, $result ); } /** @@ -404,7 +404,7 @@ if ( is_multisite() ) : wp_update_network_site_counts( self::$different_network_id ); $result = get_blog_count( self::$different_network_id ); - $this->assertEquals( 3, $result ); + $this->assertSame( 3, $result ); } /** @@ -420,7 +420,7 @@ if ( is_multisite() ) : wp_update_network_user_counts(); $result = get_user_count(); - $this->assertEquals( $expected, $result ); + $this->assertSame( $expected, $result ); } /** @@ -436,7 +436,7 @@ if ( is_multisite() ) : wp_update_network_user_counts( self::$different_network_id ); $result = get_user_count( self::$different_network_id ); - $this->assertEquals( $expected, $result ); + $this->assertSame( $expected, $result ); } /** @@ -596,7 +596,7 @@ if ( is_multisite() ) : wpmu_delete_blog( $site_id, true ); - $this->assertEquals( $original_count + 1, $result ); + $this->assertSame( $original_count + 1, $result ); } /** @@ -632,12 +632,12 @@ if ( is_multisite() ) : $new_network = $this->factory()->network->create_and_get(); // Double-check we got the ID of the new network correct. - $this->assertEquals( $new_network_id, $new_network->id ); + $this->assertSame( $new_network_id, $new_network->id ); // Verify that if we fetch the network now, it's no longer false. $fetched_network = get_network( $new_network_id ); $this->assertInstanceOf( 'WP_Network', $fetched_network ); - $this->assertEquals( $new_network_id, $fetched_network->id ); + $this->assertSame( $new_network_id, $fetched_network->id ); } /** diff --git a/tests/phpunit/tests/multisite/networkQuery.php b/tests/phpunit/tests/multisite/networkQuery.php index 0318998129..ae06d24161 100644 --- a/tests/phpunit/tests/multisite/networkQuery.php +++ b/tests/phpunit/tests/multisite/networkQuery.php @@ -70,7 +70,7 @@ if ( is_multisite() ) : ) ); - $this->assertEquals( 3, count( $found ) ); + $this->assertSame( 3, count( $found ) ); } public function test_wp_network_query_by_network__in_with_order() { @@ -85,7 +85,7 @@ if ( is_multisite() ) : ) ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); $found = $q->query( array( @@ -95,7 +95,7 @@ if ( is_multisite() ) : ) ); - $this->assertEquals( array_reverse( $expected ), $found ); + $this->assertSame( array_reverse( $expected ), $found ); } public function test_wp_network_query_by_network__in_with_single_id() { @@ -138,7 +138,7 @@ if ( is_multisite() ) : ) ); - $this->assertEquals( 2, $found ); + $this->assertSame( 2, $found ); } public function test_wp_network_query_by_network__not_in_with_single_id() { @@ -435,7 +435,7 @@ if ( is_multisite() ) : self::$network_ids['make.wordpress.org/'], ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } /** @@ -462,7 +462,7 @@ if ( is_multisite() ) : ) ); - $this->assertEquals( $number_of_queries, $wpdb->num_queries ); + $this->assertSame( $number_of_queries, $wpdb->num_queries ); } /** @@ -491,7 +491,7 @@ if ( is_multisite() ) : 'count' => true, ) ); - $this->assertEquals( $number_of_queries, $wpdb->num_queries ); + $this->assertSame( $number_of_queries, $wpdb->num_queries ); } /** @@ -520,7 +520,7 @@ if ( is_multisite() ) : 'count' => true, ) ); - $this->assertEquals( $number_of_queries + 1, $wpdb->num_queries ); + $this->assertSame( $number_of_queries + 1, $wpdb->num_queries ); } /** @@ -546,7 +546,7 @@ if ( is_multisite() ) : $this->assertSame( array( 555 ), $results ); // Make sure manually setting total_users doesn't get overwritten. - $this->assertEquals( 1, $q->found_networks ); + $this->assertSame( 1, $q->found_networks ); } public static function filter_networks_pre_query( $networks, $query ) { diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index 0e983e81b7..6cce1ac41a 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -91,44 +91,44 @@ if ( is_multisite() ) : function test_switch_restore_blog() { global $_wp_switched_stack, $wpdb; - $this->assertEquals( array(), $_wp_switched_stack ); + $this->assertSame( array(), $_wp_switched_stack ); $this->assertFalse( ms_is_switched() ); $current_blog_id = get_current_blog_id(); $this->assertInternalType( 'integer', $current_blog_id ); wp_cache_set( 'switch-test', $current_blog_id, 'switch-test' ); - $this->assertEquals( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); + $this->assertSame( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); $blog_id = self::factory()->blog->create(); $cap_key = wp_get_current_user()->cap_key; switch_to_blog( $blog_id ); $this->assertNotEquals( $cap_key, wp_get_current_user()->cap_key ); - $this->assertEquals( array( $current_blog_id ), $_wp_switched_stack ); + $this->assertSame( array( $current_blog_id ), $_wp_switched_stack ); $this->assertTrue( ms_is_switched() ); - $this->assertEquals( $blog_id, $wpdb->blogid ); + $this->assertSame( $blog_id, $wpdb->blogid ); $this->assertFalse( wp_cache_get( 'switch-test', 'switch-test' ) ); wp_cache_set( 'switch-test', $blog_id, 'switch-test' ); - $this->assertEquals( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); + $this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); switch_to_blog( $blog_id ); - $this->assertEquals( array( $current_blog_id, $blog_id ), $_wp_switched_stack ); + $this->assertSame( array( $current_blog_id, $blog_id ), $_wp_switched_stack ); $this->assertTrue( ms_is_switched() ); - $this->assertEquals( $blog_id, $wpdb->blogid ); - $this->assertEquals( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); + $this->assertSame( $blog_id, $wpdb->blogid ); + $this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); restore_current_blog(); - $this->assertEquals( array( $current_blog_id ), $_wp_switched_stack ); + $this->assertSame( array( $current_blog_id ), $_wp_switched_stack ); $this->assertTrue( ms_is_switched() ); - $this->assertEquals( $blog_id, $wpdb->blogid ); - $this->assertEquals( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); + $this->assertSame( $blog_id, $wpdb->blogid ); + $this->assertSame( $blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); restore_current_blog(); - $this->assertEquals( $cap_key, wp_get_current_user()->cap_key ); - $this->assertEquals( $current_blog_id, get_current_blog_id() ); - $this->assertEquals( array(), $_wp_switched_stack ); + $this->assertSame( $cap_key, wp_get_current_user()->cap_key ); + $this->assertSame( $current_blog_id, get_current_blog_id() ); + $this->assertSame( array(), $_wp_switched_stack ); $this->assertFalse( ms_is_switched() ); - $this->assertEquals( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); + $this->assertSame( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); $this->assertFalse( restore_current_blog() ); } @@ -153,11 +153,11 @@ if ( is_multisite() ) : $this->assertEquals( $details, wp_cache_get( $blog_id . 'short', 'blog-details' ) ); // get_blogaddress_by_name(). - $this->assertEquals( 'http://' . $details->domain . $details->path, get_blogaddress_by_name( trim( $details->path, '/' ) ) ); + $this->assertSame( 'http://' . $details->domain . $details->path, get_blogaddress_by_name( trim( $details->path, '/' ) ) ); // These are empty until get_blog_details() is called with $get_all = true. - $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) ); - $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) ); + $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) ); + $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) ); // $get_all = true, populate the full blog-details cache and the blog slug lookup cache. $details = get_blog_details( $blog_id, true ); @@ -189,7 +189,7 @@ if ( is_multisite() ) : // Update the blog count cache to use get_blog_count(). wp_update_network_counts(); - $this->assertEquals( 2, (int) get_blog_count() ); + $this->assertSame( 2, (int) get_blog_count() ); } public function test_site_caches_should_invalidate_when_invalidation_is_not_suspended() { @@ -215,7 +215,7 @@ if ( is_multisite() ) : $new_details = get_site( $site_id ); wp_suspend_cache_invalidation( $suspend ); - $this->assertEquals( $details->path, $new_details->path ); + $this->assertSame( $details->path, $new_details->path ); } /** @@ -230,10 +230,10 @@ if ( is_multisite() ) : // Delete the site without forcing a table drop. wpmu_delete_blog( $blog_id, false ); - $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) ); - $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) ); - $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) ); - $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) ); + $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) ); + $this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) ); + $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) ); + $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) ); } /** @@ -271,10 +271,10 @@ if ( is_multisite() ) : // Delete the site and force a table drop. wpmu_delete_blog( $blog_id, true ); - $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) ); - $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) ); - $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) ); - $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) ); + $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) ); + $this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) ); + $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) ); + $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) ); } /** @@ -312,10 +312,10 @@ if ( is_multisite() ) : // Delete the site and force a table drop. wpmu_delete_blog( $blog_id, true ); - $this->assertEquals( false, wp_cache_get( $blog_id, 'blog-details' ) ); - $this->assertEquals( false, wp_cache_get( $blog_id . 'short', 'blog-details' ) ); - $this->assertEquals( false, wp_cache_get( $key, 'blog-lookup' ) ); - $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) ); + $this->assertFalse( wp_cache_get( $blog_id, 'blog-details' ) ); + $this->assertFalse( wp_cache_get( $blog_id . 'short', 'blog-details' ) ); + $this->assertFalse( wp_cache_get( $key, 'blog-lookup' ) ); + $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) ); } /** @@ -352,7 +352,7 @@ if ( is_multisite() ) : // Update the blog count cache to use get_blog_count(). wp_update_network_counts(); - $this->assertEquals( 1, get_blog_count() ); + $this->assertSame( 1, get_blog_count() ); } /** @@ -366,7 +366,7 @@ if ( is_multisite() ) : // Update the blog count cache to use get_blog_count(). wp_update_network_counts(); - $this->assertEquals( 1, get_blog_count() ); + $this->assertSame( 1, get_blog_count() ); } /** @@ -434,7 +434,7 @@ if ( is_multisite() ) : get_blog_details( $blog_id ); // When the cache is primed with an invalid site, the value is set to -1. - $this->assertEquals( -1, wp_cache_get( $blog_id, 'blog-details' ) ); + $this->assertSame( -1, wp_cache_get( $blog_id, 'blog-details' ) ); // Create a site in the invalid site's place. self::factory()->blog->create(); @@ -453,7 +453,7 @@ if ( is_multisite() ) : */ function test_update_blog_status() { $result = update_blog_status( 1, 'spam', 0 ); - $this->assertEquals( 0, $result ); + $this->assertSame( 0, $result ); } /** @@ -461,7 +461,7 @@ if ( is_multisite() ) : */ function test_update_blog_status_invalid_status() { $result = update_blog_status( 1, 'doesnotexist', 'invalid' ); - $this->assertEquals( 'invalid', $result ); + $this->assertSame( 'invalid', $result ); } function test_update_blog_status_make_ham_blog_action() { @@ -475,15 +475,15 @@ if ( is_multisite() ) : update_blog_status( $blog_id, 'spam', 0 ); $blog = get_site( $blog_id ); - $this->assertEquals( '0', $blog->spam ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '0', $blog->spam ); + $this->assertSame( 1, $test_action_counter ); // The action should not fire if the status of 'spam' stays the same. update_blog_status( $blog_id, 'spam', 0 ); $blog = get_site( $blog_id ); - $this->assertEquals( '0', $blog->spam ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '0', $blog->spam ); + $this->assertSame( 1, $test_action_counter ); remove_action( 'make_ham_blog', array( $this, '_action_counter_cb' ), 10 ); } @@ -498,15 +498,15 @@ if ( is_multisite() ) : update_blog_status( $blog_id, 'spam', 1 ); $blog = get_site( $blog_id ); - $this->assertEquals( '1', $blog->spam ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '1', $blog->spam ); + $this->assertSame( 1, $test_action_counter ); // The action should not fire if the status of 'spam' stays the same. update_blog_status( $blog_id, 'spam', 1 ); $blog = get_site( $blog_id ); - $this->assertEquals( '1', $blog->spam ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '1', $blog->spam ); + $this->assertSame( 1, $test_action_counter ); remove_action( 'make_spam_blog', array( $this, '_action_counter_cb' ), 10 ); } @@ -521,15 +521,15 @@ if ( is_multisite() ) : update_blog_status( $blog_id, 'archived', 1 ); $blog = get_site( $blog_id ); - $this->assertEquals( '1', $blog->archived ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '1', $blog->archived ); + $this->assertSame( 1, $test_action_counter ); // The action should not fire if the status of 'archived' stays the same. update_blog_status( $blog_id, 'archived', 1 ); $blog = get_site( $blog_id ); - $this->assertEquals( '1', $blog->archived ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '1', $blog->archived ); + $this->assertSame( 1, $test_action_counter ); remove_action( 'archive_blog', array( $this, '_action_counter_cb' ), 10 ); } @@ -545,14 +545,14 @@ if ( is_multisite() ) : update_blog_status( $blog_id, 'archived', 0 ); $blog = get_site( $blog_id ); - $this->assertEquals( '0', $blog->archived ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '0', $blog->archived ); + $this->assertSame( 1, $test_action_counter ); // The action should not fire if the status of 'archived' stays the same. update_blog_status( $blog_id, 'archived', 0 ); $blog = get_site( $blog_id ); - $this->assertEquals( '0', $blog->archived ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '0', $blog->archived ); + $this->assertSame( 1, $test_action_counter ); remove_action( 'unarchive_blog', array( $this, '_action_counter_cb' ), 10 ); } @@ -567,15 +567,15 @@ if ( is_multisite() ) : update_blog_status( $blog_id, 'deleted', 1 ); $blog = get_site( $blog_id ); - $this->assertEquals( '1', $blog->deleted ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '1', $blog->deleted ); + $this->assertSame( 1, $test_action_counter ); // The action should not fire if the status of 'deleted' stays the same. update_blog_status( $blog_id, 'deleted', 1 ); $blog = get_site( $blog_id ); - $this->assertEquals( '1', $blog->deleted ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '1', $blog->deleted ); + $this->assertSame( 1, $test_action_counter ); remove_action( 'make_delete_blog', array( $this, '_action_counter_cb' ), 10 ); } @@ -591,15 +591,15 @@ if ( is_multisite() ) : update_blog_status( $blog_id, 'deleted', 0 ); $blog = get_site( $blog_id ); - $this->assertEquals( '0', $blog->deleted ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '0', $blog->deleted ); + $this->assertSame( 1, $test_action_counter ); // The action should not fire if the status of 'deleted' stays the same. update_blog_status( $blog_id, 'deleted', 0 ); $blog = get_site( $blog_id ); - $this->assertEquals( '0', $blog->deleted ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '0', $blog->deleted ); + $this->assertSame( 1, $test_action_counter ); remove_action( 'make_undelete_blog', array( $this, '_action_counter_cb' ), 10 ); } @@ -614,15 +614,15 @@ if ( is_multisite() ) : update_blog_status( $blog_id, 'mature', 1 ); $blog = get_site( $blog_id ); - $this->assertEquals( '1', $blog->mature ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '1', $blog->mature ); + $this->assertSame( 1, $test_action_counter ); // The action should not fire if the status of 'mature' stays the same. update_blog_status( $blog_id, 'mature', 1 ); $blog = get_site( $blog_id ); - $this->assertEquals( '1', $blog->mature ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '1', $blog->mature ); + $this->assertSame( 1, $test_action_counter ); remove_action( 'mature_blog', array( $this, '_action_counter_cb' ), 10 ); } @@ -638,15 +638,15 @@ if ( is_multisite() ) : update_blog_status( $blog_id, 'mature', 0 ); $blog = get_site( $blog_id ); - $this->assertEquals( '0', $blog->mature ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '0', $blog->mature ); + $this->assertSame( 1, $test_action_counter ); // The action should not fire if the status of 'mature' stays the same. update_blog_status( $blog_id, 'mature', 0 ); $blog = get_site( $blog_id ); - $this->assertEquals( '0', $blog->mature ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '0', $blog->mature ); + $this->assertSame( 1, $test_action_counter ); remove_action( 'unmature_blog', array( $this, '_action_counter_cb' ), 10 ); } @@ -661,15 +661,15 @@ if ( is_multisite() ) : update_blog_status( $blog_id, 'public', 0 ); $blog = get_site( $blog_id ); - $this->assertEquals( '0', $blog->public ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '0', $blog->public ); + $this->assertSame( 1, $test_action_counter ); // The action should not fire if the status of 'mature' stays the same. update_blog_status( $blog_id, 'public', 0 ); $blog = get_site( $blog_id ); - $this->assertEquals( '0', $blog->public ); - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( '0', $blog->public ); + $this->assertSame( 1, $test_action_counter ); remove_action( 'update_blog_public', array( $this, '_action_counter_cb' ), 10 ); } @@ -680,10 +680,10 @@ if ( is_multisite() ) : function test_posts_count() { self::factory()->post->create(); $post2 = self::factory()->post->create(); - $this->assertEquals( 2, get_site()->post_count ); + $this->assertSame( 2, get_site()->post_count ); wp_delete_post( $post2 ); - $this->assertEquals( 1, get_site()->post_count ); + $this->assertSame( 1, get_site()->post_count ); } /** @@ -692,11 +692,11 @@ if ( is_multisite() ) : function test_blog_details_cache_invalidation() { update_option( 'blogname', 'foo' ); $details = get_site( get_current_blog_id() ); - $this->assertEquals( 'foo', $details->blogname ); + $this->assertSame( 'foo', $details->blogname ); update_option( 'blogname', 'bar' ); $details = get_site( get_current_blog_id() ); - $this->assertEquals( 'bar', $details->blogname ); + $this->assertSame( 'bar', $details->blogname ); } /** @@ -709,8 +709,8 @@ if ( is_multisite() ) : $key = md5( $details->domain . $details->path ); // Test the original response and cached response for the newly created site. - $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) ); - $this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) ); + $this->assertSame( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) ); + $this->assertSame( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) ); } /** @@ -725,7 +725,7 @@ if ( is_multisite() ) : ); $details = get_site( $blog_id ); - $this->assertEquals( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) ); + $this->assertSame( $blog_id, get_blog_id_from_url( strtoupper( $details->domain ), strtoupper( $details->path ) ) ); } /** @@ -735,8 +735,8 @@ if ( is_multisite() ) : $blog_id = self::factory()->blog->create( array( 'path' => '/xyz' ) ); $details = get_site( $blog_id ); - $this->assertEquals( 0, get_blog_id_from_url( $details->domain, 'foo' ) ); - $this->assertEquals( -1, wp_cache_get( md5( $details->domain . 'foo' ), 'blog-id-cache' ) ); + $this->assertSame( 0, get_blog_id_from_url( $details->domain, 'foo' ) ); + $this->assertSame( -1, wp_cache_get( md5( $details->domain . 'foo' ), 'blog-id-cache' ) ); } /** @@ -749,8 +749,8 @@ if ( is_multisite() ) : $key = md5( $details->domain . $details->path ); wpmu_delete_blog( $blog_id ); - $this->assertEquals( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) ); - $this->assertEquals( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) ); + $this->assertSame( $blog_id, get_blog_id_from_url( $details->domain, $details->path ) ); + $this->assertSame( $blog_id, wp_cache_get( $key, 'blog-id-cache' ) ); } /** @@ -763,9 +763,9 @@ if ( is_multisite() ) : $key = md5( $details->domain . $details->path ); wpmu_delete_blog( $blog_id, true ); - $this->assertEquals( false, wp_cache_get( $key, 'blog-id-cache' ) ); - $this->assertEquals( 0, get_blog_id_from_url( $details->domain, $details->path ) ); - $this->assertEquals( -1, wp_cache_get( $key, 'blog-id-cache' ) ); + $this->assertFalse( wp_cache_get( $key, 'blog-id-cache' ) ); + $this->assertSame( 0, get_blog_id_from_url( $details->domain, $details->path ) ); + $this->assertSame( -1, wp_cache_get( $key, 'blog-id-cache' ) ); } /** @@ -810,26 +810,26 @@ if ( is_multisite() ) : $site = get_current_site(); $info = wp_upload_dir(); - $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] ); - $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] ); - $this->assertEquals( gmstrftime( '/%Y/%m' ), $info['subdir'] ); - $this->assertEquals( '', $info['error'] ); + $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] ); + $this->assertSame( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] ); + $this->assertSame( gmstrftime( '/%Y/%m' ), $info['subdir'] ); + $this->assertFalse( $info['error'] ); $blog_id = self::factory()->blog->create(); switch_to_blog( $blog_id ); $info = wp_upload_dir(); - $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime( '%Y/%m' ), $info['url'] ); - $this->assertEquals( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime( '%Y/%m' ), $info['path'] ); - $this->assertEquals( gmstrftime( '/%Y/%m' ), $info['subdir'] ); - $this->assertEquals( '', $info['error'] ); + $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime( '%Y/%m' ), $info['url'] ); + $this->assertSame( ABSPATH . 'wp-content/uploads/sites/' . get_current_blog_id() . '/' . gmstrftime( '%Y/%m' ), $info['path'] ); + $this->assertSame( gmstrftime( '/%Y/%m' ), $info['subdir'] ); + $this->assertFalse( $info['error'] ); restore_current_blog(); $info = wp_upload_dir(); - $this->assertEquals( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] ); - $this->assertEquals( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] ); - $this->assertEquals( gmstrftime( '/%Y/%m' ), $info['subdir'] ); - $this->assertEquals( '', $info['error'] ); + $this->assertSame( 'http://' . $site->domain . '/wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['url'] ); + $this->assertSame( ABSPATH . 'wp-content/uploads/' . gmstrftime( '%Y/%m' ), $info['path'] ); + $this->assertSame( gmstrftime( '/%Y/%m' ), $info['subdir'] ); + $this->assertFalse( $info['error'] ); } /** @@ -879,13 +879,13 @@ if ( is_multisite() ) : function test_domain_exists_with_default_site_id() { $details = get_site( 1 ); - $this->assertEquals( 1, domain_exists( $details->domain, $details->path ) ); + $this->assertSame( 1, domain_exists( $details->domain, $details->path ) ); } function test_domain_exists_with_specified_site_id() { $details = get_site( 1 ); - $this->assertEquals( 1, domain_exists( $details->domain, $details->path, $details->site_id ) ); + $this->assertSame( 1, domain_exists( $details->domain, $details->path, $details->site_id ) ); } /** @@ -895,18 +895,18 @@ if ( is_multisite() ) : function test_domain_does_not_exist_with_invalid_site_id() { $details = get_site( 1 ); - $this->assertEquals( null, domain_exists( $details->domain, $details->path, 999 ) ); + $this->assertNull( domain_exists( $details->domain, $details->path, 999 ) ); } function test_invalid_domain_does_not_exist_with_default_site_id() { - $this->assertEquals( null, domain_exists( 'foo', 'bar' ) ); + $this->assertNull( domain_exists( 'foo', 'bar' ) ); } function test_domain_filtered_to_exist() { add_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 ); $exists = domain_exists( 'foo', 'bar' ); remove_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 ); - $this->assertEquals( 1234, $exists ); + $this->assertSame( 1234, $exists ); } /** @@ -920,7 +920,7 @@ if ( is_multisite() ) : remove_filter( 'domain_exists', array( $this, '_domain_exists_cb' ), 10, 4 ); // Make sure the same result is returned with or without a trailing slash. - $this->assertEquals( $exists1, $exists2 ); + $this->assertSame( $exists1, $exists2 ); } /** @@ -928,7 +928,7 @@ if ( is_multisite() ) : */ function test_get_blogaddress_by_id_with_valid_id() { $blogaddress = get_blogaddress_by_id( 1 ); - $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/', $blogaddress ); + $this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/', $blogaddress ); } /** @@ -936,7 +936,7 @@ if ( is_multisite() ) : */ function test_get_blogaddress_by_id_with_invalid_id() { $blogaddress = get_blogaddress_by_id( 42 ); - $this->assertEquals( '', $blogaddress ); + $this->assertSame( '', $blogaddress ); } /** @@ -1180,7 +1180,7 @@ if ( is_multisite() ) : $old_count = did_action( 'clean_site_cache' ); clean_blog_cache( $site ); - $this->assertEquals( $old_count + 1, did_action( 'clean_site_cache' ) ); + $this->assertSame( $old_count + 1, did_action( 'clean_site_cache' ) ); } /** @@ -1194,7 +1194,7 @@ if ( is_multisite() ) : $suspend = wp_suspend_cache_invalidation(); clean_blog_cache( $site ); wp_suspend_cache_invalidation( $suspend ); - $this->assertEquals( $old_count, did_action( 'clean_site_cache' ) ); + $this->assertSame( $old_count, did_action( 'clean_site_cache' ) ); } /** @@ -1204,7 +1204,7 @@ if ( is_multisite() ) : $old_count = did_action( 'clean_site_cache' ); clean_blog_cache( null ); - $this->assertEquals( $old_count, did_action( 'clean_site_cache' ) ); + $this->assertSame( $old_count, did_action( 'clean_site_cache' ) ); } /** @@ -1214,7 +1214,7 @@ if ( is_multisite() ) : $old_count = did_action( 'clean_site_cache' ); clean_blog_cache( 'something' ); - $this->assertEquals( $old_count, did_action( 'clean_site_cache' ) ); + $this->assertSame( $old_count, did_action( 'clean_site_cache' ) ); } /** @@ -1443,7 +1443,7 @@ if ( is_multisite() ) : } elseif ( 'last_updated' === $key ) { $this->assertTrue( $old_site->last_updated <= $value ); } else { - $this->assertEquals( $old_site->$key, $value ); + $this->assertSame( $old_site->$key, $value ); } } } @@ -1540,7 +1540,7 @@ if ( is_multisite() ) : $result = wp_delete_site( $site_id ); $this->assertInstanceOf( 'WP_Site', $result ); - $this->assertEquals( $result->to_array(), $site->to_array() ); + $this->assertSame( $result->to_array(), $site->to_array() ); } /** @@ -2116,8 +2116,8 @@ if ( is_multisite() ) : $this->assertTrue( $result ); $this->assertTrue( $initialized ); - $this->assertEquals( $expected_options, $options ); - $this->assertEquals( $expected_meta, $meta ); + $this->assertSame( $expected_options, $options ); + $this->assertSame( $expected_meta, $meta ); } public function data_wp_initialize_site() { @@ -2214,7 +2214,7 @@ if ( is_multisite() ) : $this->assertTrue( $result ); $this->assertTrue( $user_is_admin ); - $this->assertEquals( get_userdata( 1 )->user_email, $admin_email ); + $this->assertSame( get_userdata( 1 )->user_email, $admin_email ); } /** @@ -2370,8 +2370,8 @@ if ( is_multisite() ) : // Should not hit blog_details cache initialised in $this->populate_options_callback tirggered during // populate_options callback's call of get_blog_details. - $this->assertEquals( 'http://testsite1.example.org/test', get_blog_details( $blog_id )->siteurl ); - $this->assertEquals( 'http://testsite1.example.org/test', get_site( $blog_id )->siteurl ); + $this->assertSame( 'http://testsite1.example.org/test', get_blog_details( $blog_id )->siteurl ); + $this->assertSame( 'http://testsite1.example.org/test', get_site( $blog_id )->siteurl ); remove_action( 'populate_options', array( $this, 'populate_options_callback' ) ); } diff --git a/tests/phpunit/tests/multisite/siteMeta.php b/tests/phpunit/tests/multisite/siteMeta.php index 3eee11eb97..dd46058e2f 100644 --- a/tests/phpunit/tests/multisite/siteMeta.php +++ b/tests/phpunit/tests/multisite/siteMeta.php @@ -186,13 +186,13 @@ if ( is_multisite() ) : add_site_meta( self::$site_id, 'unique_delete_by_key', 'value', true ); add_site_meta( self::$site_id2, 'unique_delete_by_key', 'value', true ); - $this->assertEquals( 'value', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) ); - $this->assertEquals( 'value', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) ); + $this->assertSame( 'value', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) ); + $this->assertSame( 'value', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) ); $this->assertTrue( delete_site_meta_by_key( 'unique_delete_by_key' ) ); - $this->assertEquals( '', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) ); - $this->assertEquals( '', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) ); + $this->assertSame( '', get_site_meta( self::$site_id, 'unique_delete_by_key', true ) ); + $this->assertSame( '', get_site_meta( self::$site_id2, 'unique_delete_by_key', true ) ); } public function test_site_meta_should_be_deleted_when_site_is_deleted() { diff --git a/tests/phpunit/tests/multisite/siteQuery.php b/tests/phpunit/tests/multisite/siteQuery.php index ecabdbc8db..def4f7d824 100644 --- a/tests/phpunit/tests/multisite/siteQuery.php +++ b/tests/phpunit/tests/multisite/siteQuery.php @@ -135,7 +135,7 @@ if ( is_multisite() ) : ) ); - $this->assertEquals( 3, count( $found ) ); + $this->assertSame( 3, count( $found ) ); } public function test_wp_site_query_by_site__in_with_single_id() { @@ -181,7 +181,7 @@ if ( is_multisite() ) : ) ); - $this->assertEquals( 2, $found ); + $this->assertSame( 2, $found ); } public function test_wp_site_query_by_site__not_in_with_single_id() { @@ -237,7 +237,7 @@ if ( is_multisite() ) : self::$site_ids['wordpress.org/foo/bar/'], ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); $found = $q->query( array( @@ -248,7 +248,7 @@ if ( is_multisite() ) : ) ); - $this->assertEquals( array_reverse( $expected ), $found ); + $this->assertSame( array_reverse( $expected ), $found ); } public function test_wp_site_query_by_network_id_with_existing_sites() { @@ -698,7 +698,7 @@ if ( is_multisite() ) : self::$site_ids['make.wordpress.org/foo/'], ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } public function test_wp_site_query_by_search_with_text_in_path_exclude_domain_from_search() { @@ -715,7 +715,7 @@ if ( is_multisite() ) : self::$site_ids['www.w.org/make/'], ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } public function test_wp_site_query_by_search_with_text_in_domain_exclude_path_from_search() { @@ -733,7 +733,7 @@ if ( is_multisite() ) : self::$site_ids['make.wordpress.org/foo/'], ); - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } public function test_wp_site_query_by_search_with_wildcard_in_text() { @@ -814,7 +814,7 @@ if ( is_multisite() ) : ) ); - $this->assertEquals( $number_of_queries, $wpdb->num_queries ); + $this->assertSame( $number_of_queries, $wpdb->num_queries ); } /** @@ -844,7 +844,7 @@ if ( is_multisite() ) : 'count' => true, ) ); - $this->assertEquals( $number_of_queries, $wpdb->num_queries ); + $this->assertSame( $number_of_queries, $wpdb->num_queries ); } /** @@ -874,7 +874,7 @@ if ( is_multisite() ) : 'count' => true, ) ); - $this->assertEquals( $number_of_queries + 1, $wpdb->num_queries ); + $this->assertSame( $number_of_queries + 1, $wpdb->num_queries ); } /** @@ -903,7 +903,7 @@ if ( is_multisite() ) : } if ( $strict ) { - $this->assertEquals( $expected, $found ); + $this->assertSame( $expected, $found ); } else { $this->assertEqualSets( $expected, $found ); } @@ -933,7 +933,7 @@ if ( is_multisite() ) : $this->assertSame( array( 555 ), $results ); // Make sure manually setting total_users doesn't get overwritten. - $this->assertEquals( 1, $q->found_sites ); + $this->assertSame( 1, $q->found_sites ); } public static function filter_sites_pre_query( $sites, $query ) { diff --git a/tests/phpunit/tests/multisite/updateBlogDetails.php b/tests/phpunit/tests/multisite/updateBlogDetails.php index 48c3b7cdd8..c3bd0e3cdf 100644 --- a/tests/phpunit/tests/multisite/updateBlogDetails.php +++ b/tests/phpunit/tests/multisite/updateBlogDetails.php @@ -39,9 +39,9 @@ if ( is_multisite() ) : $blog = get_site( $blog_id ); - $this->assertEquals( 'example.com', $blog->domain ); - $this->assertEquals( '/my_path/', $blog->path ); - $this->assertEquals( '0', $blog->spam ); + $this->assertSame( 'example.com', $blog->domain ); + $this->assertSame( '/my_path/', $blog->path ); + $this->assertSame( '0', $blog->spam ); } /** @@ -71,16 +71,16 @@ if ( is_multisite() ) : update_blog_details( $blog_id, array( $flag => $flag_value ) ); $blog = get_site( $blog_id ); - $this->assertEquals( $flag_value, $blog->{$flag} ); + $this->assertSame( $flag_value, $blog->{$flag} ); // The hook attached to this flag should have fired once during update_blog_details(). - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( 1, $test_action_counter ); // Update the site to the exact same flag value for this flag. update_blog_details( $blog_id, array( $flag => $flag_value ) ); // The hook attached to this flag should not have fired again. - $this->assertEquals( 1, $test_action_counter ); + $this->assertSame( 1, $test_action_counter ); remove_action( $hook, array( $this, '_action_counter_cb' ), 10 ); } @@ -116,7 +116,7 @@ if ( is_multisite() ) : update_blog_details( 1, array( 'path' => $path ) ); $site = get_site( 1 ); - $this->assertEquals( $expected, $site->path ); + $this->assertSame( $expected, $site->path ); } public function data_single_directory_path() { diff --git a/tests/phpunit/tests/multisite/wpGetSites.php b/tests/phpunit/tests/multisite/wpGetSites.php index 3a068e87e5..700b8d21c1 100644 --- a/tests/phpunit/tests/multisite/wpGetSites.php +++ b/tests/phpunit/tests/multisite/wpGetSites.php @@ -72,7 +72,7 @@ if ( is_multisite() ) : $missing_keys = array_diff_key( array_flip( $keys ), $sites[0] ); - $this->assertEquals( array(), $missing_keys, 'Keys are missing from site arrays.' ); + $this->assertSame( array(), $missing_keys, 'Keys are missing from site arrays.' ); } /** diff --git a/tests/phpunit/tests/multisite/wpInstallDefaults.php b/tests/phpunit/tests/multisite/wpInstallDefaults.php index dad6a99b84..05371f2159 100644 --- a/tests/phpunit/tests/multisite/wpInstallDefaults.php +++ b/tests/phpunit/tests/multisite/wpInstallDefaults.php @@ -76,8 +76,8 @@ if ( is_multisite() ) : wp_delete_site( $blog_id ); - $this->assertEquals( 'Some page content', $first_page->post_content ); - $this->assertEquals( 'Some comment content', $first_comment[0]->comment_content ); + $this->assertSame( 'Some page content', $first_page->post_content ); + $this->assertSame( 'Some comment content', $first_comment[0]->comment_content ); } } diff --git a/tests/phpunit/tests/oembed/WpEmbed.php b/tests/phpunit/tests/oembed/WpEmbed.php index 86f3c32d3a..ac5e694d44 100644 --- a/tests/phpunit/tests/oembed/WpEmbed.php +++ b/tests/phpunit/tests/oembed/WpEmbed.php @@ -109,7 +109,7 @@ class Tests_WP_Embed extends WP_UnitTestCase { $content = "\nhttp://example.com/embed/foo\n"; $actual = $this->wp_embed->autoembed( $content ); - $this->assertEquals( $content, $actual ); + $this->assertSame( $content, $actual ); } public function test_autoembed_should_return_modified_content() { @@ -124,7 +124,7 @@ class Tests_WP_Embed extends WP_UnitTestCase { $actual = $GLOBALS['wp_embed']->autoembed( $content ); wp_embed_unregister_handler( $handle ); - $this->assertEquals( "\nEmbedded http://example.com/embed/foo\n", $actual ); + $this->assertSame( "\nEmbedded http://example.com/embed/foo\n", $actual ); } public function test_delete_oembed_caches() { @@ -136,8 +136,8 @@ class Tests_WP_Embed extends WP_UnitTestCase { $this->wp_embed->delete_oembed_caches( $post_id ); - $this->assertEquals( array(), get_post_meta( $post_id, '_oembed_foo' ) ); - $this->assertEquals( array(), get_post_meta( $post_id, '_oembed_baz' ) ); + $this->assertSame( array(), get_post_meta( $post_id, '_oembed_foo' ) ); + $this->assertSame( array(), get_post_meta( $post_id, '_oembed_baz' ) ); } public function test_cache_oembed_invalid_post_type() { @@ -168,7 +168,7 @@ class Tests_WP_Embed extends WP_UnitTestCase { remove_filter( 'pre_oembed_result', array( $this, '_pre_oembed_result_callback' ) ); $this->assertSame( $post_id, $this->wp_embed->post_ID ); - $this->assertEquals( $expected, get_post_meta( $post_id, $cachekey, true ) ); + $this->assertSame( $expected, get_post_meta( $post_id, $cachekey, true ) ); $this->assertNotEmpty( get_post_meta( $post_id, $cachekey_time, true ) ); } @@ -194,9 +194,9 @@ class Tests_WP_Embed extends WP_UnitTestCase { // Cleanup. unset( $post ); - $this->assertEquals( $expected, $actual ); - $this->assertEquals( $expected, $actual_2 ); - $this->assertEquals( $expected, $cached ); + $this->assertSame( $expected, $actual ); + $this->assertSame( $expected, $actual_2 ); + $this->assertSame( $expected, $cached ); } public function test_shortcode_should_get_cached_failure_from_post_meta_for_known_post() { @@ -225,10 +225,10 @@ class Tests_WP_Embed extends WP_UnitTestCase { // Cleanup. unset( $post ); - $this->assertEquals( $expected, $actual ); - $this->assertEquals( '{{unknown}}', $cached ); + $this->assertSame( $expected, $actual ); + $this->assertSame( '{{unknown}}', $cached ); $this->assertEmpty( $cached_time ); - $this->assertEquals( $expected, $actual_2 ); + $this->assertSame( $expected, $actual_2 ); } /** @@ -252,9 +252,9 @@ class Tests_WP_Embed extends WP_UnitTestCase { wp_delete_post( $oembed_post_id ); $this->assertNotNull( $oembed_post_id ); - $this->assertEquals( $expected, $post_content ); - $this->assertEquals( $expected, $actual ); - $this->assertEquals( $expected, $actual_2 ); + $this->assertSame( $expected, $post_content ); + $this->assertSame( $expected, $actual ); + $this->assertSame( $expected, $actual_2 ); } /** @@ -277,10 +277,10 @@ class Tests_WP_Embed extends WP_UnitTestCase { wp_delete_post( $oembed_post_id ); - $this->assertEquals( $expected, $actual ); - $this->assertEquals( $expected, $actual_2 ); + $this->assertSame( $expected, $actual ); + $this->assertSame( $expected, $actual_2 ); $this->assertNotNull( $oembed_post_id ); - $this->assertEquals( '{{unknown}}', $post_content ); + $this->assertSame( '{{unknown}}', $post_content ); } /** @@ -321,7 +321,7 @@ class Tests_WP_Embed extends WP_UnitTestCase { $url = 'http://example.com/embed/foo'; $actual = $this->wp_embed->shortcode( array( 'src' => $url ) ); - $this->assertEquals( '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>', $actual ); + $this->assertSame( '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>', $actual ); } public function test_shortcode_should_return_empty_string_for_missing_url() { @@ -332,20 +332,20 @@ class Tests_WP_Embed extends WP_UnitTestCase { $url = 'http://example.com/embed/foo'; $actual = $this->wp_embed->shortcode( array(), $url ); - $this->assertEquals( '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>', $actual ); + $this->assertSame( '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>', $actual ); } public function test_run_shortcode_url_only() { $url = 'http://example.com/embed/foo'; $actual = $this->wp_embed->run_shortcode( '[embed]' . $url . '[/embed]' ); - $this->assertEquals( '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>', $actual ); + $this->assertSame( '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>', $actual ); } public function test_maybe_make_link() { $url = 'http://example.com/embed/foo'; $actual = $this->wp_embed->maybe_make_link( $url ); - $this->assertEquals( '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>', $actual ); + $this->assertSame( '<a href="' . esc_url( $url ) . '">' . esc_html( $url ) . '</a>', $actual ); } public function test_maybe_make_link_return_false_on_fail() { @@ -357,6 +357,6 @@ class Tests_WP_Embed extends WP_UnitTestCase { $url = 'http://example.com/'; $this->wp_embed->linkifunknown = false; - $this->assertEquals( $url, $this->wp_embed->maybe_make_link( $url ) ); + $this->assertSame( $url, $this->wp_embed->maybe_make_link( $url ) ); } } diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php index 72b3aed0bf..3facaf0c97 100644 --- a/tests/phpunit/tests/oembed/controller.php +++ b/tests/phpunit/tests/oembed/controller.php @@ -175,11 +175,11 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { } function test_wp_oembed_ensure_format() { - $this->assertEquals( 'json', wp_oembed_ensure_format( 'json' ) ); - $this->assertEquals( 'xml', wp_oembed_ensure_format( 'xml' ) ); - $this->assertEquals( 'json', wp_oembed_ensure_format( 123 ) ); - $this->assertEquals( 'json', wp_oembed_ensure_format( 'random' ) ); - $this->assertEquals( 'json', wp_oembed_ensure_format( array() ) ); + $this->assertSame( 'json', wp_oembed_ensure_format( 'json' ) ); + $this->assertSame( 'xml', wp_oembed_ensure_format( 'xml' ) ); + $this->assertSame( 'json', wp_oembed_ensure_format( 123 ) ); + $this->assertSame( 'json', wp_oembed_ensure_format( 'random' ) ); + $this->assertSame( 'json', wp_oembed_ensure_format( array() ) ); } function test_oembed_create_xml() { @@ -265,7 +265,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'rest_no_route', $data['code'] ); + $this->assertSame( 'rest_no_route', $data['code'] ); } function test_request_without_url_param() { @@ -274,8 +274,8 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'rest_missing_callback_param', $data['code'] ); - $this->assertEquals( 'url', $data['data']['params'][0] ); + $this->assertSame( 'rest_missing_callback_param', $data['code'] ); + $this->assertSame( 'url', $data['data']['params'][0] ); } function test_request_with_bad_url() { @@ -285,7 +285,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'oembed_invalid_url', $data['code'] ); + $this->assertSame( 'oembed_invalid_url', $data['code'] ); } function test_request_invalid_format() { @@ -334,13 +334,13 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $this->assertArrayHasKey( 'type', $data ); $this->assertArrayHasKey( 'width', $data ); - $this->assertEquals( '1.0', $data['version'] ); - $this->assertEquals( get_bloginfo( 'name' ), $data['provider_name'] ); - $this->assertEquals( home_url(), $data['provider_url'] ); - $this->assertEquals( $user->display_name, $data['author_name'] ); - $this->assertEquals( get_author_posts_url( $user->ID, $user->user_nicename ), $data['author_url'] ); - $this->assertEquals( $post->post_title, $data['title'] ); - $this->assertEquals( 'rich', $data['type'] ); + $this->assertSame( '1.0', $data['version'] ); + $this->assertSame( get_bloginfo( 'name' ), $data['provider_name'] ); + $this->assertSame( home_url(), $data['provider_url'] ); + $this->assertSame( $user->display_name, $data['author_name'] ); + $this->assertSame( get_author_posts_url( $user->ID, $user->user_nicename ), $data['author_url'] ); + $this->assertSame( $post->post_title, $data['title'] ); + $this->assertSame( 'rich', $data['type'] ); $this->assertTrue( $data['width'] <= $request['maxwidth'] ); } @@ -377,13 +377,13 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $this->assertArrayHasKey( 'type', $data ); $this->assertArrayHasKey( 'width', $data ); - $this->assertEquals( '1.0', $data['version'] ); - $this->assertEquals( get_bloginfo( 'name' ), $data['provider_name'] ); - $this->assertEquals( home_url(), $data['provider_url'] ); - $this->assertEquals( get_bloginfo( 'name' ), $data['author_name'] ); - $this->assertEquals( home_url(), $data['author_url'] ); - $this->assertEquals( $post->post_title, $data['title'] ); - $this->assertEquals( 'rich', $data['type'] ); + $this->assertSame( '1.0', $data['version'] ); + $this->assertSame( get_bloginfo( 'name' ), $data['provider_name'] ); + $this->assertSame( home_url(), $data['provider_url'] ); + $this->assertSame( get_bloginfo( 'name' ), $data['author_name'] ); + $this->assertSame( home_url(), $data['author_url'] ); + $this->assertSame( $post->post_title, $data['title'] ); + $this->assertSame( 'rich', $data['type'] ); $this->assertTrue( $data['width'] <= $request['maxwidth'] ); update_option( 'show_on_front', 'posts' ); @@ -422,13 +422,13 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $this->assertArrayHasKey( 'type', $data ); $this->assertArrayHasKey( 'width', $data ); - $this->assertEquals( '1.0', $data['version'] ); - $this->assertEquals( get_bloginfo( 'name' ), $data['provider_name'] ); - $this->assertEquals( home_url(), $data['provider_url'] ); - $this->assertEquals( $user->display_name, $data['author_name'] ); - $this->assertEquals( get_author_posts_url( $user->ID, $user->user_nicename ), $data['author_url'] ); - $this->assertEquals( $post->post_title, $data['title'] ); - $this->assertEquals( 'rich', $data['type'] ); + $this->assertSame( '1.0', $data['version'] ); + $this->assertSame( get_bloginfo( 'name' ), $data['provider_name'] ); + $this->assertSame( home_url(), $data['provider_url'] ); + $this->assertSame( $user->display_name, $data['author_name'] ); + $this->assertSame( get_author_posts_url( $user->ID, $user->user_nicename ), $data['author_url'] ); + $this->assertSame( $post->post_title, $data['title'] ); + $this->assertSame( 'rich', $data['type'] ); $this->assertTrue( $data['width'] <= $request['maxwidth'] ); } @@ -508,30 +508,30 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { } function test_get_oembed_endpoint_url() { - $this->assertEquals( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url() ); - $this->assertEquals( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'json' ) ); - $this->assertEquals( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) ); + $this->assertSame( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url() ); + $this->assertSame( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'json' ) ); + $this->assertSame( home_url() . '/index.php?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) ); $post_id = $this->factory()->post->create(); $url = get_permalink( $post_id ); $url_encoded = urlencode( $url ); - $this->assertEquals( home_url() . '/index.php?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $url_encoded, get_oembed_endpoint_url( $url ) ); - $this->assertEquals( home_url() . '/index.php?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $url_encoded . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) ); + $this->assertSame( home_url() . '/index.php?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $url_encoded, get_oembed_endpoint_url( $url ) ); + $this->assertSame( home_url() . '/index.php?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $url_encoded . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) ); } function test_get_oembed_endpoint_url_pretty_permalinks() { update_option( 'permalink_structure', '/%postname%' ); - $this->assertEquals( home_url() . '/wp-json/oembed/1.0/embed', get_oembed_endpoint_url() ); - $this->assertEquals( home_url() . '/wp-json/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) ); + $this->assertSame( home_url() . '/wp-json/oembed/1.0/embed', get_oembed_endpoint_url() ); + $this->assertSame( home_url() . '/wp-json/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) ); $post_id = $this->factory()->post->create(); $url = get_permalink( $post_id ); $url_encoded = urlencode( $url ); - $this->assertEquals( home_url() . '/wp-json/oembed/1.0/embed?url=' . $url_encoded, get_oembed_endpoint_url( $url ) ); - $this->assertEquals( home_url() . '/wp-json/oembed/1.0/embed?url=' . $url_encoded . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) ); + $this->assertSame( home_url() . '/wp-json/oembed/1.0/embed?url=' . $url_encoded, get_oembed_endpoint_url( $url ) ); + $this->assertSame( home_url() . '/wp-json/oembed/1.0/embed?url=' . $url_encoded . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) ); update_option( 'permalink_structure', '' ); } @@ -541,7 +541,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); // Test with a user that does not have edit_posts capability. wp_set_current_user( self::$subscriber ); @@ -549,9 +549,9 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $request->set_param( 'url', self::INVALID_OEMBED_URL ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 403, $response->get_status() ); + $this->assertSame( 403, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $data['code'], 'rest_forbidden' ); + $this->assertSame( $data['code'], 'rest_forbidden' ); } public function test_proxy_with_invalid_oembed_provider() { @@ -559,9 +559,9 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' ); $request->set_param( 'url', self::INVALID_OEMBED_URL ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'oembed_invalid_url', $data['code'] ); + $this->assertSame( 'oembed_invalid_url', $data['code'] ); } public function test_proxy_with_invalid_type() { @@ -570,7 +570,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $request->set_param( 'type', 'xml' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); } public function test_proxy_with_valid_oembed_provider() { @@ -581,12 +581,12 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $request->set_param( 'maxheight', 789 ); $request->set_param( '_wpnonce', wp_create_nonce( 'wp_rest' ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 1, $this->request_count ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 1, $this->request_count ); // Subsequent request is cached and so it should not cause a request. rest_get_server()->dispatch( $request ); - $this->assertEquals( 1, $this->request_count ); + $this->assertSame( 1, $this->request_count ); // Rest with another user should also be cached. wp_set_current_user( self::$administrator ); @@ -596,15 +596,15 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $request->set_param( 'maxwidth', 456 ); $request->set_param( 'maxheight', 789 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 1, $this->request_count ); + $this->assertSame( 1, $this->request_count ); // Test data object. $data = $response->get_data(); $this->assertNotEmpty( $data ); $this->assertInternalType( 'object', $data ); - $this->assertEquals( 'YouTube', $data->provider_name ); - $this->assertEquals( 'https://i.ytimg.com/vi/' . self::YOUTUBE_VIDEO_ID . '/hqdefault.jpg', $data->thumbnail_url ); + $this->assertSame( 'YouTube', $data->provider_name ); + $this->assertSame( 'https://i.ytimg.com/vi/' . self::YOUTUBE_VIDEO_ID . '/hqdefault.jpg', $data->thumbnail_url ); $this->assertEquals( $data->width, $request['maxwidth'] ); $this->assertEquals( $data->height, $request['maxheight'] ); } @@ -622,8 +622,8 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $request->set_param( 'maxheight', 789 ); $request->set_param( '_wpnonce', wp_create_nonce( 'wp_rest' ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 2, $this->request_count ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 2, $this->request_count ); // Test data object. $data = $response->get_data(); @@ -642,8 +642,8 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $request->set_param( 'url', self::INVALID_OEMBED_URL ); $request->set_param( 'discover', false ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); - $this->assertEquals( 0, $this->request_count ); + $this->assertSame( 404, $response->get_status() ); + $this->assertSame( 0, $this->request_count ); } public function test_proxy_with_invalid_oembed_provider_with_default_discover_param() { @@ -653,8 +653,8 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $request = new WP_REST_Request( 'GET', '/oembed/1.0/proxy' ); $request->set_param( 'url', self::INVALID_OEMBED_URL ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); - $this->assertEquals( 1, $this->request_count ); + $this->assertSame( 404, $response->get_status() ); + $this->assertSame( 1, $this->request_count ); } public function test_proxy_with_invalid_discover_param() { @@ -665,9 +665,9 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $data['code'], 'rest_invalid_param' ); + $this->assertSame( $data['code'], 'rest_invalid_param' ); } /** @@ -708,13 +708,13 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $this->assertArrayHasKey( 'type', $data ); $this->assertArrayHasKey( 'width', $data ); - $this->assertEquals( '1.0', $data['version'] ); - $this->assertEquals( get_bloginfo( 'name' ), $data['provider_name'] ); - $this->assertEquals( home_url(), $data['provider_url'] ); - $this->assertEquals( $user->display_name, $data['author_name'] ); - $this->assertEquals( get_author_posts_url( $user->ID, $user->user_nicename ), $data['author_url'] ); - $this->assertEquals( $post->post_title, $data['title'] ); - $this->assertEquals( 'rich', $data['type'] ); + $this->assertSame( '1.0', $data['version'] ); + $this->assertSame( get_bloginfo( 'name' ), $data['provider_name'] ); + $this->assertSame( home_url(), $data['provider_url'] ); + $this->assertSame( $user->display_name, $data['author_name'] ); + $this->assertSame( get_author_posts_url( $user->ID, $user->user_nicename ), $data['author_url'] ); + $this->assertSame( $post->post_title, $data['title'] ); + $this->assertSame( 'rich', $data['type'] ); $this->assertTrue( $data['width'] <= $request['maxwidth'] ); } @@ -757,13 +757,13 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $this->assertArrayHasKey( 'type', $data ); $this->assertArrayHasKey( 'width', $data ); - $this->assertEquals( '1.0', $data['version'] ); - $this->assertEquals( get_bloginfo( 'name' ), $data['provider_name'] ); - $this->assertEquals( home_url(), $data['provider_url'] ); - $this->assertEquals( get_bloginfo( 'name' ), $data['author_name'] ); - $this->assertEquals( home_url(), $data['author_url'] ); - $this->assertEquals( $post->post_title, $data['title'] ); - $this->assertEquals( 'rich', $data['type'] ); + $this->assertSame( '1.0', $data['version'] ); + $this->assertSame( get_bloginfo( 'name' ), $data['provider_name'] ); + $this->assertSame( home_url(), $data['provider_url'] ); + $this->assertSame( get_bloginfo( 'name' ), $data['author_name'] ); + $this->assertSame( home_url(), $data['author_url'] ); + $this->assertSame( $post->post_title, $data['title'] ); + $this->assertSame( 'rich', $data['type'] ); $this->assertTrue( $data['width'] <= $request['maxwidth'] ); update_option( 'show_on_front', 'posts' ); @@ -784,11 +784,11 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, $this->oembed_result_filter_count ); + $this->assertSame( 1, $this->oembed_result_filter_count ); $this->assertInternalType( 'object', $data ); - $this->assertEquals( 'Untrusted', $data->provider_name ); - $this->assertEquals( self::UNTRUSTED_PROVIDER_URL, $data->provider_url ); - $this->assertEquals( 'rich', $data->type ); + $this->assertSame( 'Untrusted', $data->provider_name ); + $this->assertSame( self::UNTRUSTED_PROVIDER_URL, $data->provider_url ); + $this->assertSame( 'rich', $data->type ); $this->assertFalse( $data->html ); } @@ -807,7 +807,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, $this->oembed_result_filter_count ); + $this->assertSame( 1, $this->oembed_result_filter_count ); $this->assertInternalType( 'object', $data ); $this->assertStringStartsWith( '<b>Unfiltered</b>', $data->html ); diff --git a/tests/phpunit/tests/oembed/discovery.php b/tests/phpunit/tests/oembed/discovery.php index 19f9ee2f61..db435490a4 100644 --- a/tests/phpunit/tests/oembed/discovery.php +++ b/tests/phpunit/tests/oembed/discovery.php @@ -48,7 +48,7 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase { $expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n"; $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n"; - $this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); + $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); } function test_add_oembed_discovery_links_to_page() { @@ -63,7 +63,7 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase { $expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n"; $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n"; - $this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); + $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); } function test_add_oembed_discovery_links_to_attachment() { @@ -83,6 +83,6 @@ class Tests_oEmbed_Discovery extends WP_UnitTestCase { $expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n"; $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n"; - $this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); + $this->assertSame( $expected, get_echo( 'wp_oembed_add_discovery_links' ) ); } } diff --git a/tests/phpunit/tests/oembed/filterResult.php b/tests/phpunit/tests/oembed/filterResult.php index 1b93b07040..06ed74532a 100644 --- a/tests/phpunit/tests/oembed/filterResult.php +++ b/tests/phpunit/tests/oembed/filterResult.php @@ -9,7 +9,7 @@ class Tests_Filter_oEmbed_Result extends WP_UnitTestCase { $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' ); - $this->assertEquals( $html, $actual ); + $this->assertSame( $html, $actual ); } function test_filter_oembed_result_with_untrusted_provider() { @@ -21,14 +21,14 @@ class Tests_Filter_oEmbed_Result extends WP_UnitTestCase { $this->assertTrue( isset( $matches[1] ) ); $this->assertTrue( isset( $matches[2] ) ); - $this->assertEquals( $matches[1], $matches[2] ); + $this->assertSame( $matches[1], $matches[2] ); } function test_filter_oembed_result_only_one_iframe_is_allowed() { $html = '<div><iframe></iframe><iframe></iframe><p></p></div>'; $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); - $this->assertEquals( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual ); + $this->assertSame( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual ); } function test_filter_oembed_result_with_newlines() { @@ -41,7 +41,7 @@ EOD; $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); - $this->assertEquals( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual ); + $this->assertSame( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual ); } function test_filter_oembed_result_without_iframe() { @@ -65,13 +65,13 @@ EOD; $this->assertTrue( isset( $matches[1] ) ); $this->assertTrue( isset( $matches[2] ) ); - $this->assertEquals( $matches[1], $matches[2] ); + $this->assertSame( $matches[1], $matches[2] ); } function test_filter_oembed_result_wrong_type_provided() { $actual = wp_filter_oembed_result( 'some string', (object) array( 'type' => 'link' ), '' ); - $this->assertEquals( 'some string', $actual ); + $this->assertSame( 'some string', $actual ); } function test_filter_oembed_result_invalid_result() { @@ -83,14 +83,14 @@ EOD; $html = '<blockquote></blockquote><iframe></iframe>'; $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); - $this->assertEquals( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"></iframe>', $actual ); + $this->assertSame( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"></iframe>', $actual ); } function test_filter_oembed_result_allowed_html() { $html = '<blockquote class="foo" id="bar"><strong><a href="" target=""></a></strong></blockquote><iframe></iframe>'; $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); - $this->assertEquals( '<blockquote class="wp-embedded-content"><a href=""></a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"></iframe>', $actual ); + $this->assertSame( '<blockquote class="wp-embedded-content"><a href=""></a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; clip: rect(1px, 1px, 1px, 1px);"></iframe>', $actual ); } public function _data_oembed_test_strings() { @@ -124,7 +124,7 @@ EOD; 'html' => $html, ); $actual = _wp_oembed_get_object()->data2html( $data, 'https://untrusted.localhost' ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** @@ -134,6 +134,6 @@ EOD; $html = '<blockquote></blockquote><iframe></iframe>'; $actual = _oembed_filter_feed_content( wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ) ); - $this->assertEquals( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual ); + $this->assertSame( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual ); } } diff --git a/tests/phpunit/tests/oembed/getResponseData.php b/tests/phpunit/tests/oembed/getResponseData.php index 1941db1201..661d8ca896 100644 --- a/tests/phpunit/tests/oembed/getResponseData.php +++ b/tests/phpunit/tests/oembed/getResponseData.php @@ -133,8 +133,8 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { $data = get_oembed_response_data( $post, 1000 ); - $this->assertEquals( 600, $data['width'] ); - $this->assertEquals( 338, $data['height'] ); + $this->assertSame( 600, $data['width'] ); + $this->assertSame( 338, $data['height'] ); } function test_get_oembed_response_data_maxwidth_too_low() { @@ -142,8 +142,8 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { $data = get_oembed_response_data( $post, 100 ); - $this->assertEquals( 200, $data['width'] ); - $this->assertEquals( 200, $data['height'] ); + $this->assertSame( 200, $data['width'] ); + $this->assertSame( 200, $data['height'] ); } function test_get_oembed_response_data_maxwidth_invalid() { @@ -151,13 +151,13 @@ class Tests_oEmbed_Response_Data extends WP_UnitTestCase { $data = get_oembed_response_data( $post, '400;" DROP TABLES' ); - $this->assertEquals( 400, $data['width'] ); - $this->assertEquals( 225, $data['height'] ); + $this->assertSame( 400, $data['width'] ); + $this->assertSame( 225, $data['height'] ); $data = get_oembed_response_data( $post, "lol this isn't even a number?!?!?" ); - $this->assertEquals( 200, $data['width'] ); - $this->assertEquals( 200, $data['height'] ); + $this->assertSame( 200, $data['width'] ); + $this->assertSame( 200, $data['height'] ); } function test_get_oembed_response_data_with_thumbnail() { diff --git a/tests/phpunit/tests/oembed/postEmbedUrl.php b/tests/phpunit/tests/oembed/postEmbedUrl.php index 5432e5182b..c5613b98f1 100644 --- a/tests/phpunit/tests/oembed/postEmbedUrl.php +++ b/tests/phpunit/tests/oembed/postEmbedUrl.php @@ -16,7 +16,7 @@ class Tests_Post_Embed_URL extends WP_UnitTestCase { $permalink = get_permalink( $post_id ); $embed_url = get_post_embed_url( $post_id ); - $this->assertEquals( $permalink . '/embed', $embed_url ); + $this->assertSame( $permalink . '/embed', $embed_url ); } function test_with_ugly_permalinks() { @@ -24,7 +24,7 @@ class Tests_Post_Embed_URL extends WP_UnitTestCase { $permalink = get_permalink( $post_id ); $embed_url = get_post_embed_url( $post_id ); - $this->assertEquals( $permalink . '&embed=true', $embed_url ); + $this->assertSame( $permalink . '&embed=true', $embed_url ); } /** diff --git a/tests/phpunit/tests/oembed/template.php b/tests/phpunit/tests/oembed/template.php index 2384fbabe6..0eefb8f4c0 100644 --- a/tests/phpunit/tests/oembed/template.php +++ b/tests/phpunit/tests/oembed/template.php @@ -211,7 +211,7 @@ class Tests_Embed_Template extends WP_UnitTestCase { function test_wp_embed_excerpt_more_no_embed() { $GLOBALS['wp_query'] = new WP_Query(); - $this->assertEquals( 'foo bar', wp_embed_excerpt_more( 'foo bar' ) ); + $this->assertSame( 'foo bar', wp_embed_excerpt_more( 'foo bar' ) ); } function test_wp_embed_excerpt_more() { @@ -222,7 +222,7 @@ class Tests_Embed_Template extends WP_UnitTestCase { ) ); - $this->assertEquals( '', wp_embed_excerpt_more( '' ) ); + $this->assertSame( '', wp_embed_excerpt_more( '' ) ); $this->go_to( get_post_embed_url( $post_id ) ); @@ -233,7 +233,7 @@ class Tests_Embed_Template extends WP_UnitTestCase { get_the_permalink() ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } function test_is_embed_post() { diff --git a/tests/phpunit/tests/oembed/wpOembed.php b/tests/phpunit/tests/oembed/wpOembed.php index 2c029da6b2..1f15abbad8 100644 --- a/tests/phpunit/tests/oembed/wpOembed.php +++ b/tests/phpunit/tests/oembed/wpOembed.php @@ -37,7 +37,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase { remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) ); $this->assertNotFalse( $this->pre_oembed_result_filtered ); - $this->assertEquals( $this->pre_oembed_result_filtered, $actual ); + $this->assertSame( $this->pre_oembed_result_filtered, $actual ); } public function test_wp_filter_pre_oembed_result_prevents_http_request_when_viewing_the_post() { @@ -52,7 +52,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase { remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) ); $this->assertNotFalse( $this->pre_oembed_result_filtered ); - $this->assertEquals( $this->pre_oembed_result_filtered, $actual ); + $this->assertSame( $this->pre_oembed_result_filtered, $actual ); } public function test_wp_filter_pre_oembed_result_non_existent_post() { @@ -84,7 +84,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase { remove_filter( 'pre_oembed_result', array( $this, '_filter_pre_oembed_result' ) ); $this->assertNotNull( $this->pre_oembed_result_filtered ); - $this->assertEquals( $this->pre_oembed_result_filtered, $actual ); + $this->assertSame( $this->pre_oembed_result_filtered, $actual ); } /** @@ -113,7 +113,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase { restore_current_blog(); $this->assertNotNull( $this->pre_oembed_result_filtered ); - $this->assertEquals( $this->pre_oembed_result_filtered, $actual ); + $this->assertSame( $this->pre_oembed_result_filtered, $actual ); } /** @@ -150,7 +150,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase { restore_current_blog(); $this->assertNotNull( $this->pre_oembed_result_filtered ); - $this->assertEquals( $this->pre_oembed_result_filtered, $actual ); + $this->assertSame( $this->pre_oembed_result_filtered, $actual ); } /** @@ -177,7 +177,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase { restore_current_blog(); $this->assertNotNull( $this->pre_oembed_result_filtered ); - $this->assertEquals( $this->pre_oembed_result_filtered, $actual ); + $this->assertSame( $this->pre_oembed_result_filtered, $actual ); } /** @@ -205,7 +205,7 @@ class Tests_WP_oEmbed extends WP_UnitTestCase { restore_current_blog(); $this->assertNotNull( $this->pre_oembed_result_filtered ); - $this->assertEquals( $this->pre_oembed_result_filtered, $actual ); + $this->assertSame( $this->pre_oembed_result_filtered, $actual ); $this->assertSame( $expected_stack, $actual_stack ); } diff --git a/tests/phpunit/tests/option/multisite.php b/tests/phpunit/tests/option/multisite.php index 3ab4dd9184..49c7197431 100644 --- a/tests/phpunit/tests/option/multisite.php +++ b/tests/phpunit/tests/option/multisite.php @@ -35,27 +35,27 @@ if ( is_multisite() ) : $this->assertTrue( add_blog_option( 1, $key, $value ) ); // Assert all values of $blog_id that means the current or main blog (the same here). - $this->assertEquals( $value, get_blog_option( 1, $key ) ); - $this->assertEquals( $value, get_blog_option( null, $key ) ); - $this->assertEquals( $value, get_blog_option( '1', $key ) ); - $this->assertEquals( $value, get_option( $key ) ); // Check get_option(). + $this->assertSame( $value, get_blog_option( 1, $key ) ); + $this->assertSame( $value, get_blog_option( null, $key ) ); + $this->assertSame( $value, get_blog_option( '1', $key ) ); + $this->assertSame( $value, get_option( $key ) ); // Check get_option(). $this->assertFalse( add_blog_option( 1, $key, $value ) ); // Already exists. $this->assertFalse( update_blog_option( 1, $key, $value ) ); // Value is the same. $this->assertTrue( update_blog_option( 1, $key, $value2 ) ); - $this->assertEquals( $value2, get_blog_option( 1, $key ) ); - $this->assertEquals( $value2, get_option( $key ) ); // Check get_option(). + $this->assertSame( $value2, get_blog_option( 1, $key ) ); + $this->assertSame( $value2, get_option( $key ) ); // Check get_option(). $this->assertFalse( add_blog_option( 1, $key, $value ) ); - $this->assertEquals( $value2, get_blog_option( 1, $key ) ); - $this->assertEquals( $value2, get_option( $key ) ); // Check get_option(). + $this->assertSame( $value2, get_blog_option( 1, $key ) ); + $this->assertSame( $value2, get_option( $key ) ); // Check get_option(). $this->assertTrue( delete_blog_option( 1, $key ) ); $this->assertFalse( get_blog_option( 1, $key ) ); $this->assertFalse( get_option( $key ) ); // Check get_option(). $this->assertFalse( delete_blog_option( 1, $key ) ); $this->assertTrue( update_blog_option( 1, $key2, $value2 ) ); - $this->assertEquals( $value2, get_blog_option( 1, $key2 ) ); - $this->assertEquals( $value2, get_option( $key2 ) ); // Check get_option(). + $this->assertSame( $value2, get_blog_option( 1, $key2 ) ); + $this->assertSame( $value2, get_option( $key2 ) ); // Check get_option(). $this->assertTrue( delete_blog_option( 1, $key2 ) ); $this->assertFalse( get_blog_option( 1, $key2 ) ); $this->assertFalse( get_option( $key2 ) ); // Check get_option(). @@ -72,26 +72,26 @@ if ( is_multisite() ) : $this->assertTrue( add_blog_option( null, $key, $value ) ); // Assert all values of $blog_id that means the current or main blog (the same here). - $this->assertEquals( $value, get_blog_option( null, $key ) ); - $this->assertEquals( $value, get_blog_option( null, $key ) ); - $this->assertEquals( $value, get_option( $key ) ); // Check get_option(). + $this->assertSame( $value, get_blog_option( null, $key ) ); + $this->assertSame( $value, get_blog_option( null, $key ) ); + $this->assertSame( $value, get_option( $key ) ); // Check get_option(). $this->assertFalse( add_blog_option( null, $key, $value ) ); // Already exists. $this->assertFalse( update_blog_option( null, $key, $value ) ); // Value is the same. $this->assertTrue( update_blog_option( null, $key, $value2 ) ); - $this->assertEquals( $value2, get_blog_option( null, $key ) ); - $this->assertEquals( $value2, get_option( $key ) ); // Check get_option(). + $this->assertSame( $value2, get_blog_option( null, $key ) ); + $this->assertSame( $value2, get_option( $key ) ); // Check get_option(). $this->assertFalse( add_blog_option( null, $key, $value ) ); - $this->assertEquals( $value2, get_blog_option( null, $key ) ); - $this->assertEquals( $value2, get_option( $key ) ); // Check get_option(). + $this->assertSame( $value2, get_blog_option( null, $key ) ); + $this->assertSame( $value2, get_option( $key ) ); // Check get_option(). $this->assertTrue( delete_blog_option( null, $key ) ); $this->assertFalse( get_blog_option( null, $key ) ); $this->assertFalse( get_option( $key ) ); // Check get_option(). $this->assertFalse( delete_blog_option( null, $key ) ); $this->assertTrue( update_blog_option( null, $key2, $value2 ) ); - $this->assertEquals( $value2, get_blog_option( null, $key2 ) ); - $this->assertEquals( $value2, get_option( $key2 ) ); // Check get_option(). + $this->assertSame( $value2, get_blog_option( null, $key2 ) ); + $this->assertSame( $value2, get_option( $key2 ) ); // Check get_option(). $this->assertTrue( delete_blog_option( null, $key2 ) ); $this->assertFalse( get_blog_option( null, $key2 ) ); $this->assertFalse( get_option( $key2 ) ); // Check get_option(). @@ -119,26 +119,26 @@ if ( is_multisite() ) : $this->assertTrue( add_blog_option( $blog_id, $key, $value ) ); // Assert all values of $blog_id that means the current or main blog (the same here). - $this->assertEquals( $value, get_blog_option( $blog_id, $key ) ); - $this->assertEquals( $value, get_blog_option( "$blog_id", $key ) ); - // $this->assertEquals( $value, get_option( $key ) ); // Check get_option(). + $this->assertSame( $value, get_blog_option( $blog_id, $key ) ); + $this->assertSame( $value, get_blog_option( "$blog_id", $key ) ); + // $this->assertSame( $value, get_option( $key ) ); // Check get_option(). $this->assertFalse( add_blog_option( $blog_id, $key, $value ) ); // Already exists. $this->assertFalse( update_blog_option( $blog_id, $key, $value ) ); // Value is the same. $this->assertTrue( update_blog_option( $blog_id, $key, $value2 ) ); - $this->assertEquals( $value2, get_blog_option( $blog_id, $key ) ); - // $this->assertEquals( $value2, get_option( $key ) ); // Check get_option(). + $this->assertSame( $value2, get_blog_option( $blog_id, $key ) ); + // $this->assertSame( $value2, get_option( $key ) ); // Check get_option(). $this->assertFalse( add_blog_option( $blog_id, $key, $value ) ); - $this->assertEquals( $value2, get_blog_option( $blog_id, $key ) ); - // $this->assertEquals( $value2, get_option( $key ) ); // Check get_option(). + $this->assertSame( $value2, get_blog_option( $blog_id, $key ) ); + // $this->assertSame( $value2, get_option( $key ) ); // Check get_option(). $this->assertTrue( delete_blog_option( $blog_id, $key ) ); $this->assertFalse( get_blog_option( $blog_id, $key ) ); // $this->assertFalse( get_option( $key ) ); // Check get_option(). $this->assertFalse( delete_blog_option( $blog_id, $key ) ); $this->assertTrue( update_blog_option( $blog_id, $key2, $value2 ) ); - $this->assertEquals( $value2, get_blog_option( $blog_id, $key2 ) ); - // $this->assertEquals( $value2, get_option( $key2 ) ); // Check get_option(). + $this->assertSame( $value2, get_blog_option( $blog_id, $key2 ) ); + // $this->assertSame( $value2, get_option( $key2 ) ); // Check get_option(). $this->assertTrue( delete_blog_option( $blog_id, $key2 ) ); $this->assertFalse( get_blog_option( $blog_id, $key2 ) ); // $this->assertFalse( get_option( $key2 ) ); // Check get_option(). @@ -184,7 +184,7 @@ if ( is_multisite() ) : */ function test_sanitize_network_option_illegal_names( $option_value, $sanitized_option_value ) { update_site_option( 'illegal_names', $option_value ); - $this->assertEquals( $sanitized_option_value, get_site_option( 'illegal_names' ) ); + $this->assertSame( $sanitized_option_value, get_site_option( 'illegal_names' ) ); } function data_illegal_names() { @@ -203,7 +203,7 @@ if ( is_multisite() ) : */ function test_sanitize_network_option_limited_email_domains( $option_value, $sanitized_option_value ) { update_site_option( 'limited_email_domains', $option_value ); - $this->assertEquals( $sanitized_option_value, get_site_option( 'limited_email_domains' ) ); + $this->assertSame( $sanitized_option_value, get_site_option( 'limited_email_domains' ) ); } /** @@ -214,7 +214,7 @@ if ( is_multisite() ) : */ function test_sanitize_network_option_banned_email_domains( $option_value, $sanitized_option_value ) { update_site_option( 'banned_email_domains', $option_value ); - $this->assertEquals( $sanitized_option_value, get_site_option( 'banned_email_domains' ) ); + $this->assertSame( $sanitized_option_value, get_site_option( 'banned_email_domains' ) ); } function data_email_domains() { diff --git a/tests/phpunit/tests/option/networkOption.php b/tests/phpunit/tests/option/networkOption.php index 244ea43898..a6cd1b6690 100644 --- a/tests/phpunit/tests/option/networkOption.php +++ b/tests/phpunit/tests/option/networkOption.php @@ -33,7 +33,7 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { $value = __FUNCTION__; add_network_option( $id, $option, $value ); - $this->assertEquals( $value, get_network_option( $id, $option, false ) ); + $this->assertSame( $value, get_network_option( $id, $option, false ) ); } /** @@ -47,7 +47,7 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { add_site_option( $option, $value ); add_network_option( $id, $option, $value ); delete_site_option( $option ); - $this->assertEquals( $value, get_network_option( $id, $option, false ) ); + $this->assertSame( $value, get_network_option( $id, $option, false ) ); } /** @@ -88,7 +88,7 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { $option = rand_str(); $value = rand_str(); - $this->assertEquals( $expected_response, add_network_option( $network_id, $option, $value ) ); + $this->assertSame( $expected_response, add_network_option( $network_id, $option, $value ) ); } /** @@ -100,7 +100,7 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { function test_get_network_option_network_id_parameter( $network_id, $expected_response ) { $option = rand_str(); - $this->assertEquals( $expected_response, get_network_option( $network_id, $option, true ) ); + $this->assertSame( $expected_response, get_network_option( $network_id, $option, true ) ); } function data_network_id_parameter() { @@ -203,6 +203,6 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase { $this->assertFalse( update_network_option( null, 'array_w_object', $array_w_object_2 ) ); // Check that no new database queries were performed. - $this->assertEquals( $num_queries_pre_update, get_num_queries() ); + $this->assertSame( $num_queries_pre_update, get_num_queries() ); } } diff --git a/tests/phpunit/tests/option/option.php b/tests/phpunit/tests/option/option.php index 0d2f36595d..f461a7db98 100644 --- a/tests/phpunit/tests/option/option.php +++ b/tests/phpunit/tests/option/option.php @@ -17,19 +17,19 @@ class Tests_Option_Option extends WP_UnitTestCase { $this->assertFalse( get_option( 'doesnotexist' ) ); $this->assertTrue( add_option( $key, $value ) ); - $this->assertEquals( $value, get_option( $key ) ); + $this->assertSame( $value, get_option( $key ) ); $this->assertFalse( add_option( $key, $value ) ); // Already exists. $this->assertFalse( update_option( $key, $value ) ); // Value is the same. $this->assertTrue( update_option( $key, $value2 ) ); - $this->assertEquals( $value2, get_option( $key ) ); + $this->assertSame( $value2, get_option( $key ) ); $this->assertFalse( add_option( $key, $value ) ); - $this->assertEquals( $value2, get_option( $key ) ); + $this->assertSame( $value2, get_option( $key ) ); $this->assertTrue( delete_option( $key ) ); $this->assertFalse( get_option( $key ) ); $this->assertFalse( delete_option( $key ) ); $this->assertTrue( update_option( $key2, $value2 ) ); - $this->assertEquals( $value2, get_option( $key2 ) ); + $this->assertSame( $value2, get_option( $key2 ) ); $this->assertTrue( delete_option( $key2 ) ); $this->assertFalse( get_option( $key2 ) ); } @@ -41,17 +41,17 @@ class Tests_Option_Option extends WP_UnitTestCase { // Default filter overrides $default arg. add_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); - $this->assertEquals( 'foo', get_option( 'doesnotexist', 'bar' ) ); + $this->assertSame( 'foo', get_option( 'doesnotexist', 'bar' ) ); // Remove the filter and the $default arg is honored. remove_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); - $this->assertEquals( 'bar', get_option( 'doesnotexist', 'bar' ) ); + $this->assertSame( 'bar', get_option( 'doesnotexist', 'bar' ) ); // Once the option exists, the $default arg and the default filter are ignored. add_option( 'doesnotexist', $value ); - $this->assertEquals( $value, get_option( 'doesnotexist', 'foo' ) ); + $this->assertSame( $value, get_option( 'doesnotexist', 'foo' ) ); add_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); - $this->assertEquals( $value, get_option( 'doesnotexist', 'foo' ) ); + $this->assertSame( $value, get_option( 'doesnotexist', 'foo' ) ); remove_filter( 'default_option_doesnotexist', array( $this, '__return_foo' ) ); // Cleanup. @@ -79,7 +79,7 @@ class Tests_Option_Option extends WP_UnitTestCase { ); $this->assertTrue( add_option( $key, $value ) ); - $this->assertEquals( $value, get_option( $key ) ); + $this->assertSame( $value, get_option( $key ) ); $value = (object) $value; $this->assertTrue( update_option( $key, $value ) ); @@ -138,6 +138,6 @@ class Tests_Option_Option extends WP_UnitTestCase { $this->assertTrue( $added ); $actual = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s LIMIT 1", $name ) ); - $this->assertEquals( $expected, $actual->autoload ); + $this->assertSame( $expected, $actual->autoload ); } } diff --git a/tests/phpunit/tests/option/registration.php b/tests/phpunit/tests/option/registration.php index 8e6dd64b41..d60acb9ef1 100644 --- a/tests/phpunit/tests/option/registration.php +++ b/tests/phpunit/tests/option/registration.php @@ -11,19 +11,19 @@ class Tests_Option_Registration extends WP_UnitTestCase { $this->assertArrayHasKey( 'test_option', $registered ); $args = $registered['test_option']; - $this->assertEquals( 'test_group', $args['group'] ); + $this->assertSame( 'test_group', $args['group'] ); // Check defaults. - $this->assertEquals( 'string', $args['type'] ); - $this->assertEquals( false, $args['show_in_rest'] ); - $this->assertEquals( '', $args['description'] ); + $this->assertSame( 'string', $args['type'] ); + $this->assertFalse( $args['show_in_rest'] ); + $this->assertSame( '', $args['description'] ); } public function test_register_with_callback() { register_setting( 'test_group', 'test_option', array( $this, 'filter_registered_setting' ) ); $filtered = apply_filters( 'sanitize_option_test_option', 'smart', 'test_option', 'smart' ); - $this->assertEquals( 'S-M-R-T', $filtered ); + $this->assertSame( 'S-M-R-T', $filtered ); } public function test_register_with_array() { @@ -36,7 +36,7 @@ class Tests_Option_Registration extends WP_UnitTestCase { ); $filtered = apply_filters( 'sanitize_option_test_option', 'smart', 'test_option', 'smart' ); - $this->assertEquals( 'S-M-R-T', $filtered ); + $this->assertSame( 'S-M-R-T', $filtered ); } public function filter_registered_setting() { @@ -55,7 +55,7 @@ class Tests_Option_Registration extends WP_UnitTestCase { ) ); - $this->assertEquals( 'Got that Viper with them rally stripes', get_option( 'test_default' ) ); + $this->assertSame( 'Got that Viper with them rally stripes', get_option( 'test_default' ) ); } /** @@ -72,7 +72,7 @@ class Tests_Option_Registration extends WP_UnitTestCase { // This set of tests/references (and a previous version) are in support of Viper007Bond. // His Viper doesn't have rally stripes, but for the sake of the Big Tymers, we'll go with it. - $this->assertEquals( 'We the #1 Stunnas', get_option( 'test_default', 'We the #1 Stunnas' ) ); + $this->assertSame( 'We the #1 Stunnas', get_option( 'test_default', 'We the #1 Stunnas' ) ); } /** @@ -88,7 +88,7 @@ class Tests_Option_Registration extends WP_UnitTestCase { ); wp_cache_delete( 'notoptions', 'options' ); $this->assertTrue( add_option( 'test_default', 'hello' ) ); - $this->assertEquals( 'hello', get_option( 'test_default' ) ); + $this->assertSame( 'hello', get_option( 'test_default' ) ); } /** diff --git a/tests/phpunit/tests/option/sanitize-option.php b/tests/phpunit/tests/option/sanitize-option.php index 0a6ec865bb..3a1c22215d 100644 --- a/tests/phpunit/tests/option/sanitize-option.php +++ b/tests/phpunit/tests/option/sanitize-option.php @@ -138,7 +138,7 @@ class Tests_Sanitize_Option extends WP_UnitTestCase { $this->assertEmpty( $errors ); } else { $this->assertNotEmpty( $errors ); - $this->assertEquals( 'invalid_permalink_structure', $errors[0]['code'] ); + $this->assertSame( 'invalid_permalink_structure', $errors[0]['code'] ); } $this->assertEquals( $expected, $actual ); diff --git a/tests/phpunit/tests/option/siteOption.php b/tests/phpunit/tests/option/siteOption.php index 67065019b8..12d25f622b 100644 --- a/tests/phpunit/tests/option/siteOption.php +++ b/tests/phpunit/tests/option/siteOption.php @@ -24,7 +24,7 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $key = __FUNCTION__; $value = __FUNCTION__; add_site_option( $key, $value ); - $this->assertEquals( $value, get_site_option( $key ) ); + $this->assertSame( $value, get_site_option( $key ) ); } function test_get_site_option_returns_updated_value() { @@ -33,32 +33,32 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $new_value = __FUNCTION__ . '_2'; add_site_option( $key, $value ); update_site_option( $key, $new_value ); - $this->assertEquals( $new_value, get_site_option( $key ) ); + $this->assertSame( $new_value, get_site_option( $key ) ); } function test_get_site_option_does_not_exist_returns_filtered_default_with_no_default_provided() { add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); $site_option = get_site_option( 'doesnotexist' ); remove_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); - $this->assertEquals( 'foo', $site_option ); + $this->assertSame( 'foo', $site_option ); } function test_get_site_option_does_not_exist_returns_filtered_default_with_default_provided() { add_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); $site_option = get_site_option( 'doesnotexist', 'bar' ); remove_filter( 'default_site_option_doesnotexist', array( $this, '__return_foo' ) ); - $this->assertEquals( 'foo', $site_option ); + $this->assertSame( 'foo', $site_option ); } function test_get_site_option_does_not_exist_returns_provided_default() { - $this->assertEquals( 'bar', get_site_option( 'doesnotexist', 'bar' ) ); + $this->assertSame( 'bar', get_site_option( 'doesnotexist', 'bar' ) ); } function test_get_site_option_exists_does_not_return_provided_default() { $key = __FUNCTION__; $value = __FUNCTION__; add_site_option( $key, $value ); - $this->assertEquals( $value, get_site_option( $key, 'foo' ) ); + $this->assertSame( $value, get_site_option( $key, 'foo' ) ); } function test_get_site_option_exists_does_not_return_filtered_default() { @@ -68,7 +68,7 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { add_filter( 'default_site_option_' . $key, array( $this, '__return_foo' ) ); $site_option = get_site_option( $key ); remove_filter( 'default_site_option_' . $key, array( $this, '__return_foo' ) ); - $this->assertEquals( $value, $site_option ); + $this->assertSame( $value, $site_option ); } function test_add_site_option_returns_true_for_new_option() { @@ -121,7 +121,7 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { 'bar' => true, ); add_site_option( $key, $value ); - $this->assertEquals( $value, get_site_option( $key ) ); + $this->assertSame( $value, get_site_option( $key ) ); } function test_site_option_add_and_get_serialized_object() { @@ -157,7 +157,7 @@ class Tests_Option_SiteOption extends WP_UnitTestCase { $option = __FUNCTION__; $default = 'a default'; - $this->assertEquals( get_site_option( $option, $default ), $default ); + $this->assertSame( get_site_option( $option, $default ), $default ); $this->assertFalse( get_site_option( $option ) ); } } diff --git a/tests/phpunit/tests/option/siteTransient.php b/tests/phpunit/tests/option/siteTransient.php index f9680e6ca3..7050b2cd90 100644 --- a/tests/phpunit/tests/option/siteTransient.php +++ b/tests/phpunit/tests/option/siteTransient.php @@ -20,10 +20,10 @@ class Tests_Option_SiteTransient extends WP_UnitTestCase { $this->assertFalse( get_site_transient( 'doesnotexist' ) ); $this->assertTrue( set_site_transient( $key, $value ) ); - $this->assertEquals( $value, get_site_transient( $key ) ); + $this->assertSame( $value, get_site_transient( $key ) ); $this->assertFalse( set_site_transient( $key, $value ) ); $this->assertTrue( set_site_transient( $key, $value2 ) ); - $this->assertEquals( $value2, get_site_transient( $key ) ); + $this->assertSame( $value2, get_site_transient( $key ) ); $this->assertTrue( delete_site_transient( $key ) ); $this->assertFalse( get_site_transient( $key ) ); $this->assertFalse( delete_site_transient( $key ) ); @@ -37,7 +37,7 @@ class Tests_Option_SiteTransient extends WP_UnitTestCase { ); $this->assertTrue( set_site_transient( $key, $value ) ); - $this->assertEquals( $value, get_site_transient( $key ) ); + $this->assertSame( $value, get_site_transient( $key ) ); $value = (object) $value; $this->assertTrue( set_site_transient( $key, $value ) ); diff --git a/tests/phpunit/tests/option/slashes.php b/tests/phpunit/tests/option/slashes.php index 5a7c9f6a5f..20220e5d58 100644 --- a/tests/phpunit/tests/option/slashes.php +++ b/tests/phpunit/tests/option/slashes.php @@ -28,10 +28,10 @@ class Tests_Option_Slashes extends WP_UnitTestCase { add_option( 'slash_test_3', $this->slash_3 ); add_option( 'slash_test_4', $this->slash_4 ); - $this->assertEquals( $this->slash_1, get_option( 'slash_test_1' ) ); - $this->assertEquals( $this->slash_2, get_option( 'slash_test_2' ) ); - $this->assertEquals( $this->slash_3, get_option( 'slash_test_3' ) ); - $this->assertEquals( $this->slash_4, get_option( 'slash_test_4' ) ); + $this->assertSame( $this->slash_1, get_option( 'slash_test_1' ) ); + $this->assertSame( $this->slash_2, get_option( 'slash_test_2' ) ); + $this->assertSame( $this->slash_3, get_option( 'slash_test_3' ) ); + $this->assertSame( $this->slash_4, get_option( 'slash_test_4' ) ); } /** @@ -41,15 +41,15 @@ class Tests_Option_Slashes extends WP_UnitTestCase { add_option( 'slash_test_5', 'foo' ); update_option( 'slash_test_5', $this->slash_1 ); - $this->assertEquals( $this->slash_1, get_option( 'slash_test_5' ) ); + $this->assertSame( $this->slash_1, get_option( 'slash_test_5' ) ); update_option( 'slash_test_5', $this->slash_2 ); - $this->assertEquals( $this->slash_2, get_option( 'slash_test_5' ) ); + $this->assertSame( $this->slash_2, get_option( 'slash_test_5' ) ); update_option( 'slash_test_5', $this->slash_3 ); - $this->assertEquals( $this->slash_3, get_option( 'slash_test_5' ) ); + $this->assertSame( $this->slash_3, get_option( 'slash_test_5' ) ); update_option( 'slash_test_5', $this->slash_4 ); - $this->assertEquals( $this->slash_4, get_option( 'slash_test_5' ) ); + $this->assertSame( $this->slash_4, get_option( 'slash_test_5' ) ); } } diff --git a/tests/phpunit/tests/option/themeMods.php b/tests/phpunit/tests/option/themeMods.php index 5c39de6b9e..53683f72a0 100644 --- a/tests/phpunit/tests/option/themeMods.php +++ b/tests/phpunit/tests/option/themeMods.php @@ -6,30 +6,30 @@ class Tests_Option_Theme_Mods extends WP_UnitTestCase { function test_theme_mod_default() { - $this->assertEquals( '', get_theme_mod( 'non_existent' ) ); + $this->assertFalse( get_theme_mod( 'non_existent' ) ); } function test_theme_mod_defined_default() { - $this->assertEquals( 'default', get_theme_mod( 'non_existent', 'default' ) ); + $this->assertSame( 'default', get_theme_mod( 'non_existent', 'default' ) ); } function test_theme_mod_set() { $expected = 'value'; set_theme_mod( 'test_name', $expected ); - $this->assertEquals( $expected, get_theme_mod( 'test_name' ) ); + $this->assertSame( $expected, get_theme_mod( 'test_name' ) ); } function test_theme_mod_update() { set_theme_mod( 'test_update', 'first_value' ); $expected = 'updated_value'; set_theme_mod( 'test_update', $expected ); - $this->assertEquals( $expected, get_theme_mod( 'test_update' ) ); + $this->assertSame( $expected, get_theme_mod( 'test_update' ) ); } function test_theme_mod_remove() { set_theme_mod( 'test_remove', 'value' ); remove_theme_mod( 'test_remove' ); - $this->assertEquals( '', get_theme_mod( 'test_remove' ) ); + $this->assertFalse( get_theme_mod( 'test_remove' ) ); } /** @@ -38,7 +38,7 @@ class Tests_Option_Theme_Mods extends WP_UnitTestCase { * @dataProvider data_theme_mod_default_value_with_percent_symbols */ function test_theme_mod_default_value_with_percent_symbols( $default, $expected ) { - $this->assertEquals( $expected, get_theme_mod( 'test_name', $default ) ); + $this->assertSame( $expected, get_theme_mod( 'test_name', $default ) ); } function data_theme_mod_default_value_with_percent_symbols() { diff --git a/tests/phpunit/tests/option/transient.php b/tests/phpunit/tests/option/transient.php index 90432a5e69..5f3116a1f4 100644 --- a/tests/phpunit/tests/option/transient.php +++ b/tests/phpunit/tests/option/transient.php @@ -20,10 +20,10 @@ class Tests_Option_Transient extends WP_UnitTestCase { $this->assertFalse( get_transient( 'doesnotexist' ) ); $this->assertTrue( set_transient( $key, $value ) ); - $this->assertEquals( $value, get_transient( $key ) ); + $this->assertSame( $value, get_transient( $key ) ); $this->assertFalse( set_transient( $key, $value ) ); $this->assertTrue( set_transient( $key, $value2 ) ); - $this->assertEquals( $value2, get_transient( $key ) ); + $this->assertSame( $value2, get_transient( $key ) ); $this->assertTrue( delete_transient( $key ) ); $this->assertFalse( get_transient( $key ) ); $this->assertFalse( delete_transient( $key ) ); @@ -37,7 +37,7 @@ class Tests_Option_Transient extends WP_UnitTestCase { ); $this->assertTrue( set_transient( $key, $value ) ); - $this->assertEquals( $value, get_transient( $key ) ); + $this->assertSame( $value, get_transient( $key ) ); $value = (object) $value; $this->assertTrue( set_transient( $key, $value ) ); @@ -74,7 +74,7 @@ class Tests_Option_Transient extends WP_UnitTestCase { $value = rand_str(); $value2 = rand_str(); $this->assertTrue( set_transient( $key, $value ) ); - $this->assertEquals( $value, get_transient( $key ) ); + $this->assertSame( $value, get_transient( $key ) ); $this->assertFalse( get_option( '_transient_timeout_' . $key ) ); @@ -96,7 +96,7 @@ class Tests_Option_Transient extends WP_UnitTestCase { // Create a bogus a transient. $key = 'test_transient'; set_transient( $key, 'test', 60 * 10 ); - $this->assertEquals( 'test', get_transient( $key ) ); + $this->assertSame( 'test', get_transient( $key ) ); // Useful variables for tracking. $transient_timeout = '_transient_timeout_' . $key; @@ -114,7 +114,7 @@ class Tests_Option_Transient extends WP_UnitTestCase { get_transient( $key ); // Make sure 'delete_option' was not called for both the transient and the timeout. - $this->assertEquals( 0, $a->get_call_count() ); + $this->assertSame( 0, $a->get_call_count() ); } /** @@ -124,7 +124,7 @@ class Tests_Option_Transient extends WP_UnitTestCase { // Create a transient. $key = 'test_transient'; set_transient( $key, 'test', 60 * 10 ); - $this->assertEquals( 'test', get_transient( $key ) ); + $this->assertSame( 'test', get_transient( $key ) ); // Make sure the timeout option returns false. $timeout = '_transient_timeout_' . $key; @@ -141,7 +141,7 @@ class Tests_Option_Transient extends WP_UnitTestCase { get_transient( $key ); // Make sure 'delete_option' was called for both the transient and the timeout. - $this->assertEquals( 2, $a->get_call_count() ); + $this->assertSame( 2, $a->get_call_count() ); $expected = array( array( @@ -155,6 +155,6 @@ class Tests_Option_Transient extends WP_UnitTestCase { 'args' => array( $timeout ), ), ); - $this->assertEquals( $expected, $a->get_events() ); + $this->assertSame( $expected, $a->get_events() ); } } diff --git a/tests/phpunit/tests/option/updateOption.php b/tests/phpunit/tests/option/updateOption.php index 77a884fc41..db2aab24a2 100644 --- a/tests/phpunit/tests/option/updateOption.php +++ b/tests/phpunit/tests/option/updateOption.php @@ -32,8 +32,8 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { $value = get_option( 'test_update_option_default' ); $after = $wpdb->num_queries; - $this->assertEquals( $before, $after ); - $this->assertEquals( $value, 'value' ); + $this->assertSame( $before, $after ); + $this->assertSame( $value, 'value' ); } /** @@ -52,8 +52,8 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { $value = get_option( 'test_update_option_default' ); $after = $wpdb->num_queries; - $this->assertEquals( $before, $after ); - $this->assertEquals( $value, 'value' ); + $this->assertSame( $before, $after ); + $this->assertSame( $value, 'value' ); } /** @@ -73,8 +73,8 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { $after = $wpdb->num_queries; // Database has been hit. - $this->assertEquals( $before + 1, $after ); - $this->assertEquals( $value, 'value' ); + $this->assertSame( $before + 1, $after ); + $this->assertSame( $value, 'value' ); } /** @@ -94,8 +94,8 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { $after = $wpdb->num_queries; // Database has been hit. - $this->assertEquals( $before + 1, $after ); - $this->assertEquals( $value, 'value' ); + $this->assertSame( $before + 1, $after ); + $this->assertSame( $value, 'value' ); } /** @@ -115,8 +115,8 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { $before = $wpdb->num_queries; $value = get_option( 'foo' ); - $this->assertEquals( $before, $wpdb->num_queries ); - $this->assertEquals( $value, 'bar2' ); + $this->assertSame( $before, $wpdb->num_queries ); + $this->assertSame( $value, 'bar2' ); } /** @@ -137,8 +137,8 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { $value = get_option( 'foo' ); // 'foo' should still be autoload=yes, so we should see no additional querios. - $this->assertEquals( $before, $wpdb->num_queries ); - $this->assertEquals( $value, 'bar' ); + $this->assertSame( $before, $wpdb->num_queries ); + $this->assertSame( $value, 'bar' ); } /** @@ -161,8 +161,8 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { $value = get_option( 'foo' ); // 'foo' should still be autoload=yes, so we should see no additional querios. - $this->assertEquals( $before, $wpdb->num_queries ); - $this->assertEquals( $value, 'bar2' ); + $this->assertSame( $before, $wpdb->num_queries ); + $this->assertSame( $value, 'bar2' ); } /** @@ -187,7 +187,7 @@ class Tests_Option_UpdateOption extends WP_UnitTestCase { $this->assertFalse( update_option( 'array_w_object', $array_w_object ) ); // Check that no new database queries were performed. - $this->assertEquals( $num_queries_pre_update, get_num_queries() ); + $this->assertSame( $num_queries_pre_update, get_num_queries() ); } /** diff --git a/tests/phpunit/tests/option/userSettings.php b/tests/phpunit/tests/option/userSettings.php index 7e979de6e9..e09c226355 100644 --- a/tests/phpunit/tests/option/userSettings.php +++ b/tests/phpunit/tests/option/userSettings.php @@ -27,7 +27,7 @@ class Tests_User_Settings extends WP_UnitTestCase { $this->set_user_setting( 'foo', 'bar' ); - $this->assertEquals( 'bar', get_user_setting( 'foo' ) ); + $this->assertSame( 'bar', get_user_setting( 'foo' ) ); } function test_set_user_setting_dashes() { @@ -37,7 +37,7 @@ class Tests_User_Settings extends WP_UnitTestCase { $this->set_user_setting( 'foo', 'foo-bar-baz' ); - $this->assertEquals( 'foo-bar-baz', get_user_setting( 'foo' ) ); + $this->assertSame( 'foo-bar-baz', get_user_setting( 'foo' ) ); } function test_set_user_setting_strip_asterisks() { @@ -47,7 +47,7 @@ class Tests_User_Settings extends WP_UnitTestCase { $this->set_user_setting( 'foo', 'foo*bar*baz' ); - $this->assertEquals( 'foobarbaz', get_user_setting( 'foo' ) ); + $this->assertSame( 'foobarbaz', get_user_setting( 'foo' ) ); } // set_user_setting() bails if `headers_sent()` is true. diff --git a/tests/phpunit/tests/option/wpLoadAllOptions.php b/tests/phpunit/tests/option/wpLoadAllOptions.php index 5088f10b9a..76c23d29e0 100644 --- a/tests/phpunit/tests/option/wpLoadAllOptions.php +++ b/tests/phpunit/tests/option/wpLoadAllOptions.php @@ -33,7 +33,7 @@ class Tests_Option_WP_Load_Alloptions extends WP_UnitTestCase { $after = $wpdb->num_queries; // Database has not been hit. - $this->assertEquals( $before, $after ); + $this->assertSame( $before, $after ); } /** @@ -50,7 +50,7 @@ class Tests_Option_WP_Load_Alloptions extends WP_UnitTestCase { $after = $wpdb->num_queries; // Database has been hit. - $this->assertEquals( $before + 1, $after ); + $this->assertSame( $before + 1, $after ); } /** @@ -76,7 +76,7 @@ class Tests_Option_WP_Load_Alloptions extends WP_UnitTestCase { wp_installing( $temp ); // Filter was called. - $this->assertEquals( $this->alloptions, $all_options ); + $this->assertSame( $this->alloptions, $all_options ); } /** diff --git a/tests/phpunit/tests/pomo/mo.php b/tests/phpunit/tests/pomo/mo.php index a3990198dd..5dd9956f9f 100644 --- a/tests/phpunit/tests/pomo/mo.php +++ b/tests/phpunit/tests/pomo/mo.php @@ -8,48 +8,48 @@ class Tests_POMO_MO extends WP_UnitTestCase { function test_mo_simple() { $mo = new MO(); $mo->import_from_file( DIR_TESTDATA . '/pomo/simple.mo' ); - $this->assertEquals( + $this->assertSame( array( 'Project-Id-Version' => 'WordPress 2.6-bleeding', 'Report-Msgid-Bugs-To' => 'wp-polyglots@lists.automattic.com', ), $mo->headers ); - $this->assertEquals( 2, count( $mo->entries ) ); - $this->assertEquals( array( 'dyado' ), $mo->entries['baba']->translations ); - $this->assertEquals( array( 'yes' ), $mo->entries["kuku\nruku"]->translations ); + $this->assertSame( 2, count( $mo->entries ) ); + $this->assertSame( array( 'dyado' ), $mo->entries['baba']->translations ); + $this->assertSame( array( 'yes' ), $mo->entries["kuku\nruku"]->translations ); } function test_mo_plural() { $mo = new MO(); $mo->import_from_file( DIR_TESTDATA . '/pomo/plural.mo' ); - $this->assertEquals( 1, count( $mo->entries ) ); - $this->assertEquals( array( 'oney dragoney', 'twoey dragoney', 'manyey dragoney', 'manyeyey dragoney', 'manyeyeyey dragoney' ), $mo->entries['one dragon']->translations ); + $this->assertSame( 1, count( $mo->entries ) ); + $this->assertSame( array( 'oney dragoney', 'twoey dragoney', 'manyey dragoney', 'manyeyey dragoney', 'manyeyeyey dragoney' ), $mo->entries['one dragon']->translations ); - $this->assertEquals( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 1 ) ); - $this->assertEquals( 'twoey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 2 ) ); - $this->assertEquals( 'twoey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', -8 ) ); + $this->assertSame( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 1 ) ); + $this->assertSame( 'twoey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 2 ) ); + $this->assertSame( 'twoey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', -8 ) ); $mo->set_header( 'Plural-Forms', 'nplurals=5; plural=0' ); - $this->assertEquals( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 1 ) ); - $this->assertEquals( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 2 ) ); - $this->assertEquals( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', -8 ) ); + $this->assertSame( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 1 ) ); + $this->assertSame( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 2 ) ); + $this->assertSame( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', -8 ) ); $mo->set_header( 'Plural-Forms', 'nplurals=5; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;' ); - $this->assertEquals( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 1 ) ); - $this->assertEquals( 'manyey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 11 ) ); - $this->assertEquals( 'twoey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 3 ) ); + $this->assertSame( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 1 ) ); + $this->assertSame( 'manyey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 11 ) ); + $this->assertSame( 'twoey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 3 ) ); $mo->set_header( 'Plural-Forms', 'nplurals=2; plural=n !=1;' ); - $this->assertEquals( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 1 ) ); - $this->assertEquals( 'twoey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 2 ) ); - $this->assertEquals( 'twoey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', -8 ) ); + $this->assertSame( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 1 ) ); + $this->assertSame( 'twoey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 2 ) ); + $this->assertSame( 'twoey dragoney', $mo->translate_plural( 'one dragon', '%d dragons', -8 ) ); } function test_mo_context() { $mo = new MO(); $mo->import_from_file( DIR_TESTDATA . '/pomo/context.mo' ); - $this->assertEquals( 2, count( $mo->entries ) ); + $this->assertSame( 2, count( $mo->entries ) ); $plural_entry = new Translation_Entry( array( 'singular' => 'one dragon', @@ -59,7 +59,7 @@ class Tests_POMO_MO extends WP_UnitTestCase { ) ); $this->assertEquals( $plural_entry, $mo->entries[ $plural_entry->key() ] ); - $this->assertEquals( 'dragonland', $mo->entries[ $plural_entry->key() ]->context ); + $this->assertSame( 'dragonland', $mo->entries[ $plural_entry->key() ]->context ); $single_entry = new Translation_Entry( array( @@ -69,7 +69,7 @@ class Tests_POMO_MO extends WP_UnitTestCase { ) ); $this->assertEquals( $single_entry, $mo->entries[ $single_entry->key() ] ); - $this->assertEquals( 'not so dragon', $mo->entries[ $single_entry->key() ]->context ); + $this->assertSame( 'not so dragon', $mo->entries[ $single_entry->key() ]->context ); } @@ -81,8 +81,8 @@ class Tests_POMO_MO extends WP_UnitTestCase { $guest->add_entry( new Translation_Entry( array( 'singular' => 'green' ) ) ); $guest->add_entry( new Translation_Entry( array( 'singular' => 'red' ) ) ); $host->merge_with( $guest ); - $this->assertEquals( 3, count( $host->entries ) ); - $this->assertEquals( array(), array_diff( array( 'pink', 'green', 'red' ), array_keys( $host->entries ) ) ); + $this->assertSame( 3, count( $host->entries ) ); + $this->assertSame( array(), array_diff( array( 'pink', 'green', 'red' ), array_keys( $host->entries ) ) ); } function test_export_mo_file() { @@ -137,7 +137,7 @@ class Tests_POMO_MO extends WP_UnitTestCase { $again = new MO(); $again->import_from_file( $temp_fn ); - $this->assertEquals( count( $entries ), count( $again->entries ) ); + $this->assertSame( count( $entries ), count( $again->entries ) ); foreach ( $entries as $entry ) { $this->assertEquals( $entry, $again->entries[ $entry->key() ] ); } @@ -159,15 +159,15 @@ class Tests_POMO_MO extends WP_UnitTestCase { $again = new MO(); $again->import_from_file( $temp_fn ); - $this->assertEquals( 0, count( $again->entries ) ); + $this->assertSame( 0, count( $again->entries ) ); } function test_nplurals_with_backslashn() { $mo = new MO(); $mo->import_from_file( DIR_TESTDATA . '/pomo/bad_nplurals.mo' ); - $this->assertEquals( '%d foro', $mo->translate_plural( '%d forum', '%d forums', 1 ) ); - $this->assertEquals( '%d foros', $mo->translate_plural( '%d forum', '%d forums', 2 ) ); - $this->assertEquals( '%d foros', $mo->translate_plural( '%d forum', '%d forums', -1 ) ); + $this->assertSame( '%d foro', $mo->translate_plural( '%d forum', '%d forums', 1 ) ); + $this->assertSame( '%d foros', $mo->translate_plural( '%d forum', '%d forums', 2 ) ); + $this->assertSame( '%d foros', $mo->translate_plural( '%d forum', '%d forums', -1 ) ); } function disabled_test_performance() { @@ -184,11 +184,11 @@ class Tests_POMO_MO extends WP_UnitTestCase { $mo = new MO(); $mo->import_from_file( DIR_TESTDATA . '/pomo/overload.mo' ); - $this->assertEquals( array( 'Табло' ), $mo->entries['Dashboard']->translations ); + $this->assertSame( array( 'Табло' ), $mo->entries['Dashboard']->translations ); } function test_load_pot_file() { $mo = new MO(); - $this->assertEquals( false, $mo->import_from_file( DIR_TESTDATA . '/pomo/mo.pot' ) ); + $this->assertFalse( $mo->import_from_file( DIR_TESTDATA . '/pomo/mo.pot' ) ); } } diff --git a/tests/phpunit/tests/pomo/noopTranslations.php b/tests/phpunit/tests/pomo/noopTranslations.php index 1e1a60c4c1..13ff9e6187 100644 --- a/tests/phpunit/tests/pomo/noopTranslations.php +++ b/tests/phpunit/tests/pomo/noopTranslations.php @@ -18,33 +18,33 @@ class Tests_POMO_NOOPTranslations extends WP_UnitTestCase { } function test_get_header() { - $this->assertEquals( false, $this->noop->get_header( 'Content-Type' ) ); + $this->assertFalse( $this->noop->get_header( 'Content-Type' ) ); } function test_add_entry() { $this->noop->add_entry( $this->entry ); - $this->assertEquals( array(), $this->noop->entries ); + $this->assertSame( array(), $this->noop->entries ); } function test_set_header() { $this->noop->set_header( 'header', 'value' ); - $this->assertEquals( array(), $this->noop->headers ); + $this->assertSame( array(), $this->noop->headers ); } function test_translate_entry() { $this->noop->add_entry( $this->entry ); - $this->assertEquals( false, $this->noop->translate_entry( $this->entry ) ); + $this->assertFalse( $this->noop->translate_entry( $this->entry ) ); } function test_translate() { $this->noop->add_entry( $this->entry ); - $this->assertEquals( 'baba', $this->noop->translate( 'baba' ) ); + $this->assertSame( 'baba', $this->noop->translate( 'baba' ) ); } function test_plural() { $this->noop->add_entry( $this->plural_entry ); - $this->assertEquals( 'dyado', $this->noop->translate_plural( 'dyado', 'dyados', 1 ) ); - $this->assertEquals( 'dyados', $this->noop->translate_plural( 'dyado', 'dyados', 11 ) ); - $this->assertEquals( 'dyados', $this->noop->translate_plural( 'dyado', 'dyados', 0 ) ); + $this->assertSame( 'dyado', $this->noop->translate_plural( 'dyado', 'dyados', 1 ) ); + $this->assertSame( 'dyados', $this->noop->translate_plural( 'dyado', 'dyados', 11 ) ); + $this->assertSame( 'dyados', $this->noop->translate_plural( 'dyado', 'dyados', 0 ) ); } } diff --git a/tests/phpunit/tests/pomo/pluralForms.php b/tests/phpunit/tests/pomo/pluralForms.php index 2d53c29c56..3c84321652 100644 --- a/tests/phpunit/tests/pomo/pluralForms.php +++ b/tests/phpunit/tests/pomo/pluralForms.php @@ -213,7 +213,7 @@ class PluralFormsTest extends WP_UnitTestCase { $plural_forms->get( 1 ); } } catch ( Exception $e ) { - $this->assertEquals( $expected_exception, $e->getMessage() ); + $this->assertSame( $expected_exception, $e->getMessage() ); return; } @@ -236,6 +236,6 @@ class PluralFormsTest extends WP_UnitTestCase { $first = $mock->get( 2 ); $second = $mock->get( 2 ); - $this->assertEquals( $first, $second ); + $this->assertSame( $first, $second ); } } diff --git a/tests/phpunit/tests/pomo/po.php b/tests/phpunit/tests/pomo/po.php index 81cc058932..028c9ece9a 100644 --- a/tests/phpunit/tests/pomo/po.php +++ b/tests/phpunit/tests/pomo/po.php @@ -43,45 +43,45 @@ http://wordpress.org/ function test_prepend_each_line() { $po = new PO(); - $this->assertEquals( 'baba_', $po->prepend_each_line( '', 'baba_' ) ); - $this->assertEquals( 'baba_dyado', $po->prepend_each_line( 'dyado', 'baba_' ) ); - $this->assertEquals( "# baba\n# dyado\n# \n", $po->prepend_each_line( "baba\ndyado\n\n", '# ' ) ); + $this->assertSame( 'baba_', $po->prepend_each_line( '', 'baba_' ) ); + $this->assertSame( 'baba_dyado', $po->prepend_each_line( 'dyado', 'baba_' ) ); + $this->assertSame( "# baba\n# dyado\n# \n", $po->prepend_each_line( "baba\ndyado\n\n", '# ' ) ); } function test_poify() { $po = new PO(); // Simple. - $this->assertEquals( '"baba"', $po->poify( 'baba' ) ); + $this->assertSame( '"baba"', $po->poify( 'baba' ) ); // Long word. - $this->assertEquals( $this->po_a90, $po->poify( $this->a90 ) ); + $this->assertSame( $this->po_a90, $po->poify( $this->a90 ) ); // Tab. - $this->assertEquals( '"ba\tba"', $po->poify( "ba\tba" ) ); + $this->assertSame( '"ba\tba"', $po->poify( "ba\tba" ) ); // Do not add leading empty string of one-line string ending on a newline. - $this->assertEquals( '"\\\\a\\\\n\\n"', $po->poify( "\a\\n\n" ) ); + $this->assertSame( '"\\\\a\\\\n\\n"', $po->poify( "\a\\n\n" ) ); // Backslash. - $this->assertEquals( '"ba\\\\ba"', $po->poify( 'ba\\ba' ) ); + $this->assertSame( '"ba\\\\ba"', $po->poify( 'ba\\ba' ) ); // Random wordpress.pot string. $src = 'Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'; - $this->assertEquals( '"Categories can be selectively converted to tags using the <a href=\\"%s\\">category to tag converter</a>."', $po->poify( $src ) ); + $this->assertSame( '"Categories can be selectively converted to tags using the <a href=\\"%s\\">category to tag converter</a>."', $po->poify( $src ) ); - $this->assertEqualsIgnoreEOL( $this->po_mail, $po->poify( $this->mail ) ); + $this->assertSameIgnoreEOL( $this->po_mail, $po->poify( $this->mail ) ); } function test_unpoify() { $po = new PO(); - $this->assertEquals( 'baba', $po->unpoify( '"baba"' ) ); - $this->assertEquals( "baba\ngugu", $po->unpoify( '"baba\n"' . "\t\t\t\n" . '"gugu"' ) ); - $this->assertEquals( $this->a90, $po->unpoify( $this->po_a90 ) ); - $this->assertEquals( '\\t\\n', $po->unpoify( '"\\\\t\\\\n"' ) ); + $this->assertSame( 'baba', $po->unpoify( '"baba"' ) ); + $this->assertSame( "baba\ngugu", $po->unpoify( '"baba\n"' . "\t\t\t\n" . '"gugu"' ) ); + $this->assertSame( $this->a90, $po->unpoify( $this->po_a90 ) ); + $this->assertSame( '\\t\\n', $po->unpoify( '"\\\\t\\\\n"' ) ); // Wordwrapped. - $this->assertEquals( 'babadyado', $po->unpoify( "\"\"\n\"baba\"\n\"dyado\"" ) ); - $this->assertEqualsIgnoreEOL( $this->mail, $po->unpoify( $this->po_mail ) ); + $this->assertSame( 'babadyado', $po->unpoify( "\"\"\n\"baba\"\n\"dyado\"" ) ); + $this->assertSameIgnoreEOL( $this->mail, $po->unpoify( $this->po_mail ) ); } function test_export_entry() { $po = new PO(); $entry = new Translation_Entry( array( 'singular' => 'baba' ) ); - $this->assertEquals( "msgid \"baba\"\nmsgstr \"\"", $po->export_entry( $entry ) ); + $this->assertSame( "msgid \"baba\"\nmsgstr \"\"", $po->export_entry( $entry ) ); // Plural. $entry = new Translation_Entry( array( @@ -89,7 +89,7 @@ http://wordpress.org/ 'plural' => 'babas', ) ); - $this->assertEqualsIgnoreEOL( + $this->assertSameIgnoreEOL( 'msgid "baba" msgid_plural "babas" msgstr[0] "" @@ -102,7 +102,7 @@ msgstr[1] ""', 'translator_comments' => "baba\ndyado", ) ); - $this->assertEqualsIgnoreEOL( + $this->assertSameIgnoreEOL( '# baba # dyado msgid "baba" @@ -115,7 +115,7 @@ msgstr ""', 'extracted_comments' => 'baba', ) ); - $this->assertEqualsIgnoreEOL( + $this->assertSameIgnoreEOL( '#. baba msgid "baba" msgstr ""', @@ -128,7 +128,7 @@ msgstr ""', 'references' => range( 1, 29 ), ) ); - $this->assertEqualsIgnoreEOL( + $this->assertSameIgnoreEOL( '#. baba #: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 #: 29 @@ -142,7 +142,7 @@ msgstr ""', 'translations' => array(), ) ); - $this->assertEquals( "msgid \"baba\"\nmsgstr \"\"", $po->export_entry( $entry ) ); + $this->assertSame( "msgid \"baba\"\nmsgstr \"\"", $po->export_entry( $entry ) ); $entry = new Translation_Entry( array( @@ -150,7 +150,7 @@ msgstr ""', 'translations' => array( 'куку', 'буку' ), ) ); - $this->assertEquals( "msgid \"baba\"\nmsgstr \"куку\"", $po->export_entry( $entry ) ); + $this->assertSame( "msgid \"baba\"\nmsgstr \"куку\"", $po->export_entry( $entry ) ); $entry = new Translation_Entry( array( @@ -159,7 +159,7 @@ msgstr ""', 'translations' => array( 'кукубуку' ), ) ); - $this->assertEqualsIgnoreEOL( + $this->assertSameIgnoreEOL( 'msgid "baba" msgid_plural "babas" msgstr[0] "кукубуку"', @@ -173,7 +173,7 @@ msgstr[0] "кукубуку"', 'translations' => array( 'кукубуку', 'кукуруку', 'бабаяга' ), ) ); - $this->assertEqualsIgnoreEOL( + $this->assertSameIgnoreEOL( 'msgid "baba" msgid_plural "babas" msgstr[0] "кукубуку" @@ -191,7 +191,7 @@ msgstr[2] "бабаяга"', 'flags' => array( 'fuzzy', 'php-format' ), ) ); - $this->assertEqualsIgnoreEOL( + $this->assertSameIgnoreEOL( '#, fuzzy, php-format msgctxt "ctxt" msgid "baba" @@ -209,14 +209,14 @@ msgstr[2] "бабаяга"', $po = new PO(); $po->add_entry( $entry ); $po->add_entry( $entry2 ); - $this->assertEquals( "msgid \"baba\"\nmsgstr \"\"\n\nmsgid \"dyado\"\nmsgstr \"\"", $po->export_entries() ); + $this->assertSame( "msgid \"baba\"\nmsgstr \"\"\n\nmsgid \"dyado\"\nmsgstr \"\"", $po->export_entries() ); } function test_export_headers() { $po = new PO(); $po->set_header( 'Project-Id-Version', 'WordPress 2.6-bleeding' ); $po->set_header( 'POT-Creation-Date', '2008-04-08 18:00+0000' ); - $this->assertEquals( "msgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: WordPress 2.6-bleeding\\n\"\n\"POT-Creation-Date: 2008-04-08 18:00+0000\\n\"", $po->export_headers() ); + $this->assertSame( "msgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: WordPress 2.6-bleeding\\n\"\n\"POT-Creation-Date: 2008-04-08 18:00+0000\\n\"", $po->export_headers() ); } function test_export() { @@ -227,8 +227,8 @@ msgstr[2] "бабаяга"', $po->set_header( 'POT-Creation-Date', '2008-04-08 18:00+0000' ); $po->add_entry( $entry ); $po->add_entry( $entry2 ); - $this->assertEquals( "msgid \"baba\"\nmsgstr \"\"\n\nmsgid \"dyado\"\nmsgstr \"\"", $po->export( false ) ); - $this->assertEquals( "msgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: WordPress 2.6-bleeding\\n\"\n\"POT-Creation-Date: 2008-04-08 18:00+0000\\n\"\n\nmsgid \"baba\"\nmsgstr \"\"\n\nmsgid \"dyado\"\nmsgstr \"\"", $po->export() ); + $this->assertSame( "msgid \"baba\"\nmsgstr \"\"\n\nmsgid \"dyado\"\nmsgstr \"\"", $po->export( false ) ); + $this->assertSame( "msgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: WordPress 2.6-bleeding\\n\"\n\"POT-Creation-Date: 2008-04-08 18:00+0000\\n\"\n\nmsgid \"baba\"\nmsgstr \"\"\n\nmsgid \"dyado\"\nmsgstr \"\"", $po->export() ); } @@ -243,19 +243,19 @@ msgstr[2] "бабаяга"', $temp_fn = $this->temp_filename(); $po->export_to_file( $temp_fn, false ); - $this->assertEquals( $po->export( false ), file_get_contents( $temp_fn ) ); + $this->assertSame( $po->export( false ), file_get_contents( $temp_fn ) ); $temp_fn2 = $this->temp_filename(); $po->export_to_file( $temp_fn2 ); - $this->assertEquals( $po->export(), file_get_contents( $temp_fn2 ) ); + $this->assertSame( $po->export(), file_get_contents( $temp_fn2 ) ); } function test_import_from_file() { $po = new PO(); $res = $po->import_from_file( DIR_TESTDATA . '/pomo/simple.po' ); - $this->assertEquals( true, $res ); + $this->assertTrue( $res ); - $this->assertEquals( + $this->assertSame( array( 'Project-Id-Version' => 'WordPress 2.6-bleeding', 'Plural-Forms' => 'nplurals=2; plural=n != 1;', @@ -317,7 +317,7 @@ msgstr[2] "бабаяга"', function test_import_from_file_with_windows_line_endings_should_work_as_with_unix_line_endings() { $po = new PO(); $this->assertTrue( $po->import_from_file( DIR_TESTDATA . '/pomo/windows-line-endings.po' ) ); - $this->assertEquals( 1, count( $po->entries ) ); + $this->assertSame( 1, count( $po->entries ) ); } // TODO: Add tests for bad files. diff --git a/tests/phpunit/tests/pomo/translationEntry.php b/tests/phpunit/tests/pomo/translationEntry.php index 0f68ba7cc2..60485cd8aa 100644 --- a/tests/phpunit/tests/pomo/translationEntry.php +++ b/tests/phpunit/tests/pomo/translationEntry.php @@ -21,12 +21,12 @@ class Tests_POMO_TranslationEntry extends WP_UnitTestCase { 'flags' => 'baba', ) ); - $this->assertEquals( 'baba', $entry->singular ); - $this->assertEquals( 'babas', $entry->plural ); + $this->assertSame( 'baba', $entry->singular ); + $this->assertSame( 'babas', $entry->plural ); $this->assertTrue( $entry->is_plural ); - $this->assertEquals( array( 'баба', 'баби' ), $entry->translations ); - $this->assertEquals( array(), $entry->references ); - $this->assertEquals( array(), $entry->flags ); + $this->assertSame( array( 'баба', 'баби' ), $entry->translations ); + $this->assertSame( array(), $entry->references ); + $this->assertSame( array(), $entry->flags ); } function test_key() { @@ -44,7 +44,7 @@ class Tests_POMO_TranslationEntry extends WP_UnitTestCase { 'plural' => 'babas', ) ); - $this->assertEquals( $entry_baba->key(), $entry_baba_plural->key() ); + $this->assertSame( $entry_baba->key(), $entry_baba_plural->key() ); $this->assertNotEquals( $entry_baba->key(), $entry_baba_ctxt->key() ); $this->assertNotEquals( $entry_baba_plural->key(), $entry_baba_ctxt->key() ); $this->assertNotEquals( $entry_baba->key(), $entry_dyado->key() ); diff --git a/tests/phpunit/tests/pomo/translations.php b/tests/phpunit/tests/pomo/translations.php index c9f034b524..daa3f630b2 100644 --- a/tests/phpunit/tests/pomo/translations.php +++ b/tests/phpunit/tests/pomo/translations.php @@ -11,14 +11,14 @@ class Tests_POMO_Translations extends WP_UnitTestCase { $empty = new Translation_Entry(); $po = new Translations(); $po->add_entry( $entry ); - $this->assertEquals( array( $entry->key() => $entry ), $po->entries ); + $this->assertSame( array( $entry->key() => $entry ), $po->entries ); // Add the same entry more than once. // We do not need to test proper key generation here, see test_key(). $po->add_entry( $entry ); $po->add_entry( $entry ); - $this->assertEquals( array( $entry->key() => $entry ), $po->entries ); + $this->assertSame( array( $entry->key() => $entry ), $po->entries ); $po->add_entry( $entry2 ); - $this->assertEquals( + $this->assertSame( array( $entry->key() => $entry, $entry2->key() => $entry2, @@ -26,8 +26,8 @@ class Tests_POMO_Translations extends WP_UnitTestCase { $po->entries ); // Add empty entry. - $this->assertEquals( false, $po->add_entry( $empty ) ); - $this->assertEquals( + $this->assertFalse( $po->add_entry( $empty ) ); + $this->assertSame( array( $entry->key() => $entry, $entry2->key() => $entry2, @@ -39,7 +39,7 @@ class Tests_POMO_Translations extends WP_UnitTestCase { $po = new Translations(); $po->add_entry( array( 'singular' => 'baba' ) ); $entries = array_values( $po->entries ); - $this->assertEquals( $entry->key(), $entries[0]->key() ); + $this->assertSame( $entry->key(), $entries[0]->key() ); } function test_translate() { @@ -59,10 +59,10 @@ class Tests_POMO_Translations extends WP_UnitTestCase { $domain = new Translations(); $domain->add_entry( $entry1 ); $domain->add_entry( $entry2 ); - $this->assertEquals( 'babax', $domain->translate( 'baba' ) ); - $this->assertEquals( 'babay', $domain->translate( 'baba', 'x' ) ); - $this->assertEquals( 'baba', $domain->translate( 'baba', 'y' ) ); - $this->assertEquals( 'babaz', $domain->translate( 'babaz' ) ); + $this->assertSame( 'babax', $domain->translate( 'baba' ) ); + $this->assertSame( 'babay', $domain->translate( 'baba', 'x' ) ); + $this->assertSame( 'baba', $domain->translate( 'baba', 'y' ) ); + $this->assertSame( 'babaz', $domain->translate( 'babaz' ) ); } function test_translate_plural() { @@ -91,18 +91,18 @@ class Tests_POMO_Translations extends WP_UnitTestCase { $domain->add_entry( $entry_incomplete ); $domain->add_entry( $entry_toomany ); $domain->add_entry( $entry_2 ); - $this->assertEquals( 'other', $domain->translate_plural( 'other', 'others', 1 ) ); - $this->assertEquals( 'others', $domain->translate_plural( 'other', 'others', 111 ) ); + $this->assertSame( 'other', $domain->translate_plural( 'other', 'others', 1 ) ); + $this->assertSame( 'others', $domain->translate_plural( 'other', 'others', 111 ) ); // Too few translations + cont logic. - $this->assertEquals( 'babas', $domain->translate_plural( 'baba', 'babas', 2 ) ); - $this->assertEquals( 'babas', $domain->translate_plural( 'baba', 'babas', 0 ) ); - $this->assertEquals( 'babas', $domain->translate_plural( 'baba', 'babas', -1 ) ); - $this->assertEquals( 'babas', $domain->translate_plural( 'baba', 'babas', 999 ) ); + $this->assertSame( 'babas', $domain->translate_plural( 'baba', 'babas', 2 ) ); + $this->assertSame( 'babas', $domain->translate_plural( 'baba', 'babas', 0 ) ); + $this->assertSame( 'babas', $domain->translate_plural( 'baba', 'babas', -1 ) ); + $this->assertSame( 'babas', $domain->translate_plural( 'baba', 'babas', 999 ) ); // Proper. - $this->assertEquals( 'dyadox', $domain->translate_plural( 'dyado', 'dyados', 1 ) ); - $this->assertEquals( 'dyadoy', $domain->translate_plural( 'dyado', 'dyados', 0 ) ); - $this->assertEquals( 'dyadoy', $domain->translate_plural( 'dyado', 'dyados', 18881 ) ); - $this->assertEquals( 'dyadoy', $domain->translate_plural( 'dyado', 'dyados', -18881 ) ); + $this->assertSame( 'dyadox', $domain->translate_plural( 'dyado', 'dyados', 1 ) ); + $this->assertSame( 'dyadoy', $domain->translate_plural( 'dyado', 'dyados', 0 ) ); + $this->assertSame( 'dyadoy', $domain->translate_plural( 'dyado', 'dyados', 18881 ) ); + $this->assertSame( 'dyadoy', $domain->translate_plural( 'dyado', 'dyados', -18881 ) ); } function test_digit_and_merge() { @@ -122,9 +122,9 @@ class Tests_POMO_Translations extends WP_UnitTestCase { $domain->add_entry( $entry_digit_1 ); $domain->add_entry( $entry_digit_2 ); $dummy_translation = new Translations; - $this->assertEquals( '1', $domain->translate( '1' ) ); + $this->assertSame( '1', $domain->translate( '1' ) ); $domain->merge_with( $dummy_translation ); - $this->assertEquals( '1', $domain->translate( '1' ) ); + $this->assertSame( '1', $domain->translate( '1' ) ); } } diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 3b5af7bad4..f70304ba98 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -85,25 +85,25 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post and make sure it matches. $out = get_post( $id ); - $this->assertEquals( $post['post_content'], $out->post_content ); - $this->assertEquals( $post['post_title'], $out->post_title ); - $this->assertEquals( $post['post_status'], $out->post_status ); + $this->assertSame( $post['post_content'], $out->post_content ); + $this->assertSame( $post['post_title'], $out->post_title ); + $this->assertSame( $post['post_status'], $out->post_status ); $this->assertEquals( $post['post_author'], $out->post_author ); // Test cache state. $pcache = wp_cache_get( $id, 'posts' ); $this->assertInstanceOf( 'stdClass', $pcache ); - $this->assertEquals( $id, $pcache->ID ); + $this->assertSame( $id, $pcache->ID ); update_object_term_cache( $id, $post_type ); $tcache = wp_cache_get( $id, 'post_tag_relationships' ); $this->assertInternalType( 'array', $tcache ); - $this->assertEquals( 2, count( $tcache ) ); + $this->assertSame( 2, count( $tcache ) ); $tcache = wp_cache_get( $id, 'ctax_relationships' ); if ( 'cpt' === $post_type ) { $this->assertInternalType( 'array', $tcache ); - $this->assertEquals( 2, count( $tcache ) ); + $this->assertSame( 2, count( $tcache ) ); } else { $this->assertFalse( $tcache ); } @@ -141,14 +141,14 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post and make sure it matches. $out = get_post( $id ); - $this->assertEquals( $post['post_content'], $out->post_content ); - $this->assertEquals( $post['post_title'], $out->post_title ); - $this->assertEquals( 'future', $out->post_status ); + $this->assertSame( $post['post_content'], $out->post_content ); + $this->assertSame( $post['post_title'], $out->post_title ); + $this->assertSame( 'future', $out->post_status ); $this->assertEquals( $post['post_author'], $out->post_author ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( $post['post_date'], $out->post_date ); // There should be a publish_future_post hook scheduled on the future date. - $this->assertEquals( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertSame( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); } /** @@ -173,11 +173,11 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post and make sure has the correct date and status. $out = get_post( $id ); - $this->assertEquals( 'future', $out->post_status ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( 'future', $out->post_status ); + $this->assertSame( $post['post_date'], $out->post_date ); // Check that there's a publish_future_post job scheduled at the right time. - $this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); // Now save it again with a date further in the future. @@ -188,11 +188,11 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post again and make sure it has the new post_date. $out = get_post( $id ); - $this->assertEquals( 'future', $out->post_status ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( 'future', $out->post_status ); + $this->assertSame( $post['post_date'], $out->post_date ); // And the correct date on the cron job. - $this->assertEquals( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertSame( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); } /** @@ -218,11 +218,11 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post and make sure has the correct date and status. $out = get_post( $id ); - $this->assertEquals( 'future', $out->post_status ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( 'future', $out->post_status ); + $this->assertSame( $post['post_date'], $out->post_date ); // Check that there's a publish_future_post job scheduled at the right time. - $this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); // Now save it again with a date further in the future. @@ -233,11 +233,11 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post again and make sure it has the new post_date. $out = get_post( $id ); - $this->assertEquals( 'future', $out->post_status ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( 'future', $out->post_status ); + $this->assertSame( $post['post_date'], $out->post_date ); // And the correct date on the cron job. - $this->assertEquals( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertSame( $future_date_2, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); } /** @@ -264,14 +264,14 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post and make sure it matches. $out = get_post( $id ); - $this->assertEquals( $post['post_content'], $out->post_content ); - $this->assertEquals( $post['post_title'], $out->post_title ); - $this->assertEquals( 'draft', $out->post_status ); + $this->assertSame( $post['post_content'], $out->post_content ); + $this->assertSame( $post['post_title'], $out->post_title ); + $this->assertSame( 'draft', $out->post_status ); $this->assertEquals( $post['post_author'], $out->post_author ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( $post['post_date'], $out->post_date ); // There should be a publish_future_post hook scheduled on the future date. - $this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) ); } @@ -295,11 +295,11 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post and make sure has the correct date and status. $out = get_post( $id ); - $this->assertEquals( 'future', $out->post_status ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( 'future', $out->post_status ); + $this->assertSame( $post['post_date'], $out->post_date ); // Check that there's a publish_future_post job scheduled at the right time. - $this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); // Now save it again with status set to draft. @@ -309,11 +309,11 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post again and make sure it has the new post_date. $out = get_post( $id ); - $this->assertEquals( 'draft', $out->post_status ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( 'draft', $out->post_status ); + $this->assertSame( $post['post_date'], $out->post_date ); // And the correct date on the cron job. - $this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) ); } /** @@ -339,11 +339,11 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post and make sure has the correct date and status. $out = get_post( $id ); - $this->assertEquals( 'future', $out->post_status ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( 'future', $out->post_status ); + $this->assertSame( $post['post_date'], $out->post_date ); // Check that there's a publish_future_post job scheduled at the right time. - $this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); // Now save it again with status changed. @@ -353,11 +353,11 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post again and make sure it has the new post_date. $out = get_post( $id ); - $this->assertEquals( $status, $out->post_status ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( $status, $out->post_status ); + $this->assertSame( $post['post_date'], $out->post_date ); // And the correct date on the cron job. - $this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) ); } } @@ -385,14 +385,14 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post and make sure it matches. $out = get_post( $id ); - $this->assertEquals( $post['post_content'], $out->post_content ); - $this->assertEquals( $post['post_title'], $out->post_title ); - $this->assertEquals( 'private', $out->post_status ); + $this->assertSame( $post['post_content'], $out->post_content ); + $this->assertSame( $post['post_title'], $out->post_title ); + $this->assertSame( 'private', $out->post_status ); $this->assertEquals( $post['post_author'], $out->post_author ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( $post['post_date'], $out->post_date ); // There should be a publish_future_post hook scheduled on the future date. - $this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) ); } /** @@ -412,10 +412,10 @@ class Tests_Post extends WP_UnitTestCase { // Test both return paths with or without WP_Error. $insert_post = wp_insert_post( $post, true ); $this->assertWPError( $insert_post ); - $this->assertEquals( 'invalid_date', $insert_post->get_error_code() ); + $this->assertSame( 'invalid_date', $insert_post->get_error_code() ); $insert_post = wp_insert_post( $post ); - $this->assertEquals( 0, $insert_post ); + $this->assertSame( 0, $insert_post ); } /** @@ -438,11 +438,11 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post and make sure has the correct date and status. $out = get_post( $id ); - $this->assertEquals( 'future', $out->post_status ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( 'future', $out->post_status ); + $this->assertSame( $post['post_date'], $out->post_date ); // Check that there's a publish_future_post job scheduled at the right time. - $this->assertEquals( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertSame( $future_date_1, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); // Now save it again with status set to draft. @@ -452,11 +452,11 @@ class Tests_Post extends WP_UnitTestCase { // Fetch the post again and make sure it has the new post_date. $out = get_post( $id ); - $this->assertEquals( 'private', $out->post_status ); - $this->assertEquals( $post['post_date'], $out->post_date ); + $this->assertSame( 'private', $out->post_status ); + $this->assertSame( $post['post_date'], $out->post_date ); // And the correct date on the cron job. - $this->assertEquals( false, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertFalse( $this->_next_schedule_for_post( 'publish_future_post', $id ) ); } /** @@ -478,7 +478,7 @@ class Tests_Post extends WP_UnitTestCase { $this->set_permalink_structure(); - $this->assertEquals( "$p-2", $post->post_name ); + $this->assertSame( "$p-2", $post->post_name ); } /** @@ -518,8 +518,8 @@ class Tests_Post extends WP_UnitTestCase { ) ); - $this->assertEquals( 'world', get_post_meta( $post_id, 'hello', true ) ); - $this->assertEquals( 'bar', get_post_meta( $post_id, 'foo', true ) ); + $this->assertSame( 'world', get_post_meta( $post_id, 'hello', true ) ); + $this->assertSame( 'bar', get_post_meta( $post_id, 'foo', true ) ); } /** @@ -543,7 +543,7 @@ class Tests_Post extends WP_UnitTestCase { $this->post_ids[] = $id; // Check that there's a publish_future_post job scheduled at the right time. - $this->assertEquals( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); + $this->assertSame( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) ); // Now delete the post and make sure the cron entry is removed. wp_delete_post( $id ); @@ -576,19 +576,19 @@ class Tests_Post extends WP_UnitTestCase { $plink = get_permalink( $id ); // Permalink should include the post ID at the end. - $this->assertEquals( get_option( 'siteurl' ) . '/2007/10/31/' . $id . '/', $plink ); + $this->assertSame( get_option( 'siteurl' ) . '/2007/10/31/' . $id . '/', $plink ); } function test_wp_publish_post() { $draft_id = self::factory()->post->create( array( 'post_status' => 'draft' ) ); $post = get_post( $draft_id ); - $this->assertEquals( 'draft', $post->post_status ); + $this->assertSame( 'draft', $post->post_status ); wp_publish_post( $draft_id ); $post = get_post( $draft_id ); - $this->assertEquals( 'publish', $post->post_status ); + $this->assertSame( 'publish', $post->post_status ); } /** @@ -604,14 +604,14 @@ class Tests_Post extends WP_UnitTestCase { ); $post = get_post( $post_id ); - $this->assertEquals( 'future', $post->post_status ); - $this->assertEquals( $future_date, $post->post_date ); + $this->assertSame( 'future', $post->post_status ); + $this->assertSame( $future_date, $post->post_date ); wp_publish_post( $post_id ); $post = get_post( $post_id ); - $this->assertEquals( 'publish', $post->post_status ); - $this->assertEquals( $future_date, $post->post_date ); + $this->assertSame( 'publish', $post->post_status ); + $this->assertSame( $future_date, $post->post_date ); } /** @@ -626,8 +626,8 @@ class Tests_Post extends WP_UnitTestCase { ); $post = get_post( $post_id ); - $this->assertEquals( 'publish', $post->post_status ); - $this->assertEquals( $future_date, $post->post_date ); + $this->assertSame( 'publish', $post->post_status ); + $this->assertSame( $future_date, $post->post_date ); } /** @@ -638,8 +638,8 @@ class Tests_Post extends WP_UnitTestCase { $post_id = wp_insert_post( array( 'post_title' => '<script>Test</script>' ) ); $post = get_post( $post_id ); - $this->assertEquals( '<script>Test</script>', $post->post_title ); - $this->assertEquals( 'draft', $post->post_status ); + $this->assertSame( '<script>Test</script>', $post->post_title ); + $this->assertSame( 'draft', $post->post_status ); kses_init_filters(); @@ -650,7 +650,7 @@ class Tests_Post extends WP_UnitTestCase { ) ); $post = get_post( $post->ID ); - $this->assertEquals( 'Test', $post->post_title ); + $this->assertSame( 'Test', $post->post_title ); kses_remove_filters(); } @@ -663,14 +663,14 @@ class Tests_Post extends WP_UnitTestCase { $post_id = wp_insert_post( array( 'post_title' => '<script>Test</script>' ) ); $post = get_post( $post_id ); - $this->assertEquals( '<script>Test</script>', $post->post_title ); - $this->assertEquals( 'draft', $post->post_status ); + $this->assertSame( '<script>Test</script>', $post->post_title ); + $this->assertSame( 'draft', $post->post_status ); kses_init_filters(); wp_publish_post( $post->ID ); $post = get_post( $post->ID ); - $this->assertEquals( '<script>Test</script>', $post->post_title ); + $this->assertSame( '<script>Test</script>', $post->post_title ); kses_remove_filters(); } @@ -682,7 +682,7 @@ class Tests_Post extends WP_UnitTestCase { global $post; $parent_id = self::factory()->post->create(); $post = self::factory()->post->create_and_get( array( 'post_parent' => $parent_id ) ); - $this->assertEquals( array( $parent_id ), get_post_ancestors( 0 ) ); + $this->assertSame( array( $parent_id ), get_post_ancestors( 0 ) ); } /** @@ -694,8 +694,8 @@ class Tests_Post extends WP_UnitTestCase { $post['ID'] = 123456789; - $this->assertEquals( 0, wp_insert_post( $post ) ); - $this->assertEquals( 0, wp_update_post( $post ) ); + $this->assertSame( 0, wp_insert_post( $post ) ); + $this->assertSame( 0, wp_update_post( $post ) ); $this->assertInstanceOf( 'WP_Error', wp_insert_post( $post, true ) ); $this->assertInstanceOf( 'WP_Error', wp_update_post( $post, true ) ); @@ -707,10 +707,10 @@ class Tests_Post extends WP_UnitTestCase { $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) ); $post = get_post( $post_id ); setup_postdata( $post ); - $this->assertEquals( 0, $multipage ); + $this->assertSame( 0, $multipage ); $this->assertCount( 1, $pages ); - $this->assertEquals( 1, $numpages ); - $this->assertEquals( array( 'Page 0' ), $pages ); + $this->assertSame( 1, $numpages ); + $this->assertSame( array( 'Page 0' ), $pages ); } function test_parse_post_content_multi_page() { @@ -718,10 +718,10 @@ class Tests_Post extends WP_UnitTestCase { $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); $post = get_post( $post_id ); setup_postdata( $post ); - $this->assertEquals( 1, $multipage ); + $this->assertSame( 1, $multipage ); $this->assertCount( 4, $pages ); - $this->assertEquals( 4, $numpages ); - $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages ); + $this->assertSame( 4, $numpages ); + $this->assertSame( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages ); } function test_parse_post_content_remaining_single_page() { @@ -729,10 +729,10 @@ class Tests_Post extends WP_UnitTestCase { $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) ); $post = get_post( $post_id ); setup_postdata( $post ); - $this->assertEquals( 0, $multipage ); + $this->assertSame( 0, $multipage ); $this->assertCount( 1, $pages ); - $this->assertEquals( 1, $numpages ); - $this->assertEquals( array( 'Page 0' ), $pages ); + $this->assertSame( 1, $numpages ); + $this->assertSame( array( 'Page 0' ), $pages ); } function test_parse_post_content_remaining_multi_page() { @@ -740,10 +740,10 @@ class Tests_Post extends WP_UnitTestCase { $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); $post = get_post( $post_id ); setup_postdata( $post ); - $this->assertEquals( 1, $multipage ); + $this->assertSame( 1, $multipage ); $this->assertCount( 4, $pages ); - $this->assertEquals( 4, $numpages ); - $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages ); + $this->assertSame( 4, $numpages ); + $this->assertSame( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages ); } /** @@ -754,10 +754,10 @@ class Tests_Post extends WP_UnitTestCase { $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); $post = get_post( $post_id ); setup_postdata( $post ); - $this->assertEquals( 1, $multipage ); + $this->assertSame( 1, $multipage ); $this->assertCount( 4, $pages ); - $this->assertEquals( 4, $numpages ); - $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages ); + $this->assertSame( 4, $numpages ); + $this->assertSame( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $pages ); } /** @@ -768,10 +768,10 @@ class Tests_Post extends WP_UnitTestCase { $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) ); $post = get_post( $post_id ); setup_postdata( $post ); - $this->assertEquals( 0, $multipage ); + $this->assertSame( 0, $multipage ); $this->assertCount( 1, $pages ); - $this->assertEquals( 1, $numpages ); - $this->assertEquals( array( 'Page 0' ), $pages ); + $this->assertSame( 1, $numpages ); + $this->assertSame( array( 'Page 0' ), $pages ); } /** @@ -797,7 +797,7 @@ class Tests_Post extends WP_UnitTestCase { $post = get_post( $insert_post_id ); $this->assertEquals( $post->post_author, self::$editor_id ); - $this->assertEquals( $post->post_title, $title ); + $this->assertSame( $post->post_title, $title ); } /** @@ -852,7 +852,7 @@ class Tests_Post extends WP_UnitTestCase { $_post['post_status'] = 'draft'; wp_insert_post( $_post ); $post = get_post( $post_ids[ $key ] ); - $this->assertEquals( 'draft', $post->post_status ); + $this->assertSame( 'draft', $post->post_status ); $this->assertNotEquals( 'publish', $post->post_status ); $after_draft_counts = wp_count_posts(); @@ -870,7 +870,7 @@ class Tests_Post extends WP_UnitTestCase { wp_trash_post( $post_ids[ $key ] ); $post = get_post( $post_ids[ $key ] ); - $this->assertEquals( 'trash', $post->post_status ); + $this->assertSame( 'trash', $post->post_status ); $this->assertNotEquals( 'publish', $post->post_status ); $after_trash_counts = wp_count_posts(); @@ -892,7 +892,7 @@ class Tests_Post extends WP_UnitTestCase { $counts = wp_count_posts(); $this->assertTrue( isset( $counts->test ) ); - $this->assertEquals( 0, $counts->test ); + $this->assertSame( 0, $counts->test ); } /** @@ -960,7 +960,7 @@ class Tests_Post extends WP_UnitTestCase { $post = get_post( $post_id ); foreach ( $expected as $field => $value ) { - $this->assertEquals( $value, $post->$field ); + $this->assertSame( $value, $post->$field ); } } @@ -978,8 +978,8 @@ class Tests_Post extends WP_UnitTestCase { ); $post = get_post( $post_id ); - $this->assertEquals( 'open', $post->comment_status ); - $this->assertEquals( 'open', $post->ping_status ); + $this->assertSame( 'open', $post->comment_status ); + $this->assertSame( 'open', $post->ping_status ); } /** @@ -997,8 +997,8 @@ class Tests_Post extends WP_UnitTestCase { ); $post = get_post( $post_id ); - $this->assertEquals( 'closed', $post->comment_status ); - $this->assertEquals( 'closed', $post->ping_status ); + $this->assertSame( 'closed', $post->comment_status ); + $this->assertSame( 'closed', $post->ping_status ); } /** @@ -1018,8 +1018,8 @@ class Tests_Post extends WP_UnitTestCase { ); $post = get_post( $post_id ); - $this->assertEquals( 'open', $post->comment_status ); - $this->assertEquals( 'open', $post->ping_status ); + $this->assertSame( 'open', $post->comment_status ); + $this->assertSame( 'open', $post->ping_status ); _unregister_post_type( $post_type ); } @@ -1040,8 +1040,8 @@ class Tests_Post extends WP_UnitTestCase { ); $post = get_post( $post_id ); - $this->assertEquals( 'closed', $post->comment_status ); - $this->assertEquals( 'closed', $post->ping_status ); + $this->assertSame( 'closed', $post->comment_status ); + $this->assertSame( 'closed', $post->ping_status ); _unregister_post_type( $post_type ); } @@ -1079,8 +1079,8 @@ class Tests_Post extends WP_UnitTestCase { // Make sure it's still sticky. $saved_post = get_post( $post->ID ); $this->assertTrue( is_sticky( $saved_post->ID ) ); - $this->assertEquals( 'Updated', $saved_post->post_title ); - $this->assertEquals( 'Updated', $saved_post->post_content ); + $this->assertSame( 'Updated', $saved_post->post_title ); + $this->assertSame( 'Updated', $saved_post->post_content ); } /** @@ -1120,8 +1120,8 @@ class Tests_Post extends WP_UnitTestCase { // Make sure it's still sticky. $saved_post = get_post( $post->ID ); $this->assertTrue( is_sticky( $saved_post->ID ) ); - $this->assertEquals( 'Updated', $saved_post->post_title ); - $this->assertEquals( 'Updated', $saved_post->post_content ); + $this->assertSame( 'Updated', $saved_post->post_title ); + $this->assertSame( 'Updated', $saved_post->post_content ); } /** @@ -1147,8 +1147,8 @@ class Tests_Post extends WP_UnitTestCase { remove_action( 'post_stuck', array( $a1, 'action' ) ); remove_action( 'post_unstuck', array( $a2, 'action' ) ); - $this->assertEquals( 1, $a1->get_call_count() ); - $this->assertEquals( 1, $a2->get_call_count() ); + $this->assertSame( 1, $a1->get_call_count() ); + $this->assertSame( 1, $a2->get_call_count() ); } /** @@ -1174,7 +1174,7 @@ class Tests_Post extends WP_UnitTestCase { $updated_post = get_post( $post_id ); // Ensure changing the post_title didn't modify the post_name. - $this->assertEquals( 'stuff', $updated_post->post_name ); + $this->assertSame( 'stuff', $updated_post->post_name ); } /** @@ -1212,11 +1212,11 @@ class Tests_Post extends WP_UnitTestCase { $out = get_post( $id ); - $this->assertEquals( $post['post_content'], $out->post_content ); - $this->assertEquals( $post['post_title'], $out->post_title ); + $this->assertSame( $post['post_content'], $out->post_content ); + $this->assertSame( $post['post_title'], $out->post_title ); $this->assertEquals( $post['post_author'], $out->post_author ); - $this->assertEquals( get_date_from_gmt( $post['post_date_gmt'] ), $out->post_date ); - $this->assertEquals( $post['post_date_gmt'], $out->post_date_gmt ); + $this->assertSame( get_date_from_gmt( $post['post_date_gmt'] ), $out->post_date ); + $this->assertSame( $post['post_date_gmt'], $out->post_date_gmt ); } function test_wp_delete_post_reassign_hierarchical_post_type() { @@ -1233,11 +1233,11 @@ class Tests_Post extends WP_UnitTestCase { 'post_parent' => $parent_page_id, ) ); - $this->assertEquals( $parent_page_id, get_post( $page_id )->post_parent ); + $this->assertSame( $parent_page_id, get_post( $page_id )->post_parent ); wp_delete_post( $parent_page_id, true ); - $this->assertEquals( $grandparent_page_id, get_post( $page_id )->post_parent ); + $this->assertSame( $grandparent_page_id, get_post( $page_id )->post_parent ); wp_delete_post( $grandparent_page_id, true ); - $this->assertEquals( 0, get_post( $page_id )->post_parent ); + $this->assertSame( 0, get_post( $page_id )->post_parent ); } /** @@ -1248,7 +1248,7 @@ class Tests_Post extends WP_UnitTestCase { */ function test_wp_insert_post_for_customize_changeset_should_not_drop_post_name() { - $this->assertEquals( 10, has_filter( 'wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data' ) ); + $this->assertSame( 10, has_filter( 'wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data' ) ); $changeset_data = array( 'blogname' => array( @@ -1266,8 +1266,8 @@ class Tests_Post extends WP_UnitTestCase { 'post_content' => wp_json_encode( $changeset_data ), ) ); - $this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected lower-case UUID4 to be inserted.' ); - $this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) ); + $this->assertSame( $uuid, get_post( $post_id )->post_name, 'Expected lower-case UUID4 to be inserted.' ); + $this->assertSame( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) ); $changeset_data['blogname']['value'] = 'Hola Mundo'; wp_update_post( @@ -1277,8 +1277,8 @@ class Tests_Post extends WP_UnitTestCase { 'post_content' => wp_json_encode( $changeset_data ), ) ); - $this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for drafts.' ); - $this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) ); + $this->assertSame( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for drafts.' ); + $this->assertSame( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) ); $changeset_data['blogname']['value'] = 'Hallo Welt'; wp_update_post( @@ -1288,8 +1288,8 @@ class Tests_Post extends WP_UnitTestCase { 'post_content' => wp_json_encode( $changeset_data ), ) ); - $this->assertEquals( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for pending.' ); - $this->assertEquals( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) ); + $this->assertSame( $uuid, get_post( $post_id )->post_name, 'Expected post_name to not have been dropped for pending.' ); + $this->assertSame( $changeset_data, json_decode( get_post( $post_id )->post_content, true ) ); } /** @@ -1310,7 +1310,7 @@ class Tests_Post extends WP_UnitTestCase { ) ); $post = get_post( $post_id ); - $this->assertEquals( 'override-slug-' . $post->post_type, $post->post_name ); + $this->assertSame( 'override-slug-' . $post->post_type, $post->post_name ); remove_filter( 'pre_wp_unique_post_slug', array( $this, 'filter_pre_wp_unique_post_slug' ), 10, 6 ); } @@ -1334,7 +1334,7 @@ class Tests_Post extends WP_UnitTestCase { ); $post = get_post( $post_id ); - self::assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + self::assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); } /** diff --git a/tests/phpunit/tests/post/attachments.php b/tests/phpunit/tests/post/attachments.php index 8acb0b0068..8f75c41b5a 100644 --- a/tests/phpunit/tests/post/attachments.php +++ b/tests/phpunit/tests/post/attachments.php @@ -39,19 +39,19 @@ class Tests_Post_Attachments extends WP_UnitTestCase { // medium, medium_large, and full size will both point to the original. $downsize = image_downsize( $id, 'medium' ); - $this->assertEquals( wp_basename( $upload['file'] ), wp_basename( $downsize[0] ) ); - $this->assertEquals( 50, $downsize[1] ); - $this->assertEquals( 50, $downsize[2] ); + $this->assertSame( wp_basename( $upload['file'] ), wp_basename( $downsize[0] ) ); + $this->assertSame( 50, $downsize[1] ); + $this->assertSame( 50, $downsize[2] ); $downsize = image_downsize( $id, 'medium_large' ); - $this->assertEquals( wp_basename( $upload['file'] ), wp_basename( $downsize[0] ) ); - $this->assertEquals( 50, $downsize[1] ); - $this->assertEquals( 50, $downsize[2] ); + $this->assertSame( wp_basename( $upload['file'] ), wp_basename( $downsize[0] ) ); + $this->assertSame( 50, $downsize[1] ); + $this->assertSame( 50, $downsize[2] ); $downsize = image_downsize( $id, 'full' ); - $this->assertEquals( wp_basename( $upload['file'] ), wp_basename( $downsize[0] ) ); - $this->assertEquals( 50, $downsize[1] ); - $this->assertEquals( 50, $downsize[2] ); + $this->assertSame( wp_basename( $upload['file'] ), wp_basename( $downsize[0] ) ); + $this->assertSame( 50, $downsize[1] ); + $this->assertSame( 50, $downsize[2] ); } function test_insert_image_thumb_only() { @@ -72,7 +72,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { // Intermediate copies should exist: thumbnail only. $thumb = image_get_intermediate_size( $id, 'thumbnail' ); - $this->assertEquals( 'a2-small-150x150.jpg', $thumb['file'] ); + $this->assertSame( 'a2-small-150x150.jpg', $thumb['file'] ); $uploads = wp_upload_dir(); $this->assertTrue( is_file( $uploads['basedir'] . DIRECTORY_SEPARATOR . $thumb['path'] ) ); @@ -81,29 +81,29 @@ class Tests_Post_Attachments extends WP_UnitTestCase { $this->assertFalse( image_get_intermediate_size( $id, 'medium_large' ) ); // The thumb url should point to the thumbnail intermediate. - $this->assertEquals( $thumb['url'], wp_get_attachment_thumb_url( $id ) ); + $this->assertSame( $thumb['url'], wp_get_attachment_thumb_url( $id ) ); // image_downsize() should return the correct images and sizes. $downsize = image_downsize( $id, 'thumbnail' ); - $this->assertEquals( 'a2-small-150x150.jpg', wp_basename( $downsize[0] ) ); - $this->assertEquals( 150, $downsize[1] ); - $this->assertEquals( 150, $downsize[2] ); + $this->assertSame( 'a2-small-150x150.jpg', wp_basename( $downsize[0] ) ); + $this->assertSame( 150, $downsize[1] ); + $this->assertSame( 150, $downsize[2] ); // medium, medium_large, and full will both point to the original. $downsize = image_downsize( $id, 'medium' ); - $this->assertEquals( 'a2-small.jpg', wp_basename( $downsize[0] ) ); - $this->assertEquals( 400, $downsize[1] ); - $this->assertEquals( 300, $downsize[2] ); + $this->assertSame( 'a2-small.jpg', wp_basename( $downsize[0] ) ); + $this->assertSame( 400, $downsize[1] ); + $this->assertSame( 300, $downsize[2] ); $downsize = image_downsize( $id, 'medium_large' ); - $this->assertEquals( 'a2-small.jpg', wp_basename( $downsize[0] ) ); - $this->assertEquals( 400, $downsize[1] ); - $this->assertEquals( 300, $downsize[2] ); + $this->assertSame( 'a2-small.jpg', wp_basename( $downsize[0] ) ); + $this->assertSame( 400, $downsize[1] ); + $this->assertSame( 300, $downsize[2] ); $downsize = image_downsize( $id, 'full' ); - $this->assertEquals( 'a2-small.jpg', wp_basename( $downsize[0] ) ); - $this->assertEquals( 400, $downsize[1] ); - $this->assertEquals( 300, $downsize[2] ); + $this->assertSame( 'a2-small.jpg', wp_basename( $downsize[0] ) ); + $this->assertSame( 400, $downsize[1] ); + $this->assertSame( 300, $downsize[2] ); } function test_insert_image_medium_sizes() { @@ -128,40 +128,40 @@ class Tests_Post_Attachments extends WP_UnitTestCase { // Intermediate copies should exist: thumbnail and medium. $thumb = image_get_intermediate_size( $id, 'thumbnail' ); - $this->assertEquals( '2007-06-17DSC_4173-150x150.jpg', $thumb['file'] ); + $this->assertSame( '2007-06-17DSC_4173-150x150.jpg', $thumb['file'] ); $this->assertTrue( is_file( $uploads['basedir'] . DIRECTORY_SEPARATOR . $thumb['path'] ) ); $medium = image_get_intermediate_size( $id, 'medium' ); - $this->assertEquals( '2007-06-17DSC_4173-400x602.jpg', $medium['file'] ); + $this->assertSame( '2007-06-17DSC_4173-400x602.jpg', $medium['file'] ); $this->assertTrue( is_file( $uploads['basedir'] . DIRECTORY_SEPARATOR . $medium['path'] ) ); $medium_large = image_get_intermediate_size( $id, 'medium_large' ); - $this->assertEquals( '2007-06-17DSC_4173-600x904.jpg', $medium_large['file'] ); + $this->assertSame( '2007-06-17DSC_4173-600x904.jpg', $medium_large['file'] ); $this->assertTrue( is_file( $uploads['basedir'] . DIRECTORY_SEPARATOR . $medium_large['path'] ) ); // The thumb url should point to the thumbnail intermediate. - $this->assertEquals( $thumb['url'], wp_get_attachment_thumb_url( $id ) ); + $this->assertSame( $thumb['url'], wp_get_attachment_thumb_url( $id ) ); // image_downsize() should return the correct images and sizes. $downsize = image_downsize( $id, 'thumbnail' ); - $this->assertEquals( '2007-06-17DSC_4173-150x150.jpg', wp_basename( $downsize[0] ) ); - $this->assertEquals( 150, $downsize[1] ); - $this->assertEquals( 150, $downsize[2] ); + $this->assertSame( '2007-06-17DSC_4173-150x150.jpg', wp_basename( $downsize[0] ) ); + $this->assertSame( 150, $downsize[1] ); + $this->assertSame( 150, $downsize[2] ); $downsize = image_downsize( $id, 'medium' ); - $this->assertEquals( '2007-06-17DSC_4173-400x602.jpg', wp_basename( $downsize[0] ) ); - $this->assertEquals( 400, $downsize[1] ); - $this->assertEquals( 602, $downsize[2] ); + $this->assertSame( '2007-06-17DSC_4173-400x602.jpg', wp_basename( $downsize[0] ) ); + $this->assertSame( 400, $downsize[1] ); + $this->assertSame( 602, $downsize[2] ); $downsize = image_downsize( $id, 'medium_large' ); - $this->assertEquals( '2007-06-17DSC_4173-600x904.jpg', wp_basename( $downsize[0] ) ); - $this->assertEquals( 600, $downsize[1] ); - $this->assertEquals( 904, $downsize[2] ); + $this->assertSame( '2007-06-17DSC_4173-600x904.jpg', wp_basename( $downsize[0] ) ); + $this->assertSame( 600, $downsize[1] ); + $this->assertSame( 904, $downsize[2] ); $downsize = image_downsize( $id, 'full' ); - $this->assertEquals( '2007-06-17DSC_4173.jpg', wp_basename( $downsize[0] ) ); - $this->assertEquals( 680, $downsize[1] ); - $this->assertEquals( 1024, $downsize[2] ); + $this->assertSame( '2007-06-17DSC_4173.jpg', wp_basename( $downsize[0] ) ); + $this->assertSame( 680, $downsize[1] ); + $this->assertSame( 1024, $downsize[2] ); } @@ -187,15 +187,15 @@ class Tests_Post_Attachments extends WP_UnitTestCase { // Check that the file and intermediates exist. $thumb = image_get_intermediate_size( $id, 'thumbnail' ); - $this->assertEquals( '2007-06-17DSC_4173-150x150.jpg', $thumb['file'] ); + $this->assertSame( '2007-06-17DSC_4173-150x150.jpg', $thumb['file'] ); $this->assertTrue( is_file( $uploads['basedir'] . DIRECTORY_SEPARATOR . $thumb['path'] ) ); $medium = image_get_intermediate_size( $id, 'medium' ); - $this->assertEquals( '2007-06-17DSC_4173-400x602.jpg', $medium['file'] ); + $this->assertSame( '2007-06-17DSC_4173-400x602.jpg', $medium['file'] ); $this->assertTrue( is_file( $uploads['basedir'] . DIRECTORY_SEPARATOR . $medium['path'] ) ); $medium_large = image_get_intermediate_size( $id, 'medium_large' ); - $this->assertEquals( '2007-06-17DSC_4173-600x904.jpg', $medium_large['file'] ); + $this->assertSame( '2007-06-17DSC_4173-600x904.jpg', $medium_large['file'] ); $this->assertTrue( is_file( $uploads['basedir'] . DIRECTORY_SEPARATOR . $medium_large['path'] ) ); $meta = wp_get_attachment_metadata( $id ); @@ -255,7 +255,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { wp_update_post( $post ); // Make sure the update didn't remove the attached file. - $this->assertEquals( $attached_file, get_post_meta( $id, '_wp_attached_file', true ) ); + $this->assertSame( $attached_file, get_post_meta( $id, '_wp_attached_file', true ) ); } /** @@ -272,7 +272,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { // Assert that the attachment is an orphan. $attachment = get_post( $attachment_id ); - $this->assertEquals( $attachment->post_parent, 0 ); + $this->assertSame( $attachment->post_parent, 0 ); $post_id = wp_insert_post( array( @@ -284,7 +284,7 @@ class Tests_Post_Attachments extends WP_UnitTestCase { // Assert that the attachment has a parent. wp_insert_attachment( $attachment, '', $post_id ); $attachment = get_post( $attachment_id ); - $this->assertEquals( $attachment->post_parent, $post_id ); + $this->assertSame( $attachment->post_parent, $post_id ); } /** diff --git a/tests/phpunit/tests/post/filtering.php b/tests/phpunit/tests/post/filtering.php index 937fdc3196..7a3a0cb5c6 100644 --- a/tests/phpunit/tests/post/filtering.php +++ b/tests/phpunit/tests/post/filtering.php @@ -36,7 +36,7 @@ EOF; $id = self::factory()->post->create( array( 'post_content' => $content ) ); $post = get_post( $id ); - $this->assertEquals( $expected, $post->post_content ); + $this->assertSame( $expected, $post->post_content ); } // A simple test to make sure unbalanced tags are fixed. @@ -53,7 +53,7 @@ EOF; $id = self::factory()->post->create( array( 'post_content' => $content ) ); $post = get_post( $id ); - $this->assertEquals( $expected, $post->post_content ); + $this->assertSame( $expected, $post->post_content ); } // Test KSES filtering of disallowed attribute. @@ -70,7 +70,7 @@ EOF; $id = self::factory()->post->create( array( 'post_content' => $content ) ); $post = get_post( $id ); - $this->assertEquals( $expected, $post->post_content ); + $this->assertSame( $expected, $post->post_content ); } /** @@ -90,7 +90,7 @@ EOF; $id = self::factory()->post->create( array( 'post_content' => $content ) ); $post = get_post( $id ); - $this->assertEquals( $expected, $post->post_content ); + $this->assertSame( $expected, $post->post_content ); } // Make sure unbalanced tags are untouched when the balance option is off. @@ -110,6 +110,6 @@ EOF; $id = self::factory()->post->create( array( 'post_content' => $content ) ); $post = get_post( $id ); - $this->assertEquals( $content, $post->post_content ); + $this->assertSame( $content, $post->post_content ); } } diff --git a/tests/phpunit/tests/post/formats.php b/tests/phpunit/tests/post/formats.php index f18a821e4d..44cedfc9a6 100644 --- a/tests/phpunit/tests/post/formats.php +++ b/tests/phpunit/tests/post/formats.php @@ -17,20 +17,20 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'aside' ); $this->assertNotWPError( $result ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( 1, count( $result ) ); + $this->assertSame( 1, count( $result ) ); $format = get_post_format( $post_id ); - $this->assertEquals( 'aside', $format ); + $this->assertSame( 'aside', $format ); $result = set_post_format( $post_id, 'standard' ); $this->assertNotWPError( $result ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( 0, count( $result ) ); + $this->assertSame( 0, count( $result ) ); $result = set_post_format( $post_id, '' ); $this->assertNotWPError( $result ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( 0, count( $result ) ); + $this->assertSame( 0, count( $result ) ); } /** @@ -45,7 +45,7 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'aside' ); $this->assertNotWPError( $result ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( 1, count( $result ) ); + $this->assertSame( 1, count( $result ) ); // The format can be set but not retrieved until it is registered. $format = get_post_format( $post_id ); $this->assertFalse( $format ); @@ -53,17 +53,17 @@ class Tests_Post_Formats extends WP_UnitTestCase { add_post_type_support( 'page', 'post-formats' ); // The previous set can now be retrieved. $format = get_post_format( $post_id ); - $this->assertEquals( 'aside', $format ); + $this->assertSame( 'aside', $format ); $result = set_post_format( $post_id, 'standard' ); $this->assertNotWPError( $result ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( 0, count( $result ) ); + $this->assertSame( 0, count( $result ) ); $result = set_post_format( $post_id, '' ); $this->assertNotWPError( $result ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( 0, count( $result ) ); + $this->assertSame( 0, count( $result ) ); remove_post_type_support( 'page', 'post-formats' ); } @@ -77,13 +77,13 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'aside' ); $this->assertNotWPError( $result ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( 1, count( $result ) ); + $this->assertSame( 1, count( $result ) ); $this->assertTrue( has_post_format( 'aside', $post_id ) ); $result = set_post_format( $post_id, 'standard' ); $this->assertNotWPError( $result ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( 0, count( $result ) ); + $this->assertSame( 0, count( $result ) ); // Standard is a special case. It shows as false when set. $this->assertFalse( has_post_format( 'standard', $post_id ) ); @@ -113,47 +113,47 @@ $commentary DATA; $link_post_id = self::factory()->post->create( array( 'post_content' => $link ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $link_post_id ) ); - $this->assertEquals( false, $content_link ); + $this->assertFalse( $content_link ); $link_with_post_id = self::factory()->post->create( array( 'post_content' => $link_with_commentary ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) ); - $this->assertEquals( false, $content_link ); + $this->assertFalse( $content_link ); $content_link = get_url_in_content( get_post_field( 'post_content', $link_post_id ) ); - $this->assertEquals( false, $content_link ); + $this->assertFalse( $content_link ); $content_link = get_url_in_content( get_post_field( 'post_content', $link_with_post_id ) ); - $this->assertEquals( false, $content_link ); + $this->assertFalse( $content_link ); $empty_post_id = self::factory()->post->create( array( 'post_content' => '' ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) ); - $this->assertEquals( false, $content_link ); + $this->assertFalse( $content_link ); $comm_post_id = self::factory()->post->create( array( 'post_content' => $commentary ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) ); - $this->assertEquals( false, $content_link ); + $this->assertFalse( $content_link ); // Now with an href. $href_post_id = self::factory()->post->create( array( 'post_content' => $href ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $href_post_id ) ); - $this->assertEquals( $link, $content_link ); + $this->assertSame( $link, $content_link ); $href_with_post_id = self::factory()->post->create( array( 'post_content' => $href_with_commentary ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) ); - $this->assertEquals( $link, $content_link ); + $this->assertSame( $link, $content_link ); $content_link = get_url_in_content( get_post_field( 'post_content', $href_post_id ) ); - $this->assertEquals( $link, $content_link ); + $this->assertSame( $link, $content_link ); $content_link = get_url_in_content( get_post_field( 'post_content', $href_with_post_id ) ); - $this->assertEquals( $link, $content_link ); + $this->assertSame( $link, $content_link ); $empty_post_id = self::factory()->post->create( array( 'post_content' => '' ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $empty_post_id ) ); - $this->assertEquals( false, $content_link ); + $this->assertFalse( $content_link ); $comm_post_id = self::factory()->post->create( array( 'post_content' => $commentary ) ); $content_link = get_url_in_content( get_post_field( 'post_content', $comm_post_id ) ); - $this->assertEquals( false, $content_link ); + $this->assertFalse( $content_link ); } } diff --git a/tests/phpunit/tests/post/getLastPostDate.php b/tests/phpunit/tests/post/getLastPostDate.php index 00eb80074c..8941c52827 100644 --- a/tests/phpunit/tests/post/getLastPostDate.php +++ b/tests/phpunit/tests/post/getLastPostDate.php @@ -52,7 +52,7 @@ class Tests_Post_GetLastPostDate extends WP_UnitTestCase { ) ); - $this->assertEquals( $post_post_date_last, get_lastpostdate( 'blog', 'post' ) ); - $this->assertEquals( $book_post_date_last, get_lastpostdate( 'blog', 'book' ) ); + $this->assertSame( $post_post_date_last, get_lastpostdate( 'blog', 'post' ) ); + $this->assertSame( $book_post_date_last, get_lastpostdate( 'blog', 'book' ) ); } } diff --git a/tests/phpunit/tests/post/getLastPostModified.php b/tests/phpunit/tests/post/getLastPostModified.php index 249656da28..45b2cb651d 100644 --- a/tests/phpunit/tests/post/getLastPostModified.php +++ b/tests/phpunit/tests/post/getLastPostModified.php @@ -103,7 +103,7 @@ class Tests_Post_GetLastPostModified extends WP_UnitTestCase { ) ); - $this->assertEquals( $post_post_modified_last, get_lastpostmodified( 'blog', 'post' ) ); - $this->assertEquals( $book_post_modified_last, get_lastpostmodified( 'blog', 'book' ) ); + $this->assertSame( $post_post_modified_last, get_lastpostmodified( 'blog', 'post' ) ); + $this->assertSame( $book_post_modified_last, get_lastpostmodified( 'blog', 'book' ) ); } } diff --git a/tests/phpunit/tests/post/getPageByPath.php b/tests/phpunit/tests/post/getPageByPath.php index 9b288b64f6..f7912b87be 100644 --- a/tests/phpunit/tests/post/getPageByPath.php +++ b/tests/phpunit/tests/post/getPageByPath.php @@ -34,8 +34,8 @@ class Tests_Post_GetPageByPath extends WP_UnitTestCase { $page = get_post( $page->ID ); - $this->assertEquals( 'some-page', $attachment->post_name ); - $this->assertEquals( 'some-page', $page->post_name ); + $this->assertSame( 'some-page', $attachment->post_name ); + $this->assertSame( 'some-page', $page->post_name ); // get_page_by_path() should return a post of the requested type before returning an attachment. $this->assertEquals( $page, get_page_by_path( 'some-page' ) ); diff --git a/tests/phpunit/tests/post/getPageChildren.php b/tests/phpunit/tests/post/getPageChildren.php index 6bd9d453ce..379f72776c 100644 --- a/tests/phpunit/tests/post/getPageChildren.php +++ b/tests/phpunit/tests/post/getPageChildren.php @@ -74,22 +74,22 @@ class Tests_Post_GetPageChildren extends WP_UnitTestCase { public function test_hierarchical_order_should_be_respected_in_results() { $expected = array( 100, 101, 103, 102, 106, 107, 108, 105 ); $actual = get_page_children( 0, $this->pages ); - $this->assertEquals( $expected, wp_list_pluck( $actual, 'ID' ) ); + $this->assertSame( $expected, wp_list_pluck( $actual, 'ID' ) ); } public function test_not_all_pages_should_be_returned_when_page_id_is_in_the_middle_of_the_tree() { $expected = array( 106, 107, 108 ); $actual = get_page_children( 102, $this->pages ); - $this->assertEquals( $expected, wp_list_pluck( $actual, 'ID' ) ); + $this->assertSame( $expected, wp_list_pluck( $actual, 'ID' ) ); } public function test_page_id_that_is_a_leaf_should_return_empty_array() { $actual = get_page_children( 103, $this->pages ); - $this->assertEquals( array(), $actual ); + $this->assertSame( array(), $actual ); } public function test_nonzero_page_id_not_matching_any_actual_post_id_should_return_empty_array() { $actual = get_page_children( 200, $this->pages ); - $this->assertEquals( array(), $actual ); + $this->assertSame( array(), $actual ); } } diff --git a/tests/phpunit/tests/post/getPageUri.php b/tests/phpunit/tests/post/getPageUri.php index 0c302914e6..5e33944c09 100644 --- a/tests/phpunit/tests/post/getPageUri.php +++ b/tests/phpunit/tests/post/getPageUri.php @@ -16,7 +16,7 @@ class Tests_Post_getPageUri extends WP_UnitTestCase { unset( $post_array->ancestors ); // Dummy assertion. If this test fails, it will actually error out on an E_WARNING. - $this->assertEquals( 'get-page-uri-post-name', get_page_uri( $post_array ) ); + $this->assertSame( 'get-page-uri-post-name', get_page_uri( $post_array ) ); } /** @@ -41,14 +41,14 @@ class Tests_Post_getPageUri extends WP_UnitTestCase { ); // Check the parent for good measure. - $this->assertEquals( 'parent', get_page_uri( $parent_id ) ); + $this->assertSame( 'parent', get_page_uri( $parent_id ) ); // Try the child normally. - $this->assertEquals( 'parent/child', get_page_uri( $child_id ) ); + $this->assertSame( 'parent/child', get_page_uri( $child_id ) ); // Now delete the parent from the database and check. wp_delete_post( $parent_id, true ); - $this->assertEquals( 'child', get_page_uri( $child_id ) ); + $this->assertSame( 'child', get_page_uri( $child_id ) ); } /** @@ -71,7 +71,7 @@ class Tests_Post_getPageUri extends WP_UnitTestCase { ) ); - $this->assertEquals( 'child', get_page_uri( $child_id ) ); + $this->assertSame( 'child', get_page_uri( $child_id ) ); } /** @@ -86,6 +86,6 @@ class Tests_Post_getPageUri extends WP_UnitTestCase { ); $post = get_post( $post_id ); $this->go_to( get_permalink( $post_id ) ); - $this->assertEquals( 'blood-orange-announces-summer-tour-dates', get_page_uri() ); + $this->assertSame( 'blood-orange-announces-summer-tour-dates', get_page_uri() ); } } diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php index e9e1126259..c85ead1685 100644 --- a/tests/phpunit/tests/post/getPages.php +++ b/tests/phpunit/tests/post/getPages.php @@ -20,7 +20,7 @@ class Tests_Post_getPages extends WP_UnitTestCase { $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) ); $pages = get_pages(); - $this->assertEquals( 3, count( $pages ) ); + $this->assertSame( 3, count( $pages ) ); $time1 = wp_cache_get( 'last_changed', 'posts' ); $this->assertNotEmpty( $time1 ); $num_queries = $wpdb->num_queries; @@ -30,9 +30,9 @@ class Tests_Post_getPages extends WP_UnitTestCase { // Again. num_queries and last_changed should remain the same. $pages = get_pages(); - $this->assertEquals( 3, count( $pages ) ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( 3, count( $pages ) ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); foreach ( $pages as $page ) { $this->assertInstanceOf( 'WP_Post', $page ); } @@ -40,9 +40,9 @@ class Tests_Post_getPages extends WP_UnitTestCase { // Again with different args. last_changed should not increment because of // different args to get_pages(). num_queries should bump by 1. $pages = get_pages( array( 'number' => 2 ) ); - $this->assertEquals( 2, count( $pages ) ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( 2, count( $pages ) ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); foreach ( $pages as $page ) { $this->assertInstanceOf( 'WP_Post', $page ); } @@ -51,18 +51,18 @@ class Tests_Post_getPages extends WP_UnitTestCase { // Again. num_queries and last_changed should remain the same. $pages = get_pages( array( 'number' => 2 ) ); - $this->assertEquals( 2, count( $pages ) ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( 2, count( $pages ) ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); foreach ( $pages as $page ) { $this->assertInstanceOf( 'WP_Post', $page ); } // Do the first query again. The interim queries should not affect it. $pages = get_pages(); - $this->assertEquals( 3, count( $pages ) ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( 3, count( $pages ) ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); foreach ( $pages as $page ) { $this->assertInstanceOf( 'WP_Post', $page ); } @@ -75,9 +75,9 @@ class Tests_Post_getPages extends WP_UnitTestCase { // last_changed bumped so num_queries should increment. $pages = get_pages( array( 'number' => 2 ) ); - $this->assertEquals( 2, count( $pages ) ); - $this->assertEquals( $time2, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( 2, count( $pages ) ); + $this->assertSame( $time2, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); foreach ( $pages as $page ) { $this->assertInstanceOf( 'WP_Post', $page ); } @@ -95,9 +95,9 @@ class Tests_Post_getPages extends WP_UnitTestCase { // num_queries should bump after wp_delete_post() bumps last_changed. $pages = get_pages(); - $this->assertEquals( 2, count( $pages ) ); - $this->assertEquals( $last_changed, wp_cache_get( 'last_changed', 'posts' ) ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( 2, count( $pages ) ); + $this->assertSame( $last_changed, wp_cache_get( 'last_changed', 'posts' ) ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); foreach ( $pages as $page ) { $this->assertInstanceOf( 'WP_Post', $page ); } @@ -259,7 +259,7 @@ class Tests_Post_getPages extends WP_UnitTestCase { add_post_meta( $posts[1], 'some-meta-key', '' ); add_post_meta( $posts[2], 'some-meta-key', '1' ); - $this->assertEquals( + $this->assertSame( 1, count( get_pages( @@ -270,7 +270,7 @@ class Tests_Post_getPages extends WP_UnitTestCase { ) ) ); - $this->assertEquals( + $this->assertSame( 1, count( get_pages( @@ -281,7 +281,7 @@ class Tests_Post_getPages extends WP_UnitTestCase { ) ) ); - $this->assertEquals( 3, count( get_pages( array( 'meta_key' => 'some-meta-key' ) ) ) ); + $this->assertSame( 3, count( get_pages( array( 'meta_key' => 'some-meta-key' ) ) ) ); } /** @@ -302,12 +302,12 @@ class Tests_Post_getPages extends WP_UnitTestCase { $include = get_pages( array( 'include' => $inc ) ); $inc_result = wp_list_pluck( $include, 'ID' ); sort( $inc_result ); - $this->assertEquals( $inc, $inc_result ); + $this->assertSame( $inc, $inc_result ); $exclude = get_pages( array( 'exclude' => $exc ) ); $exc_result = wp_list_pluck( $exclude, 'ID' ); sort( $exc_result ); - $this->assertEquals( $inc, $exc_result ); + $this->assertSame( $inc, $exc_result ); } /** @@ -376,7 +376,7 @@ class Tests_Post_getPages extends WP_UnitTestCase { preg_match_all( '#<option#', wp_dropdown_pages( 'echo=0' ), $matches ); - $this->assertEquals( 5, count( $matches[0] ) ); + $this->assertSame( 5, count( $matches[0] ) ); } /** @@ -637,7 +637,7 @@ class Tests_Post_getPages extends WP_UnitTestCase { $this->go_to( "/?p=$post_id&post_type=$type" ); - $this->assertEquals( $post_id, get_queried_object_id() ); + $this->assertSame( $post_id, get_queried_object_id() ); $output = wp_list_pages( array( @@ -648,9 +648,9 @@ class Tests_Post_getPages extends WP_UnitTestCase { ); $this->assertNotEmpty( $output ); - $this->assertEquals( 2, substr_count( $output, 'class="page_item ' ) ); + $this->assertSame( 2, substr_count( $output, 'class="page_item ' ) ); $this->assertContains( 'current_page_item', $output ); - $this->assertEquals( 1, substr_count( $output, 'current_page_item' ) ); + $this->assertSame( 1, substr_count( $output, 'current_page_item' ) ); _unregister_post_type( $type ); } @@ -715,12 +715,12 @@ class Tests_Post_getPages extends WP_UnitTestCase { $pages = get_pages(); // Database gets queried. - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); $num_queries = $wpdb->num_queries; $pages = get_pages(); // Database should not get queried. - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); } } diff --git a/tests/phpunit/tests/post/getPostClass.php b/tests/phpunit/tests/post/getPostClass.php index 12205f0506..03ebac49df 100644 --- a/tests/phpunit/tests/post/getPostClass.php +++ b/tests/phpunit/tests/post/getPostClass.php @@ -48,9 +48,9 @@ class Tests_Post_GetPostClass extends WP_UnitTestCase { * @ticket 22271 */ public function test_with_custom_classes_and_no_post() { - $this->assertEquals( array(), get_post_class( '', null ) ); - $this->assertEquals( array( 'foo' ), get_post_class( 'foo', null ) ); - $this->assertEquals( array( 'foo', 'bar' ), get_post_class( array( 'foo', 'bar' ), null ) ); + $this->assertSame( array(), get_post_class( '', null ) ); + $this->assertSame( array( 'foo' ), get_post_class( 'foo', null ) ); + $this->assertSame( array( 'foo', 'bar' ), get_post_class( array( 'foo', 'bar' ), null ) ); } /** diff --git a/tests/phpunit/tests/post/listPages.php b/tests/phpunit/tests/post/listPages.php index f5bee299a3..ba9562261c 100644 --- a/tests/phpunit/tests/post/listPages.php +++ b/tests/phpunit/tests/post/listPages.php @@ -143,7 +143,7 @@ class Tests_List_Pages extends WP_UnitTestCase { </li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_depth() { @@ -157,7 +157,7 @@ class Tests_List_Pages extends WP_UnitTestCase { <li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a></li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_show_date() { @@ -173,7 +173,7 @@ class Tests_List_Pages extends WP_UnitTestCase { <li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a> ' . $date . '</li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_date_format() { @@ -207,7 +207,7 @@ class Tests_List_Pages extends WP_UnitTestCase { </li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_child_of() { @@ -221,7 +221,7 @@ class Tests_List_Pages extends WP_UnitTestCase { <li class="page_item page-item-' . self::$children[ self::$parent_2 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][2] ) . '">Child 3</a></li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_exclude() { @@ -249,7 +249,7 @@ class Tests_List_Pages extends WP_UnitTestCase { <li class="page_item page-item-' . self::$children[ self::$parent_2 ][2] . '"><a href="' . get_permalink( self::$children[ self::$parent_2 ][2] ) . '">Child 3</a></li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_title_li() { @@ -264,7 +264,7 @@ class Tests_List_Pages extends WP_UnitTestCase { <li class="page_item page-item-' . self::$parent_3 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a></li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_echo() { @@ -291,7 +291,7 @@ class Tests_List_Pages extends WP_UnitTestCase { $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_3 . '"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a></li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_number() { @@ -304,7 +304,7 @@ class Tests_List_Pages extends WP_UnitTestCase { $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . '"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a></li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_sort_column() { @@ -320,7 +320,7 @@ class Tests_List_Pages extends WP_UnitTestCase { <li class="page_item page-item-' . self::$parent_2 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_2 ) . '">Parent 2</a></li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_link_before() { @@ -352,7 +352,7 @@ class Tests_List_Pages extends WP_UnitTestCase { </li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_link_after() { @@ -384,7 +384,7 @@ class Tests_List_Pages extends WP_UnitTestCase { </li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } @@ -398,7 +398,7 @@ class Tests_List_Pages extends WP_UnitTestCase { <li class="page_item page-item-' . self::$parent_3 . '"><a href="' . get_permalink( self::$parent_3 ) . '">Parent 3</a></li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_exclude_tree() { @@ -416,7 +416,7 @@ class Tests_List_Pages extends WP_UnitTestCase { </li> </ul></li>'; - $this->assertEqualsIgnoreEOL( $expected, wp_list_pages( $args ) ); + $this->assertSameIgnoreEOL( $expected, wp_list_pages( $args ) ); } function test_wp_list_pages_discarded_whitespace() { @@ -446,6 +446,6 @@ class Tests_List_Pages extends WP_UnitTestCase { </ul></li>'; $expected = str_replace( array( "\r\n", "\n", "\t" ), '', $expected ); - $this->assertEquals( $expected, wp_list_pages( $args ) ); + $this->assertSame( $expected, wp_list_pages( $args ) ); } } diff --git a/tests/phpunit/tests/post/meta.php b/tests/phpunit/tests/post/meta.php index 8876ce5cb0..369deef954 100644 --- a/tests/phpunit/tests/post/meta.php +++ b/tests/phpunit/tests/post/meta.php @@ -52,8 +52,8 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertFalse( add_post_meta( self::$post_id, 'unique', 'another value', true ) ); // Check it exists. - $this->assertEquals( 'value', get_post_meta( self::$post_id, 'unique', true ) ); - $this->assertEquals( array( 'value' ), get_post_meta( self::$post_id, 'unique', false ) ); + $this->assertSame( 'value', get_post_meta( self::$post_id, 'unique', true ) ); + $this->assertSame( array( 'value' ), get_post_meta( self::$post_id, 'unique', false ) ); // Fail to delete the wrong value. $this->assertFalse( delete_post_meta( self::$post_id, 'unique', 'wrong value' ) ); @@ -62,8 +62,8 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertTrue( delete_post_meta( self::$post_id, 'unique', 'value' ) ); // Check it is deleted. - $this->assertEquals( '', get_post_meta( self::$post_id, 'unique', true ) ); - $this->assertEquals( array(), get_post_meta( self::$post_id, 'unique', false ) ); + $this->assertSame( '', get_post_meta( self::$post_id, 'unique', true ) ); + $this->assertSame( array(), get_post_meta( self::$post_id, 'unique', false ) ); } @@ -73,8 +73,8 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique', 'another value' ) ); // Check they exist. - $this->assertEquals( 'value', get_post_meta( self::$post_id, 'nonunique', true ) ); - $this->assertEquals( array( 'value', 'another value' ), get_post_meta( self::$post_id, 'nonunique', false ) ); + $this->assertSame( 'value', get_post_meta( self::$post_id, 'nonunique', true ) ); + $this->assertSame( array( 'value', 'another value' ), get_post_meta( self::$post_id, 'nonunique', false ) ); // Fail to delete the wrong value. $this->assertFalse( delete_post_meta( self::$post_id, 'nonunique', 'wrong value' ) ); @@ -83,8 +83,8 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertTrue( delete_post_meta( self::$post_id, 'nonunique', 'value' ) ); // Check the remainder exists. - $this->assertEquals( 'another value', get_post_meta( self::$post_id, 'nonunique', true ) ); - $this->assertEquals( array( 'another value' ), get_post_meta( self::$post_id, 'nonunique', false ) ); + $this->assertSame( 'another value', get_post_meta( self::$post_id, 'nonunique', true ) ); + $this->assertSame( array( 'another value' ), get_post_meta( self::$post_id, 'nonunique', false ) ); // Add a third one. $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique', 'someother value' ) ); @@ -98,7 +98,7 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertTrue( in_array( get_post_meta( self::$post_id, 'nonunique', true ), $expected, true ) ); $actual = get_post_meta( self::$post_id, 'nonunique', false ); sort( $actual ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); // Delete the lot. $this->assertTrue( delete_post_meta_by_key( 'nonunique' ) ); @@ -113,10 +113,10 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique_update', 'another value' ) ); // Check they exist. - $this->assertEquals( 'value', get_post_meta( self::$post_id, 'unique_update', true ) ); - $this->assertEquals( array( 'value' ), get_post_meta( self::$post_id, 'unique_update', false ) ); - $this->assertEquals( 'value', get_post_meta( self::$post_id, 'nonunique_update', true ) ); - $this->assertEquals( array( 'value', 'another value' ), get_post_meta( self::$post_id, 'nonunique_update', false ) ); + $this->assertSame( 'value', get_post_meta( self::$post_id, 'unique_update', true ) ); + $this->assertSame( array( 'value' ), get_post_meta( self::$post_id, 'unique_update', false ) ); + $this->assertSame( 'value', get_post_meta( self::$post_id, 'nonunique_update', true ) ); + $this->assertSame( array( 'value', 'another value' ), get_post_meta( self::$post_id, 'nonunique_update', false ) ); // Update them. $this->assertTrue( update_post_meta( self::$post_id, 'unique_update', 'new', 'value' ) ); @@ -124,10 +124,10 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertTrue( update_post_meta( self::$post_id, 'nonunique_update', 'another new', 'another value' ) ); // Check they updated. - $this->assertEquals( 'new', get_post_meta( self::$post_id, 'unique_update', true ) ); - $this->assertEquals( array( 'new' ), get_post_meta( self::$post_id, 'unique_update', false ) ); - $this->assertEquals( 'new', get_post_meta( self::$post_id, 'nonunique_update', true ) ); - $this->assertEquals( array( 'new', 'another new' ), get_post_meta( self::$post_id, 'nonunique_update', false ) ); + $this->assertSame( 'new', get_post_meta( self::$post_id, 'unique_update', true ) ); + $this->assertSame( array( 'new' ), get_post_meta( self::$post_id, 'unique_update', false ) ); + $this->assertSame( 'new', get_post_meta( self::$post_id, 'nonunique_update', true ) ); + $this->assertSame( array( 'new', 'another new' ), get_post_meta( self::$post_id, 'nonunique_update', false ) ); } @@ -137,14 +137,14 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertInternalType( 'integer', add_post_meta( self::$post_id_2, 'unique_delete', 'value', true ) ); // Check they exist. - $this->assertEquals( 'value', get_post_meta( self::$post_id, 'unique_delete', true ) ); - $this->assertEquals( 'value', get_post_meta( self::$post_id_2, 'unique_delete', true ) ); + $this->assertSame( 'value', get_post_meta( self::$post_id, 'unique_delete', true ) ); + $this->assertSame( 'value', get_post_meta( self::$post_id_2, 'unique_delete', true ) ); // Delete one of them. $this->assertTrue( delete_post_meta( self::$post_id, 'unique_delete', 'value' ) ); // Check the other still exists. - $this->assertEquals( 'value', get_post_meta( self::$post_id_2, 'unique_delete', true ) ); + $this->assertSame( 'value', get_post_meta( self::$post_id_2, 'unique_delete', true ) ); } @@ -154,15 +154,15 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertInternalType( 'integer', add_post_meta( self::$post_id_2, 'unique_delete_by_key', 'value', true ) ); // Check they exist. - $this->assertEquals( 'value', get_post_meta( self::$post_id, 'unique_delete_by_key', true ) ); - $this->assertEquals( 'value', get_post_meta( self::$post_id_2, 'unique_delete_by_key', true ) ); + $this->assertSame( 'value', get_post_meta( self::$post_id, 'unique_delete_by_key', true ) ); + $this->assertSame( 'value', get_post_meta( self::$post_id_2, 'unique_delete_by_key', true ) ); // Delete one of them. $this->assertTrue( delete_post_meta_by_key( 'unique_delete_by_key' ) ); // Check the other still exists. - $this->assertEquals( '', get_post_meta( self::$post_id_2, 'unique_delete_by_key', true ) ); - $this->assertEquals( '', get_post_meta( self::$post_id_2, 'unique_delete_by_key', true ) ); + $this->assertSame( '', get_post_meta( self::$post_id_2, 'unique_delete_by_key', true ) ); + $this->assertSame( '', get_post_meta( self::$post_id_2, 'unique_delete_by_key', true ) ); } function test_get_post_meta_by_id() { @@ -204,10 +204,10 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertInternalType( 'integer', $mid3 = add_post_meta( self::$post_id, 'nonunique_update', 'another value' ) ); // Check they exist. - $this->assertEquals( 'value', get_post_meta( self::$post_id, 'unique_update', true ) ); - $this->assertEquals( array( 'value' ), get_post_meta( self::$post_id, 'unique_update', false ) ); - $this->assertEquals( 'value', get_post_meta( self::$post_id, 'nonunique_update', true ) ); - $this->assertEquals( array( 'value', 'another value' ), get_post_meta( self::$post_id, 'nonunique_update', false ) ); + $this->assertSame( 'value', get_post_meta( self::$post_id, 'unique_update', true ) ); + $this->assertSame( array( 'value' ), get_post_meta( self::$post_id, 'unique_update', false ) ); + $this->assertSame( 'value', get_post_meta( self::$post_id, 'nonunique_update', true ) ); + $this->assertSame( array( 'value', 'another value' ), get_post_meta( self::$post_id, 'nonunique_update', false ) ); // Update them. $this->assertTrue( update_meta( $mid1, 'unique_update', 'new' ) ); @@ -215,16 +215,16 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertTrue( update_meta( $mid3, 'nonunique_update', 'another new' ) ); // Check they updated. - $this->assertEquals( 'new', get_post_meta( self::$post_id, 'unique_update', true ) ); - $this->assertEquals( array( 'new' ), get_post_meta( self::$post_id, 'unique_update', false ) ); - $this->assertEquals( 'new', get_post_meta( self::$post_id, 'nonunique_update', true ) ); - $this->assertEquals( array( 'new', 'another new' ), get_post_meta( self::$post_id, 'nonunique_update', false ) ); + $this->assertSame( 'new', get_post_meta( self::$post_id, 'unique_update', true ) ); + $this->assertSame( array( 'new' ), get_post_meta( self::$post_id, 'unique_update', false ) ); + $this->assertSame( 'new', get_post_meta( self::$post_id, 'nonunique_update', true ) ); + $this->assertSame( array( 'new', 'another new' ), get_post_meta( self::$post_id, 'nonunique_update', false ) ); // Slashed update. $data = "'quote and \slash"; $this->assertTrue( update_meta( $mid1, 'unique_update', addslashes( $data ) ) ); $meta = get_metadata_by_mid( 'post', $mid1 ); - $this->assertEquals( $data, $meta->meta_value ); + $this->assertSame( $data, $meta->meta_value ); } /** @@ -263,9 +263,9 @@ class Tests_Post_Meta extends WP_UnitTestCase { // Reset global so subsequent data tests do not get polluted. $GLOBALS['wp_meta_keys'] = array(); - $this->assertEquals( 'post', $this->last_register_meta_call['object_type'] ); - $this->assertEquals( $meta_key, $this->last_register_meta_call['meta_key'] ); - $this->assertEquals( $args, $this->last_register_meta_call['args'] ); + $this->assertSame( 'post', $this->last_register_meta_call['object_type'] ); + $this->assertSame( $meta_key, $this->last_register_meta_call['meta_key'] ); + $this->assertSame( $args, $this->last_register_meta_call['args'] ); } public function data_register_post_meta() { diff --git a/tests/phpunit/tests/post/nav-menu.php b/tests/phpunit/tests/post/nav-menu.php index 641b423cc1..cc80e85cdf 100644 --- a/tests/phpunit/tests/post/nav-menu.php +++ b/tests/phpunit/tests/post/nav-menu.php @@ -40,7 +40,7 @@ class Test_Nav_Menus extends WP_UnitTestCase { ) ); - $this->assertEquals( 0, strpos( $menu, '<ul' ) ); + $this->assertSame( 0, strpos( $menu, '<ul' ) ); } function test_wp_get_associated_nav_menu_items() { @@ -156,7 +156,7 @@ class Test_Nav_Menus extends WP_UnitTestCase { // Confirm it saved properly. $custom_item = wp_setup_nav_menu_item( get_post( $custom_item_id ) ); - $this->assertEquals( 'Wordpress.org', $custom_item->title ); + $this->assertSame( 'Wordpress.org', $custom_item->title ); // Update the orphan with an associated nav menu. wp_update_nav_menu_item( @@ -169,7 +169,7 @@ class Test_Nav_Menus extends WP_UnitTestCase { $menu_items = wp_get_nav_menu_items( $this->menu_id ); $custom_item = wp_filter_object_list( $menu_items, array( 'db_id' => $custom_item_id ) ); $custom_item = array_pop( $custom_item ); - $this->assertEquals( 'WordPress.org', $custom_item->title ); + $this->assertSame( 'WordPress.org', $custom_item->title ); } @@ -218,7 +218,7 @@ class Test_Nav_Menus extends WP_UnitTestCase { $locations['primary'] = $menu_obj->term_id; set_theme_mod( 'nav_menu_locations', $locations ); - $this->assertEquals( 'My Menu', wp_get_nav_menu_name( 'primary' ) ); + $this->assertSame( 'My Menu', wp_get_nav_menu_name( 'primary' ) ); } /** @@ -247,7 +247,7 @@ class Test_Nav_Menus extends WP_UnitTestCase { // And this is what we got when calling wp_get_nav_menus(). $nav_menus_names = wp_list_pluck( wp_get_nav_menus(), 'name' ); - $this->assertEquals( $nav_menus_names, $expected_nav_menus_names ); + $this->assertSame( $nav_menus_names, $expected_nav_menus_names ); } /** @@ -279,8 +279,8 @@ class Test_Nav_Menus extends WP_UnitTestCase { ); $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); - $this->assertEquals( $post_type_slug, $post_type_archive_item->title ); - $this->assertEquals( $post_type_description, $post_type_archive_item->description ); + $this->assertSame( $post_type_slug, $post_type_archive_item->title ); + $this->assertSame( $post_type_description, $post_type_archive_item->description ); } /** @@ -310,8 +310,8 @@ class Test_Nav_Menus extends WP_UnitTestCase { ); $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); - $this->assertEquals( $post_type_slug, $post_type_archive_item->title ); - $this->assertEquals( $post_type_description, $post_type_archive_item->description ); // Fail! + $this->assertSame( $post_type_slug, $post_type_archive_item->title ); + $this->assertSame( $post_type_description, $post_type_archive_item->description ); // Fail! } /** @@ -345,8 +345,8 @@ class Test_Nav_Menus extends WP_UnitTestCase { ); $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); - $this->assertEquals( $post_type_slug, $post_type_archive_item->title ); - $this->assertEquals( $menu_item_description, $post_type_archive_item->description ); + $this->assertSame( $post_type_slug, $post_type_archive_item->title ); + $this->assertSame( $menu_item_description, $post_type_archive_item->description ); } /** @@ -723,13 +723,13 @@ class Test_Nav_Menus extends WP_UnitTestCase { 'data' => $data, ) ); - $this->assertEquals( 'auto-draft', get_post_status( $auto_draft_post_id ) ); - $this->assertEquals( 'draft', get_post_status( $draft_post_id ) ); - $this->assertEquals( 'private', get_post_status( $private_post_id ) ); + $this->assertSame( 'auto-draft', get_post_status( $auto_draft_post_id ) ); + $this->assertSame( 'draft', get_post_status( $draft_post_id ) ); + $this->assertSame( 'private', get_post_status( $private_post_id ) ); wp_delete_post( $wp_customize->changeset_post_id(), true ); $this->assertFalse( get_post_status( $auto_draft_post_id ) ); - $this->assertEquals( 'trash', get_post_status( $draft_post_id ) ); - $this->assertEquals( 'private', get_post_status( $private_post_id ) ); + $this->assertSame( 'trash', get_post_status( $draft_post_id ) ); + $this->assertSame( 'private', get_post_status( $private_post_id ) ); } /** @@ -943,7 +943,7 @@ class Test_Nav_Menus extends WP_UnitTestCase { ); $custom_item = wp_setup_nav_menu_item( get_post( $custom_item_id ) ); - $this->assertEquals( $correct_url, $custom_item->url ); + $this->assertSame( $correct_url, $custom_item->url ); } /** diff --git a/tests/phpunit/tests/post/objects.php b/tests/phpunit/tests/post/objects.php index 5451f73b54..d173d1362a 100644 --- a/tests/phpunit/tests/post/objects.php +++ b/tests/phpunit/tests/post/objects.php @@ -10,28 +10,28 @@ class Tests_Post_Objects extends WP_UnitTestCase { $post = get_post( $id ); $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( $id, $post->ID ); + $this->assertSame( $id, $post->ID ); $this->assertTrue( isset( $post->ancestors ) ); - $this->assertEquals( array(), $post->ancestors ); + $this->assertSame( array(), $post->ancestors ); // Unset and then verify that the magic method fills the property again. unset( $post->ancestors ); - $this->assertEquals( array(), $post->ancestors ); + $this->assertSame( array(), $post->ancestors ); // Magic get should make meta accessible as properties. add_post_meta( $id, 'test', 'test' ); - $this->assertEquals( 'test', get_post_meta( $id, 'test', true ) ); - $this->assertEquals( 'test', $post->test ); + $this->assertSame( 'test', get_post_meta( $id, 'test', true ) ); + $this->assertSame( 'test', $post->test ); // Make sure meta does not eclipse true properties. add_post_meta( $id, 'post_type', 'dummy' ); - $this->assertEquals( 'dummy', get_post_meta( $id, 'post_type', true ) ); - $this->assertEquals( 'post', $post->post_type ); + $this->assertSame( 'dummy', get_post_meta( $id, 'post_type', true ) ); + $this->assertSame( 'post', $post->post_type ); // Excercise the output argument. $post = get_post( $id, ARRAY_A ); $this->assertInternalType( 'array', $post ); - $this->assertEquals( 'post', $post['post_type'] ); + $this->assertSame( 'post', $post['post_type'] ); $post = get_post( $id, ARRAY_N ); $this->assertInternalType( 'array', $post ); @@ -41,13 +41,13 @@ class Tests_Post_Objects extends WP_UnitTestCase { $post = get_post( $id ); $post = get_post( $post, ARRAY_A ); $this->assertInternalType( 'array', $post ); - $this->assertEquals( 'post', $post['post_type'] ); - $this->assertEquals( $id, $post['ID'] ); + $this->assertSame( 'post', $post['post_type'] ); + $this->assertSame( $id, $post['ID'] ); // Should default to OBJECT when given invalid output argument. $post = get_post( $id, 'invalid-output-value' ); $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( $id, $post->ID ); + $this->assertSame( $id, $post->ID ); // Make sure stdClass in $GLOBALS['post'] is handled. $post_std = $post->to_array(); @@ -56,7 +56,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { $GLOBALS['post'] = $post_std; $post = get_post( null ); $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( $id, $post->ID ); + $this->assertSame( $id, $post->ID ); unset( $GLOBALS['post'] ); // If no global post and passing empty value, expect null. @@ -76,26 +76,26 @@ class Tests_Post_Objects extends WP_UnitTestCase { 'post_parent' => $parent_id, ) ); - $this->assertEquals( $updated, $child_id ); + $this->assertSame( $updated, $child_id ); $updated = wp_update_post( array( 'ID' => $grandchild_id, 'post_parent' => $child_id, ) ); - $this->assertEquals( $updated, $grandchild_id ); + $this->assertSame( $updated, $grandchild_id ); - $this->assertEquals( array( $parent_id ), get_post( $child_id )->ancestors ); - $this->assertEquals( array( $parent_id ), get_post_ancestors( $child_id ) ); - $this->assertEquals( array( $parent_id ), get_post_ancestors( get_post( $child_id ) ) ); + $this->assertSame( array( $parent_id ), get_post( $child_id )->ancestors ); + $this->assertSame( array( $parent_id ), get_post_ancestors( $child_id ) ); + $this->assertSame( array( $parent_id ), get_post_ancestors( get_post( $child_id ) ) ); - $this->assertEquals( array( $child_id, $parent_id ), get_post( $grandchild_id )->ancestors ); - $this->assertEquals( array( $child_id, $parent_id ), get_post_ancestors( $grandchild_id ) ); - $this->assertEquals( array( $child_id, $parent_id ), get_post_ancestors( get_post( $grandchild_id ) ) ); + $this->assertSame( array( $child_id, $parent_id ), get_post( $grandchild_id )->ancestors ); + $this->assertSame( array( $child_id, $parent_id ), get_post_ancestors( $grandchild_id ) ); + $this->assertSame( array( $child_id, $parent_id ), get_post_ancestors( get_post( $grandchild_id ) ) ); - $this->assertEquals( array(), get_post( $parent_id )->ancestors ); - $this->assertEquals( array(), get_post_ancestors( $parent_id ) ); - $this->assertEquals( array(), get_post_ancestors( get_post( $parent_id ) ) ); + $this->assertSame( array(), get_post( $parent_id )->ancestors ); + $this->assertSame( array(), get_post_ancestors( $parent_id ) ); + $this->assertSame( array(), get_post_ancestors( get_post( $parent_id ) ) ); } /** @@ -104,7 +104,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { function test_get_post_ancestors_with_falsey_values() { foreach ( array( null, 0, false, '0', '' ) as $post_id ) { $this->assertInternalType( 'array', get_post_ancestors( $post_id ) ); - $this->assertEquals( array(), get_post_ancestors( $post_id ) ); + $this->assertSame( array(), get_post_ancestors( $post_id ) ); } } @@ -113,18 +113,18 @@ class Tests_Post_Objects extends WP_UnitTestCase { $post = get_post( $post_id ); $this->assertInternalType( 'array', $post->post_category ); - $this->assertEquals( 1, count( $post->post_category ) ); + $this->assertSame( 1, count( $post->post_category ) ); $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] ); $term1 = wp_insert_term( 'Foo', 'category' ); $term2 = wp_insert_term( 'Bar', 'category' ); $term3 = wp_insert_term( 'Baz', 'category' ); wp_set_post_categories( $post_id, array( $term1['term_id'], $term2['term_id'], $term3['term_id'] ) ); - $this->assertEquals( 3, count( $post->post_category ) ); - $this->assertEquals( array( $term2['term_id'], $term3['term_id'], $term1['term_id'] ), $post->post_category ); + $this->assertSame( 3, count( $post->post_category ) ); + $this->assertSame( array( $term2['term_id'], $term3['term_id'], $term1['term_id'] ), $post->post_category ); $post = get_post( $post_id, ARRAY_A ); - $this->assertEquals( 3, count( $post['post_category'] ) ); - $this->assertEquals( array( $term2['term_id'], $term3['term_id'], $term1['term_id'] ), $post['post_category'] ); + $this->assertSame( 3, count( $post['post_category'] ) ); + $this->assertSame( array( $term2['term_id'], $term3['term_id'], $term1['term_id'] ), $post['post_category'] ); } function test_get_tags_input_property() { @@ -135,13 +135,13 @@ class Tests_Post_Objects extends WP_UnitTestCase { $this->assertEmpty( $post->tags_input ); wp_set_post_tags( $post_id, 'Foo, Bar, Baz' ); $this->assertInternalType( 'array', $post->tags_input ); - $this->assertEquals( 3, count( $post->tags_input ) ); - $this->assertEquals( array( 'Bar', 'Baz', 'Foo' ), $post->tags_input ); + $this->assertSame( 3, count( $post->tags_input ) ); + $this->assertSame( array( 'Bar', 'Baz', 'Foo' ), $post->tags_input ); $post = get_post( $post_id, ARRAY_A ); $this->assertInternalType( 'array', $post['tags_input'] ); - $this->assertEquals( 3, count( $post['tags_input'] ) ); - $this->assertEquals( array( 'Bar', 'Baz', 'Foo' ), $post['tags_input'] ); + $this->assertSame( 3, count( $post['tags_input'] ) ); + $this->assertSame( array( 'Bar', 'Baz', 'Foo' ), $post['tags_input'] ); } function test_get_page_template_property() { @@ -150,11 +150,11 @@ class Tests_Post_Objects extends WP_UnitTestCase { $this->assertInternalType( 'string', $post->page_template ); $template = get_post_meta( $post->ID, '_wp_page_template', true ); - $this->assertEquals( $template, $post->page_template ); + $this->assertSame( $template, $post->page_template ); update_post_meta( $post_id, '_wp_page_template', 'foo.php' ); $template = get_post_meta( $post->ID, '_wp_page_template', true ); - $this->assertEquals( 'foo.php', $template ); - $this->assertEquals( $template, $post->page_template ); + $this->assertSame( 'foo.php', $template ); + $this->assertSame( $template, $post->page_template ); } function test_get_post_filter() { @@ -166,22 +166,22 @@ class Tests_Post_Objects extends WP_UnitTestCase { ) ); - $this->assertEquals( 'raw', $post->filter ); + $this->assertSame( 'raw', $post->filter ); $this->assertInternalType( 'int', $post->post_parent ); $display_post = get_post( $post, OBJECT, 'js' ); - $this->assertEquals( 'js', $display_post->filter ); - $this->assertEquals( esc_js( "Mary's home" ), $display_post->post_title ); + $this->assertSame( 'js', $display_post->filter ); + $this->assertSame( esc_js( "Mary's home" ), $display_post->post_title ); // Pass a js filtered WP_Post to get_post() with the filter set to raw. // The post should be fetched from cache instead of using the passed object. $raw_post = get_post( $display_post, OBJECT, 'raw' ); - $this->assertEquals( 'raw', $raw_post->filter ); + $this->assertSame( 'raw', $raw_post->filter ); $this->assertNotEquals( esc_js( "Mary's home" ), $raw_post->post_title ); $raw_post->filter( 'js' ); - $this->assertEquals( 'js', $post->filter ); - $this->assertEquals( esc_js( "Mary's home" ), $raw_post->post_title ); + $this->assertSame( 'js', $post->filter ); + $this->assertSame( esc_js( "Mary's home" ), $raw_post->post_title ); } function test_get_post_identity() { @@ -189,8 +189,8 @@ class Tests_Post_Objects extends WP_UnitTestCase { $post->foo = 'bar'; - $this->assertEquals( 'bar', get_post( $post )->foo ); - $this->assertEquals( 'bar', get_post( $post, OBJECT, 'display' )->foo ); + $this->assertSame( 'bar', get_post( $post )->foo ); + $this->assertSame( 'bar', get_post( $post, OBJECT, 'display' )->foo ); } function test_get_post_array() { @@ -198,9 +198,9 @@ class Tests_Post_Objects extends WP_UnitTestCase { $post = get_post( $id, ARRAY_A ); - $this->assertEquals( $id, $post['ID'] ); + $this->assertSame( $id, $post['ID'] ); $this->assertInternalType( 'array', $post['ancestors'] ); - $this->assertEquals( 'raw', $post['filter'] ); + $this->assertSame( 'raw', $post['filter'] ); } /** diff --git a/tests/phpunit/tests/post/output.php b/tests/phpunit/tests/post/output.php index 3e6ae1ea9d..62f5db9ecf 100644 --- a/tests/phpunit/tests/post/output.php +++ b/tests/phpunit/tests/post/output.php @@ -59,7 +59,7 @@ EOF; $this->assertTrue( have_posts() ); $this->assertNull( the_post() ); - $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); + $this->assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); } function test_the_content_shortcode() { @@ -87,7 +87,7 @@ EOF; $this->assertTrue( have_posts() ); $this->assertNull( the_post() ); - $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); + $this->assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); } function test_the_content_shortcode_paragraph() { @@ -125,7 +125,7 @@ EOF; $this->assertTrue( have_posts() ); $this->assertNull( the_post() ); - $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); + $this->assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); } function test_the_content_attribute_filtering() { @@ -147,7 +147,7 @@ EOF; $this->assertTrue( have_posts() ); $this->assertNull( the_post() ); - $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); + $this->assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); kses_remove_filters(); } @@ -171,7 +171,7 @@ EOF; $this->assertTrue( have_posts() ); $this->assertNull( the_post() ); - $this->assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); + $this->assertSame( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) ); kses_remove_filters(); } diff --git a/tests/phpunit/tests/post/query.php b/tests/phpunit/tests/post/query.php index 5f131f5200..46e0ec38cf 100644 --- a/tests/phpunit/tests/post/query.php +++ b/tests/phpunit/tests/post/query.php @@ -35,7 +35,7 @@ class Tests_Post_Query extends WP_UnitTestCase { $this->assertCount( 1, $q->get( 'category__in' ) ); $this->assertNotEmpty( $posts ); - $this->assertEquals( array( $post_id ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $post_id ), wp_list_pluck( $posts, 'ID' ) ); $posts2 = $q->query( array( 'category__and' => array( $term_id, $term_id2 ) ) ); $this->assertNotEmpty( $q->get( 'category__and' ) ); @@ -96,8 +96,8 @@ class Tests_Post_Query extends WP_UnitTestCase { ); // Fourth post added in filter. - $this->assertEquals( 4, count( $query->posts ) ); - $this->assertEquals( 4, $query->post_count ); + $this->assertSame( 4, count( $query->posts ) ); + $this->assertSame( 4, $query->post_count ); foreach ( $query->posts as $post ) { @@ -105,10 +105,10 @@ class Tests_Post_Query extends WP_UnitTestCase { $this->assertTrue( is_a( $post, 'WP_Post' ) ); // Filters are raw. - $this->assertEquals( 'raw', $post->filter ); + $this->assertSame( 'raw', $post->filter ); // Custom data added in the_posts filter is preserved. - $this->assertEquals( array( $post->ID, 'custom data' ), $post->custom_data ); + $this->assertSame( array( $post->ID, 'custom data' ), $post->custom_data ); } remove_filter( 'the_posts', array( $this, 'the_posts_filter' ) ); @@ -613,7 +613,7 @@ class Tests_Post_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( 2, $q->found_posts ); + $this->assertSame( 2, $q->found_posts ); $this->assertEquals( 2, $q->max_num_pages ); } @@ -636,7 +636,7 @@ class Tests_Post_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( 2, $q->found_posts ); + $this->assertSame( 2, $q->found_posts ); $this->assertEquals( 2, $q->max_num_pages ); } @@ -662,7 +662,7 @@ class Tests_Post_Query extends WP_UnitTestCase { remove_filter( 'split_the_query', '__return_true' ); - $this->assertEquals( 2, $q->found_posts ); + $this->assertSame( 2, $q->found_posts ); $this->assertEquals( 2, $q->max_num_pages ); } @@ -689,7 +689,7 @@ class Tests_Post_Query extends WP_UnitTestCase { remove_filter( 'split_the_query', '__return_false' ); - $this->assertEquals( 2, $q->found_posts ); + $this->assertSame( 2, $q->found_posts ); $this->assertEquals( 2, $q->max_num_pages ); } @@ -722,7 +722,7 @@ class Tests_Post_Query extends WP_UnitTestCase { $methd->setAccessible( true ); $methd->invoke( $q, array( 'no_found_rows' => false ), array() ); - $this->assertEquals( $expected, $q->found_posts ); + $this->assertSame( $expected, $q->found_posts ); } /** diff --git a/tests/phpunit/tests/post/revisions.php b/tests/phpunit/tests/post/revisions.php index 525dc2be88..5e028a304b 100644 --- a/tests/phpunit/tests/post/revisions.php +++ b/tests/phpunit/tests/post/revisions.php @@ -60,7 +60,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { $this->assertCount( 2, $revisions ); $lastrevision = end( $revisions ); - $this->assertEquals( 'I cant spel werds.', $lastrevision->post_content ); + $this->assertSame( 'I cant spel werds.', $lastrevision->post_content ); // #16215 $this->assertEquals( self::$author_user_id, $lastrevision->post_author ); @@ -544,7 +544,7 @@ class Tests_Post_Revisions extends WP_UnitTestCase { $revisions = wp_get_post_revisions( $post['ID'] ); - $this->assertEquals( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) ); + $this->assertSame( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) ); } /** @@ -579,6 +579,6 @@ class Tests_Post_Revisions extends WP_UnitTestCase { $revisions = wp_get_post_revisions( $post['ID'] ); - $this->assertEquals( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) ); + $this->assertSame( $revision_ids, array_values( wp_list_pluck( $revisions, 'ID' ) ) ); } } diff --git a/tests/phpunit/tests/post/slashes.php b/tests/phpunit/tests/post/slashes.php index c50abd4267..229ec29aa2 100644 --- a/tests/phpunit/tests/post/slashes.php +++ b/tests/phpunit/tests/post/slashes.php @@ -40,9 +40,9 @@ class Tests_Post_Slashes extends WP_UnitTestCase { $post_id = edit_post(); $post = get_post( $post_id ); - $this->assertEquals( $this->slash_1, $post->post_title ); - $this->assertEquals( $this->slash_5, $post->post_content ); - $this->assertEquals( $this->slash_7, $post->post_excerpt ); + $this->assertSame( $this->slash_1, $post->post_title ); + $this->assertSame( $this->slash_5, $post->post_content ); + $this->assertSame( $this->slash_7, $post->post_excerpt ); $_POST = array(); $_POST['post_ID'] = $id; @@ -55,9 +55,9 @@ class Tests_Post_Slashes extends WP_UnitTestCase { $post_id = edit_post(); $post = get_post( $post_id ); - $this->assertEquals( $this->slash_2, $post->post_title ); - $this->assertEquals( $this->slash_4, $post->post_content ); - $this->assertEquals( $this->slash_6, $post->post_excerpt ); + $this->assertSame( $this->slash_2, $post->post_title ); + $this->assertSame( $this->slash_4, $post->post_content ); + $this->assertSame( $this->slash_6, $post->post_excerpt ); } /** @@ -76,9 +76,9 @@ class Tests_Post_Slashes extends WP_UnitTestCase { ); $post = get_post( $id ); - $this->assertEquals( wp_unslash( $this->slash_1 ), $post->post_title ); - $this->assertEquals( wp_unslash( $this->slash_3 ), $post->post_content ); - $this->assertEquals( wp_unslash( $this->slash_5 ), $post->post_excerpt ); + $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title ); + $this->assertSame( wp_unslash( $this->slash_3 ), $post->post_content ); + $this->assertSame( wp_unslash( $this->slash_5 ), $post->post_excerpt ); $id = wp_insert_post( array( @@ -91,9 +91,9 @@ class Tests_Post_Slashes extends WP_UnitTestCase { ); $post = get_post( $id ); - $this->assertEquals( wp_unslash( $this->slash_2 ), $post->post_title ); - $this->assertEquals( wp_unslash( $this->slash_4 ), $post->post_content ); - $this->assertEquals( wp_unslash( $this->slash_6 ), $post->post_excerpt ); + $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title ); + $this->assertSame( wp_unslash( $this->slash_4 ), $post->post_content ); + $this->assertSame( wp_unslash( $this->slash_6 ), $post->post_excerpt ); } /** @@ -112,9 +112,9 @@ class Tests_Post_Slashes extends WP_UnitTestCase { ); $post = get_post( $id ); - $this->assertEquals( wp_unslash( $this->slash_1 ), $post->post_title ); - $this->assertEquals( wp_unslash( $this->slash_3 ), $post->post_content ); - $this->assertEquals( wp_unslash( $this->slash_5 ), $post->post_excerpt ); + $this->assertSame( wp_unslash( $this->slash_1 ), $post->post_title ); + $this->assertSame( wp_unslash( $this->slash_3 ), $post->post_content ); + $this->assertSame( wp_unslash( $this->slash_5 ), $post->post_excerpt ); wp_update_post( array( @@ -126,9 +126,9 @@ class Tests_Post_Slashes extends WP_UnitTestCase { ); $post = get_post( $id ); - $this->assertEquals( wp_unslash( $this->slash_2 ), $post->post_title ); - $this->assertEquals( wp_unslash( $this->slash_4 ), $post->post_content ); - $this->assertEquals( wp_unslash( $this->slash_6 ), $post->post_excerpt ); + $this->assertSame( wp_unslash( $this->slash_2 ), $post->post_title ); + $this->assertSame( wp_unslash( $this->slash_4 ), $post->post_content ); + $this->assertSame( wp_unslash( $this->slash_6 ), $post->post_excerpt ); } /** @@ -147,17 +147,17 @@ class Tests_Post_Slashes extends WP_UnitTestCase { $post = get_post( $id ); - $this->assertEquals( $this->slash_1, $post->post_title ); - $this->assertEquals( $this->slash_3, $post->post_content ); - $this->assertEquals( $this->slash_5, $post->post_excerpt ); + $this->assertSame( $this->slash_1, $post->post_title ); + $this->assertSame( $this->slash_3, $post->post_content ); + $this->assertSame( $this->slash_5, $post->post_excerpt ); $untrashed = wp_untrash_post( $id ); $this->assertNotEmpty( $untrashed ); $post = get_post( $id ); - $this->assertEquals( $this->slash_1, $post->post_title ); - $this->assertEquals( $this->slash_3, $post->post_content ); - $this->assertEquals( $this->slash_5, $post->post_excerpt ); + $this->assertSame( $this->slash_1, $post->post_title ); + $this->assertSame( $this->slash_3, $post->post_content ); + $this->assertSame( $this->slash_5, $post->post_excerpt ); } } diff --git a/tests/phpunit/tests/post/template.php b/tests/phpunit/tests/post/template.php index 5f9b233067..dad6bf1d11 100644 --- a/tests/phpunit/tests/post/template.php +++ b/tests/phpunit/tests/post/template.php @@ -21,7 +21,7 @@ class Tests_Post_Template extends WP_UnitTestCase { $expected = '<p class="post-nav-links">Pages: <span class="post-page-numbers current" aria-current="page">1</span> ' . $page2 . '2</a> ' . $page3 . '3</a></p>'; $output = wp_link_pages( array( 'echo' => 0 ) ); - $this->assertEquals( $expected, $output ); + $this->assertSame( $expected, $output ); $before_after = " <span class=\"post-page-numbers current\" aria-current=\"page\">1</span> {$page2}2</a> {$page3}3</a>"; $output = wp_link_pages( @@ -32,7 +32,7 @@ class Tests_Post_Template extends WP_UnitTestCase { ) ); - $this->assertEquals( $before_after, $output ); + $this->assertSame( $before_after, $output ); $separator = " <span class=\"post-page-numbers current\" aria-current=\"page\">1</span>{$page2}2</a>{$page3}3</a>"; $output = wp_link_pages( @@ -44,7 +44,7 @@ class Tests_Post_Template extends WP_UnitTestCase { ) ); - $this->assertEquals( $separator, $output ); + $this->assertSame( $separator, $output ); $link = " <span class=\"post-page-numbers current\" aria-current=\"page\"><em>1</em></span>{$page2}<em>2</em></a>{$page3}<em>3</em></a>"; $output = wp_link_pages( @@ -58,7 +58,7 @@ class Tests_Post_Template extends WP_UnitTestCase { ) ); - $this->assertEquals( $link, $output ); + $this->assertSame( $link, $output ); $next = "{$page2}<em>Next page</em></a>"; $output = wp_link_pages( @@ -73,7 +73,7 @@ class Tests_Post_Template extends WP_UnitTestCase { ) ); - $this->assertEquals( $next, $output ); + $this->assertSame( $next, $output ); $GLOBALS['page'] = 2; $next_prev = "{$permalink}<em>Previous page</em></a>{$page3}<em>Next page</em></a>"; @@ -89,7 +89,7 @@ class Tests_Post_Template extends WP_UnitTestCase { ) ); - $this->assertEquals( $next_prev, $output ); + $this->assertSame( $next_prev, $output ); $next_prev_link = "{$permalink}Woo page</a>{$page3}Hoo page</a>"; $output = wp_link_pages( @@ -104,7 +104,7 @@ class Tests_Post_Template extends WP_UnitTestCase { ) ); - $this->assertEquals( $next_prev_link, $output ); + $this->assertSame( $next_prev_link, $output ); $GLOBALS['page'] = 1; $separator = "<p class=\"post-nav-links\">Pages: <span class=\"post-page-numbers current\" aria-current=\"page\">1</span> | {$page2}2</a> | {$page3}3</a></p>"; @@ -115,7 +115,7 @@ class Tests_Post_Template extends WP_UnitTestCase { ) ); - $this->assertEquals( $separator, $output ); + $this->assertSame( $separator, $output ); $pagelink = " <span class=\"post-page-numbers current\" aria-current=\"page\">Page 1</span> | {$page2}Page 2</a> | {$page3}Page 3</a>"; $output = wp_link_pages( @@ -128,7 +128,7 @@ class Tests_Post_Template extends WP_UnitTestCase { ) ); - $this->assertEquals( $pagelink, $output ); + $this->assertSame( $pagelink, $output ); } function test_wp_dropdown_pages() { @@ -164,7 +164,7 @@ class Tests_Post_Template extends WP_UnitTestCase { LINEAGE; $output = wp_dropdown_pages( array( 'echo' => 0 ) ); - $this->assertEqualsIgnoreEOL( $lineage, $output ); + $this->assertSameIgnoreEOL( $lineage, $output ); $depth = <<<DEPTH <select name='page_id' id='page_id'> @@ -179,7 +179,7 @@ DEPTH; 'depth' => 1, ) ); - $this->assertEqualsIgnoreEOL( $depth, $output ); + $this->assertSameIgnoreEOL( $depth, $output ); $option_none = <<<NONE <select name='page_id' id='page_id'> @@ -197,7 +197,7 @@ NONE; 'option_none_value' => 'Woo', ) ); - $this->assertEqualsIgnoreEOL( $option_none, $output ); + $this->assertSameIgnoreEOL( $option_none, $output ); $option_no_change = <<<NO <select name='page_id' id='page_id'> @@ -217,7 +217,7 @@ NO; 'show_option_no_change' => 'Burrito', ) ); - $this->assertEqualsIgnoreEOL( $option_no_change, $output ); + $this->assertSameIgnoreEOL( $option_no_change, $output ); } /** @@ -353,13 +353,13 @@ NO; ) ); - $this->assertEquals( '', get_page_template_slug( $page_id ) ); + $this->assertSame( '', get_page_template_slug( $page_id ) ); update_post_meta( $page_id, '_wp_page_template', 'default' ); - $this->assertEquals( '', get_page_template_slug( $page_id ) ); + $this->assertSame( '', get_page_template_slug( $page_id ) ); update_post_meta( $page_id, '_wp_page_template', 'example.php' ); - $this->assertEquals( 'example.php', get_page_template_slug( $page_id ) ); + $this->assertSame( 'example.php', get_page_template_slug( $page_id ) ); } /** @@ -375,7 +375,7 @@ NO; update_post_meta( $page_id, '_wp_page_template', 'example.php' ); $this->go_to( get_permalink( $page_id ) ); - $this->assertEquals( 'example.php', get_page_template_slug() ); + $this->assertSame( 'example.php', get_page_template_slug() ); } /** @@ -385,14 +385,14 @@ NO; public function test_get_page_template_slug_non_page() { $post_id = self::factory()->post->create(); - $this->assertEquals( '', get_page_template_slug( $post_id ) ); + $this->assertSame( '', get_page_template_slug( $post_id ) ); update_post_meta( $post_id, '_wp_page_template', 'default' ); - $this->assertEquals( '', get_page_template_slug( $post_id ) ); + $this->assertSame( '', get_page_template_slug( $post_id ) ); update_post_meta( $post_id, '_wp_page_template', 'example.php' ); - $this->assertEquals( 'example.php', get_page_template_slug( $post_id ) ); + $this->assertSame( 'example.php', get_page_template_slug( $post_id ) ); } /** @@ -405,7 +405,7 @@ NO; $this->go_to( get_permalink( $post_id ) ); - $this->assertEquals( 'example.php', get_page_template_slug() ); + $this->assertSame( 'example.php', get_page_template_slug() ); } /** diff --git a/tests/phpunit/tests/post/thumbnails.php b/tests/phpunit/tests/post/thumbnails.php index 2c932379ee..36a386d9bd 100644 --- a/tests/phpunit/tests/post/thumbnails.php +++ b/tests/phpunit/tests/post/thumbnails.php @@ -60,12 +60,12 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { set_post_thumbnail( self::$post, self::$attachment_id ); - $this->assertEquals( self::$attachment_id, get_post_thumbnail_id( self::$post ) ); - $this->assertEquals( self::$attachment_id, get_post_thumbnail_id( self::$post->ID ) ); + $this->assertSame( self::$attachment_id, get_post_thumbnail_id( self::$post ) ); + $this->assertSame( self::$attachment_id, get_post_thumbnail_id( self::$post->ID ) ); $GLOBALS['post'] = self::$post; - $this->assertEquals( self::$attachment_id, get_post_thumbnail_id() ); + $this->assertSame( self::$attachment_id, get_post_thumbnail_id() ); } function test_update_post_thumbnail_cache() { @@ -90,7 +90,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { * @ticket 12235 */ function test_get_the_post_thumbnail_caption() { - $this->assertEquals( '', get_the_post_thumbnail_caption() ); + $this->assertSame( '', get_the_post_thumbnail_caption() ); $caption = 'This is a caption.'; @@ -107,7 +107,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { set_post_thumbnail( $post_id, $attachment_id ); - $this->assertEquals( $caption, get_the_post_thumbnail_caption( $post_id ) ); + $this->assertSame( $caption, get_the_post_thumbnail_caption( $post_id ) ); } /** @@ -127,7 +127,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { set_post_thumbnail( $post_id, $attachment_id ); - $this->assertEquals( '', get_the_post_thumbnail_caption( $post_id ) ); + $this->assertSame( '', get_the_post_thumbnail_caption( $post_id ) ); } /** @@ -154,8 +154,8 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { } function test_get_the_post_thumbnail() { - $this->assertEquals( '', get_the_post_thumbnail() ); - $this->assertEquals( '', get_the_post_thumbnail( self::$post ) ); + $this->assertSame( '', get_the_post_thumbnail() ); + $this->assertSame( '', get_the_post_thumbnail( self::$post ) ); set_post_thumbnail( self::$post, self::$attachment_id ); $expected = wp_get_attachment_image( @@ -167,11 +167,11 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { ) ); - $this->assertEquals( $expected, get_the_post_thumbnail( self::$post ) ); + $this->assertSame( $expected, get_the_post_thumbnail( self::$post ) ); $GLOBALS['post'] = self::$post; - $this->assertEquals( $expected, get_the_post_thumbnail() ); + $this->assertSame( $expected, get_the_post_thumbnail() ); } function test_the_post_thumbnail() { @@ -210,11 +210,11 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { set_post_thumbnail( self::$post, self::$attachment_id ); $this->assertFalse( get_the_post_thumbnail_url() ); - $this->assertEquals( wp_get_attachment_url( self::$attachment_id ), get_the_post_thumbnail_url( self::$post ) ); + $this->assertSame( wp_get_attachment_url( self::$attachment_id ), get_the_post_thumbnail_url( self::$post ) ); $GLOBALS['post'] = self::$post; - $this->assertEquals( wp_get_attachment_url( self::$attachment_id ), get_the_post_thumbnail_url() ); + $this->assertSame( wp_get_attachment_url( self::$attachment_id ), get_the_post_thumbnail_url() ); } /** @@ -307,7 +307,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { ); $thumbnail_id = get_post_thumbnail_id( $post_id ); - $this->assertEquals( self::$attachment_id, $thumbnail_id ); + $this->assertSame( self::$attachment_id, $thumbnail_id ); $post_id = wp_insert_post( array( @@ -342,7 +342,7 @@ class Tests_Post_Thumbnail_Template extends WP_UnitTestCase { ); $thumbnail_id = get_post_thumbnail_id( $post_id ); - $this->assertEquals( self::$attachment_id, $thumbnail_id ); + $this->assertSame( self::$attachment_id, $thumbnail_id ); // Images do not support featured images. $post_id = wp_insert_post( diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index 4a74cfefbd..f526d60227 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -30,11 +30,11 @@ class Tests_Post_Types extends WP_UnitTestCase { $pobj = get_post_type_object( 'foo' ); $this->assertInstanceOf( 'WP_Post_Type', $pobj ); - $this->assertEquals( 'foo', $pobj->name ); + $this->assertSame( 'foo', $pobj->name ); // Test some defaults. $this->assertFalse( is_post_type_hierarchical( 'foo' ) ); - $this->assertEquals( array(), get_object_taxonomies( 'foo' ) ); + $this->assertSame( array(), get_object_taxonomies( 'foo' ) ); _unregister_post_type( 'foo' ); } @@ -168,9 +168,9 @@ class Tests_Post_Types extends WP_UnitTestCase { register_post_type( 'bar' ); register_taxonomy_for_object_type( 'post_tag', 'bar' ); - $this->assertEquals( array( 'post_tag' ), get_object_taxonomies( 'bar' ) ); + $this->assertSame( array( 'post_tag' ), get_object_taxonomies( 'bar' ) ); register_taxonomy_for_object_type( 'category', 'bar' ); - $this->assertEquals( array( 'category', 'post_tag' ), get_object_taxonomies( 'bar' ) ); + $this->assertSame( array( 'category', 'post_tag' ), get_object_taxonomies( 'bar' ) ); $this->assertTrue( is_object_in_taxonomy( 'bar', 'post_tag' ) ); $this->assertTrue( is_object_in_taxonomy( 'bar', 'post_tag' ) ); @@ -267,9 +267,9 @@ class Tests_Post_Types extends WP_UnitTestCase { * @ticket 38844 */ public function test_get_post_type_object_includes_menu_icon_for_builtin_post_types() { - $this->assertEquals( 'dashicons-admin-post', get_post_type_object( 'post' )->menu_icon ); - $this->assertEquals( 'dashicons-admin-page', get_post_type_object( 'page' )->menu_icon ); - $this->assertEquals( 'dashicons-admin-media', get_post_type_object( 'attachment' )->menu_icon ); + $this->assertSame( 'dashicons-admin-post', get_post_type_object( 'post' )->menu_icon ); + $this->assertSame( 'dashicons-admin-page', get_post_type_object( 'page' )->menu_icon ); + $this->assertSame( 'dashicons-admin-media', get_post_type_object( 'attachment' )->menu_icon ); } /** diff --git a/tests/phpunit/tests/post/wpInsertPost.php b/tests/phpunit/tests/post/wpInsertPost.php index 649dd55e28..4c9f7a6390 100644 --- a/tests/phpunit/tests/post/wpInsertPost.php +++ b/tests/phpunit/tests/post/wpInsertPost.php @@ -77,7 +77,7 @@ class Tests_WPInsertPost extends WP_UnitTestCase { ) ); wp_trash_post( $trashed_about_page_id ); - $this->assertEquals( 'about__trashed', get_post( $trashed_about_page_id )->post_name ); + $this->assertSame( 'about__trashed', get_post( $trashed_about_page_id )->post_name ); } /** @@ -93,7 +93,7 @@ class Tests_WPInsertPost extends WP_UnitTestCase { ) ); wp_trash_post( $trashed_about_page_id ); - $this->assertEquals( 'foo__trashed__foo__trashed', get_post( $trashed_about_page_id )->post_name ); + $this->assertSame( 'foo__trashed__foo__trashed', get_post( $trashed_about_page_id )->post_name ); } /** @@ -110,7 +110,7 @@ class Tests_WPInsertPost extends WP_UnitTestCase { wp_trash_post( $about_page_id ); wp_untrash_post( $about_page_id ); - $this->assertEquals( 'about', get_post( $about_page_id )->post_name ); + $this->assertSame( 'about', get_post( $about_page_id )->post_name ); } /** @@ -133,8 +133,8 @@ class Tests_WPInsertPost extends WP_UnitTestCase { ) ); - $this->assertEquals( 'about__trashed', get_post( $trashed_about_page_id )->post_name ); - $this->assertEquals( 'about', get_post( $about_page_id )->post_name ); + $this->assertSame( 'about__trashed', get_post( $trashed_about_page_id )->post_name ); + $this->assertSame( 'about', get_post( $about_page_id )->post_name ); } /** @@ -160,8 +160,8 @@ class Tests_WPInsertPost extends WP_UnitTestCase { wp_untrash_post( $about_page_id ); - $this->assertEquals( 'about', get_post( $another_about_page_id )->post_name ); - $this->assertEquals( 'about-2', get_post( $about_page_id )->post_name ); + $this->assertSame( 'about', get_post( $another_about_page_id )->post_name ); + $this->assertSame( 'about-2', get_post( $about_page_id )->post_name ); } /** @@ -316,7 +316,7 @@ class Tests_WPInsertPost extends WP_UnitTestCase { ) ); - $this->assertEquals( 'publish', get_post_status( $post_id ) ); + $this->assertSame( 'publish', get_post_status( $post_id ) ); $post_id = $this->factory()->post->create( array( @@ -325,6 +325,6 @@ class Tests_WPInsertPost extends WP_UnitTestCase { ) ); - $this->assertEquals( 'future', get_post_status( $post_id ) ); + $this->assertSame( 'future', get_post_status( $post_id ) ); } } diff --git a/tests/phpunit/tests/post/wpUniquePostSlug.php b/tests/phpunit/tests/post/wpUniquePostSlug.php index 70b43ee947..45a8cd7e7d 100644 --- a/tests/phpunit/tests/post/wpUniquePostSlug.php +++ b/tests/phpunit/tests/post/wpUniquePostSlug.php @@ -36,7 +36,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { } $post = get_post( $id ); - $this->assertEquals( $outputs[ $k ], urldecode( $post->post_name ) ); + $this->assertSame( $outputs[ $k ], urldecode( $post->post_name ) ); } } @@ -56,11 +56,11 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { $args['post_type'] = 'post-type-2'; $two = self::factory()->post->create( $args ); - $this->assertEquals( 'some-slug', get_post( $one )->post_name ); - $this->assertEquals( 'some-slug', get_post( $two )->post_name ); + $this->assertSame( 'some-slug', get_post( $one )->post_name ); + $this->assertSame( 'some-slug', get_post( $two )->post_name ); - $this->assertEquals( 'some-other-slug', wp_unique_post_slug( 'some-other-slug', $one, 'publish', 'post-type-1', 0 ) ); - $this->assertEquals( 'some-other-slug', wp_unique_post_slug( 'some-other-slug', $one, 'publish', 'post-type-2', 0 ) ); + $this->assertSame( 'some-other-slug', wp_unique_post_slug( 'some-other-slug', $one, 'publish', 'post-type-1', 0 ) ); + $this->assertSame( 'some-other-slug', wp_unique_post_slug( 'some-other-slug', $one, 'publish', 'post-type-2', 0 ) ); _unregister_post_type( 'post-type-1' ); _unregister_post_type( 'post-type-2' ); @@ -81,10 +81,10 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { $args['post_name'] = 'some-slug-2'; $two = self::factory()->post->create( $args ); - $this->assertEquals( 'some-slug', get_post( $one )->post_name ); - $this->assertEquals( 'some-slug-2', get_post( $two )->post_name ); + $this->assertSame( 'some-slug', get_post( $one )->post_name ); + $this->assertSame( 'some-slug-2', get_post( $two )->post_name ); - $this->assertEquals( 'some-slug-3', wp_unique_post_slug( 'some-slug', 0, 'publish', 'post-type-1', 0 ) ); + $this->assertSame( 'some-slug-3', wp_unique_post_slug( 'some-slug', 0, 'publish', 'post-type-1', 0 ) ); _unregister_post_type( 'post-type-1' ); } @@ -117,12 +117,12 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { ); $two = self::factory()->post->create( $args ); - $this->assertEquals( 'some-slug', get_post( $one )->post_name ); - $this->assertEquals( 'image', get_post( $attachment )->post_name ); - $this->assertEquals( 'image-2', get_post( $two )->post_name ); + $this->assertSame( 'some-slug', get_post( $one )->post_name ); + $this->assertSame( 'image', get_post( $attachment )->post_name ); + $this->assertSame( 'image-2', get_post( $two )->post_name ); // 'image' can be a child of image-2. - $this->assertEquals( 'image', wp_unique_post_slug( 'image', 0, 'publish', 'post-type-1', $two ) ); + $this->assertSame( 'image', wp_unique_post_slug( 'image', 0, 'publish', 'post-type-1', $two ) ); _unregister_post_type( 'post-type-1' ); } @@ -190,7 +190,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { ); $found = wp_unique_post_slug( '2015', $p, 'publish', 'post', 0 ); - $this->assertEquals( '2015-2', $found ); + $this->assertSame( '2015-2', $found ); } /** @@ -208,7 +208,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { ); $found = wp_unique_post_slug( '2015', $p, 'publish', 'post', 0 ); - $this->assertEquals( '2015-2', $found ); + $this->assertSame( '2015-2', $found ); } /** @@ -225,7 +225,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { ); $found = wp_unique_post_slug( '2015', $p, 'publish', 'post', 0 ); - $this->assertEquals( '2015', $found ); + $this->assertSame( '2015', $found ); } /** @@ -242,7 +242,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { ); $found = wp_unique_post_slug( '11', $p, 'publish', 'post', 0 ); - $this->assertEquals( '11-2', $found ); + $this->assertSame( '11-2', $found ); } /** @@ -259,7 +259,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { ); $found = wp_unique_post_slug( '11', $p, 'publish', 'post', 0 ); - $this->assertEquals( '11', $found ); + $this->assertSame( '11', $found ); } /** @@ -276,7 +276,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { ); $found = wp_unique_post_slug( '13', $p, 'publish', 'post', 0 ); - $this->assertEquals( '13', $found ); + $this->assertSame( '13', $found ); } /** @@ -293,7 +293,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { ); $found = wp_unique_post_slug( '30', $p, 'publish', 'post', 0 ); - $this->assertEquals( '30-2', $found ); + $this->assertSame( '30-2', $found ); } /** @@ -310,7 +310,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { ); $found = wp_unique_post_slug( '30', $p, 'publish', 'post', 0 ); - $this->assertEquals( '30', $found ); + $this->assertSame( '30', $found ); } /** @@ -327,7 +327,7 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { ); $found = wp_unique_post_slug( '32', $p, 'publish', 'post', 0 ); - $this->assertEquals( '32', $found ); + $this->assertSame( '32', $found ); } /** diff --git a/tests/phpunit/tests/query.php b/tests/phpunit/tests/query.php index f6a2d28e1e..135e5536c7 100644 --- a/tests/phpunit/tests/query.php +++ b/tests/phpunit/tests/query.php @@ -22,10 +22,10 @@ class Tests_Query extends WP_UnitTestCase { $second_query = new WP_Query( array( 'post__in' => array( $nested_post_id ) ) ); while ( $second_query->have_posts() ) { $second_query->the_post(); - $this->assertEquals( get_the_ID(), $nested_post_id ); + $this->assertSame( get_the_ID(), $nested_post_id ); } $first_query->reset_postdata(); - $this->assertEquals( get_the_ID(), $post_id ); + $this->assertSame( get_the_ID(), $post_id ); } } @@ -34,7 +34,7 @@ class Tests_Query extends WP_UnitTestCase { */ function test_default_query_var() { $query = new WP_Query; - $this->assertEquals( '', $query->get( 'nonexistent' ) ); + $this->assertSame( '', $query->get( 'nonexistent' ) ); $this->assertFalse( $query->get( 'nonexistent', false ) ); $this->assertTrue( $query->get( 'nonexistent', true ) ); } @@ -49,7 +49,7 @@ class Tests_Query extends WP_UnitTestCase { $this->go_to( get_feed_link() ); - $this->assertEquals( 30, get_query_var( 'posts_per_page' ) ); + $this->assertSame( 30, get_query_var( 'posts_per_page' ) ); } function filter_posts_per_page( &$query ) { @@ -519,7 +519,7 @@ class Tests_Query extends WP_UnitTestCase { remove_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) ); $this->assertFalse( $GLOBALS['wp_query']->is_404() ); - $this->assertEquals( $post_id, $GLOBALS['wp_query']->post->ID ); + $this->assertSame( $post_id, $GLOBALS['wp_query']->post->ID ); } /** @@ -552,7 +552,7 @@ class Tests_Query extends WP_UnitTestCase { remove_action( 'parse_query', array( $this, 'filter_parse_query_to_modify_queried_post_id' ) ); $this->assertFalse( $GLOBALS['wp_query']->is_404() ); - $this->assertEquals( $post_id, $GLOBALS['wp_query']->post->ID ); + $this->assertSame( $post_id, $GLOBALS['wp_query']->post->ID ); } public function filter_parse_query_to_modify_queried_post_id( $query ) { diff --git a/tests/phpunit/tests/query/conditionals.php b/tests/phpunit/tests/query/conditionals.php index 14ebf2d860..c4f36bee8e 100644 --- a/tests/phpunit/tests/query/conditionals.php +++ b/tests/phpunit/tests/query/conditionals.php @@ -192,7 +192,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // Make sure the correct page was fetched. global $wp_query; - $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID ); + $this->assertSame( $page_id, $wp_query->get_queried_object()->ID ); } } @@ -231,7 +231,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // Make sure the correct page was fetched. global $wp_query; - $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID ); + $this->assertSame( $page_id, $wp_query->get_queried_object()->ID ); } } @@ -268,7 +268,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // Make sure the correct page was fetched. global $wp_query; - $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID ); + $this->assertSame( $page_id, $wp_query->get_queried_object()->ID ); } } @@ -308,7 +308,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // Make sure the correct page was fetched. global $wp_query; - $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID ); + $this->assertSame( $page_id, $wp_query->get_queried_object()->ID ); } } @@ -328,7 +328,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // Make sure the correct page was fetched. global $wp_query; - $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID ); + $this->assertSame( $page_id, $wp_query->get_queried_object()->ID ); } // '(about)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[2]' @@ -347,7 +347,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // Make sure the correct page was fetched. global $wp_query; - $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID ); + $this->assertSame( $page_id, $wp_query->get_queried_object()->ID ); } // '(about)(/[0-9]+)?/?$' => 'index.php?pagename=$matches[1]&page=$matches[2]' @@ -368,7 +368,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { // Make sure the correct page was fetched. global $wp_query; - $this->assertEquals( $page_id, $wp_query->get_queried_object()->ID ); + $this->assertSame( $page_id, $wp_query->get_queried_object()->ID ); update_option( 'show_on_front', 'posts' ); delete_option( 'page_for_posts' ); @@ -482,7 +482,7 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { */ function test_search_encoded_chars() { $this->go_to( '/search/F%C3%BCnf%2Bbar/' ); - $this->assertEquals( get_query_var( 's' ), 'Fünf+bar' ); + $this->assertSame( get_query_var( 's' ), 'Fünf+bar' ); } // 'category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?category_name=$matches[1]&feed=$matches[2]', @@ -823,13 +823,13 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { $this->go_to( '/ptawtq/' ); $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' ); - $this->assertEquals( get_queried_object(), get_post_type_object( $cpt_name ) ); + $this->assertSame( get_queried_object(), get_post_type_object( $cpt_name ) ); add_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_tax_query' ) ); $this->go_to( '/ptawtq/' ); $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' ); - $this->assertEquals( get_queried_object(), get_post_type_object( $cpt_name ) ); + $this->assertSame( get_queried_object(), get_post_type_object( $cpt_name ) ); remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_tax_query' ) ); } @@ -865,13 +865,13 @@ class Tests_Query_Conditionals extends WP_UnitTestCase { $this->go_to( "/$cpt_name/" ); $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' ); - $this->assertEquals( get_queried_object(), get_post_type_object( $cpt_name ) ); + $this->assertSame( get_queried_object(), get_post_type_object( $cpt_name ) ); add_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_type_array' ) ); $this->go_to( "/$cpt_name/" ); $this->assertQueryTrue( 'is_post_type_archive', 'is_archive' ); - $this->assertEquals( get_queried_object(), get_post_type_object( 'post' ) ); + $this->assertSame( get_queried_object(), get_post_type_object( 'post' ) ); remove_action( 'pre_get_posts', array( $this, 'pre_get_posts_with_type_array' ) ); } diff --git a/tests/phpunit/tests/query/date.php b/tests/phpunit/tests/query/date.php index b93bd8662a..0372233cfb 100644 --- a/tests/phpunit/tests/query/date.php +++ b/tests/phpunit/tests/query/date.php @@ -78,7 +78,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2008-12-10 13:06:27', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } public function test_simple_year_expecting_noresults() { @@ -104,7 +104,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2007-09-24 07:17:23', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } public function test_simple_m_with_year_expecting_noresults() { @@ -129,7 +129,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2025-04-20 10:13:01', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } public function test_simple_m_with_yearmonth_expecting_noresults() { @@ -154,7 +154,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2025-04-20 10:13:01', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } public function test_simple_m_with_yearmonthday_expecting_noresults() { @@ -179,7 +179,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2025-04-20 10:13:01', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } public function test_simple_m_with_yearmonthdayhour_expecting_noresults() { @@ -207,7 +207,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2025-04-20 10:13:01', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } /** @@ -237,7 +237,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2025-04-20 10:13:01', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } /** @@ -267,7 +267,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2025-04-20 10:13:00', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } /** @@ -284,7 +284,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2025-04-20 10:13:00', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } /** @@ -316,7 +316,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2025-05-20 10:13:01', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } public function test_simple_monthnum_expecting_noresults() { @@ -342,7 +342,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2012-06-13 14:03:34', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } public function test_simple_w_as_in_week_expecting_noresults() { @@ -367,7 +367,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2007-01-22 03:49:21', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } public function test_simple_day_expecting_noresults() { @@ -391,7 +391,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2009-06-11 21:30:28', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } public function test_simple_hour_expecting_noresults() { @@ -416,7 +416,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2008-07-15 11:32:26', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } public function test_simple_minute_expecting_noresults() { @@ -440,7 +440,7 @@ class Tests_Query_Date extends WP_UnitTestCase { '2010-06-17 17:09:30', ); - $this->assertEquals( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); + $this->assertSame( $expected_dates, wp_list_pluck( $posts, 'post_date' ) ); } public function test_simple_second_expecting_noresults() { diff --git a/tests/phpunit/tests/query/dateQuery.php b/tests/phpunit/tests/query/dateQuery.php index da7599bad6..bde99c9041 100644 --- a/tests/phpunit/tests/query/dateQuery.php +++ b/tests/phpunit/tests/query/dateQuery.php @@ -96,7 +96,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1, $p2 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1, $p2 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_after_array() { @@ -141,7 +141,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p2 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_after_string() { @@ -159,7 +159,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p3 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p3 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_after_string_inclusive() { @@ -178,7 +178,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2, $p3 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p2, $p3 ), wp_list_pluck( $posts, 'ID' ) ); } /** @@ -207,7 +207,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2, $p3, $p4 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p2, $p3, $p4 ), wp_list_pluck( $posts, 'ID' ) ); } /** @@ -247,8 +247,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), $before_posts ); - $this->assertEquals( array( $p1 ), $after_posts ); + $this->assertSame( array( $p2 ), $before_posts ); + $this->assertSame( array( $p1 ), $after_posts ); } /** @@ -331,8 +331,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), $before_posts ); - $this->assertEquals( array( $p1 ), $after_posts ); + $this->assertSame( array( $p2 ), $before_posts ); + $this->assertSame( array( $p1 ), $after_posts ); } /** @@ -415,8 +415,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), $before_posts ); - $this->assertEquals( array( $p1 ), $after_posts ); + $this->assertSame( array( $p2 ), $before_posts ); + $this->assertSame( array( $p1 ), $after_posts ); } /** @@ -499,8 +499,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), $before_posts ); - $this->assertEquals( array( $p1 ), $after_posts ); + $this->assertSame( array( $p2 ), $before_posts ); + $this->assertSame( array( $p1 ), $after_posts ); } /** @@ -583,8 +583,8 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), $before_posts ); - $this->assertEquals( array( $p1 ), $after_posts ); + $this->assertSame( array( $p2 ), $before_posts ); + $this->assertSame( array( $p1 ), $after_posts ); } /** @@ -667,7 +667,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1, $p2 ), $before_posts ); + $this->assertSame( array( $p1, $p2 ), $before_posts ); } public function test_date_query_year() { @@ -683,7 +683,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_month() { @@ -699,7 +699,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_week() { @@ -715,7 +715,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_day() { @@ -732,7 +732,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_dayofweek() { @@ -749,7 +749,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); } /** @@ -769,7 +769,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_hour() { @@ -786,7 +786,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); } /** @@ -806,7 +806,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_minute() { @@ -823,7 +823,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_second() { @@ -840,7 +840,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_between_two_times() { @@ -889,7 +889,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1, $p3 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1, $p3 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_query_compare_greater_than_or_equal_to() { @@ -910,7 +910,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2, $p3, $p4 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p2, $p3, $p4 ), wp_list_pluck( $posts, 'ID' ) ); } public function test_date_params_monthnum_m_duplicate() { @@ -929,7 +929,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); $this->assertContains( "MONTH( $wpdb->posts.post_date ) = 5", $this->q->request ); $this->assertNotContains( "MONTH( $wpdb->posts.post_date ) = 9", $this->q->request ); @@ -951,7 +951,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p2 ), wp_list_pluck( $posts, 'ID' ) ); $this->assertContains( "WEEK( $wpdb->posts.post_date, 1 ) = 43", $this->q->request ); $this->assertNotContains( "WEEK( $wpdb->posts.post_date, 1 ) = 42", $this->q->request ); @@ -992,7 +992,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { _unregister_taxonomy( 'foo' ); - $this->assertEquals( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p1 ), wp_list_pluck( $posts, 'ID' ) ); } /** @@ -1023,7 +1023,7 @@ class Tests_Query_DateQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2, $p3 ), wp_list_pluck( $posts, 'ID' ) ); + $this->assertSame( array( $p2, $p3 ), wp_list_pluck( $posts, 'ID' ) ); } /** diff --git a/tests/phpunit/tests/query/generatePostdata.php b/tests/phpunit/tests/query/generatePostdata.php index fa7d0afb46..c223e4b598 100644 --- a/tests/phpunit/tests/query/generatePostdata.php +++ b/tests/phpunit/tests/query/generatePostdata.php @@ -94,7 +94,7 @@ class Tests_Query_GeneratePostdata extends WP_UnitTestCase { $this->assertSame( 0, $data['multipage'] ); $this->assertSame( 1, $data['numpages'] ); - $this->assertEquals( array( 'Page 0' ), $data['pages'] ); + $this->assertSame( array( 'Page 0' ), $data['pages'] ); } /** @@ -110,7 +110,7 @@ class Tests_Query_GeneratePostdata extends WP_UnitTestCase { $this->assertSame( 1, $data['multipage'] ); $this->assertSame( 4, $data['numpages'] ); - $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $data['pages'] ); + $this->assertSame( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $data['pages'] ); } /** @@ -126,7 +126,7 @@ class Tests_Query_GeneratePostdata extends WP_UnitTestCase { $this->assertSame( 1, $data['multipage'] ); $this->assertSame( 3, $data['numpages'] ); - $this->assertEquals( array( 'Page 1', 'Page 2', 'Page 3' ), $data['pages'] ); + $this->assertSame( array( 'Page 1', 'Page 2', 'Page 3' ), $data['pages'] ); } /** @@ -140,6 +140,6 @@ class Tests_Query_GeneratePostdata extends WP_UnitTestCase { ); $data = generate_postdata( $post ); - $this->assertEquals( array( 'Page 0', "Page 1\nhas a line break", 'Page 2', "\nPage 3" ), $data['pages'] ); + $this->assertSame( array( 'Page 0', "Page 1\nhas a line break", 'Page 2', "\nPage 3" ), $data['pages'] ); } } diff --git a/tests/phpunit/tests/query/isTerm.php b/tests/phpunit/tests/query/isTerm.php index 92edd97d02..1de8c522e9 100644 --- a/tests/phpunit/tests/query/isTerm.php +++ b/tests/phpunit/tests/query/isTerm.php @@ -251,7 +251,7 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { $expected = get_term( $this->tax_id, 'testtax' ); // Only compare term_id because object_id may or may not be part of either value. - $this->assertEquals( $expected->term_id, $object->term_id ); + $this->assertSame( $expected->term_id, $object->term_id ); } /** @@ -295,6 +295,6 @@ class Tests_Query_IsTerm extends WP_UnitTestCase { $expected = get_term( $this->tax_id, 'testtax' ); // Only compare term_id because object_id may or may not be part of either value. - $this->assertEquals( $expected->term_id, $object->term_id ); + $this->assertSame( $expected->term_id, $object->term_id ); } } diff --git a/tests/phpunit/tests/query/metaQuery.php b/tests/phpunit/tests/query/metaQuery.php index 6b19d0c6b5..a1a155c369 100644 --- a/tests/phpunit/tests/query/metaQuery.php +++ b/tests/phpunit/tests/query/metaQuery.php @@ -419,7 +419,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ); $expected = array( $p1 ); - $this->assertEquals( $expected, $query->posts ); + $this->assertSame( $expected, $query->posts ); } public function test_meta_query_relation_or() { @@ -672,7 +672,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ); $expected = array( $post_id4 ); - $this->assertEquals( $expected, $query->posts ); + $this->assertSame( $expected, $query->posts ); $query = new WP_Query( array( @@ -696,7 +696,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( 0, count( $query->posts ) ); + $this->assertSame( 0, count( $query->posts ) ); } /** @@ -1373,7 +1373,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $posts[2], $posts[0], $posts[1] ), $query->posts ); + $this->assertSame( array( $posts[2], $posts[0], $posts[1] ), $query->posts ); } /** @@ -1418,7 +1418,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $posts[2], $posts[0], $posts[1] ), $query->posts ); + $this->assertSame( array( $posts[2], $posts[0], $posts[1] ), $query->posts ); } /** @@ -1534,10 +1534,10 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ); $query = new WP_Query( $args ); - $this->assertEquals( 2, count( $query->posts ) ); + $this->assertSame( 2, count( $query->posts ) ); foreach ( $query->posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( 'raw', $post->filter ); + $this->assertSame( 'raw', $post->filter ); } $posts = wp_list_pluck( $query->posts, 'ID' ); $this->assertEqualSets( array( $post_id2, $post_id3 ), $posts ); @@ -1550,10 +1550,10 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ); $query = new WP_Query( $args ); - $this->assertEquals( 3, count( $query->posts ) ); + $this->assertSame( 3, count( $query->posts ) ); foreach ( $query->posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( 'raw', $post->filter ); + $this->assertSame( 'raw', $post->filter ); } $posts = wp_list_pluck( $query->posts, 'ID' ); $this->assertEqualSets( array( $post_id, $post_id4, $post_id5 ), $posts ); @@ -1582,7 +1582,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( 2, count( $posts ) ); + $this->assertSame( 2, count( $posts ) ); $posts = wp_list_pluck( $posts, 'ID' ); $this->assertEqualSets( array( $post_id, $post_id3 ), $posts ); @@ -1594,10 +1594,10 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( 2, count( $posts ) ); + $this->assertSame( 2, count( $posts ) ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( 'raw', $post->filter ); + $this->assertSame( 'raw', $post->filter ); } $posts = wp_list_pluck( $posts, 'ID' ); $this->assertEqualSets( array( $post_id, $post_id3 ), $posts ); @@ -1625,10 +1625,10 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ); $posts = get_posts( $args ); - $this->assertEquals( 2, count( $posts ) ); + $this->assertSame( 2, count( $posts ) ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( 'raw', $post->filter ); + $this->assertSame( 'raw', $post->filter ); } $posts = wp_list_pluck( $posts, 'ID' ); $this->assertEqualSets( array( $post_id, $post_id2 ), $posts ); @@ -1659,12 +1659,12 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { 'meta_value' => '0', ) ); - $this->assertEquals( 1, count( $q->posts ) ); + $this->assertSame( 1, count( $q->posts ) ); foreach ( $q->posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( 'raw', $post->filter ); + $this->assertSame( 'raw', $post->filter ); } - $this->assertEquals( $post_id, $q->posts[0]->ID ); + $this->assertSame( $post_id, $q->posts[0]->ID ); $posts = get_posts( array( @@ -1672,10 +1672,10 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { 'meta_value' => '0', ) ); - $this->assertEquals( 2, count( $posts ) ); + $this->assertSame( 2, count( $posts ) ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( 'raw', $post->filter ); + $this->assertSame( 'raw', $post->filter ); } $posts = wp_list_pluck( $posts, 'ID' ); $this->assertEqualSets( array( $post_id, $post_id5 ), $posts ); @@ -1686,28 +1686,28 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { 'meta_value' => 0, ) ); - $this->assertEquals( 2, count( $posts ) ); + $this->assertSame( 2, count( $posts ) ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( 'raw', $post->filter ); + $this->assertSame( 'raw', $post->filter ); } $posts = wp_list_pluck( $posts, 'ID' ); $this->assertEqualSets( array( $post_id, $post_id5 ), $posts ); $posts = get_posts( array( 'meta_value' => 0 ) ); - $this->assertEquals( 5, count( $posts ) ); + $this->assertSame( 5, count( $posts ) ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( 'raw', $post->filter ); + $this->assertSame( 'raw', $post->filter ); } $posts = wp_list_pluck( $posts, 'ID' ); $this->assertEqualSets( array( $post_id, $post_id3, $post_id4, $post_id5, $post_id6 ), $posts ); $posts = get_posts( array( 'meta_value' => '0' ) ); - $this->assertEquals( 5, count( $posts ) ); + $this->assertSame( 5, count( $posts ) ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); - $this->assertEquals( 'raw', $post->filter ); + $this->assertSame( 'raw', $post->filter ); } $posts = wp_list_pluck( $posts, 'ID' ); $this->assertEqualSets( array( $post_id, $post_id3, $post_id4, $post_id5, $post_id6 ), $posts ); @@ -1736,7 +1736,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $posts[1], $posts[2], $posts[0] ), $q->posts ); + $this->assertSame( array( $posts[1], $posts[2], $posts[0] ), $q->posts ); } /** @@ -1779,7 +1779,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p3, $p1, $p2 ), $q->posts ); + $this->assertSame( array( $p3, $p1, $p2 ), $q->posts ); } /** @@ -1815,7 +1815,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $posts[2], $posts[0], $posts[1] ), $q->posts ); + $this->assertSame( array( $posts[2], $posts[0], $posts[1] ), $q->posts ); } /** diff --git a/tests/phpunit/tests/query/parseQuery.php b/tests/phpunit/tests/query/parseQuery.php index d3be65ac6c..5b3625ed0f 100644 --- a/tests/phpunit/tests/query/parseQuery.php +++ b/tests/phpunit/tests/query/parseQuery.php @@ -59,7 +59,7 @@ class Tests_Query_ParseQuery extends WP_UnitTestCase { ) ); - $this->assertSame( true, $q->query_vars['s'] ); + $this->assertTrue( $q->query_vars['s'] ); } /** diff --git a/tests/phpunit/tests/query/postStatus.php b/tests/phpunit/tests/query/postStatus.php index 0ba6b98e67..624fb469ea 100644 --- a/tests/phpunit/tests/query/postStatus.php +++ b/tests/phpunit/tests/query/postStatus.php @@ -334,7 +334,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p ), wp_list_pluck( $q->posts, 'ID' ) ); + $this->assertSame( array( $p ), wp_list_pluck( $q->posts, 'ID' ) ); } public function test_single_post_with_nonpublic_and_private_status_should_not_be_shown_for_user_who_cannot_edit_others_posts() { @@ -388,7 +388,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p ), wp_list_pluck( $q->posts, 'ID' ) ); + $this->assertSame( array( $p ), wp_list_pluck( $q->posts, 'ID' ) ); } /** @@ -438,7 +438,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p ), wp_list_pluck( $q->posts, 'ID' ) ); + $this->assertSame( array( $p ), wp_list_pluck( $q->posts, 'ID' ) ); } /** diff --git a/tests/phpunit/tests/query/results.php b/tests/phpunit/tests/query/results.php index 35742f6547..eb801249ab 100644 --- a/tests/phpunit/tests/query/results.php +++ b/tests/phpunit/tests/query/results.php @@ -318,7 +318,7 @@ class Tests_Query_Results extends WP_UnitTestCase { 9 => 'embedded-video', ); - $this->assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) ); + $this->assertSame( $expected, wp_list_pluck( $posts, 'post_name' ) ); } function test_query_tag_a() { @@ -326,10 +326,10 @@ class Tests_Query_Results extends WP_UnitTestCase { // There are 4 posts with Tag A. $this->assertCount( 4, $posts ); - $this->assertEquals( 'tags-a-and-c', $posts[0]->post_name ); - $this->assertEquals( 'tags-a-and-b', $posts[1]->post_name ); - $this->assertEquals( 'tag-a', $posts[2]->post_name ); - $this->assertEquals( 'tags-a-b-c', $posts[3]->post_name ); + $this->assertSame( 'tags-a-and-c', $posts[0]->post_name ); + $this->assertSame( 'tags-a-and-b', $posts[1]->post_name ); + $this->assertSame( 'tag-a', $posts[2]->post_name ); + $this->assertSame( 'tags-a-b-c', $posts[3]->post_name ); } function test_query_tag_b() { @@ -337,10 +337,10 @@ class Tests_Query_Results extends WP_UnitTestCase { // There are 4 posts with Tag A. $this->assertCount( 4, $posts ); - $this->assertEquals( 'tags-b-and-c', $posts[0]->post_name ); - $this->assertEquals( 'tags-a-and-b', $posts[1]->post_name ); - $this->assertEquals( 'tag-b', $posts[2]->post_name ); - $this->assertEquals( 'tags-a-b-c', $posts[3]->post_name ); + $this->assertSame( 'tags-b-and-c', $posts[0]->post_name ); + $this->assertSame( 'tags-a-and-b', $posts[1]->post_name ); + $this->assertSame( 'tag-b', $posts[2]->post_name ); + $this->assertSame( 'tags-a-b-c', $posts[3]->post_name ); } /** @@ -351,7 +351,7 @@ class Tests_Query_Results extends WP_UnitTestCase { // There is 1 post with Tag נ. $this->assertCount( 1, $posts ); - $this->assertEquals( 'tag-%d7%a0', $posts[0]->post_name ); + $this->assertSame( 'tag-%d7%a0', $posts[0]->post_name ); } function test_query_tag_id() { @@ -360,10 +360,10 @@ class Tests_Query_Results extends WP_UnitTestCase { // There are 4 posts with Tag A. $this->assertCount( 4, $posts ); - $this->assertEquals( 'tags-a-and-c', $posts[0]->post_name ); - $this->assertEquals( 'tags-a-and-b', $posts[1]->post_name ); - $this->assertEquals( 'tag-a', $posts[2]->post_name ); - $this->assertEquals( 'tags-a-b-c', $posts[3]->post_name ); + $this->assertSame( 'tags-a-and-c', $posts[0]->post_name ); + $this->assertSame( 'tags-a-and-b', $posts[1]->post_name ); + $this->assertSame( 'tag-a', $posts[2]->post_name ); + $this->assertSame( 'tags-a-b-c', $posts[3]->post_name ); } function test_query_tag_slug__in() { @@ -371,12 +371,12 @@ class Tests_Query_Results extends WP_UnitTestCase { // There are 4 posts with either Tag B or Tag C. $this->assertCount( 6, $posts ); - $this->assertEquals( 'tags-a-and-c', $posts[0]->post_name ); - $this->assertEquals( 'tags-b-and-c', $posts[1]->post_name ); - $this->assertEquals( 'tags-a-and-b', $posts[2]->post_name ); - $this->assertEquals( 'tag-c', $posts[3]->post_name ); - $this->assertEquals( 'tag-b', $posts[4]->post_name ); - $this->assertEquals( 'tags-a-b-c', $posts[5]->post_name ); + $this->assertSame( 'tags-a-and-c', $posts[0]->post_name ); + $this->assertSame( 'tags-b-and-c', $posts[1]->post_name ); + $this->assertSame( 'tags-a-and-b', $posts[2]->post_name ); + $this->assertSame( 'tag-c', $posts[3]->post_name ); + $this->assertSame( 'tag-b', $posts[4]->post_name ); + $this->assertSame( 'tags-a-b-c', $posts[5]->post_name ); } @@ -387,12 +387,12 @@ class Tests_Query_Results extends WP_UnitTestCase { // There are 6 posts with either Tag A or Tag B. $this->assertCount( 6, $posts ); - $this->assertEquals( 'tags-a-and-c', $posts[0]->post_name ); - $this->assertEquals( 'tags-b-and-c', $posts[1]->post_name ); - $this->assertEquals( 'tags-a-and-b', $posts[2]->post_name ); - $this->assertEquals( 'tag-b', $posts[3]->post_name ); - $this->assertEquals( 'tag-a', $posts[4]->post_name ); - $this->assertEquals( 'tags-a-b-c', $posts[5]->post_name ); + $this->assertSame( 'tags-a-and-c', $posts[0]->post_name ); + $this->assertSame( 'tags-b-and-c', $posts[1]->post_name ); + $this->assertSame( 'tags-a-and-b', $posts[2]->post_name ); + $this->assertSame( 'tag-b', $posts[3]->post_name ); + $this->assertSame( 'tag-a', $posts[4]->post_name ); + $this->assertSame( 'tags-a-b-c', $posts[5]->post_name ); } function test_query_tag__not_in() { @@ -414,7 +414,7 @@ class Tests_Query_Results extends WP_UnitTestCase { 9 => 'many-trackbacks', ); - $this->assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) ); + $this->assertSame( $expected, wp_list_pluck( $posts, 'post_name' ) ); } function test_query_tag__in_but__not_in() { @@ -424,8 +424,8 @@ class Tests_Query_Results extends WP_UnitTestCase { // There are 4 posts with Tag A, only 2 when we exclude Tag B. $this->assertCount( 2, $posts ); - $this->assertEquals( 'tags-a-and-c', $posts[0]->post_name ); - $this->assertEquals( 'tag-a', $posts[1]->post_name ); + $this->assertSame( 'tags-a-and-c', $posts[0]->post_name ); + $this->assertSame( 'tag-a', $posts[1]->post_name ); } @@ -435,10 +435,10 @@ class Tests_Query_Results extends WP_UnitTestCase { // There are 4 posts with Cat A, we'll check for them by name. $this->assertCount( 4, $posts ); - $this->assertEquals( 'cat-a', $posts[0]->post_name ); - $this->assertEquals( 'cats-a-and-c', $posts[1]->post_name ); - $this->assertEquals( 'cats-a-and-b', $posts[2]->post_name ); - $this->assertEquals( 'cats-a-b-c', $posts[3]->post_name ); + $this->assertSame( 'cat-a', $posts[0]->post_name ); + $this->assertSame( 'cats-a-and-c', $posts[1]->post_name ); + $this->assertSame( 'cats-a-and-b', $posts[2]->post_name ); + $this->assertSame( 'cats-a-b-c', $posts[3]->post_name ); } function test_query_cat() { @@ -447,10 +447,10 @@ class Tests_Query_Results extends WP_UnitTestCase { // There are 4 posts with Cat B. $this->assertCount( 4, $posts ); - $this->assertEquals( 'cat-b', $posts[0]->post_name ); - $this->assertEquals( 'cats-b-and-c', $posts[1]->post_name ); - $this->assertEquals( 'cats-a-and-b', $posts[2]->post_name ); - $this->assertEquals( 'cats-a-b-c', $posts[3]->post_name ); + $this->assertSame( 'cat-b', $posts[0]->post_name ); + $this->assertSame( 'cats-b-and-c', $posts[1]->post_name ); + $this->assertSame( 'cats-a-and-b', $posts[2]->post_name ); + $this->assertSame( 'cats-a-b-c', $posts[3]->post_name ); } function test_query_posts_per_page() { @@ -465,7 +465,7 @@ class Tests_Query_Results extends WP_UnitTestCase { ); $this->assertCount( 5, $posts ); - $this->assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) ); + $this->assertSame( $expected, wp_list_pluck( $posts, 'post_name' ) ); } function test_query_offset() { @@ -485,7 +485,7 @@ class Tests_Query_Results extends WP_UnitTestCase { ); $this->assertCount( 10, $posts ); - $this->assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) ); + $this->assertSame( $expected, wp_list_pluck( $posts, 'post_name' ) ); } function test_query_paged() { @@ -506,7 +506,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertCount( 10, $posts ); $this->assertTrue( $this->q->is_paged() ); - $this->assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) ); + $this->assertSame( $expected, wp_list_pluck( $posts, 'post_name' ) ); } function test_query_paged_and_posts_per_page() { @@ -521,7 +521,7 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertCount( 4, $posts ); $this->assertTrue( $this->q->is_paged() ); - $this->assertEquals( $expected, wp_list_pluck( $posts, 'post_name' ) ); + $this->assertSame( $expected, wp_list_pluck( $posts, 'post_name' ) ); } /** @@ -537,7 +537,7 @@ class Tests_Query_Results extends WP_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( array( 'child-one', 'child-two', @@ -554,7 +554,7 @@ class Tests_Query_Results extends WP_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( array( 'child-three', 'child-four', @@ -571,7 +571,7 @@ class Tests_Query_Results extends WP_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( array( 'child-one', 'child-two', @@ -588,7 +588,7 @@ class Tests_Query_Results extends WP_UnitTestCase { ) ); - $this->assertEquals( array(), wp_list_pluck( $posts, 'post_title' ) ); + $this->assertSame( array(), wp_list_pluck( $posts, 'post_title' ) ); } /** @@ -603,7 +603,7 @@ class Tests_Query_Results extends WP_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( array( 'child-three', 'child-four', @@ -630,7 +630,7 @@ class Tests_Query_Results extends WP_UnitTestCase { ); // 'order=desc' does not influence the order of returned results (returns same order as 'order=asc'). - $this->assertEquals( $expected_returned_array, wp_list_pluck( $posts, 'post_title' ) ); + $this->assertSame( $expected_returned_array, wp_list_pluck( $posts, 'post_title' ) ); } /** diff --git a/tests/phpunit/tests/query/search.php b/tests/phpunit/tests/query/search.php index dea08f9fbb..0b26ad0257 100644 --- a/tests/phpunit/tests/query/search.php +++ b/tests/phpunit/tests/query/search.php @@ -50,14 +50,14 @@ class Tests_Query_Search extends WP_UnitTestCase { ); $posts = $this->get_search_results( 'About' ); - $this->assertEquals( $post_id, reset( $posts )->ID ); + $this->assertSame( $post_id, reset( $posts )->ID ); } function test_search_terms_query_var() { $terms = 'This is a search term'; $query = new WP_Query( array( 's' => 'This is a search term' ) ); $this->assertNotEquals( explode( ' ', $terms ), $query->get( 'search_terms' ) ); - $this->assertEquals( array( 'search', 'term' ), $query->get( 'search_terms' ) ); + $this->assertSame( array( 'search', 'term' ), $query->get( 'search_terms' ) ); } function test_filter_stopwords() { @@ -67,7 +67,7 @@ class Tests_Query_Search extends WP_UnitTestCase { remove_filter( 'wp_search_stopwords', array( $this, 'filter_wp_search_stopwords' ) ); $this->assertNotEquals( array( 'search', 'term' ), $query->get( 'search_terms' ) ); - $this->assertEquals( array( 'This', 'is', 'search', 'term' ), $query->get( 'search_terms' ) ); + $this->assertSame( array( 'This', 'is', 'search', 'term' ), $query->get( 'search_terms' ) ); } function filter_wp_search_stopwords() { @@ -89,13 +89,13 @@ class Tests_Query_Search extends WP_UnitTestCase { ); // By default, we can use the hyphen prefix to exclude results. - $this->assertEquals( array(), $this->get_search_results( $title ) ); + $this->assertSame( array(), $this->get_search_results( $title ) ); // After we disable the feature using the filter, we should get the result. add_filter( 'wp_query_search_exclusion_prefix', '__return_false' ); $result = $this->get_search_results( $title ); $post = array_pop( $result ); - $this->assertEquals( $post->ID, $post_id ); + $this->assertSame( $post->ID, $post_id ); remove_filter( 'wp_query_search_exclusion_prefix', '__return_false' ); } @@ -116,13 +116,13 @@ class Tests_Query_Search extends WP_UnitTestCase { // By default, we should get the result. $result = $this->get_search_results( $title ); $post = array_pop( $result ); - $this->assertEquals( $post->ID, $post_id ); + $this->assertSame( $post->ID, $post_id ); // After we change the prefix, the result should be excluded. add_filter( 'wp_query_search_exclusion_prefix', array( $this, 'filter_search_exclusion_prefix_octothorpe' ) ); $found = $this->get_search_results( $title ); remove_filter( 'wp_query_search_exclusion_prefix', array( $this, 'filter_search_exclusion_prefix_octothorpe' ) ); - $this->assertEquals( array(), $found ); + $this->assertSame( array(), $found ); } function filter_search_exclusion_prefix_octothorpe() { diff --git a/tests/phpunit/tests/query/setupPostdata.php b/tests/phpunit/tests/query/setupPostdata.php index 6515e385eb..234bfdfa4d 100644 --- a/tests/phpunit/tests/query/setupPostdata.php +++ b/tests/phpunit/tests/query/setupPostdata.php @@ -165,7 +165,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { $this->assertSame( 0, $GLOBALS['multipage'] ); $this->assertSame( 1, $GLOBALS['numpages'] ); - $this->assertEquals( array( 'Page 0' ), $GLOBALS['pages'] ); + $this->assertSame( array( 'Page 0' ), $GLOBALS['pages'] ); } public function test_multi_page() { @@ -178,7 +178,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { $this->assertSame( 1, $GLOBALS['multipage'] ); $this->assertSame( 4, $GLOBALS['numpages'] ); - $this->assertEquals( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $GLOBALS['pages'] ); + $this->assertSame( array( 'Page 0', 'Page 1', 'Page 2', 'Page 3' ), $GLOBALS['pages'] ); } /** @@ -194,7 +194,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { $this->assertSame( 1, $GLOBALS['multipage'] ); $this->assertSame( 3, $GLOBALS['numpages'] ); - $this->assertEquals( array( 'Page 1', 'Page 2', 'Page 3' ), $GLOBALS['pages'] ); + $this->assertSame( array( 'Page 1', 'Page 2', 'Page 3' ), $GLOBALS['pages'] ); } public function test_trim_nextpage_linebreaks() { @@ -205,7 +205,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { ); setup_postdata( $post ); - $this->assertEquals( array( 'Page 0', "Page 1\nhas a line break", 'Page 2', "\nPage 3" ), $GLOBALS['pages'] ); + $this->assertSame( array( 'Page 0', "Page 1\nhas a line break", 'Page 2', "\nPage 3" ), $GLOBALS['pages'] ); } /** @@ -411,7 +411,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { setup_postdata( $a_post ); $content = get_echo( 'the_content' ); - $this->assertEquals( $post_id, $GLOBALS['post']->ID ); + $this->assertSame( $post_id, $GLOBALS['post']->ID ); $this->assertNotEquals( '<p>global post</p>', strip_ws( $content ) ); wp_reset_postdata(); } @@ -427,7 +427,7 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase { setup_postdata( $post ); - $this->assertEquals( $GLOBALS['pages'], $this->pages_global ); + $this->assertSame( $GLOBALS['pages'], $this->pages_global ); } /** diff --git a/tests/phpunit/tests/query/stickies.php b/tests/phpunit/tests/query/stickies.php index 01e7405e6a..2dc285ade3 100644 --- a/tests/phpunit/tests/query/stickies.php +++ b/tests/phpunit/tests/query/stickies.php @@ -40,7 +40,7 @@ class Tests_Query_Stickies extends WP_UnitTestCase { self::$posts[2], ); - $this->assertEquals( $expected, $q->posts ); + $this->assertSame( $expected, $q->posts ); } public function test_stickies_should_be_included_when_is_home_is_true() { @@ -48,9 +48,9 @@ class Tests_Query_Stickies extends WP_UnitTestCase { $q = $GLOBALS['wp_query']; - $this->assertEquals( self::$posts[2], $q->posts[0]->ID ); - $this->assertEquals( self::$posts[8], $q->posts[1]->ID ); - $this->assertEquals( self::$posts[14], $q->posts[2]->ID ); + $this->assertSame( self::$posts[2], $q->posts[0]->ID ); + $this->assertSame( self::$posts[8], $q->posts[1]->ID ); + $this->assertSame( self::$posts[14], $q->posts[2]->ID ); } public function test_stickies_should_not_be_included_on_pages_other_than_1() { @@ -82,7 +82,7 @@ class Tests_Query_Stickies extends WP_UnitTestCase { self::$posts[9], ); - $this->assertEquals( $expected, wp_list_pluck( $q->posts, 'ID' ) ); + $this->assertSame( $expected, wp_list_pluck( $q->posts, 'ID' ) ); } public function test_stickies_should_obey_post__not_in() { @@ -92,8 +92,8 @@ class Tests_Query_Stickies extends WP_UnitTestCase { $q = $GLOBALS['wp_query']; - $this->assertEquals( self::$posts[2], $q->posts[0]->ID ); - $this->assertEquals( self::$posts[14], $q->posts[1]->ID ); + $this->assertSame( self::$posts[2], $q->posts[0]->ID ); + $this->assertSame( self::$posts[14], $q->posts[1]->ID ); $this->assertNotContains( self::$posts[8], wp_list_pluck( $q->posts, 'ID' ) ); } diff --git a/tests/phpunit/tests/query/taxQuery.php b/tests/phpunit/tests/query/taxQuery.php index 14637c801a..0f3ca06eda 100644 --- a/tests/phpunit/tests/query/taxQuery.php +++ b/tests/phpunit/tests/query/taxQuery.php @@ -33,7 +33,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), $q->posts ); + $this->assertSame( array( $p1 ), $q->posts ); } public function test_tax_query_single_query_single_term_field_name() { @@ -64,7 +64,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), $q->posts ); + $this->assertSame( array( $p1 ), $q->posts ); } /** @@ -98,7 +98,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), $q->posts ); + $this->assertSame( array( $p1 ), $q->posts ); } public function test_tax_query_single_query_single_term_field_term_taxonomy_id() { @@ -129,7 +129,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), $q->posts ); + $this->assertSame( array( $p1 ), $q->posts ); } public function test_tax_query_single_query_single_term_field_term_id() { @@ -160,7 +160,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), $q->posts ); + $this->assertSame( array( $p1 ), $q->posts ); } public function test_tax_query_single_query_single_term_operator_in() { @@ -192,7 +192,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), $q->posts ); + $this->assertSame( array( $p1 ), $q->posts ); } public function test_tax_query_single_query_single_term_operator_not_in() { @@ -224,7 +224,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), $q->posts ); + $this->assertSame( array( $p2 ), $q->posts ); } public function test_tax_query_single_query_single_term_operator_and() { @@ -256,7 +256,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p1 ), $q->posts ); + $this->assertSame( array( $p1 ), $q->posts ); } public function test_tax_query_single_query_multiple_terms_operator_in() { @@ -338,7 +338,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p3 ), $q->posts ); + $this->assertSame( array( $p3 ), $q->posts ); } /** @@ -389,7 +389,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p3 ), $q->posts ); + $this->assertSame( array( $p3 ), $q->posts ); } public function test_tax_query_single_query_multiple_terms_operator_and() { @@ -430,7 +430,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), $q->posts ); + $this->assertSame( array( $p2 ), $q->posts ); } /** @@ -659,7 +659,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $p2 ), $q->posts ); + $this->assertSame( array( $p2 ), $q->posts ); } public function test_tax_query_multiple_queries_relation_or() { @@ -1025,7 +1025,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ); $posts = $query->get_posts(); - $this->assertEquals( 0, count( $posts ) ); + $this->assertSame( 0, count( $posts ) ); } /** @@ -1060,7 +1060,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ); $posts = $query->get_posts(); - $this->assertEquals( 0, count( $posts ) ); + $this->assertSame( 0, count( $posts ) ); } public function test_tax_query_include_children() { @@ -1112,7 +1112,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( 4, count( $posts ) ); + $this->assertSame( 4, count( $posts ) ); $posts = get_posts( array( @@ -1130,7 +1130,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( 1, count( $posts ) ); + $this->assertSame( 1, count( $posts ) ); $posts = get_posts( array( @@ -1147,7 +1147,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( 3, count( $posts ) ); + $this->assertSame( 3, count( $posts ) ); $posts = get_posts( array( @@ -1165,7 +1165,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( 1, count( $posts ) ); + $this->assertSame( 1, count( $posts ) ); $posts = get_posts( array( @@ -1182,7 +1182,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( 1, count( $posts ) ); + $this->assertSame( 1, count( $posts ) ); $posts = get_posts( array( @@ -1200,7 +1200,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( 1, count( $posts ) ); + $this->assertSame( 1, count( $posts ) ); } public function test_tax_query_taxonomy_with_attachments() { @@ -1240,7 +1240,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $image_id ), $posts ); + $this->assertSame( array( $image_id ), $posts ); } public function test_tax_query_no_taxonomy() { @@ -1345,7 +1345,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $posts[0], $posts[1], $posts[2] ), $results1, 'Relation: OR; Operator: AND' ); + $this->assertSame( array( $posts[0], $posts[1], $posts[2] ), $results1, 'Relation: OR; Operator: AND' ); $results2 = $q->query( array( @@ -1372,7 +1372,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $posts[0], $posts[3] ), $results2, 'Relation: AND; Operator: IN' ); + $this->assertSame( array( $posts[0], $posts[3] ), $results2, 'Relation: AND; Operator: IN' ); } /** @@ -1493,7 +1493,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( $t, $q->get( 'term_id' ) ); + $this->assertSame( $t, $q->get( 'term_id' ) ); _unregister_taxonomy( 'foo' ); } @@ -1539,8 +1539,8 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( $c, $q->get( 'cat' ) ); - $this->assertEquals( 'bar', $q->get( 'category_name' ) ); + $this->assertSame( $c, $q->get( 'cat' ) ); + $this->assertSame( 'bar', $q->get( 'category_name' ) ); _unregister_taxonomy( 'foo' ); } @@ -1586,7 +1586,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertEquals( $tag, $q->get( 'tag_id' ) ); + $this->assertSame( $tag, $q->get( 'tag_id' ) ); _unregister_taxonomy( 'foo' ); } diff --git a/tests/phpunit/tests/query/vars.php b/tests/phpunit/tests/query/vars.php index 051fceb3ab..7f336908a2 100644 --- a/tests/phpunit/tests/query/vars.php +++ b/tests/phpunit/tests/query/vars.php @@ -17,7 +17,7 @@ class Tests_Query_Vars extends WP_UnitTestCase { // Re-initialise any dynamically-added public query vars: do_action( 'init' ); - $this->assertEquals( + $this->assertSame( array( // Static public query vars: diff --git a/tests/phpunit/tests/rest-api.php b/tests/phpunit/tests/rest-api.php index 3a1240827b..08f498e5bb 100644 --- a/tests/phpunit/tests/rest-api.php +++ b/tests/phpunit/tests/rest-api.php @@ -42,36 +42,36 @@ class Tests_REST_API extends WP_UnitTestCase { * have a default priority of 10. */ function test_init_action_added() { - $this->assertEquals( 10, has_action( 'init', 'rest_api_init' ) ); + $this->assertSame( 10, has_action( 'init', 'rest_api_init' ) ); } public function test_add_extra_api_taxonomy_arguments() { $taxonomy = get_taxonomy( 'category' ); $this->assertTrue( $taxonomy->show_in_rest ); - $this->assertEquals( 'categories', $taxonomy->rest_base ); - $this->assertEquals( 'WP_REST_Terms_Controller', $taxonomy->rest_controller_class ); + $this->assertSame( 'categories', $taxonomy->rest_base ); + $this->assertSame( 'WP_REST_Terms_Controller', $taxonomy->rest_controller_class ); $taxonomy = get_taxonomy( 'post_tag' ); $this->assertTrue( $taxonomy->show_in_rest ); - $this->assertEquals( 'tags', $taxonomy->rest_base ); - $this->assertEquals( 'WP_REST_Terms_Controller', $taxonomy->rest_controller_class ); + $this->assertSame( 'tags', $taxonomy->rest_base ); + $this->assertSame( 'WP_REST_Terms_Controller', $taxonomy->rest_controller_class ); } public function test_add_extra_api_post_type_arguments() { $post_type = get_post_type_object( 'post' ); $this->assertTrue( $post_type->show_in_rest ); - $this->assertEquals( 'posts', $post_type->rest_base ); - $this->assertEquals( 'WP_REST_Posts_Controller', $post_type->rest_controller_class ); + $this->assertSame( 'posts', $post_type->rest_base ); + $this->assertSame( 'WP_REST_Posts_Controller', $post_type->rest_controller_class ); $post_type = get_post_type_object( 'page' ); $this->assertTrue( $post_type->show_in_rest ); - $this->assertEquals( 'pages', $post_type->rest_base ); - $this->assertEquals( 'WP_REST_Posts_Controller', $post_type->rest_controller_class ); + $this->assertSame( 'pages', $post_type->rest_base ); + $this->assertSame( 'WP_REST_Posts_Controller', $post_type->rest_controller_class ); $post_type = get_post_type_object( 'attachment' ); $this->assertTrue( $post_type->show_in_rest ); - $this->assertEquals( 'media', $post_type->rest_base ); - $this->assertEquals( 'WP_REST_Attachments_Controller', $post_type->rest_controller_class ); + $this->assertSame( 'media', $post_type->rest_base ); + $this->assertSame( 'WP_REST_Attachments_Controller', $post_type->rest_controller_class ); } /** @@ -98,7 +98,7 @@ class Tests_REST_API extends WP_UnitTestCase { $endpoint = $endpoints['/test-ns/test']; $this->assertArrayNotHasKey( 'callback', $endpoint ); $this->assertArrayHasKey( 'namespace', $endpoint ); - $this->assertEquals( 'test-ns', $endpoint['namespace'] ); + $this->assertSame( 'test-ns', $endpoint['namespace'] ); // Grab the filtered data. $filtered_endpoints = $GLOBALS['wp_rest_server']->get_routes(); @@ -141,7 +141,7 @@ class Tests_REST_API extends WP_UnitTestCase { $endpoint = $endpoints['/test-ns/test']; $this->assertArrayNotHasKey( 'callback', $endpoint ); $this->assertArrayHasKey( 'namespace', $endpoint ); - $this->assertEquals( 'test-ns', $endpoint['namespace'] ); + $this->assertSame( 'test-ns', $endpoint['namespace'] ); $filtered_endpoints = $GLOBALS['wp_rest_server']->get_routes(); $endpoint = $filtered_endpoints['/test-ns/test']; @@ -281,7 +281,7 @@ class Tests_REST_API extends WP_UnitTestCase { $routes = $GLOBALS['wp_rest_server']->get_routes(); - $this->assertEquals( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) ); + $this->assertSame( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) ); } /** @@ -300,7 +300,7 @@ class Tests_REST_API extends WP_UnitTestCase { $routes = $GLOBALS['wp_rest_server']->get_routes(); - $this->assertEquals( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) ); + $this->assertSame( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) ); } /** @@ -319,7 +319,7 @@ class Tests_REST_API extends WP_UnitTestCase { $routes = $GLOBALS['wp_rest_server']->get_routes(); - $this->assertEquals( + $this->assertSame( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true, @@ -344,7 +344,7 @@ class Tests_REST_API extends WP_UnitTestCase { $routes = $GLOBALS['wp_rest_server']->get_routes(); - $this->assertEquals( + $this->assertSame( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true, @@ -370,7 +370,7 @@ class Tests_REST_API extends WP_UnitTestCase { $headers = $response->get_headers(); $this->assertArrayHasKey( 'Allow', $headers ); - $this->assertEquals( 'GET, POST', $headers['Allow'] ); + $this->assertSame( 'GET, POST', $headers['Allow'] ); } /** @@ -402,7 +402,7 @@ class Tests_REST_API extends WP_UnitTestCase { $request = array(); $response = rest_filter_response_fields( $response, null, $request ); - $this->assertEquals( array( 'a' => true ), $response->get_data() ); + $this->assertSame( array( 'a' => true ), $response->get_data() ); } /** @@ -422,7 +422,7 @@ class Tests_REST_API extends WP_UnitTestCase { ); $response = rest_filter_response_fields( $response, null, $request ); - $this->assertEquals( array( 'b' => 1 ), $response->get_data() ); + $this->assertSame( array( 'b' => 1 ), $response->get_data() ); } /** @@ -445,7 +445,7 @@ class Tests_REST_API extends WP_UnitTestCase { ); $response = rest_filter_response_fields( $response, null, $request ); - $this->assertEquals( + $this->assertSame( array( 'b' => 1, 'c' => 2, @@ -477,7 +477,7 @@ class Tests_REST_API extends WP_UnitTestCase { ); $response = rest_filter_response_fields( $response, null, $request ); - $this->assertEquals( + $this->assertSame( array( 'b' => 1, 'c' => 2, @@ -516,7 +516,7 @@ class Tests_REST_API extends WP_UnitTestCase { ); $response = rest_filter_response_fields( $response, null, $request ); - $this->assertEquals( + $this->assertSame( array( array( 'b' => 1, @@ -562,7 +562,7 @@ class Tests_REST_API extends WP_UnitTestCase { ); $response = rest_filter_response_fields( $response, null, $request ); - $this->assertEquals( + $this->assertSame( array( 'b' => array( '1' => 1, @@ -603,7 +603,7 @@ class Tests_REST_API extends WP_UnitTestCase { ); $response = rest_filter_response_fields( $response, null, $request ); - $this->assertEquals( + $this->assertSame( array( 'field' => array( 'a' => array( @@ -639,7 +639,7 @@ class Tests_REST_API extends WP_UnitTestCase { ); $response = rest_filter_response_fields( $response, null, $request ); - $this->assertEquals( + $this->assertSame( array( 'meta' => array( 'key1' => 1, @@ -671,7 +671,7 @@ class Tests_REST_API extends WP_UnitTestCase { ); $response = rest_filter_response_fields( $response, null, $request ); - $this->assertEquals( + $this->assertSame( array( 'meta' => array( 'key1' => 1, @@ -703,7 +703,7 @@ class Tests_REST_API extends WP_UnitTestCase { ); $response = rest_filter_response_fields( $response, null, $request ); - $this->assertEquals( + $this->assertSame( array( 'meta' => array( 'key1' => 1, @@ -745,15 +745,15 @@ class Tests_REST_API extends WP_UnitTestCase { public function test_rest_url_generation() { // In pretty permalinks case, we expect a path of wp-json/ with no query. $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); - $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/wp-json/', get_rest_url() ); + $this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/wp-json/', get_rest_url() ); // In index permalinks case, we expect a path of index.php/wp-json/ with no query. $this->set_permalink_structure( '/index.php/%year%/%monthnum%/%day%/%postname%/' ); - $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/index.php/wp-json/', get_rest_url() ); + $this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/index.php/wp-json/', get_rest_url() ); // In non-pretty case, we get a query string to invoke the rest router. $this->set_permalink_structure( '' ); - $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/index.php?rest_route=/', get_rest_url() ); + $this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/index.php?rest_route=/', get_rest_url() ); } /** @@ -807,19 +807,19 @@ class Tests_REST_API extends WP_UnitTestCase { // Passing no path should return a slash. get_rest_url(); $args = $filter->get_args(); - $this->assertEquals( '/', $args[0][1] ); + $this->assertSame( '/', $args[0][1] ); $filter->reset(); // Paths without a prepended slash should have one added. get_rest_url( null, 'wp/media/' ); $args = $filter->get_args(); - $this->assertEquals( '/wp/media/', $args[0][1] ); + $this->assertSame( '/wp/media/', $args[0][1] ); $filter->reset(); // Do not modify paths with a prepended slash. get_rest_url( null, '/wp/media/' ); $args = $filter->get_args(); - $this->assertEquals( '/wp/media/', $args[0][1] ); + $this->assertSame( '/wp/media/', $args[0][1] ); unset( $filter ); } @@ -846,7 +846,7 @@ class Tests_REST_API extends WP_UnitTestCase { * @dataProvider jsonp_callback_provider */ public function test_jsonp_callback_check( $callback, $valid ) { - $this->assertEquals( $valid, wp_check_jsonp_callback( $callback ) ); + $this->assertSame( $valid, wp_check_jsonp_callback( $callback ) ); } public function rest_date_provider() { @@ -910,7 +910,7 @@ class Tests_REST_API extends WP_UnitTestCase { * @dataProvider rest_date_force_utc_provider */ public function test_rest_parse_date_force_utc( $string, $value ) { - $this->assertEquals( $value, rest_parse_date( $string, true ) ); + $this->assertSame( $value, rest_parse_date( $string, true ) ); } public function filter_wp_rest_server_class( $class_name ) { @@ -932,7 +932,7 @@ class Tests_REST_API extends WP_UnitTestCase { ); $routes = $GLOBALS['wp_rest_server']->get_routes(); - $this->assertEquals( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) ); + $this->assertSame( $routes['/test-ns/test'][0]['methods'], array( 'GET' => true ) ); } function test_rest_preload_api_request_with_method() { @@ -962,15 +962,15 @@ class Tests_REST_API extends WP_UnitTestCase { function test_rest_ensure_request_accepts_path_string() { $request = rest_ensure_request( '/wp/v2/posts' ); $this->assertInstanceOf( 'WP_REST_Request', $request ); - $this->assertEquals( '/wp/v2/posts', $request->get_route() ); - $this->assertEquals( 'GET', $request->get_method() ); + $this->assertSame( '/wp/v2/posts', $request->get_route() ); + $this->assertSame( 'GET', $request->get_method() ); } /** * @dataProvider _dp_rest_parse_embed_param */ public function test_rest_parse_embed_param( $expected, $embed ) { - $this->assertEquals( $expected, rest_parse_embed_param( $embed ) ); + $this->assertSame( $expected, rest_parse_embed_param( $embed ) ); } public function _dp_rest_parse_embed_param() { @@ -999,7 +999,7 @@ class Tests_REST_API extends WP_UnitTestCase { * @dataProvider _dp_rest_filter_response_by_context */ public function test_rest_filter_response_by_context( $schema, $data, $expected ) { - $this->assertEquals( $expected, rest_filter_response_by_context( $data, $schema, 'view' ) ); + $this->assertSame( $expected, rest_filter_response_by_context( $data, $schema, 'view' ) ); } /** @@ -1552,7 +1552,7 @@ class Tests_REST_API extends WP_UnitTestCase { * @ticket 49116 */ public function test_rest_get_route_for_post_non_post() { - $this->assertEquals( '', rest_get_route_for_post( 'garbage' ) ); + $this->assertSame( '', rest_get_route_for_post( 'garbage' ) ); } /** @@ -1563,7 +1563,7 @@ class Tests_REST_API extends WP_UnitTestCase { $post = self::factory()->post->create_and_get( array( 'post_type' => 'invalid' ) ); unregister_post_type( 'invalid' ); - $this->assertEquals( '', rest_get_route_for_post( $post ) ); + $this->assertSame( '', rest_get_route_for_post( $post ) ); } /** @@ -1571,7 +1571,7 @@ class Tests_REST_API extends WP_UnitTestCase { */ public function test_rest_get_route_for_post_non_rest() { $post = self::factory()->post->create_and_get( array( 'post_type' => 'custom_css' ) ); - $this->assertEquals( '', rest_get_route_for_post( $post ) ); + $this->assertSame( '', rest_get_route_for_post( $post ) ); } /** @@ -1579,7 +1579,7 @@ class Tests_REST_API extends WP_UnitTestCase { */ public function test_rest_get_route_for_post_custom_controller() { $post = self::factory()->post->create_and_get( array( 'post_type' => 'wp_block' ) ); - $this->assertEquals( '', rest_get_route_for_post( $post ) ); + $this->assertSame( '', rest_get_route_for_post( $post ) ); } /** @@ -1587,7 +1587,7 @@ class Tests_REST_API extends WP_UnitTestCase { */ public function test_rest_get_route_for_post() { $post = self::factory()->post->create_and_get(); - $this->assertEquals( '/wp/v2/posts/' . $post->ID, rest_get_route_for_post( $post ) ); + $this->assertSame( '/wp/v2/posts/' . $post->ID, rest_get_route_for_post( $post ) ); } /** @@ -1595,7 +1595,7 @@ class Tests_REST_API extends WP_UnitTestCase { */ public function test_rest_get_route_for_media() { $post = self::factory()->attachment->create_and_get(); - $this->assertEquals( '/wp/v2/media/' . $post->ID, rest_get_route_for_post( $post ) ); + $this->assertSame( '/wp/v2/media/' . $post->ID, rest_get_route_for_post( $post ) ); } /** @@ -1603,14 +1603,14 @@ class Tests_REST_API extends WP_UnitTestCase { */ public function test_rest_get_route_for_post_id() { $post = self::factory()->post->create_and_get(); - $this->assertEquals( '/wp/v2/posts/' . $post->ID, rest_get_route_for_post( $post->ID ) ); + $this->assertSame( '/wp/v2/posts/' . $post->ID, rest_get_route_for_post( $post->ID ) ); } /** * @ticket 49116 */ public function test_rest_get_route_for_term_non_term() { - $this->assertEquals( '', rest_get_route_for_term( 'garbage' ) ); + $this->assertSame( '', rest_get_route_for_term( 'garbage' ) ); } /** @@ -1621,7 +1621,7 @@ class Tests_REST_API extends WP_UnitTestCase { $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'invalid' ) ); unregister_taxonomy( 'invalid' ); - $this->assertEquals( '', rest_get_route_for_term( $term ) ); + $this->assertSame( '', rest_get_route_for_term( $term ) ); } /** @@ -1629,7 +1629,7 @@ class Tests_REST_API extends WP_UnitTestCase { */ public function test_rest_get_route_for_term_non_rest() { $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'post_format' ) ); - $this->assertEquals( '', rest_get_route_for_term( $term ) ); + $this->assertSame( '', rest_get_route_for_term( $term ) ); } /** @@ -1637,7 +1637,7 @@ class Tests_REST_API extends WP_UnitTestCase { */ public function test_rest_get_route_for_term() { $term = self::factory()->term->create_and_get(); - $this->assertEquals( '/wp/v2/tags/' . $term->term_id, rest_get_route_for_term( $term ) ); + $this->assertSame( '/wp/v2/tags/' . $term->term_id, rest_get_route_for_term( $term ) ); } /** @@ -1645,7 +1645,7 @@ class Tests_REST_API extends WP_UnitTestCase { */ public function test_rest_get_route_for_category() { $term = self::factory()->category->create_and_get(); - $this->assertEquals( '/wp/v2/categories/' . $term->term_id, rest_get_route_for_term( $term ) ); + $this->assertSame( '/wp/v2/categories/' . $term->term_id, rest_get_route_for_term( $term ) ); } /** @@ -1653,7 +1653,7 @@ class Tests_REST_API extends WP_UnitTestCase { */ public function test_rest_get_route_for_term_id() { $term = self::factory()->term->create_and_get(); - $this->assertEquals( '/wp/v2/tags/' . $term->term_id, rest_get_route_for_term( $term->term_id ) ); + $this->assertSame( '/wp/v2/tags/' . $term->term_id, rest_get_route_for_term( $term->term_id ) ); } /** @@ -1729,7 +1729,7 @@ class Tests_REST_API extends WP_UnitTestCase { */ public function test_rest_sanitize_object( $expected, $value ) { $sanitized = rest_sanitize_object( $value ); - $this->assertEquals( $expected, $sanitized ); + $this->assertSame( $expected, $sanitized ); } public function _dp_rest_sanitize_object() { @@ -1858,7 +1858,7 @@ class Tests_REST_API extends WP_UnitTestCase { */ public function test_rest_sanitize_array( $expected, $value ) { $sanitized = rest_sanitize_array( $value ); - $this->assertEquals( $expected, $sanitized ); + $this->assertSame( $expected, $sanitized ); } public function _dp_rest_sanitize_array() { @@ -1991,7 +1991,7 @@ class Tests_REST_API extends WP_UnitTestCase { * @param array $types The list of available types. */ public function test_get_best_type_for_value( $expected, $value, $types ) { - $this->assertEquals( $expected, rest_get_best_type_for_value( $value, $types ) ); + $this->assertSame( $expected, rest_get_best_type_for_value( $value, $types ) ); } public function _dp_get_best_type_for_value() { diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php index 09297129f4..c98df2b954 100644 --- a/tests/phpunit/tests/rest-api/rest-attachments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-attachments-controller.php @@ -155,7 +155,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control public function test_parse_disposition( $header, $expected ) { $header_list = array( $header ); $parsed = WP_REST_Attachments_Controller::get_filename_from_disposition( $header_list ); - $this->assertEquals( $expected, $parsed ); + $this->assertSame( $expected, $parsed ); } public function test_context_param() { @@ -163,8 +163,8 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/media' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $attachment_id = $this->factory->attachment->create_object( $this->test_file, @@ -177,8 +177,8 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/media/' . $attachment_id ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); } public function test_registered_query_params() { @@ -187,7 +187,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $data = $response->get_data(); $keys = array_keys( $data['endpoints'][0]['args'] ); sort( $keys ); - $this->assertEquals( + $this->assertSame( array( 'after', 'author', @@ -237,7 +237,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $data = $response->get_data(); $keys = array_keys( $data['endpoints'][0]['args'] ); sort( $keys ); - $this->assertEquals( array( 'context', 'id' ), $keys ); + $this->assertSame( array( 'context', 'id' ), $keys ); } /** @@ -258,7 +258,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $headers = $response->get_headers(); $this->assertNotEmpty( $headers['Allow'] ); - $this->assertEquals( $headers['Allow'], 'GET' ); + $this->assertSame( $headers['Allow'], 'GET' ); wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'OPTIONS', sprintf( '/wp/v2/media/%d', $id1 ) ); @@ -267,7 +267,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $headers = $response->get_headers(); $this->assertNotEmpty( $headers['Allow'] ); - $this->assertEquals( $headers['Allow'], 'GET, POST, PUT, PATCH, DELETE' ); + $this->assertSame( $headers['Allow'], 'GET, POST, PUT, PATCH, DELETE' ); } public function test_get_items() { @@ -360,7 +360,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( $id1, $data[0]['id'] ); // 'media_type' => 'video'. $request->set_param( 'media_type', 'video' ); $response = rest_get_server()->dispatch( $request ); @@ -369,7 +369,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request->set_param( 'media_type', 'image' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( $id1, $data[0]['id'] ); } public function test_get_items_mime_type() { @@ -383,7 +383,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( $id1, $data[0]['id'] ); // 'mime_type' => 'image/png'. $request->set_param( 'mime_type', 'image/png' ); $response = rest_get_server()->dispatch( $request ); @@ -392,7 +392,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request->set_param( 'mime_type', 'image/jpeg' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( $id1, $data[0]['id'] ); } public function test_get_items_parent() { @@ -416,27 +416,27 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control // All attachments. $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 2, count( $response->get_data() ) ); + $this->assertSame( 2, count( $response->get_data() ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); // Attachments without a parent. $request->set_param( 'parent', 0 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( $attachment_id2, $data[0]['id'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( $attachment_id2, $data[0]['id'] ); // Attachments with parent=post_id. $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); $request->set_param( 'parent', $post_id ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( $attachment_id, $data[0]['id'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( $attachment_id, $data[0]['id'] ); // Attachments with invalid parent. $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); $request->set_param( 'parent', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 0, count( $data ) ); + $this->assertSame( 0, count( $data ) ); } public function test_get_items_invalid_status_param_is_error_response() { @@ -455,7 +455,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( 3, $data ); - $this->assertEquals( 'rest_invalid_param', $data['code'] ); + $this->assertSame( 'rest_invalid_param', $data['code'] ); } public function test_get_items_private_status() { @@ -477,9 +477,9 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control // Properly authorized users can make the request. wp_set_current_user( self::$editor_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $attachment_id1, $data[0]['id'] ); + $this->assertSame( $attachment_id1, $data[0]['id'] ); } public function test_get_items_multiple_statuses() { @@ -510,15 +510,15 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control // Properly authorized users can make the request. wp_set_current_user( self::$editor_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); + $this->assertSame( 2, count( $data ) ); $ids = array( $data[0]['id'], $data[1]['id'], ); sort( $ids ); - $this->assertEquals( array( $attachment_id1, $attachment_id2 ), $ids ); + $this->assertSame( array( $attachment_id1, $attachment_id2 ), $ids ); } public function test_get_items_invalid_date() { @@ -563,7 +563,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertEquals( $id2, $data[0]['id'] ); + $this->assertSame( $id2, $data[0]['id'] ); } public function test_get_item() { @@ -580,7 +580,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_get_server()->dispatch( $request ); $this->check_get_post_response( $response ); $data = $response->get_data(); - $this->assertEquals( 'image/jpeg', $data['mime_type'] ); + $this->assertSame( 'image/jpeg', $data['mime_type'] ); } public function test_get_item_sizes() { @@ -604,10 +604,10 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $original_image_src = wp_get_attachment_image_src( $attachment_id, 'full' ); remove_image_size( 'rest-api-test' ); - $this->assertEquals( $image_src[0], $data['media_details']['sizes']['rest-api-test']['source_url'] ); - $this->assertEquals( 'image/jpeg', $data['media_details']['sizes']['rest-api-test']['mime_type'] ); - $this->assertEquals( $original_image_src[0], $data['media_details']['sizes']['full']['source_url'] ); - $this->assertEquals( 'image/jpeg', $data['media_details']['sizes']['full']['mime_type'] ); + $this->assertSame( $image_src[0], $data['media_details']['sizes']['rest-api-test']['source_url'] ); + $this->assertSame( 'image/jpeg', $data['media_details']['sizes']['rest-api-test']['mime_type'] ); + $this->assertSame( $original_image_src[0], $data['media_details']['sizes']['full']['source_url'] ); + $this->assertSame( 'image/jpeg', $data['media_details']['sizes']['full']['mime_type'] ); } public function test_get_item_sizes_with_no_url() { @@ -648,7 +648,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control ); $request = new WP_REST_Request( 'GET', '/wp/v2/media/' . $id1 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 401, $response->get_status() ); + $this->assertSame( 401, $response->get_status() ); } public function test_get_item_inherit_status_with_invalid_parent() { @@ -664,8 +664,8 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( $attachment_id, $data['id'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( $attachment_id, $data['id'] ); } public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() { @@ -699,18 +699,18 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 201, $response->get_status() ); - $this->assertEquals( 'image', $data['media_type'] ); + $this->assertSame( 201, $response->get_status() ); + $this->assertSame( 'image', $data['media_type'] ); $attachment = get_post( $data['id'] ); - $this->assertEquals( 'My title is very cool', $data['title']['raw'] ); - $this->assertEquals( 'My title is very cool', $attachment->post_title ); - $this->assertEquals( 'This is a better caption.', $data['caption']['raw'] ); - $this->assertEquals( 'This is a better caption.', $attachment->post_excerpt ); - $this->assertEquals( 'Without a description, my attachment is descriptionless.', $data['description']['raw'] ); - $this->assertEquals( 'Without a description, my attachment is descriptionless.', $attachment->post_content ); - $this->assertEquals( 'Alt text is stored outside post schema.', $data['alt_text'] ); - $this->assertEquals( 'Alt text is stored outside post schema.', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) ); + $this->assertSame( 'My title is very cool', $data['title']['raw'] ); + $this->assertSame( 'My title is very cool', $attachment->post_title ); + $this->assertSame( 'This is a better caption.', $data['caption']['raw'] ); + $this->assertSame( 'This is a better caption.', $attachment->post_excerpt ); + $this->assertSame( 'Without a description, my attachment is descriptionless.', $data['description']['raw'] ); + $this->assertSame( 'Without a description, my attachment is descriptionless.', $attachment->post_content ); + $this->assertSame( 'Alt text is stored outside post schema.', $data['alt_text'] ); + $this->assertSame( 'Alt text is stored outside post schema.', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) ); } public function test_create_item_default_filename_title() { @@ -728,9 +728,9 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control ); $request->set_header( 'Content-MD5', md5_file( $this->test_file2 ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'codeispoetry', $data['title']['raw'] ); + $this->assertSame( 'codeispoetry', $data['title']['raw'] ); } public function test_create_item_with_files() { @@ -748,7 +748,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control ); $request->set_header( 'Content-MD5', md5_file( $this->test_file ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); } public function test_create_item_with_upload_files_role() { @@ -766,7 +766,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control ); $request->set_header( 'Content-MD5', md5_file( $this->test_file ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); } public function test_create_item_empty_body() { @@ -875,7 +875,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request->set_param( 'alt_text', 'test alt text' ); $response = rest_get_server()->dispatch( $request ); $attachment = $response->get_data(); - $this->assertEquals( 'test alt text', $attachment['alt_text'] ); + $this->assertSame( 'test alt text', $attachment['alt_text'] ); } public function test_create_item_unsafe_alt_text() { @@ -887,7 +887,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request->set_param( 'alt_text', '<script>alert(document.cookie)</script>' ); $response = rest_get_server()->dispatch( $request ); $attachment = $response->get_data(); - $this->assertEquals( '', $attachment['alt_text'] ); + $this->assertSame( '', $attachment['alt_text'] ); } /** @@ -923,14 +923,14 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $attachment = get_post( $data['id'] ); - $this->assertEquals( 'My title is very cool', $data['title']['raw'] ); - $this->assertEquals( 'My title is very cool', $attachment->post_title ); - $this->assertEquals( 'This is a better caption.', $data['caption']['raw'] ); - $this->assertEquals( 'This is a better caption.', $attachment->post_excerpt ); - $this->assertEquals( 'Without a description, my attachment is descriptionless.', $data['description']['raw'] ); - $this->assertEquals( 'Without a description, my attachment is descriptionless.', $attachment->post_content ); - $this->assertEquals( 'Alt text is stored outside post schema.', $data['alt_text'] ); - $this->assertEquals( 'Alt text is stored outside post schema.', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) ); + $this->assertSame( 'My title is very cool', $data['title']['raw'] ); + $this->assertSame( 'My title is very cool', $attachment->post_title ); + $this->assertSame( 'This is a better caption.', $data['caption']['raw'] ); + $this->assertSame( 'This is a better caption.', $attachment->post_excerpt ); + $this->assertSame( 'Without a description, my attachment is descriptionless.', $data['description']['raw'] ); + $this->assertSame( 'Without a description, my attachment is descriptionless.', $attachment->post_content ); + $this->assertSame( 'Alt text is stored outside post schema.', $data['alt_text'] ); + $this->assertSame( 'Alt text is stored outside post schema.', get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ) ); } public function test_update_item_parent() { @@ -947,7 +947,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control ); $attachment = get_post( $attachment_id ); - $this->assertEquals( $original_parent, $attachment->post_parent ); + $this->assertSame( $original_parent, $attachment->post_parent ); $new_parent = $this->factory->post->create( array() ); $request = new WP_REST_Request( 'POST', '/wp/v2/media/' . $attachment_id ); @@ -955,7 +955,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control rest_get_server()->dispatch( $request ); $attachment = get_post( $attachment_id ); - $this->assertEquals( $new_parent, $attachment->post_parent ); + $this->assertSame( $new_parent, $attachment->post_parent ); } public function test_update_item_invalid_permissions() { @@ -1010,7 +1010,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request->set_param( $name, $value ); } $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $actual_output = $response->get_data(); // Remove <p class="attachment"> from rendered description. @@ -1023,18 +1023,18 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control } // Compare expected API output to actual API output. - $this->assertEquals( $expected_output['title']['raw'], $actual_output['title']['raw'] ); - $this->assertEquals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); - $this->assertEquals( $expected_output['description']['raw'], $actual_output['description']['raw'] ); - $this->assertEquals( $expected_output['description']['rendered'], trim( $actual_output['description']['rendered'] ) ); - $this->assertEquals( $expected_output['caption']['raw'], $actual_output['caption']['raw'] ); - $this->assertEquals( $expected_output['caption']['rendered'], trim( $actual_output['caption']['rendered'] ) ); + $this->assertSame( $expected_output['title']['raw'], $actual_output['title']['raw'] ); + $this->assertSame( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); + $this->assertSame( $expected_output['description']['raw'], $actual_output['description']['raw'] ); + $this->assertSame( $expected_output['description']['rendered'], trim( $actual_output['description']['rendered'] ) ); + $this->assertSame( $expected_output['caption']['raw'], $actual_output['caption']['raw'] ); + $this->assertSame( $expected_output['caption']['rendered'], trim( $actual_output['caption']['rendered'] ) ); // Compare expected API output to WP internal values. $post = get_post( $actual_output['id'] ); - $this->assertEquals( $expected_output['title']['raw'], $post->post_title ); - $this->assertEquals( $expected_output['description']['raw'], $post->post_content ); - $this->assertEquals( $expected_output['caption']['raw'], $post->post_excerpt ); + $this->assertSame( $expected_output['title']['raw'], $post->post_title ); + $this->assertSame( $expected_output['description']['raw'], $post->post_content ); + $this->assertSame( $expected_output['caption']['raw'], $post->post_excerpt ); // Update the post. $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/media/%d', $actual_output['id'] ) ); @@ -1042,7 +1042,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request->set_param( $name, $value ); } $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $actual_output = $response->get_data(); // Remove <p class="attachment"> from rendered description. @@ -1055,18 +1055,18 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control } // Compare expected API output to actual API output. - $this->assertEquals( $expected_output['title']['raw'], $actual_output['title']['raw'] ); - $this->assertEquals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); - $this->assertEquals( $expected_output['description']['raw'], $actual_output['description']['raw'] ); - $this->assertEquals( $expected_output['description']['rendered'], trim( $actual_output['description']['rendered'] ) ); - $this->assertEquals( $expected_output['caption']['raw'], $actual_output['caption']['raw'] ); - $this->assertEquals( $expected_output['caption']['rendered'], trim( $actual_output['caption']['rendered'] ) ); + $this->assertSame( $expected_output['title']['raw'], $actual_output['title']['raw'] ); + $this->assertSame( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); + $this->assertSame( $expected_output['description']['raw'], $actual_output['description']['raw'] ); + $this->assertSame( $expected_output['description']['rendered'], trim( $actual_output['description']['rendered'] ) ); + $this->assertSame( $expected_output['caption']['raw'], $actual_output['caption']['raw'] ); + $this->assertSame( $expected_output['caption']['rendered'], trim( $actual_output['caption']['rendered'] ) ); // Compare expected API output to WP internal values. $post = get_post( $actual_output['id'] ); - $this->assertEquals( $expected_output['title']['raw'], $post->post_title ); - $this->assertEquals( $expected_output['description']['raw'], $post->post_content ); - $this->assertEquals( $expected_output['caption']['raw'], $post->post_excerpt ); + $this->assertSame( $expected_output['title']['raw'], $post->post_title ); + $this->assertSame( $expected_output['description']['raw'], $post->post_content ); + $this->assertSame( $expected_output['caption']['raw'], $post->post_excerpt ); } public static function attachment_roundtrip_provider() { @@ -1265,7 +1265,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request = new WP_REST_Request( 'DELETE', '/wp/v2/media/' . $attachment_id ); $request['force'] = true; $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_delete_item_no_trash() { @@ -1345,7 +1345,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request->set_param( '_fields', 'id,slug' ); $obj = get_post( $attachment_id ); $response = $endpoint->prepare_item_for_response( $obj, $request ); - $this->assertEquals( + $this->assertSame( array( 'id', 'slug', @@ -1359,7 +1359,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 27, count( $properties ) ); + $this->assertSame( 27, count( $properties ) ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'alt_text', $properties ); $this->assertArrayHasKey( 'caption', $properties ); @@ -1418,7 +1418,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); - $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] ); + $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); $attachment_id = $this->factory->attachment->create_object( $this->test_file, @@ -1506,8 +1506,8 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertEquals( $id2, $data[0]['id'] ); - $this->assertEquals( 'image/png', $data[0]['mime_type'] ); + $this->assertSame( $id2, $data[0]['id'] ); + $this->assertSame( 'image/png', $data[0]['mime_type'] ); } public function additional_field_get_callback( $object, $request ) { @@ -1575,10 +1575,10 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $this->assertArrayNotHasKey( 'content', $data ); $this->assertArrayNotHasKey( 'excerpt', $data ); - $this->assertEquals( get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), $data['alt_text'] ); + $this->assertSame( get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ), $data['alt_text'] ); if ( 'edit' === $context ) { - $this->assertEquals( $attachment->post_excerpt, $data['caption']['raw'] ); - $this->assertEquals( $attachment->post_content, $data['description']['raw'] ); + $this->assertSame( $attachment->post_excerpt, $data['caption']['raw'] ); + $this->assertSame( $attachment->post_content, $data['description']['raw'] ); } else { $this->assertFalse( isset( $data['caption']['raw'] ) ); $this->assertFalse( isset( $data['description']['raw'] ) ); @@ -1586,12 +1586,12 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $this->assertTrue( isset( $data['media_details'] ) ); if ( $attachment->post_parent ) { - $this->assertEquals( $attachment->post_parent, $data['post'] ); + $this->assertSame( $attachment->post_parent, $data['post'] ); } else { $this->assertNull( $data['post'] ); } - $this->assertEquals( wp_get_attachment_url( $attachment->ID ), $data['source_url'] ); + $this->assertSame( wp_get_attachment_url( $attachment->ID ), $data['source_url'] ); } @@ -1721,7 +1721,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $request->set_body( file_get_contents( $this->test_file ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $this->assertSame( 1, self::$rest_insert_attachment_count ); $this->assertSame( 1, self::$rest_after_insert_attachment_count ); @@ -1782,8 +1782,8 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 201, $response->get_status() ); - $this->assertEquals( 'Chocolate-dipped, no filling', get_post_meta( $response->get_data()['id'], 'best_cannoli', true ) ); + $this->assertSame( 201, $response->get_status() ); + $this->assertSame( 'Chocolate-dipped, no filling', get_post_meta( $response->get_data()['id'], 'best_cannoli', true ) ); } public function filter_rest_insert_attachment( $attachment ) { @@ -1901,7 +1901,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $this->assertErrorResponse( 'rest_image_rotation_failed', $response, 500 ); $this->assertCount( 1, WP_Image_Editor_Mock::$spy['rotate'] ); - $this->assertEquals( array( -60 ), WP_Image_Editor_Mock::$spy['rotate'][0] ); + $this->assertSame( array( -60 ), WP_Image_Editor_Mock::$spy['rotate'][0] ); } /** @@ -1934,7 +1934,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $this->assertErrorResponse( 'rest_image_crop_failed', $response, 500 ); $this->assertCount( 1, WP_Image_Editor_Mock::$spy['crop'] ); - $this->assertEquals( + $this->assertSame( array( 320.0, 48.0, 64.0, 24.0 ), WP_Image_Editor_Mock::$spy['crop'][0] ); @@ -1957,8 +1957,8 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_do_request( $request ); $item = $response->get_data(); - $this->assertEquals( 201, $response->get_status() ); - $this->assertEquals( rest_url( '/wp/v2/media/' . $item['id'] ), $response->get_headers()['Location'] ); + $this->assertSame( 201, $response->get_status() ); + $this->assertSame( rest_url( '/wp/v2/media/' . $item['id'] ), $response->get_headers()['Location'] ); $this->assertStringEndsWith( '-edited.jpg', $item['media_details']['file'] ); $this->assertArrayHasKey( 'parent_image', $item['media_details'] ); diff --git a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php index 8d989f7df7..588972801d 100644 --- a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php +++ b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php @@ -140,14 +140,14 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id . '/autosaves' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id . '/autosaves/' . self::$autosave_post_id ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); } @@ -157,7 +157,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $data = $response->get_data(); $keys = array_keys( $data['endpoints'][0]['args'] ); sort( $keys ); - $this->assertEquals( + $this->assertSame( array( 'context', 'parent', @@ -171,10 +171,10 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/autosaves' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertCount( 1, $data ); - $this->assertEquals( self::$autosave_post_id, $data[0]['id'] ); + $this->assertSame( self::$autosave_post_id, $data[0]['id'] ); $this->check_get_autosave_response( $data[0], $this->post_autosave ); } @@ -207,7 +207,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/autosaves/' . self::$autosave_post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->check_get_autosave_response( $response, $this->post_autosave ); @@ -277,7 +277,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/autosaves/' . self::$autosave_post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->check_get_autosave_response( $response, $this->post_autosave ); } @@ -286,7 +286,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 13, count( $properties ) ); + $this->assertSame( 13, count( $properties ) ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'content', $properties ); $this->assertArrayHasKey( 'date', $properties ); @@ -377,17 +377,17 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( $current_post->ID, $new_data['parent'] ); - $this->assertEquals( $current_post->post_title, $new_data['title']['raw'] ); - $this->assertEquals( $current_post->post_excerpt, $new_data['excerpt']['raw'] ); + $this->assertSame( $current_post->ID, $new_data['parent'] ); + $this->assertSame( $current_post->post_title, $new_data['title']['raw'] ); + $this->assertSame( $current_post->post_excerpt, $new_data['excerpt']['raw'] ); // Updated post_content. $this->assertNotEquals( $current_post->post_content, $new_data['content']['raw'] ); $autosave_post = wp_get_post_autosave( self::$post_id ); - $this->assertEquals( $autosave_data['title'], $autosave_post->post_title ); - $this->assertEquals( $autosave_data['content'], $autosave_post->post_content ); - $this->assertEquals( $autosave_data['excerpt'], $autosave_post->post_excerpt ); + $this->assertSame( $autosave_data['title'], $autosave_post->post_title ); + $this->assertSame( $autosave_data['content'], $autosave_post->post_content ); + $this->assertSame( $autosave_data['excerpt'], $autosave_post->post_excerpt ); } public function test_rest_autosave_draft_post_same_author() { @@ -414,15 +414,15 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $new_data = $response->get_data(); $post = get_post( $post_id ); - $this->assertEquals( $post_id, $new_data['id'] ); + $this->assertSame( $post_id, $new_data['id'] ); // The draft post should be updated. - $this->assertEquals( $autosave_data['content'], $new_data['content']['raw'] ); - $this->assertEquals( $autosave_data['title'], $new_data['title']['raw'] ); - $this->assertEquals( $autosave_data['content'], $post->post_content ); - $this->assertEquals( $autosave_data['title'], $post->post_title ); + $this->assertSame( $autosave_data['content'], $new_data['content']['raw'] ); + $this->assertSame( $autosave_data['title'], $new_data['title']['raw'] ); + $this->assertSame( $autosave_data['content'], $post->post_content ); + $this->assertSame( $autosave_data['title'], $post->post_title ); // Not updated. - $this->assertEquals( $post_data['post_excerpt'], $post->post_excerpt ); + $this->assertSame( $post_data['post_excerpt'], $post->post_excerpt ); wp_delete_post( $post_id ); } @@ -453,21 +453,21 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $new_data = $response->get_data(); $current_post = get_post( $post_id ); - $this->assertEquals( $current_post->ID, $new_data['parent'] ); + $this->assertSame( $current_post->ID, $new_data['parent'] ); // The draft post shouldn't change. - $this->assertEquals( $current_post->post_title, $post_data['post_title'] ); - $this->assertEquals( $current_post->post_content, $post_data['post_content'] ); - $this->assertEquals( $current_post->post_excerpt, $post_data['post_excerpt'] ); + $this->assertSame( $current_post->post_title, $post_data['post_title'] ); + $this->assertSame( $current_post->post_content, $post_data['post_content'] ); + $this->assertSame( $current_post->post_excerpt, $post_data['post_excerpt'] ); $autosave_post = wp_get_post_autosave( $post_id ); // No changes. - $this->assertEquals( $current_post->post_title, $autosave_post->post_title ); - $this->assertEquals( $current_post->post_excerpt, $autosave_post->post_excerpt ); + $this->assertSame( $current_post->post_title, $autosave_post->post_title ); + $this->assertSame( $current_post->post_excerpt, $autosave_post->post_excerpt ); // Has changes. - $this->assertEquals( $autosave_data['content'], $autosave_post->post_content ); + $this->assertSame( $autosave_data['content'], $autosave_post->post_content ); wp_delete_post( $post_id ); } @@ -496,7 +496,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $data = $response->get_data(); $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); - $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] ); + $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); wp_set_current_user( 1 ); @@ -529,27 +529,27 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $this->assertEquals( $autosave->post_author, $response['author'] ); $rendered_content = apply_filters( 'the_content', $autosave->post_content ); - $this->assertEquals( $rendered_content, $response['content']['rendered'] ); + $this->assertSame( $rendered_content, $response['content']['rendered'] ); - $this->assertEquals( mysql_to_rfc3339( $autosave->post_date ), $response['date'] ); //@codingStandardsIgnoreLine - $this->assertEquals( mysql_to_rfc3339( $autosave->post_date_gmt ), $response['date_gmt'] ); //@codingStandardsIgnoreLine + $this->assertSame( mysql_to_rfc3339( $autosave->post_date ), $response['date'] ); //@codingStandardsIgnoreLine + $this->assertSame( mysql_to_rfc3339( $autosave->post_date_gmt ), $response['date_gmt'] ); //@codingStandardsIgnoreLine $rendered_guid = apply_filters( 'get_the_guid', $autosave->guid, $autosave->ID ); - $this->assertEquals( $rendered_guid, $response['guid']['rendered'] ); + $this->assertSame( $rendered_guid, $response['guid']['rendered'] ); - $this->assertEquals( $autosave->ID, $response['id'] ); - $this->assertEquals( mysql_to_rfc3339( $autosave->post_modified ), $response['modified'] ); //@codingStandardsIgnoreLine - $this->assertEquals( mysql_to_rfc3339( $autosave->post_modified_gmt ), $response['modified_gmt'] ); //@codingStandardsIgnoreLine - $this->assertEquals( $autosave->post_name, $response['slug'] ); + $this->assertSame( $autosave->ID, $response['id'] ); + $this->assertSame( mysql_to_rfc3339( $autosave->post_modified ), $response['modified'] ); //@codingStandardsIgnoreLine + $this->assertSame( mysql_to_rfc3339( $autosave->post_modified_gmt ), $response['modified_gmt'] ); //@codingStandardsIgnoreLine + $this->assertSame( $autosave->post_name, $response['slug'] ); $rendered_title = get_the_title( $autosave->ID ); - $this->assertEquals( $rendered_title, $response['title']['rendered'] ); + $this->assertSame( $rendered_title, $response['title']['rendered'] ); $parent = get_post( $autosave->post_parent ); $parent_controller = new WP_REST_Posts_Controller( $parent->post_type ); $parent_object = get_post_type_object( $parent->post_type ); $parent_base = ! empty( $parent_object->rest_base ) ? $parent_object->rest_base : $parent_object->name; - $this->assertEquals( rest_url( '/wp/v2/' . $parent_base . '/' . $autosave->post_parent ), $links['parent'][0]['href'] ); + $this->assertSame( rest_url( '/wp/v2/' . $parent_base . '/' . $autosave->post_parent ), $links['parent'][0]['href'] ); } public function test_get_item_sets_up_postdata() { @@ -560,8 +560,8 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $post = get_post(); $parent_post_id = wp_is_post_revision( $post->ID ); - $this->assertEquals( $post->ID, self::$autosave_post_id ); - $this->assertEquals( $parent_post_id, self::$post_id ); + $this->assertSame( $post->ID, self::$autosave_post_id ); + $this->assertSame( $parent_post_id, self::$post_id ); } public function test_update_item_draft_page_with_parent() { @@ -580,8 +580,8 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( self::$child_draft_page_id, $data['id'] ); - $this->assertEquals( self::$parent_page_id, $data['parent'] ); + $this->assertSame( self::$child_draft_page_id, $data['id'] ); + $this->assertSame( self::$parent_page_id, $data['parent'] ); } public function test_schema_validation_is_applied() { diff --git a/tests/phpunit/tests/rest-api/rest-block-directory-controller.php b/tests/phpunit/tests/rest-api/rest-block-directory-controller.php index ee8d21aa89..3060efb0c1 100644 --- a/tests/phpunit/tests/rest-api/rest-block-directory-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-directory-controller.php @@ -60,8 +60,8 @@ class WP_REST_Block_Directory_Controller_Test extends WP_Test_REST_Controller_Te $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/block-directory/search' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view' ), $data['endpoints'][0]['args']['context']['enum'] ); } /** @@ -75,7 +75,7 @@ class WP_REST_Block_Directory_Controller_Test extends WP_Test_REST_Controller_Te $result = rest_do_request( $request ); $this->assertNotWPError( $result->as_error() ); - $this->assertEquals( 200, $result->status ); + $this->assertSame( 200, $result->status ); } /** @@ -116,8 +116,8 @@ class WP_REST_Block_Directory_Controller_Test extends WP_Test_REST_Controller_Te $data = $response->get_data(); // Should produce a 200 status with an empty array. - $this->assertEquals( 200, $response->status ); - $this->assertEquals( array(), $data ); + $this->assertSame( 200, $response->status ); + $this->assertSame( array(), $data ); } public function test_get_item() { @@ -166,7 +166,7 @@ class WP_REST_Block_Directory_Controller_Test extends WP_Test_REST_Controller_Te 'humanized_updated' => sprintf( '%s ago', human_time_diff( strtotime( $plugin['last_updated'] ) ) ), ); - $this->assertEquals( $expected, $response->get_data() ); + $this->assertSame( $expected, $response->get_data() ); } /** @@ -181,7 +181,7 @@ class WP_REST_Block_Directory_Controller_Test extends WP_Test_REST_Controller_Te $data = $response->get_data(); // Check endpoints - $this->assertEquals( array( 'GET' ), $data['endpoints'][0]['methods'] ); + $this->assertSame( array( 'GET' ), $data['endpoints'][0]['methods'] ); $this->assertTrue( $data['endpoints'][0]['args']['term']['required'] ); $properties = $data['schema']['properties']; diff --git a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php index 8fc64c0f60..ee2b37408f 100644 --- a/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php @@ -335,7 +335,7 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); } /** @@ -356,7 +356,7 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); } /** @@ -381,10 +381,10 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca $request->set_param( 'context', 'edit' ); $request->set_param( 'attributes', array() ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $defaults, json_decode( $data['rendered'], true ) ); + $this->assertSame( $defaults, json_decode( $data['rendered'], true ) ); $this->assertEquals( json_decode( $block_type->render( $defaults ) ), json_decode( $data['rendered'] ) @@ -416,10 +416,10 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca $request->set_param( 'context', 'edit' ); $request->set_param( 'attributes', $attributes ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $expected_attributes, json_decode( $data['rendered'], true ) ); + $this->assertSame( $expected_attributes, json_decode( $data['rendered'], true ) ); $this->assertEquals( json_decode( $block_type->render( $attributes ), true ), json_decode( $data['rendered'], true ) @@ -451,10 +451,10 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca $request->set_param( 'context', 'edit' ); $request->set_param( 'attributes', $attributes ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( '<p>Alternate content.</p>', $data['rendered'] ); + $this->assertSame( '<p>Alternate content.</p>', $data['rendered'] ); remove_filter( 'pre_render_block', $pre_render_filter ); } @@ -474,7 +474,7 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca // Test without post ID. $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertTrue( empty( $data['rendered'] ) ); @@ -483,10 +483,10 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca $request->set_param( 'post_id', self::$post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $expected_title, $data['rendered'] ); + $this->assertSame( $expected_title, $data['rendered'] ); } /** @@ -504,7 +504,7 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca $request->set_body( wp_json_encode( compact( 'attributes' ) ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertContains( $string_attribute, $response->get_data()['rendered'] ); } @@ -578,7 +578,7 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca $request->set_param( 'context', 'edit' ); $request->set_param( 'attributes', $attributes ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertSame( $expected, json_decode( $data['rendered'], true ) ); @@ -601,14 +601,14 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca array( 'name', 'context', 'attributes', 'post_id' ), array_keys( $data['endpoints'][0]['args'] ) ); - $this->assertEquals( 'object', $data['endpoints'][0]['args']['attributes']['type'] ); + $this->assertSame( 'object', $data['endpoints'][0]['args']['attributes']['type'] ); $this->assertArrayHasKey( 'schema', $data ); - $this->assertEquals( 'rendered-block', $data['schema']['title'] ); - $this->assertEquals( 'object', $data['schema']['type'] ); + $this->assertSame( 'rendered-block', $data['schema']['title'] ); + $this->assertSame( 'object', $data['schema']['type'] ); $this->arrayHasKey( 'rendered', $data['schema']['properties'] ); $this->arrayHasKey( 'string', $data['schema']['properties']['rendered']['type'] ); - $this->assertEquals( array( 'edit' ), $data['schema']['properties']['rendered']['context'] ); + $this->assertSame( array( 'edit' ), $data['schema']['properties']['rendered']['context'] ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-block-type-controller.php b/tests/phpunit/tests/rest-api/rest-block-type-controller.php index cac5b67f4d..bfe98454c5 100644 --- a/tests/phpunit/tests/rest-api/rest-block-type-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-type-controller.php @@ -91,14 +91,14 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/block-types' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/block-types/fake/test' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); } /** @@ -230,14 +230,14 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/block-types/' . $block_type ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $block_type, $data['name'] ); - $this->assertEquals( '1', $data['title'] ); - $this->assertEquals( '1', $data['description'] ); - $this->assertEquals( null, $data['icon'] ); - $this->assertEquals( null, $data['editor_script'] ); - $this->assertEquals( null, $data['script'] ); - $this->assertEquals( null, $data['editor_style'] ); - $this->assertEquals( null, $data['style'] ); + $this->assertSame( $block_type, $data['name'] ); + $this->assertSame( '1', $data['title'] ); + $this->assertSame( '1', $data['description'] ); + $this->assertNull( $data['icon'] ); + $this->assertNull( $data['editor_script'] ); + $this->assertNull( $data['script'] ); + $this->assertNull( $data['editor_style'] ); + $this->assertNull( $data['style'] ); $this->assertEqualSets( array(), $data['provides_context'] ); $this->assertEqualSets( array(), $data['attributes'] ); $this->assertEqualSets( array( 'invalid_uses_context' ), $data['uses_context'] ); @@ -245,10 +245,10 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase { $this->assertEqualSets( array( 'invalid_parent' ), $data['parent'] ); $this->assertEqualSets( array(), $data['supports'] ); $this->assertEqualSets( array(), $data['styles'] ); - $this->assertEquals( null, $data['example'] ); - $this->assertEquals( null, $data['category'] ); - $this->assertEquals( null, $data['textdomain'] ); - $this->assertFalse( false, $data['is_dynamic'] ); + $this->assertNull( $data['example'] ); + $this->assertNull( $data['category'] ); + $this->assertNull( $data['textdomain'] ); + $this->assertFalse( $data['is_dynamic'] ); } /** @@ -281,14 +281,14 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/block-types/' . $block_type ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $block_type, $data['name'] ); - $this->assertEquals( '', $data['title'] ); - $this->assertEquals( '', $data['description'] ); - $this->assertEquals( null, $data['icon'] ); - $this->assertEquals( null, $data['editor_script'] ); - $this->assertEquals( null, $data['script'] ); - $this->assertEquals( null, $data['editor_style'] ); - $this->assertEquals( null, $data['style'] ); + $this->assertSame( $block_type, $data['name'] ); + $this->assertSame( '', $data['title'] ); + $this->assertSame( '', $data['description'] ); + $this->assertNull( $data['icon'] ); + $this->assertNull( $data['editor_script'] ); + $this->assertNull( $data['script'] ); + $this->assertNull( $data['editor_style'] ); + $this->assertNull( $data['style'] ); $this->assertEqualSets( array(), $data['attributes'] ); $this->assertEqualSets( array(), $data['provides_context'] ); $this->assertEqualSets( array(), $data['uses_context'] ); @@ -296,11 +296,11 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase { $this->assertEqualSets( array(), $data['parent'] ); $this->assertEqualSets( array(), $data['supports'] ); $this->assertEqualSets( array(), $data['styles'] ); - $this->assertEquals( null, $data['example'] ); - $this->assertEquals( null, $data['category'] ); - $this->assertEquals( null, $data['example'] ); - $this->assertEquals( null, $data['textdomain'] ); - $this->assertFalse( false, $data['is_dynamic'] ); + $this->assertNull( $data['example'] ); + $this->assertNull( $data['category'] ); + $this->assertNull( $data['example'] ); + $this->assertNull( $data['textdomain'] ); + $this->assertFalse( $data['is_dynamic'] ); } /** @@ -408,7 +408,7 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase { $request->set_param( 'context', 'edit' ); $request->set_param( '_fields', 'name' ); $response = $endpoint->prepare_item_for_response( $block_type, $request ); - $this->assertEquals( + $this->assertSame( array( 'name', ), @@ -427,8 +427,8 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase { */ protected function check_block_type_object( $block_type, $data, $links ) { // Test data. - $this->assertEquals( $data['attributes'], $block_type->get_attributes() ); - $this->assertEquals( $data['is_dynamic'], $block_type->is_dynamic() ); + $this->assertSame( $data['attributes'], $block_type->get_attributes() ); + $this->assertSame( $data['is_dynamic'], $block_type->is_dynamic() ); $extra_fields = array( 'name', @@ -452,13 +452,13 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase { foreach ( $extra_fields as $extra_field ) { if ( isset( $block_type->$extra_field ) ) { - $this->assertEquals( $data[ $extra_field ], $block_type->$extra_field ); + $this->assertSame( $data[ $extra_field ], $block_type->$extra_field ); } } // Test links. - $this->assertEquals( rest_url( 'wp/v2/block-types' ), $links['collection'][0]['href'] ); - $this->assertEquals( rest_url( 'wp/v2/block-types/' . $block_type->name ), $links['self'][0]['href'] ); + $this->assertSame( rest_url( 'wp/v2/block-types' ), $links['collection'][0]['href'] ); + $this->assertSame( rest_url( 'wp/v2/block-types/' . $block_type->name ), $links['self'][0]['href'] ); if ( $block_type->is_dynamic() ) { $this->assertArrayHasKey( 'https://api.w.org/render-block', $links ); } diff --git a/tests/phpunit/tests/rest-api/rest-blocks-controller.php b/tests/phpunit/tests/rest-api/rest-blocks-controller.php index 1c77633f0b..e5fbb33302 100644 --- a/tests/phpunit/tests/rest-api/rest-blocks-controller.php +++ b/tests/phpunit/tests/rest-api/rest-blocks-controller.php @@ -133,7 +133,7 @@ class REST_Blocks_Controller_Test extends WP_UnitTestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( $expected_status, $response->get_status() ); + $this->assertSame( $expected_status, $response->get_status() ); break; @@ -141,7 +141,7 @@ class REST_Blocks_Controller_Test extends WP_UnitTestCase { $request = new WP_REST_Request( 'GET', '/wp/v2/blocks/' . self::$post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( $expected_status, $response->get_status() ); + $this->assertSame( $expected_status, $response->get_status() ); break; @@ -165,12 +165,12 @@ class REST_Blocks_Controller_Test extends WP_UnitTestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( $expected_status, $response->get_status() ); + $this->assertSame( $expected_status, $response->get_status() ); $request = new WP_REST_Request( 'DELETE', '/wp/v2/blocks/' . $post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( $expected_status, $response->get_status() ); + $this->assertSame( $expected_status, $response->get_status() ); wp_delete_post( $post_id ); @@ -186,12 +186,12 @@ class REST_Blocks_Controller_Test extends WP_UnitTestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( $expected_status, $response->get_status() ); + $this->assertSame( $expected_status, $response->get_status() ); $request = new WP_REST_Request( 'DELETE', '/wp/v2/blocks/' . self::$post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( $expected_status, $response->get_status() ); + $this->assertSame( $expected_status, $response->get_status() ); break; @@ -212,13 +212,13 @@ class REST_Blocks_Controller_Test extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( + $this->assertSame( array( 'raw' => 'My cool block', ), $data['title'] ); - $this->assertEquals( + $this->assertSame( array( 'raw' => '<!-- wp:paragraph --><p>Hello!</p><!-- /wp:paragraph -->', 'protected' => false, diff --git a/tests/phpunit/tests/rest-api/rest-categories-controller.php b/tests/phpunit/tests/rest-api/rest-categories-controller.php index ecae01f880..de87f8d29c 100644 --- a/tests/phpunit/tests/rest-api/rest-categories-controller.php +++ b/tests/phpunit/tests/rest-api/rest-categories-controller.php @@ -117,14 +117,14 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/categories' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $category1 = $this->factory->category->create( array( 'name' => 'Season 5' ) ); $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/categories/' . $category1 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); } @@ -134,7 +134,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $data = $response->get_data(); $keys = array_keys( $data['endpoints'][0]['args'] ); sort( $keys ); - $this->assertEquals( + $this->assertSame( array( 'context', 'exclude', @@ -183,15 +183,15 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'hide_empty', true ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( 'Season 5', $data[0]['name'] ); - $this->assertEquals( 'The Be Sharps', $data[1]['name'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( 'Season 5', $data[0]['name'] ); + $this->assertSame( 'The Be Sharps', $data[1]['name'] ); // Confirm the empty category "Uncategorized" category appears. $request->set_param( 'hide_empty', 'false' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $total_categories, count( $data ) ); + $this->assertSame( $total_categories, count( $data ) ); } public function test_get_items_parent_zero_arg() { @@ -215,7 +215,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'parent', 0 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $args = array( @@ -223,7 +223,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas 'parent' => 0, ); $categories = get_terms( 'category', $args ); - $this->assertEquals( count( $categories ), count( $data ) ); + $this->assertSame( count( $categories ), count( $data ) ); } public function test_get_items_parent_zero_arg_string() { @@ -247,7 +247,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'parent', '0' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $args = array( @@ -255,7 +255,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas 'parent' => 0, ); $categories = get_terms( 'category', $args ); - $this->assertEquals( count( $categories ), count( $data ) ); + $this->assertSame( count( $categories ), count( $data ) ); } public function test_get_items_by_parent_non_found() { @@ -265,10 +265,10 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'parent', $parent1 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( array(), $data ); + $this->assertSame( array(), $data ); } public function test_get_items_invalid_page() { @@ -291,15 +291,15 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'include', array( $id2, $id1 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( $id1, $data[0]['id'] ); // 'orderby' => 'include'. $request->set_param( 'orderby', 'include' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( $id2, $data[0]['id'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( $id2, $data[0]['id'] ); } public function test_get_items_exclude_query() { @@ -337,20 +337,20 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'order', 'desc' ); $request->set_param( 'per_page', 1 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( 'Uncategorized', $data[0]['name'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( 'Uncategorized', $data[0]['name'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $request->set_param( 'orderby', 'name' ); $request->set_param( 'order', 'asc' ); $request->set_param( 'per_page', 2 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( 'Apple', $data[0]['name'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( 'Apple', $data[0]['name'] ); } public function test_get_items_orderby_id() { @@ -361,21 +361,21 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas // Defaults to 'orderby' => 'name', 'order' => 'asc'. $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'Apple', $data[0]['name'] ); - $this->assertEquals( 'Banana', $data[1]['name'] ); - $this->assertEquals( 'Cantaloupe', $data[2]['name'] ); + $this->assertSame( 'Apple', $data[0]['name'] ); + $this->assertSame( 'Banana', $data[1]['name'] ); + $this->assertSame( 'Cantaloupe', $data[2]['name'] ); // 'orderby' => 'id', with default 'order' => 'asc'. $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $request->set_param( 'orderby', 'id' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'Category 0', $data[1]['name'] ); - $this->assertEquals( 'Category 1', $data[2]['name'] ); - $this->assertEquals( 'Category 2', $data[3]['name'] ); + $this->assertSame( 'Category 0', $data[1]['name'] ); + $this->assertSame( 'Category 1', $data[2]['name'] ); + $this->assertSame( 'Category 2', $data[3]['name'] ); // 'orderby' => 'id', 'order' => 'desc'. $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); @@ -383,10 +383,10 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'order', 'desc' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 'Banana', $data[0]['name'] ); - $this->assertEquals( 'Apple', $data[1]['name'] ); - $this->assertEquals( 'Cantaloupe', $data[2]['name'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 'Banana', $data[0]['name'] ); + $this->assertSame( 'Apple', $data[1]['name'] ); + $this->assertSame( 'Cantaloupe', $data[2]['name'] ); } public function test_get_items_orderby_slugs() { @@ -399,10 +399,10 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'slug', array( 'taco', 'burrito', 'chalupa' ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 'taco', $data[0]['slug'] ); - $this->assertEquals( 'burrito', $data[1]['slug'] ); - $this->assertEquals( 'chalupa', $data[2]['slug'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 'taco', $data[0]['slug'] ); + $this->assertSame( 'burrito', $data[1]['slug'] ); + $this->assertSame( 'chalupa', $data[2]['slug'] ); } protected function post_with_categories() { @@ -436,14 +436,14 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $request->set_param( 'post', $post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 3, count( $data ) ); + $this->assertSame( 3, count( $data ) ); // Check ordered by name by default. $names = wp_list_pluck( $data, 'name' ); - $this->assertEquals( array( 'DC', 'Image', 'Marvel' ), $names ); + $this->assertSame( array( 'DC', 'Image', 'Marvel' ), $names ); } public function test_get_items_post_ordered_by_description() { @@ -454,22 +454,22 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'post', $post_id ); $request->set_param( 'orderby', 'description' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 3, count( $data ) ); + $this->assertSame( 3, count( $data ) ); $names = wp_list_pluck( $data, 'name' ); - $this->assertEquals( array( 'Image', 'Marvel', 'DC' ), $names, 'Terms should be ordered by description' ); + $this->assertSame( array( 'Image', 'Marvel', 'DC' ), $names, 'Terms should be ordered by description' ); // Flip the order. $request->set_param( 'order', 'desc' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 3, count( $data ) ); + $this->assertSame( 3, count( $data ) ); $names = wp_list_pluck( $data, 'name' ); - $this->assertEquals( array( 'DC', 'Marvel', 'Image' ), $names, 'Terms should be reverse-ordered by description' ); + $this->assertSame( array( 'DC', 'Marvel', 'Image' ), $names, 'Terms should be reverse-ordered by description' ); } public function test_get_items_post_ordered_by_id() { @@ -479,12 +479,12 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'post', $post_id ); $request->set_param( 'orderby', 'id' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 3, count( $data ) ); + $this->assertSame( 3, count( $data ) ); $names = wp_list_pluck( $data, 'name' ); - $this->assertEquals( array( 'DC', 'Marvel', 'Image' ), $names ); + $this->assertSame( array( 'DC', 'Marvel', 'Image' ), $names ); } public function test_get_items_custom_tax_post_args() { @@ -515,11 +515,11 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request = new WP_REST_Request( 'GET', '/wp/v2/batman' ); $request->set_param( 'post', $post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( 'Cape', $data[0]['name'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( 'Cape', $data[0]['name'] ); } public function test_get_items_search_args() { @@ -533,17 +533,17 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $request->set_param( 'search', 'App' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( 'Apple', $data[0]['name'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( 'Apple', $data[0]['name'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $request->set_param( 'search', 'Garbage' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 0, count( $data ) ); + $this->assertSame( 0, count( $data ) ); } public function test_get_items_slug_arg() { @@ -553,10 +553,10 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $request->set_param( 'slug', 'apple' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( 'Apple', $data[0]['name'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( 'Apple', $data[0]['name'] ); } public function test_get_terms_parent_arg() { @@ -572,8 +572,8 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'parent', $category1 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( 'Child', $data[0]['name'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( 'Child', $data[0]['name'] ); } public function test_get_terms_invalid_parent_arg() { @@ -617,8 +617,8 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_categories, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_categories, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $this->assertCount( 10, $response->get_data() ); $next_link = add_query_arg( array( @@ -637,8 +637,8 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'page', 3 ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_categories, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_categories, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $this->assertCount( 10, $response->get_data() ); $prev_link = add_query_arg( array( @@ -660,8 +660,8 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'page', $total_pages ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_categories, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_categories, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $this->assertCount( 1, $response->get_data() ); $prev_link = add_query_arg( array( @@ -677,8 +677,8 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'page', 100 ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_categories, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_categories, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $this->assertCount( 0, $response->get_data() ); $prev_link = add_query_arg( array( @@ -697,8 +697,8 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'per_page', 100 ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( self::$total_categories, $headers['X-WP-Total'] ); - $this->assertEquals( 1, $headers['X-WP-TotalPages'] ); + $this->assertSame( self::$total_categories, $headers['X-WP-Total'] ); + $this->assertSame( 1, $headers['X-WP-TotalPages'] ); $this->assertCount( self::$total_categories, $response->get_data() ); $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); @@ -706,8 +706,8 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'per_page', 100 ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( self::$total_categories, $headers['X-WP-Total'] ); - $this->assertEquals( 1, $headers['X-WP-TotalPages'] ); + $this->assertSame( self::$total_categories, $headers['X-WP-Total'] ); + $this->assertSame( 1, $headers['X-WP-TotalPages'] ); $this->assertCount( 0, $response->get_data() ); } @@ -807,13 +807,13 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'description', 'This term is so awesome.' ); $request->set_param( 'slug', 'so-awesome' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $headers = $response->get_headers(); $data = $response->get_data(); $this->assertContains( '/wp/v2/categories/' . $data['id'], $headers['Location'] ); - $this->assertEquals( 'My Awesome Term', $data['name'] ); - $this->assertEquals( 'This term is so awesome.', $data['description'] ); - $this->assertEquals( 'so-awesome', $data['slug'] ); + $this->assertSame( 'My Awesome Term', $data['name'] ); + $this->assertSame( 'This term is so awesome.', $data['description'] ); + $this->assertSame( 'so-awesome', $data['slug'] ); } /** @@ -828,10 +828,10 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'name', 'Existing' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'term_exists', $data['code'] ); - $this->assertEquals( $existing_id, (int) $data['data']['term_id'] ); + $this->assertSame( 'term_exists', $data['code'] ); + $this->assertSame( $existing_id, (int) $data['data']['term_id'] ); wp_delete_term( $existing_id, 'category' ); } @@ -880,9 +880,9 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'name', 'My Awesome Term' ); $request->set_param( 'parent', $parent['term_id'] ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $parent['term_id'], $data['parent'] ); + $this->assertSame( $parent['term_id'], $data['parent'] ); } public function test_create_item_invalid_parent() { @@ -906,9 +906,9 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'name', 'My Awesome Term' ); $request->set_param( 'parent', $parent ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $parent, $data['parent'] ); + $this->assertSame( $parent, $data['parent'] ); } public function test_update_item() { @@ -935,13 +935,13 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'New Name', $data['name'] ); - $this->assertEquals( 'New Description', $data['description'] ); - $this->assertEquals( 'new-slug', $data['slug'] ); - $this->assertEquals( 'just meta', $data['meta']['test_single'] ); - $this->assertEquals( 'category-specific meta', $data['meta']['test_cat_single'] ); + $this->assertSame( 'New Name', $data['name'] ); + $this->assertSame( 'New Description', $data['description'] ); + $this->assertSame( 'new-slug', $data['slug'] ); + $this->assertSame( 'just meta', $data['meta']['test_single'] ); + $this->assertSame( 'category-specific meta', $data['meta']['test_cat_single'] ); $this->assertFalse( isset( $data['meta']['test_tag_meta'] ) ); } @@ -983,10 +983,10 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); $request->set_param( 'parent', $parent->term_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $parent->term_id, $data['parent'] ); + $this->assertSame( $parent->term_id, $data['parent'] ); } public function test_update_item_remove_parent() { @@ -1005,15 +1005,15 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas 'category' ); - $this->assertEquals( $old_parent_term->term_id, $term->parent ); + $this->assertSame( $old_parent_term->term_id, $term->parent ); $request = new WP_REST_Request( 'POST', '/wp/v2/categories/' . $term->term_id ); $request->set_param( 'parent', $new_parent_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $new_parent_id, $data['parent'] ); + $this->assertSame( $new_parent_id, $data['parent'] ); } public function test_update_item_invalid_parent() { @@ -1035,10 +1035,10 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request = new WP_REST_Request( 'DELETE', '/wp/v2/categories/' . $term->term_id ); $request->set_param( 'force', true ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertTrue( $data['deleted'] ); - $this->assertEquals( 'Deleted Category', $data['previous']['name'] ); + $this->assertSame( 'Deleted Category', $data['previous']['name'] ); } public function test_delete_item_no_trash() { @@ -1096,7 +1096,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( '_fields', 'id,name' ); $term = get_term( 1, 'category' ); $response = $endpoint->prepare_item_for_response( $term, $request ); - $this->assertEquals( + $this->assertSame( array( 'id', 'name', @@ -1119,10 +1119,10 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $this->check_taxonomy_term( $term, $data, $response->get_links() ); - $this->assertEquals( 1, $data['parent'] ); + $this->assertSame( 1, $data['parent'] ); $links = $response->get_links(); - $this->assertEquals( rest_url( 'wp/v2/categories/1' ), $links['up'][0]['href'] ); + $this->assertSame( rest_url( 'wp/v2/categories/1' ), $links['up'][0]['href'] ); } public function test_get_item_schema() { @@ -1130,7 +1130,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 9, count( $properties ) ); + $this->assertSame( 9, count( $properties ) ); $this->assertArrayHasKey( 'id', $properties ); $this->assertArrayHasKey( 'count', $properties ); $this->assertArrayHasKey( 'description', $properties ); @@ -1140,7 +1140,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $this->assertArrayHasKey( 'parent', $properties ); $this->assertArrayHasKey( 'slug', $properties ); $this->assertArrayHasKey( 'taxonomy', $properties ); - $this->assertEquals( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] ); + $this->assertSame( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] ); } public function test_get_additional_field_registration() { @@ -1166,7 +1166,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); - $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] ); + $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); $category_id = $this->factory->category->create(); $request = new WP_REST_Request( 'GET', '/wp/v2/categories/' . $category_id ); @@ -1189,31 +1189,31 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas } protected function check_get_taxonomy_terms_response( $response ) { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $args = array( 'hide_empty' => false, ); $categories = get_terms( 'category', $args ); - $this->assertEquals( count( $categories ), count( $data ) ); - $this->assertEquals( $categories[0]->term_id, $data[0]['id'] ); - $this->assertEquals( $categories[0]->name, $data[0]['name'] ); - $this->assertEquals( $categories[0]->slug, $data[0]['slug'] ); - $this->assertEquals( $categories[0]->taxonomy, $data[0]['taxonomy'] ); - $this->assertEquals( $categories[0]->description, $data[0]['description'] ); - $this->assertEquals( $categories[0]->count, $data[0]['count'] ); + $this->assertSame( count( $categories ), count( $data ) ); + $this->assertSame( $categories[0]->term_id, $data[0]['id'] ); + $this->assertSame( $categories[0]->name, $data[0]['name'] ); + $this->assertSame( $categories[0]->slug, $data[0]['slug'] ); + $this->assertSame( $categories[0]->taxonomy, $data[0]['taxonomy'] ); + $this->assertSame( $categories[0]->description, $data[0]['description'] ); + $this->assertSame( $categories[0]->count, $data[0]['count'] ); } protected function check_taxonomy_term( $term, $data, $links ) { - $this->assertEquals( $term->term_id, $data['id'] ); - $this->assertEquals( $term->name, $data['name'] ); - $this->assertEquals( $term->slug, $data['slug'] ); - $this->assertEquals( $term->description, $data['description'] ); - $this->assertEquals( get_term_link( $term ), $data['link'] ); - $this->assertEquals( $term->count, $data['count'] ); + $this->assertSame( $term->term_id, $data['id'] ); + $this->assertSame( $term->name, $data['name'] ); + $this->assertSame( $term->slug, $data['slug'] ); + $this->assertSame( $term->description, $data['description'] ); + $this->assertSame( get_term_link( $term ), $data['link'] ); + $this->assertSame( $term->count, $data['count'] ); $taxonomy = get_taxonomy( $term->taxonomy ); if ( $taxonomy->hierarchical ) { - $this->assertEquals( $term->parent, $data['parent'] ); + $this->assertSame( $term->parent, $data['parent'] ); } else { $this->assertFalse( isset( $term->parent ) ); } @@ -1231,12 +1231,12 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $this->assertEqualSets( $relations, array_keys( $links ) ); $this->assertContains( 'wp/v2/taxonomies/' . $term->taxonomy, $links['about'][0]['href'] ); - $this->assertEquals( add_query_arg( 'categories', $term->term_id, rest_url( 'wp/v2/posts' ) ), $links['https://api.w.org/post_type'][0]['href'] ); + $this->assertSame( add_query_arg( 'categories', $term->term_id, rest_url( 'wp/v2/posts' ) ), $links['https://api.w.org/post_type'][0]['href'] ); } protected function check_get_taxonomy_term_response( $response ) { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $category = get_term( 1, 'category' ); diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index 84b2d51dd3..b65d4eb259 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -172,14 +172,14 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/comments/' . self::$approved_id ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); } public function test_registered_query_params() { @@ -188,7 +188,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $data = $response->get_data(); $keys = array_keys( $data['endpoints'][0]['args'] ); sort( $keys ); - $this->assertEquals( + $this->assertSame( array( 'after', 'author', @@ -220,7 +220,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'per_page', self::$per_page ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comments = $response->get_data(); $this->assertCount( self::$total_comments, $comments ); @@ -244,7 +244,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'post', self::$password_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $collection_data = $response->get_data(); $this->assertTrue( in_array( $password_comment, wp_list_pluck( $collection_data, 'id' ), true ) ); @@ -267,7 +267,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'password', 'toomanysecrets' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $collection_data = $response->get_data(); $this->assertFalse( in_array( $password_comment, wp_list_pluck( $collection_data, 'id' ), true ) ); @@ -307,7 +307,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $collection_data = $response->get_data(); $this->assertFalse( in_array( $password_comment, wp_list_pluck( $collection_data, 'id' ), true ) ); @@ -326,7 +326,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $collection_data = $response->get_data(); $this->assertTrue( in_array( $password_comment, wp_list_pluck( $collection_data, 'id' ), true ) ); @@ -345,7 +345,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $collection_data = $response->get_data(); $this->assertFalse( in_array( $private_comment, wp_list_pluck( $collection_data, 'id' ), true ) ); @@ -364,7 +364,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $collection_data = $response->get_data(); $this->assertTrue( in_array( $private_comment, wp_list_pluck( $collection_data, 'id' ), true ) ); @@ -383,7 +383,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $collection_data = $response->get_data(); $this->assertFalse( in_array( $comment_id, wp_list_pluck( $collection_data, 'id' ), true ) ); @@ -404,7 +404,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $collection_data = $response->get_data(); $this->assertTrue( in_array( $comment_id, wp_list_pluck( $collection_data, 'id' ), true ) ); @@ -429,7 +429,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $request->set_param( 'post', 0 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comments = $response->get_data(); $this->assertCount( 2, $comments ); } @@ -449,7 +449,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $request->set_param( 'context', 'edit' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_get_items_for_post() { @@ -464,7 +464,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comments = $response->get_data(); $this->assertCount( 2, $comments ); @@ -488,15 +488,15 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'include', array( $id2, $id1 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( $id1, $data[0]['id'] ); // 'orderby' => 'include'. $request->set_param( 'orderby', 'include' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( $id2, $data[0]['id'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( $id2, $data[0]['id'] ); // Invalid 'orderby' should error. $request->set_param( 'orderby', 'invalid' ); @@ -581,13 +581,13 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase // Order defaults to 'desc'. $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $id, $data[0]['id'] ); + $this->assertSame( $id, $data[0]['id'] ); // 'order' => 'asc'. $request->set_param( 'order', 'asc' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( self::$approved_id, $data[0]['id'] ); + $this->assertSame( self::$approved_id, $data[0]['id'] ); // 'order' => 'asc,id' should error. $request->set_param( 'order', 'asc,id' ); @@ -626,14 +626,14 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $request->set_param( 'author', self::$author_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comments = $response->get_data(); $this->assertCount( 1, $comments ); // Multiple authors are supported. $request->set_param( 'author', array( self::$author_id, self::$subscriber_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comments = $response->get_data(); $this->assertCount( 2, $comments ); @@ -678,7 +678,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'per_page', self::$per_page ); $request->set_param( 'author_exclude', self::$author_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comments = $response->get_data(); $this->assertCount( $total_comments - 1, $comments ); @@ -687,7 +687,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'per_page', self::$per_page ); $request->set_param( 'author_exclude', array( self::$author_id, self::$subscriber_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comments = $response->get_data(); $this->assertCount( $total_comments - 2, $comments ); @@ -800,7 +800,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertEquals( $id, $data[0]['id'] ); + $this->assertSame( $id, $data[0]['id'] ); } public function test_get_comments_pagination_headers() { @@ -813,8 +813,8 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/comments' ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_comments, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_comments, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $next_link = add_query_arg( array( 'page' => 2, @@ -836,8 +836,8 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'page', 3 ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_comments, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_comments, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( 'page' => 2, @@ -858,8 +858,8 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'page', $total_pages ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_comments, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_comments, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( 'page' => $total_pages - 1, @@ -874,7 +874,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'page', 100 ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_comments, $headers['X-WP-Total'] ); + $this->assertSame( $total_comments, $headers['X-WP-Total'] ); $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( @@ -920,14 +920,14 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertEquals( $comment2, $data[0]['id'] ); + $this->assertSame( $comment2, $data[0]['id'] ); } public function test_get_item() { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->check_comment_data( $data, 'view', $response->get_links() ); @@ -944,7 +944,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->check_comment_data( $data, 'edit', $response->get_links() ); @@ -959,7 +959,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( '_fields', 'id,status' ); $obj = get_comment( self::$approved_id ); $response = $endpoint->prepare_item_for_response( $obj, $request ); - $this->assertEquals( + $this->assertSame( array( 'id', 'status', @@ -981,7 +981,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $comment = get_comment( self::$approved_id ); // Ignore the subdomain, since get_avatar_url() randomly sets // the Gravatar server when building the URL string. - $this->assertEquals( substr( get_avatar_url( $comment->comment_author_email ), 9 ), substr( $data['author_avatar_urls'][96], 9 ) ); + $this->assertSame( substr( get_avatar_url( $comment->comment_author_email ), 9 ), substr( $data['author_avatar_urls'][96], 9 ) ); } public function test_get_comment_invalid_id() { @@ -1043,7 +1043,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%d', self::$hold_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_get_comment_with_children_link() { @@ -1066,7 +1066,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertArrayHasKey( 'children', $response->get_links() ); } @@ -1081,7 +1081,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertArrayNotHasKey( 'children', $response->get_links() ); } @@ -1117,7 +1117,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'password', 'toomanysecrets' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_create_item() { @@ -1137,13 +1137,13 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); $this->check_comment_data( $data, 'edit', $response->get_links() ); - $this->assertEquals( 'hold', $data['status'] ); - $this->assertEquals( '2014-11-07T10:14:25', $data['date'] ); - $this->assertEquals( self::$post_id, $data['post'] ); + $this->assertSame( 'hold', $data['status'] ); + $this->assertSame( '2014-11-07T10:14:25', $data['date'] ); + $this->assertSame( self::$post_id, $data['post'] ); } public function comment_dates_provider() { @@ -1212,17 +1212,17 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase update_option( 'timezone_string', '' ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); $comment = get_comment( $data['id'] ); - $this->assertEquals( $results['date'], $data['date'] ); + $this->assertSame( $results['date'], $data['date'] ); $comment_date = str_replace( 'T', ' ', $results['date'] ); - $this->assertEquals( $comment_date, $comment->comment_date ); + $this->assertSame( $comment_date, $comment->comment_date ); - $this->assertEquals( $results['date_gmt'], $data['date_gmt'] ); + $this->assertSame( $results['date_gmt'], $data['date_gmt'] ); $comment_date_gmt = str_replace( 'T', ' ', $results['date_gmt'] ); - $this->assertEquals( $comment_date_gmt, $comment->comment_date_gmt ); + $this->assertSame( $comment_date_gmt, $comment->comment_date_gmt ); } public function test_create_item_using_accepted_content_raw_value() { @@ -1243,11 +1243,11 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); $new_comment = get_comment( $data['id'] ); - $this->assertEquals( $params['content']['raw'], $new_comment->comment_content ); + $this->assertSame( $params['content']['raw'], $new_comment->comment_content ); } public function test_create_item_error_from_filter() { @@ -1443,11 +1443,11 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->add_header( 'content-type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $subscriber_id, $data['author'] ); - $this->assertEquals( '127.0.0.1', $data['author_ip'] ); + $this->assertSame( $subscriber_id, $data['author'] ); + $this->assertSame( '127.0.0.1', $data['author_ip'] ); } public function test_create_comment_without_type() { @@ -1470,10 +1470,10 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'comment', $data['type'] ); + $this->assertSame( 'comment', $data['type'] ); $comment_id = $data['id']; @@ -1482,7 +1482,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $collection->set_param( 'post', $post_id ); $collection_response = rest_get_server()->dispatch( $collection ); $collection_data = $collection_response->get_data(); - $this->assertEquals( $comment_id, $collection_data[0]['id'] ); + $this->assertSame( $comment_id, $collection_data[0]['id'] ); } /** @@ -1559,16 +1559,16 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $user_id, $data['author'] ); + $this->assertSame( $user_id, $data['author'] ); // Check author data matches. $author = get_user_by( 'id', $user_id ); $comment = get_comment( $data['id'] ); - $this->assertEquals( $author->display_name, $comment->comment_author ); - $this->assertEquals( $author->user_email, $comment->comment_author_email ); - $this->assertEquals( $author->user_url, $comment->comment_author_url ); + $this->assertSame( $author->display_name, $comment->comment_author ); + $this->assertSame( $author->user_email, $comment->comment_author_email ); + $this->assertSame( $author->user_url, $comment->comment_author_url ); } public function test_create_comment_other_user() { @@ -1588,12 +1588,12 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( self::$subscriber_id, $data['author'] ); - $this->assertEquals( 'Homer Jay Simpson', $data['author_name'] ); - $this->assertEquals( 'chunkylover53@aol.com', $data['author_email'] ); - $this->assertEquals( 'http://compuglobalhypermeganet.com', $data['author_url'] ); + $this->assertSame( self::$subscriber_id, $data['author'] ); + $this->assertSame( 'Homer Jay Simpson', $data['author_name'] ); + $this->assertSame( 'chunkylover53@aol.com', $data['author_email'] ); + $this->assertSame( 'http://compuglobalhypermeganet.com', $data['author_url'] ); } public function test_create_comment_other_user_without_permission() { @@ -1678,12 +1678,12 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'approved', $data['status'] ); - $this->assertEquals( '139.130.4.5', $data['author_ip'] ); - $this->assertEquals( 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', $data['author_user_agent'] ); + $this->assertSame( 'approved', $data['status'] ); + $this->assertSame( '139.130.4.5', $data['author_ip'] ); + $this->assertSame( 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', $data['author_user_agent'] ); } public function test_create_comment_user_agent_header() { @@ -1703,12 +1703,12 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); $new_comment = get_comment( $data['id'] ); - $this->assertEquals( 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 4.0; Windows 95)', $new_comment->comment_agent ); + $this->assertSame( 'Mozilla/4.0 (compatible; MSIE 5.5; AOL 4.0; Windows 95)', $new_comment->comment_agent ); } public function test_create_comment_author_ip() { @@ -1729,7 +1729,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $new_comment = get_comment( $data['id'] ); - $this->assertEquals( '127.0.0.3', $new_comment->comment_author_IP ); + $this->assertSame( '127.0.0.3', $new_comment->comment_author_IP ); } public function test_create_comment_invalid_author_IP() { @@ -1790,7 +1790,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $new_comment = get_comment( $data['id'] ); - $this->assertEquals( '127.0.0.2', $new_comment->comment_author_IP ); + $this->assertSame( '127.0.0.2', $new_comment->comment_author_IP ); } public function test_create_comment_no_post_id() { @@ -1957,7 +1957,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 409, $response->get_status() ); + $this->assertSame( 409, $response->get_status() ); } public function test_create_comment_closed() { @@ -1978,7 +1978,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 403, $response->get_status() ); + $this->assertSame( 403, $response->get_status() ); } public function test_create_comment_require_login() { @@ -1990,9 +1990,9 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); $request->set_param( 'post', self::$post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 401, $response->get_status() ); + $this->assertSame( 401, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'rest_comment_login_required', $data['code'] ); + $this->assertSame( 'rest_comment_login_required', $data['code'] ); } public function test_create_item_invalid_author() { @@ -2051,7 +2051,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $params = array( 'post' => self::$post_id, @@ -2066,7 +2066,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); } public function anonymous_comments_callback_null() { @@ -2229,7 +2229,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->add_header( 'content-type', 'application/json' ); $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); } public function test_update_item() { @@ -2253,20 +2253,20 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comment = $response->get_data(); $updated = get_comment( self::$approved_id ); - $this->assertEquals( $params['content'], $comment['content']['raw'] ); - $this->assertEquals( $params['author'], $comment['author'] ); - $this->assertEquals( $params['author_name'], $comment['author_name'] ); - $this->assertEquals( $params['author_url'], $comment['author_url'] ); - $this->assertEquals( $params['author_email'], $comment['author_email'] ); - $this->assertEquals( $params['author_ip'], $comment['author_ip'] ); - $this->assertEquals( $params['post'], $comment['post'] ); + $this->assertSame( $params['content'], $comment['content']['raw'] ); + $this->assertSame( $params['author'], $comment['author'] ); + $this->assertSame( $params['author_name'], $comment['author_name'] ); + $this->assertSame( $params['author_url'], $comment['author_url'] ); + $this->assertSame( $params['author_email'], $comment['author_email'] ); + $this->assertSame( $params['author_ip'], $comment['author_ip'] ); + $this->assertSame( $params['post'], $comment['post'] ); - $this->assertEquals( mysql_to_rfc3339( $updated->comment_date ), $comment['date'] ); - $this->assertEquals( '2014-11-07T10:14:25', $comment['date'] ); + $this->assertSame( mysql_to_rfc3339( $updated->comment_date ), $comment['date'] ); + $this->assertSame( '2014-11-07T10:14:25', $comment['date'] ); } /** @@ -2290,17 +2290,17 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase update_option( 'timezone_string', '' ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $comment = get_comment( $data['id'] ); - $this->assertEquals( $results['date'], $data['date'] ); + $this->assertSame( $results['date'], $data['date'] ); $comment_date = str_replace( 'T', ' ', $results['date'] ); - $this->assertEquals( $comment_date, $comment->comment_date ); + $this->assertSame( $comment_date, $comment->comment_date ); - $this->assertEquals( $results['date_gmt'], $data['date_gmt'] ); + $this->assertSame( $results['date_gmt'], $data['date_gmt'] ); $comment_date_gmt = str_replace( 'T', ' ', $results['date_gmt'] ); - $this->assertEquals( $comment_date_gmt, $comment->comment_date_gmt ); + $this->assertSame( $comment_date_gmt, $comment->comment_date_gmt ); } public function test_update_item_no_content() { @@ -2313,7 +2313,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase // Sending a request without content is fine. $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); // Sending a request with empty comment is not fine. $request->set_param( 'author_email', 'yetanother@email.com' ); @@ -2333,10 +2333,10 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase // Run twice to make sure that the update still succeeds // even if no DB rows are updated. $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_update_comment_status() { @@ -2358,11 +2358,11 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comment = $response->get_data(); $updated = get_comment( $comment_id ); - $this->assertEquals( 'approved', $comment['status'] ); + $this->assertSame( 'approved', $comment['status'] ); $this->assertEquals( 1, $updated->comment_approved ); } @@ -2386,13 +2386,13 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comment = $response->get_data(); $updated = get_comment( $comment_id ); - $this->assertEquals( 'approved', $comment['status'] ); + $this->assertSame( 'approved', $comment['status'] ); $this->assertEquals( 1, $updated->comment_approved ); - $this->assertEquals( 'some content', $updated->comment_content ); + $this->assertSame( 'some content', $updated->comment_content ); } public function test_update_comment_date_gmt() { @@ -2408,12 +2408,12 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comment = $response->get_data(); $updated = get_comment( self::$approved_id ); - $this->assertEquals( $params['date_gmt'], $comment['date_gmt'] ); - $this->assertEquals( $params['date_gmt'], mysql_to_rfc3339( $updated->comment_date_gmt ) ); + $this->assertSame( $params['date_gmt'], $comment['date_gmt'] ); + $this->assertSame( $params['date_gmt'], mysql_to_rfc3339( $updated->comment_date_gmt ) ); } public function test_update_comment_author_email_only() { @@ -2432,7 +2432,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_update_comment_empty_author_name() { @@ -2452,7 +2452,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_update_comment_author_name_only() { @@ -2471,7 +2471,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_update_comment_empty_author_email() { @@ -2491,7 +2491,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_update_comment_author_email_too_short() { @@ -2544,11 +2544,11 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comment = $response->get_data(); $updated = get_comment( self::$approved_id ); - $this->assertEquals( $params['content']['raw'], $updated->comment_content ); + $this->assertSame( $params['content']['raw'], $updated->comment_content ); } public function test_update_item_invalid_date() { @@ -2639,14 +2639,14 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_body( wp_json_encode( $params ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $comment = $response->get_data(); $updated = get_comment( self::$approved_id ); - $this->assertEquals( $params['content'], $updated->comment_content ); - $this->assertEquals( self::$post_id, $comment['post'] ); - $this->assertEquals( '2019-10-07T23:14:25', $comment['date'] ); + $this->assertSame( $params['content'], $updated->comment_content ); + $this->assertSame( self::$post_id, $comment['post'] ); + $this->assertSame( '2019-10-07T23:14:25', $comment['date'] ); } public function test_update_comment_private_post_invalid_permission() { @@ -2694,7 +2694,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase // Check if comment 1 does not have the child link. $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertArrayNotHasKey( 'children', $response->get_links() ); // Change the comment parent. @@ -2702,12 +2702,12 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'parent', $comment_id_1 ); $request->set_param( 'content', rand_str() ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); // Check if comment 1 now has the child link. $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertArrayHasKey( 'children', $response->get_links() ); } @@ -2829,22 +2829,22 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( $name, $value ); } $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $actual_output = $response->get_data(); // Compare expected API output to actual API output. $this->assertInternalType( 'array', $actual_output['content'] ); $this->assertArrayHasKey( 'raw', $actual_output['content'] ); - $this->assertEquals( $expected_output['content']['raw'], $actual_output['content']['raw'] ); - $this->assertEquals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); - $this->assertEquals( $expected_output['author_name'], $actual_output['author_name'] ); - $this->assertEquals( $expected_output['author_user_agent'], $actual_output['author_user_agent'] ); + $this->assertSame( $expected_output['content']['raw'], $actual_output['content']['raw'] ); + $this->assertSame( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); + $this->assertSame( $expected_output['author_name'], $actual_output['author_name'] ); + $this->assertSame( $expected_output['author_user_agent'], $actual_output['author_user_agent'] ); // Compare expected API output to WP internal values. $comment = get_comment( $actual_output['id'] ); - $this->assertEquals( $expected_output['content']['raw'], $comment->comment_content ); - $this->assertEquals( $expected_output['author_name'], $comment->comment_author ); - $this->assertEquals( $expected_output['author_user_agent'], $comment->comment_agent ); + $this->assertSame( $expected_output['content']['raw'], $comment->comment_content ); + $this->assertSame( $expected_output['author_name'], $comment->comment_author ); + $this->assertSame( $expected_output['author_user_agent'], $comment->comment_agent ); // Update the comment. $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', $actual_output['id'] ) ); @@ -2855,26 +2855,26 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase // See https://core.trac.wordpress.org/ticket/38700 $request->set_param( 'author_ip', '127.0.0.2' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $actual_output = $response->get_data(); // Compare expected API output to actual API output. - $this->assertEquals( $expected_output['content']['raw'], $actual_output['content']['raw'] ); - $this->assertEquals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); - $this->assertEquals( $expected_output['author_name'], $actual_output['author_name'] ); - $this->assertEquals( $expected_output['author_user_agent'], $actual_output['author_user_agent'] ); + $this->assertSame( $expected_output['content']['raw'], $actual_output['content']['raw'] ); + $this->assertSame( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); + $this->assertSame( $expected_output['author_name'], $actual_output['author_name'] ); + $this->assertSame( $expected_output['author_user_agent'], $actual_output['author_user_agent'] ); // Compare expected API output to WP internal values. $comment = get_comment( $actual_output['id'] ); - $this->assertEquals( $expected_output['content']['raw'], $comment->comment_content ); - $this->assertEquals( $expected_output['author_name'], $comment->comment_author ); - $this->assertEquals( $expected_output['author_user_agent'], $comment->comment_agent ); + $this->assertSame( $expected_output['content']['raw'], $comment->comment_content ); + $this->assertSame( $expected_output['author_name'], $comment->comment_author ); + $this->assertSame( $expected_output['author_user_agent'], $comment->comment_agent ); } public function test_comment_roundtrip_as_editor() { wp_set_current_user( self::$editor_id ); - $this->assertEquals( ! is_multisite(), current_user_can( 'unfiltered_html' ) ); + $this->assertSame( ! is_multisite(), current_user_can( 'unfiltered_html' ) ); $this->verify_comment_roundtrip( array( 'content' => '\o/ ¯\_(ツ)_/¯', @@ -2988,10 +2988,10 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) ); $request->set_param( 'force', 'false' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'trash', $data['status'] ); + $this->assertSame( 'trash', $data['status'] ); } public function test_delete_item_skip_trash() { @@ -3009,7 +3009,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request['force'] = true; $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertTrue( $data['deleted'] ); $this->assertNotEmpty( $data['previous']['post'] ); @@ -3028,7 +3028,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%d', $comment_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_already_trashed', $response, 410 ); @@ -3072,12 +3072,12 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/comments/%s', $child_comment ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); // Verify children link is gone. $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/comments/%s', $comment_id_1 ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertArrayNotHasKey( 'children', $response->get_links() ); } @@ -3086,7 +3086,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 17, count( $properties ) ); + $this->assertSame( 17, count( $properties ) ); $this->assertArrayHasKey( 'id', $properties ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'author_avatar_urls', $properties ); @@ -3105,11 +3105,11 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $this->assertArrayHasKey( 'status', $properties ); $this->assertArrayHasKey( 'type', $properties ); - $this->assertEquals( 0, $properties['parent']['default'] ); - $this->assertEquals( 0, $properties['post']['default'] ); + $this->assertSame( 0, $properties['parent']['default'] ); + $this->assertSame( 0, $properties['post']['default'] ); - $this->assertEquals( true, $properties['link']['readonly'] ); - $this->assertEquals( true, $properties['type']['readonly'] ); + $this->assertTrue( $properties['link']['readonly'] ); + $this->assertTrue( $properties['type']['readonly'] ); } public function test_get_item_schema_show_avatar() { @@ -3147,7 +3147,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $data = $response->get_data(); $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); - $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] ); + $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . self::$approved_id ); $response = rest_get_server()->dispatch( $request ); @@ -3238,12 +3238,12 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $this->assertEquals( $comment->comment_post_ID, $data['post'] ); $this->assertEquals( $comment->comment_parent, $data['parent'] ); $this->assertEquals( $comment->user_id, $data['author'] ); - $this->assertEquals( $comment->comment_author, $data['author_name'] ); - $this->assertEquals( $comment->comment_author_url, $data['author_url'] ); - $this->assertEquals( wpautop( $comment->comment_content ), $data['content']['rendered'] ); - $this->assertEquals( mysql_to_rfc3339( $comment->comment_date ), $data['date'] ); - $this->assertEquals( mysql_to_rfc3339( $comment->comment_date_gmt ), $data['date_gmt'] ); - $this->assertEquals( get_comment_link( $comment ), $data['link'] ); + $this->assertSame( $comment->comment_author, $data['author_name'] ); + $this->assertSame( $comment->comment_author_url, $data['author_url'] ); + $this->assertSame( wpautop( $comment->comment_content ), $data['content']['rendered'] ); + $this->assertSame( mysql_to_rfc3339( $comment->comment_date ), $data['date'] ); + $this->assertSame( mysql_to_rfc3339( $comment->comment_date_gmt ), $data['date_gmt'] ); + $this->assertSame( get_comment_link( $comment ), $data['link'] ); $this->assertContains( 'author_avatar_urls', $data ); $this->assertEqualSets( array( @@ -3255,10 +3255,10 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase ); if ( 'edit' === $context ) { - $this->assertEquals( $comment->comment_author_email, $data['author_email'] ); - $this->assertEquals( $comment->comment_author_IP, $data['author_ip'] ); - $this->assertEquals( $comment->comment_agent, $data['author_user_agent'] ); - $this->assertEquals( $comment->comment_content, $data['content']['raw'] ); + $this->assertSame( $comment->comment_author_email, $data['author_email'] ); + $this->assertSame( $comment->comment_author_IP, $data['author_ip'] ); + $this->assertSame( $comment->comment_agent, $data['author_user_agent'] ); + $this->assertSame( $comment->comment_content, $data['content']['raw'] ); } if ( 'edit' !== $context ) { @@ -3293,6 +3293,6 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase wp_set_current_user( self::$admin_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/comments/' . $comment_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 403, $response->get_status() ); + $this->assertSame( 403, $response->get_status() ); } } diff --git a/tests/phpunit/tests/rest-api/rest-controller.php b/tests/phpunit/tests/rest-api/rest-controller.php index b68300e270..30853392b6 100644 --- a/tests/phpunit/tests/rest-api/rest-controller.php +++ b/tests/phpunit/tests/rest-api/rest-controller.php @@ -106,35 +106,35 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase { ); // Check sanitize testing. - $this->assertEquals( + $this->assertSame( false, rest_sanitize_request_arg( 'false', $this->request, 'someboolean' ) ); - $this->assertEquals( + $this->assertSame( false, rest_sanitize_request_arg( '0', $this->request, 'someboolean' ) ); - $this->assertEquals( + $this->assertSame( false, rest_sanitize_request_arg( 0, $this->request, 'someboolean' ) ); - $this->assertEquals( + $this->assertSame( false, rest_sanitize_request_arg( 'FALSE', $this->request, 'someboolean' ) ); - $this->assertEquals( + $this->assertSame( true, rest_sanitize_request_arg( 'true', $this->request, 'someboolean' ) ); - $this->assertEquals( + $this->assertSame( true, rest_sanitize_request_arg( '1', $this->request, 'someboolean' ) ); - $this->assertEquals( + $this->assertSame( true, rest_sanitize_request_arg( 1, $this->request, 'someboolean' ) ); - $this->assertEquals( + $this->assertSame( true, rest_sanitize_request_arg( 'TRUE', $this->request, 'someboolean' ) ); @@ -225,7 +225,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase { public function test_get_endpoint_args_for_item_schema_description() { $controller = new WP_REST_Test_Controller(); $args = $controller->get_endpoint_args_for_item_schema(); - $this->assertEquals( 'A pretty string.', $args['somestring']['description'] ); + $this->assertSame( 'A pretty string.', $args['somestring']['description'] ); $this->assertFalse( isset( $args['someinteger']['description'] ) ); } @@ -235,7 +235,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase { $args = $controller->get_endpoint_args_for_item_schema(); $this->assertFalse( $args['someargoptions']['required'] ); - $this->assertEquals( '__return_true', $args['someargoptions']['sanitize_callback'] ); + $this->assertSame( '__return_true', $args['someargoptions']['sanitize_callback'] ); } public function test_get_endpoint_args_for_item_schema_default_value() { @@ -244,7 +244,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase { $args = $controller->get_endpoint_args_for_item_schema(); - $this->assertEquals( 'a', $args['somedefault']['default'] ); + $this->assertSame( 'a', $args['somedefault']['default'] ); } /** @@ -285,7 +285,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase { $controller = new WP_REST_Test_Controller(); $request = new WP_REST_Request( 'GET', '/wp/v2/testroute' ); $fields = $controller->get_fields_for_response( $request ); - $this->assertEquals( + $this->assertSame( array( 'somestring', 'someinteger', @@ -305,7 +305,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase { ); $request->set_param( '_fields', $param ); $fields = $controller->get_fields_for_response( $request ); - $this->assertEquals( $expected, $fields ); + $this->assertSame( $expected, $fields ); } public function data_get_fields_for_response() { @@ -536,7 +536,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase { $response = $controller->prepare_item_for_response( array(), $request ); $response = rest_filter_response_fields( $response, rest_get_server(), $request ); - $this->assertEquals( $expected, $response->get_data() ); + $this->assertSame( $expected, $response->get_data() ); } public function register_nested_rest_field_get_callback() { diff --git a/tests/phpunit/tests/rest-api/rest-pages-controller.php b/tests/phpunit/tests/rest-api/rest-pages-controller.php index 84b38cc30e..e98dfe8a75 100644 --- a/tests/phpunit/tests/rest-api/rest-pages-controller.php +++ b/tests/phpunit/tests/rest-api/rest-pages-controller.php @@ -49,15 +49,15 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/pages/' . $page_id ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); } public function test_registered_query_params() { @@ -66,7 +66,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $keys = array_keys( $data['endpoints'][0]['args'] ); sort( $keys ); - $this->assertEquals( + $this->assertSame( array( 'after', 'author', @@ -107,8 +107,8 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( $id1, $data[0]['id'] ); } public function test_get_items_parent_query() { @@ -130,14 +130,14 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); + $this->assertSame( 2, count( $data ) ); // Filter to parent. $request->set_param( 'parent', $id1 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( $id2, $data[0]['id'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( $id2, $data[0]['id'] ); // Invalid 'parent' should error. $request->set_param( 'parent', 'some-slug' ); @@ -177,13 +177,13 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 4, count( $data ) ); + $this->assertSame( 4, count( $data ) ); // Filter to parents. $request->set_param( 'parent', array( $id1, $id3 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); + $this->assertSame( 2, count( $data ) ); $this->assertEqualSets( array( $id2, $id4 ), wp_list_pluck( $data, 'id' ) ); } @@ -206,14 +206,14 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); + $this->assertSame( 2, count( $data ) ); // Filter to parent. $request->set_param( 'parent_exclude', $id1 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( $id1, $data[0]['id'] ); // Invalid 'parent_exclude' should error. $request->set_param( 'parent_exclude', 'some-slug' ); @@ -268,10 +268,10 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'orderby', 'menu_order' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $id1, $data[0]['id'] ); - $this->assertEquals( $id4, $data[1]['id'] ); - $this->assertEquals( $id2, $data[2]['id'] ); - $this->assertEquals( $id3, $data[3]['id'] ); + $this->assertSame( $id1, $data[0]['id'] ); + $this->assertSame( $id4, $data[1]['id'] ); + $this->assertSame( $id2, $data[2]['id'] ); + $this->assertSame( $id3, $data[3]['id'] ); // Invalid 'menu_order' should error. $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); @@ -322,7 +322,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertEquals( $draft_id, $data[0]['id'] ); + $this->assertSame( $draft_id, $data[0]['id'] ); } public function test_get_items_invalid_date() { @@ -358,7 +358,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertEquals( $post2, $data[0]['id'] ); + $this->assertSame( $post2, $data[0]['id'] ); } public function test_get_item() { @@ -369,7 +369,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $post_id = $this->factory->post->create(); $request = new WP_REST_Request( 'GET', '/wp/v2/pages/' . $post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_create_item() { @@ -390,8 +390,8 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $new_post = get_post( $data['id'] ); - $this->assertEquals( 'page-my-test-template.php', $data['template'] ); - $this->assertEquals( 'page-my-test-template.php', get_page_template_slug( $new_post->ID ) ); + $this->assertSame( 'page-my-test-template.php', $data['template'] ); + $this->assertSame( 'page-my-test-template.php', get_page_template_slug( $new_post->ID ) ); } public function test_create_page_with_parent() { @@ -411,15 +411,15 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $links = $response->get_links(); $this->assertArrayHasKey( 'up', $links ); $data = $response->get_data(); $new_post = get_post( $data['id'] ); - $this->assertEquals( $page_id, $data['parent'] ); - $this->assertEquals( $page_id, $new_post->post_parent ); + $this->assertSame( $page_id, $data['parent'] ); + $this->assertSame( $page_id, $new_post->post_parent ); } public function test_create_page_with_invalid_parent() { @@ -454,10 +454,10 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'force', 'false' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'Deleted page', $data['title']['raw'] ); - $this->assertEquals( 'trash', $data['status'] ); + $this->assertSame( 'Deleted page', $data['title']['raw'] ); + $this->assertSame( 'trash', $data['status'] ); } public function test_prepare_item() { @@ -478,7 +478,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( '_fields', 'id,slug' ); $obj = get_post( $page_id ); $response = $endpoint->prepare_item_for_response( $obj, $request ); - $this->assertEquals( + $this->assertSame( array( 'id', 'slug', @@ -504,16 +504,16 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $headers = $response->get_headers(); - $this->assertEquals( 8, $headers['X-WP-Total'] ); - $this->assertEquals( 2, $headers['X-WP-TotalPages'] ); + $this->assertSame( 8, $headers['X-WP-Total'] ); + $this->assertSame( 2, $headers['X-WP-TotalPages'] ); $all_data = $response->get_data(); - $this->assertEquals( 4, count( $all_data ) ); + $this->assertSame( 4, count( $all_data ) ); foreach ( $all_data as $post ) { - $this->assertEquals( 'page', $post['type'] ); + $this->assertSame( 'page', $post['type'] ); } } @@ -537,7 +537,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( 1, $new_data['menu_order'] ); + $this->assertSame( 1, $new_data['menu_order'] ); } public function test_update_page_menu_order_to_zero() { @@ -561,7 +561,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( 0, $new_data['menu_order'] ); + $this->assertSame( 0, $new_data['menu_order'] ); } public function test_update_page_parent_non_zero() { @@ -584,7 +584,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te ); $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( $page_id1, $new_data['parent'] ); + $this->assertSame( $page_id1, $new_data['parent'] ); } public function test_update_page_parent_zero() { @@ -608,7 +608,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te ); $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( 0, $new_data['parent'] ); + $this->assertSame( 0, $new_data['parent'] ); } public function test_get_page_with_password() { @@ -623,9 +623,9 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( '', $data['content']['rendered'] ); + $this->assertSame( '', $data['content']['rendered'] ); $this->assertTrue( $data['content']['protected'] ); - $this->assertEquals( '', $data['excerpt']['rendered'] ); + $this->assertSame( '', $data['excerpt']['rendered'] ); $this->assertTrue( $data['excerpt']['protected'] ); } @@ -645,9 +645,9 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( wpautop( $page->post_content ), $data['content']['rendered'] ); + $this->assertSame( wpautop( $page->post_content ), $data['content']['rendered'] ); $this->assertTrue( $data['content']['protected'] ); - $this->assertEquals( wpautop( $page->post_excerpt ), $data['excerpt']['rendered'] ); + $this->assertSame( wpautop( $page->post_excerpt ), $data['excerpt']['rendered'] ); $this->assertTrue( $data['excerpt']['protected'] ); } @@ -679,9 +679,9 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/pages/%d', $page_id ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( '', $data['content']['rendered'] ); + $this->assertSame( '', $data['content']['rendered'] ); $this->assertTrue( $data['content']['protected'] ); - $this->assertEquals( '', $data['excerpt']['rendered'] ); + $this->assertSame( '', $data['excerpt']['rendered'] ); $this->assertTrue( $data['excerpt']['protected'] ); } @@ -690,7 +690,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 24, count( $properties ) ); + $this->assertSame( 24, count( $properties ) ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'comment_status', $properties ); $this->assertArrayHasKey( 'content', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-plugins-controller.php b/tests/phpunit/tests/rest-api/rest-plugins-controller.php index 30bec793b4..79194543a9 100644 --- a/tests/phpunit/tests/rest-api/rest-plugins-controller.php +++ b/tests/phpunit/tests/rest-api/rest-plugins-controller.php @@ -107,14 +107,14 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'OPTIONS', self::BASE ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $request = new WP_REST_Request( 'OPTIONS', self::BASE . '/' . self::PLUGIN ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); } /** @@ -125,7 +125,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { wp_set_current_user( self::$super_admin ); $response = rest_do_request( self::BASE ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $items = wp_list_filter( $response->get_data(), array( 'plugin' => self::PLUGIN ) ); @@ -209,7 +209,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { */ public function test_get_items_logged_out() { $response = rest_do_request( self::BASE ); - $this->assertEquals( 401, $response->get_status() ); + $this->assertSame( 401, $response->get_status() ); } /** @@ -245,7 +245,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { wp_set_current_user( self::$admin ); $response = rest_do_request( self::BASE ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } /** @@ -258,7 +258,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { wp_set_current_user( self::$admin ); $response = rest_do_request( self::BASE ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $items = wp_list_filter( $response->get_data(), array( 'plugin' => self::PLUGIN ) ); $this->assertCount( 0, $items ); @@ -273,7 +273,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { wp_set_current_user( self::$admin ); $response = rest_do_request( self::BASE ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $items = wp_list_filter( $response->get_data(), array( 'plugin' => self::PLUGIN ) ); $this->assertCount( 1, $items ); @@ -290,7 +290,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { wp_set_current_user( self::$super_admin ); $response = rest_do_request( self::BASE ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $items = wp_list_filter( $response->get_data(), array( 'plugin' => self::PLUGIN ) ); $this->assertCount( 1, $items ); @@ -305,7 +305,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { wp_set_current_user( self::$super_admin ); $response = rest_do_request( self::BASE . '/' . self::PLUGIN ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->check_get_plugin_data( $response->get_data() ); } @@ -314,7 +314,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { */ public function test_get_item_logged_out() { $response = rest_do_request( self::BASE . '/' . self::PLUGIN ); - $this->assertEquals( 401, $response->get_status() ); + $this->assertSame( 401, $response->get_status() ); } /** @@ -323,7 +323,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { public function test_get_item_insufficient_permissions() { wp_set_current_user( self::$subscriber_id ); $response = rest_do_request( self::BASE . '/' . self::PLUGIN ); - $this->assertEquals( 403, $response->get_status() ); + $this->assertSame( 403, $response->get_status() ); } /** @@ -350,7 +350,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { wp_set_current_user( self::$admin ); $response = rest_do_request( self::BASE . '/' . self::PLUGIN ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } /** @@ -359,7 +359,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { public function test_get_item_invalid_plugin() { wp_set_current_user( self::$super_admin ); $response = rest_do_request( self::BASE . '/' . self::PLUGIN ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } /** @@ -378,8 +378,8 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $response = rest_do_request( $request ); $this->assertNotWPError( $response->as_error() ); - $this->assertEquals( 201, $response->get_status() ); - $this->assertEquals( 'Link Manager', $response->get_data()['name'] ); + $this->assertSame( 201, $response->get_status() ); + $this->assertSame( 'Link Manager', $response->get_data()['name'] ); } /** @@ -403,8 +403,8 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $response = rest_do_request( $request ); $this->assertNotWPError( $response->as_error() ); - $this->assertEquals( 201, $response->get_status() ); - $this->assertEquals( 'Link Manager', $response->get_data()['name'] ); + $this->assertSame( 201, $response->get_status() ); + $this->assertSame( 'Link Manager', $response->get_data()['name'] ); $this->assertTrue( is_plugin_active( 'link-manager/link-manager.php' ) ); } @@ -477,8 +477,8 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $response = rest_do_request( $request ); $this->assertNotWPError( $response->as_error() ); - $this->assertEquals( 201, $response->get_status() ); - $this->assertEquals( 'Link Manager', $response->get_data()['name'] ); + $this->assertSame( 201, $response->get_status() ); + $this->assertSame( 'Link Manager', $response->get_data()['name'] ); $this->assertTrue( is_plugin_active_for_network( 'link-manager/link-manager.php' ) ); } @@ -490,7 +490,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request->set_body_params( array( 'slug' => 'link-manager' ) ); $response = rest_do_request( $request ); - $this->assertEquals( 401, $response->get_status() ); + $this->assertSame( 401, $response->get_status() ); } /** @@ -502,7 +502,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request->set_body_params( array( 'slug' => 'link-manager' ) ); $response = rest_do_request( $request ); - $this->assertEquals( 403, $response->get_status() ); + $this->assertSame( 403, $response->get_status() ); } /** @@ -561,7 +561,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'PUT', self::BASE . '/' . self::PLUGIN ); $response = rest_do_request( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } /** @@ -571,7 +571,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'PUT', self::BASE . '/' . self::PLUGIN ); $response = rest_do_request( $request ); - $this->assertEquals( 401, $response->get_status() ); + $this->assertSame( 401, $response->get_status() ); } /** @@ -583,7 +583,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'PUT', self::BASE . '/' . self::PLUGIN ); $response = rest_do_request( $request ); - $this->assertEquals( 403, $response->get_status() ); + $this->assertSame( 403, $response->get_status() ); } /** @@ -611,7 +611,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request->set_body_params( array( 'status' => 'active' ) ); $response = rest_do_request( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertTrue( is_plugin_active( self::PLUGIN_FILE ) ); } @@ -657,7 +657,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request->set_body_params( array( 'status' => 'network-active' ) ); $response = rest_do_request( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertTrue( is_plugin_active_for_network( self::PLUGIN_FILE ) ); } @@ -674,7 +674,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request->set_body_params( array( 'status' => 'network-active' ) ); $response = rest_do_request( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertTrue( is_plugin_active_for_network( self::PLUGIN_FILE ) ); } @@ -705,7 +705,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request->set_body_params( array( 'status' => 'network-active' ) ); $response = rest_do_request( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertTrue( is_plugin_active_for_network( self::PLUGIN_FILE ) ); } @@ -721,7 +721,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request->set_body_params( array( 'status' => 'active' ) ); $response = rest_do_request( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertTrue( is_plugin_active( self::PLUGIN_FILE ) ); } @@ -739,7 +739,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $response = rest_do_request( $request ); $this->assertNotWPError( $response->as_error() ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertTrue( is_plugin_active( self::PLUGIN_FILE ) ); } @@ -771,7 +771,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request->set_body_params( array( 'status' => 'inactive' ) ); $response = rest_do_request( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertTrue( is_plugin_inactive( self::PLUGIN_FILE ) ); } @@ -804,7 +804,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request->set_body_params( array( 'status' => 'inactive' ) ); $response = rest_do_request( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertTrue( is_plugin_inactive( self::PLUGIN_FILE ) ); } @@ -836,9 +836,9 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $response = rest_do_request( $request ); $this->assertNotWPError( $response->as_error() ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertTrue( $response->get_data()['deleted'] ); - $this->assertEquals( self::PLUGIN, $response->get_data()['previous']['plugin'] ); + $this->assertSame( self::PLUGIN, $response->get_data()['previous']['plugin'] ); $this->assertFileNotExists( WP_PLUGIN_DIR . '/' . self::PLUGIN_FILE ); } @@ -849,7 +849,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'DELETE', self::BASE . '/' . self::PLUGIN ); $response = rest_do_request( $request ); - $this->assertEquals( 401, $response->get_status() ); + $this->assertSame( 401, $response->get_status() ); } /** @@ -861,7 +861,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'DELETE', self::BASE . '/' . self::PLUGIN ); $response = rest_do_request( $request ); - $this->assertEquals( 403, $response->get_status() ); + $this->assertSame( 403, $response->get_status() ); } /** @@ -920,7 +920,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $this->check_get_plugin_data( $response->get_data() ); $links = $response->get_links(); $this->assertArrayHasKey( 'self', $links ); - $this->assertEquals( rest_url( self::BASE . '/' . self::PLUGIN ), $links['self'][0]['href'] ); + $this->assertSame( rest_url( self::BASE . '/' . self::PLUGIN ), $links['self'][0]['href'] ); } /** @@ -937,7 +937,7 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { $endpoint = new WP_REST_Plugins_Controller(); $response = $endpoint->prepare_item_for_response( $item, new WP_REST_Request( 'GET', self::BASE . '/' . self::PLUGIN ) ); - $this->assertEquals( 'network-active', $response->get_data()['status'] ); + $this->assertSame( 'network-active', $response->get_data()['status'] ); } /** @@ -989,19 +989,19 @@ class WP_REST_Plugins_Controller_Test extends WP_Test_REST_Controller_Testcase { * @param bool $network_only Whether the plugin is network only. */ protected function check_get_plugin_data( $data, $network_only = false ) { - $this->assertEquals( 'test-plugin/test-plugin', $data['plugin'] ); - $this->assertEquals( '1.5.4', $data['version'] ); - $this->assertEquals( 'inactive', $data['status'] ); - $this->assertEquals( 'Test Plugin', $data['name'] ); - $this->assertEquals( 'https://wordpress.org/plugins/test-plugin/', $data['plugin_uri'] ); - $this->assertEquals( 'WordPress.org', $data['author'] ); - $this->assertEquals( 'https://wordpress.org/', $data['author_uri'] ); - $this->assertEquals( "My 'Cool' Plugin", $data['description']['raw'] ); - $this->assertEquals( 'My ‘Cool’ Plugin <cite>By <a href="https://wordpress.org/">WordPress.org</a>.</cite>', $data['description']['rendered'] ); - $this->assertEquals( $network_only, $data['network_only'] ); - $this->assertEquals( '5.6.0', $data['requires_php'] ); - $this->assertEquals( '5.4.0', $data['requires_wp'] ); - $this->assertEquals( 'test-plugin', $data['textdomain'] ); + $this->assertSame( 'test-plugin/test-plugin', $data['plugin'] ); + $this->assertSame( '1.5.4', $data['version'] ); + $this->assertSame( 'inactive', $data['status'] ); + $this->assertSame( 'Test Plugin', $data['name'] ); + $this->assertSame( 'https://wordpress.org/plugins/test-plugin/', $data['plugin_uri'] ); + $this->assertSame( 'WordPress.org', $data['author'] ); + $this->assertSame( 'https://wordpress.org/', $data['author_uri'] ); + $this->assertSame( "My 'Cool' Plugin", $data['description']['raw'] ); + $this->assertSame( 'My ‘Cool’ Plugin <cite>By <a href="https://wordpress.org/">WordPress.org</a>.</cite>', $data['description']['rendered'] ); + $this->assertSame( $network_only, $data['network_only'] ); + $this->assertSame( '5.6.0', $data['requires_php'] ); + $this->assertSame( '5.4.0', $data['requires_wp'] ); + $this->assertSame( 'test-plugin', $data['textdomain'] ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php index 0fa6fdd3af..dd17c54a8a 100644 --- a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php @@ -267,14 +267,14 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'test_single', $meta ); - $this->assertEquals( 'testvalue', $meta['test_single'] ); + $this->assertSame( 'testvalue', $meta['test_single'] ); } /** @@ -285,7 +285,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; @@ -297,7 +297,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { add_post_meta( self::$post_id, 'test_multi', 'value2' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; $this->assertContains( 'value1', $meta['test_multi'] ); @@ -312,7 +312,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; @@ -327,7 +327,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; @@ -342,7 +342,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; @@ -389,7 +389,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; @@ -404,7 +404,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $this->assertArrayHasKey( 'test_bool', $meta ); $this->assertInternalType( 'boolean', $meta['test_bool'] ); - $this->assertSame( true, $meta['test_bool'] ); + $this->assertTrue( $meta['test_bool'] ); } public function test_get_value_custom_name() { @@ -413,14 +413,14 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'new_name', $meta ); - $this->assertEquals( 'janet', $meta['new_name'] ); + $this->assertSame( 'janet', $meta['new_name'] ); } /** @@ -442,17 +442,17 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_single', false ); $this->assertNotEmpty( $meta ); $this->assertCount( 1, $meta ); - $this->assertEquals( 'test_value', $meta[0] ); + $this->assertSame( 'test_value', $meta[0] ); $data = $response->get_data(); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'test_single', $meta ); - $this->assertEquals( 'test_value', $meta['test_single'] ); + $this->assertSame( 'test_value', $meta['test_single'] ); } /** @@ -461,7 +461,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { public function test_set_duplicate_single_value() { // Start with an existing metakey and value. $values = update_post_meta( self::$post_id, 'test_single', 'test_value' ); - $this->assertEquals( 'test_value', get_post_meta( self::$post_id, 'test_single', true ) ); + $this->assertSame( 'test_value', get_post_meta( self::$post_id, 'test_single', true ) ); $this->grant_write_permission(); @@ -474,16 +474,16 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_single', true ); $this->assertNotEmpty( $meta ); - $this->assertEquals( 'test_value', $meta ); + $this->assertSame( 'test_value', $meta ); $data = $response->get_data(); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'test_single', $meta ); - $this->assertEquals( 'test_value', $meta['test_single'] ); + $this->assertSame( 'test_value', $meta['test_single'] ); } /** @@ -592,12 +592,12 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_multi', false ); $this->assertNotEmpty( $meta ); $this->assertCount( 1, $meta ); - $this->assertEquals( 'val1', $meta[0] ); + $this->assertSame( 'val1', $meta[0] ); // Add another value. $data = array( @@ -608,7 +608,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_multi', false ); $this->assertNotEmpty( $meta ); @@ -636,7 +636,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_multi', false ); $this->assertNotEmpty( $meta ); @@ -743,7 +743,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, $data['meta']['my_meta_key'] ); + $this->assertSame( 1, $data['meta']['my_meta_key'] ); } public function test_set_value_csv() { @@ -769,7 +769,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array( 1, 2, 3 ), $data['meta']['my_meta_key'] ); + $this->assertSame( array( 1, 2, 3 ), $data['meta']['my_meta_key'] ); } /** @@ -841,7 +841,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_custom_schema', false ); $this->assertNotEmpty( $meta ); @@ -870,7 +870,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_custom_schema_multi', false ); $this->assertNotEmpty( $meta ); @@ -886,7 +886,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_custom_schema_multi', false ); $this->assertNotEmpty( $meta ); @@ -914,17 +914,17 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_custom_name', false ); $this->assertNotEmpty( $meta ); $this->assertCount( 1, $meta ); - $this->assertEquals( 'janet', $meta[0] ); + $this->assertSame( 'janet', $meta[0] ); $data = $response->get_data(); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'new_name', $meta ); - $this->assertEquals( 'janet', $meta['new_name'] ); + $this->assertSame( 'janet', $meta['new_name'] ); } public function test_set_value_custom_name_multiple() { @@ -943,12 +943,12 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_custom_name_multi', false ); $this->assertNotEmpty( $meta ); $this->assertCount( 1, $meta ); - $this->assertEquals( 'janet', $meta[0] ); + $this->assertSame( 'janet', $meta[0] ); // Add another value. $data = array( @@ -959,7 +959,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_custom_name_multi', false ); $this->assertNotEmpty( $meta ); @@ -991,11 +991,11 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { // The meta value should not have changed. $current_value = get_post_meta( self::$post_id, 'test_single', true ); - $this->assertEquals( 'So I tied an onion to my belt, which was the style at the time.', $current_value ); + $this->assertSame( 'So I tied an onion to my belt, which was the style at the time.', $current_value ); // Ensure the post title update was not processed. $post_updated = get_post( self::$post_id ); - $this->assertEquals( $post_original->post_title, $post_updated->post_title ); + $this->assertSame( $post_original->post_title, $post_updated->post_title ); } /** @@ -1020,17 +1020,17 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { // The meta value should not have changed. $current_value = get_post_meta( self::$post_id, 'test_single', true ); - $this->assertEquals( 'Now, to take the ferry cost a nickel, and in those days, nickels had pictures of bumblebees on them.', $current_value ); + $this->assertSame( 'Now, to take the ferry cost a nickel, and in those days, nickels had pictures of bumblebees on them.', $current_value ); // Ensure the post content update was not processed. $post_updated = get_post( self::$post_id ); - $this->assertEquals( $post_original->post_content, $post_updated->post_content ); + $this->assertSame( $post_original->post_content, $post_updated->post_content ); } public function test_remove_multi_value_db_error() { add_post_meta( self::$post_id, 'test_multi', 'val1' ); $values = get_post_meta( self::$post_id, 'test_multi', false ); - $this->assertEquals( array( 'val1' ), $values ); + $this->assertSame( array( 'val1' ), $values ); $this->grant_write_permission(); @@ -1061,7 +1061,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { public function test_delete_value() { add_post_meta( self::$post_id, 'test_single', 'val1' ); $current = get_post_meta( self::$post_id, 'test_single', true ); - $this->assertEquals( 'val1', $current ); + $this->assertSame( 'val1', $current ); $this->grant_write_permission(); @@ -1074,7 +1074,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_single', false ); $this->assertEmpty( $meta ); @@ -1086,7 +1086,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { public function test_delete_value_blocked() { add_post_meta( self::$post_id, 'test_bad_auth', 'val1' ); $current = get_post_meta( self::$post_id, 'test_bad_auth', true ); - $this->assertEquals( 'val1', $current ); + $this->assertSame( 'val1', $current ); $this->grant_write_permission(); @@ -1102,7 +1102,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $this->assertErrorResponse( 'rest_cannot_delete', $response, 403 ); $meta = get_post_meta( self::$post_id, 'test_bad_auth', true ); - $this->assertEquals( 'val1', $meta ); + $this->assertSame( 'val1', $meta ); } /** @@ -1111,7 +1111,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { public function test_delete_value_db_error() { add_post_meta( self::$post_id, 'test_single', 'val1' ); $current = get_post_meta( self::$post_id, 'test_single', true ); - $this->assertEquals( 'val1', $current ); + $this->assertSame( 'val1', $current ); $this->grant_write_permission(); @@ -1140,7 +1140,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { public function test_delete_value_custom_name() { add_post_meta( self::$post_id, 'test_custom_name', 'janet' ); $current = get_post_meta( self::$post_id, 'test_custom_name', true ); - $this->assertEquals( 'janet', $current ); + $this->assertSame( 'janet', $current ); $this->grant_write_permission(); @@ -1153,7 +1153,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_post_meta( self::$post_id, 'test_custom_name', false ); $this->assertEmpty( $meta ); @@ -1170,15 +1170,15 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $meta_schema = $schema['properties']['meta']['properties']; $this->assertArrayHasKey( 'test_single', $meta_schema ); - $this->assertEquals( 'string', $meta_schema['test_single']['type'] ); + $this->assertSame( 'string', $meta_schema['test_single']['type'] ); $this->assertArrayHasKey( 'test_multi', $meta_schema ); - $this->assertEquals( 'array', $meta_schema['test_multi']['type'] ); + $this->assertSame( 'array', $meta_schema['test_multi']['type'] ); $this->assertArrayHasKey( 'items', $meta_schema['test_multi'] ); - $this->assertEquals( 'string', $meta_schema['test_multi']['items']['type'] ); + $this->assertSame( 'string', $meta_schema['test_multi']['items']['type'] ); $this->assertArrayHasKey( 'test_custom_schema', $meta_schema ); - $this->assertEquals( 'number', $meta_schema['test_custom_schema']['type'] ); + $this->assertSame( 'number', $meta_schema['test_custom_schema']['type'] ); $this->assertArrayNotHasKey( 'test_no_rest', $meta_schema ); $this->assertArrayNotHasKey( 'test_rest_disabled', $meta_schema ); @@ -1206,7 +1206,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/%s/%d', $endpoint, $post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); @@ -1220,7 +1220,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { } $this->assertArrayHasKey( $meta_key, $data['meta'] ); - $this->assertEquals( $expected_value, $data['meta'][ $meta_key ] ); + $this->assertSame( $expected_value, $data['meta'][ $meta_key ] ); } else { $this->assertArrayNotHasKey( $meta_key, $data['meta'] ); } @@ -1267,13 +1267,13 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $response = rest_get_server()->dispatch( $request ); if ( ! $can_write ) { - $this->assertEquals( 403, $response->get_status() ); + $this->assertSame( 403, $response->get_status() ); $this->assertEmpty( get_post_meta( $post_id, $meta_key, $single ) ); return; } - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); @@ -1285,9 +1285,9 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $expected_value = array( $expected_value ); } - $this->assertEquals( $expected_value, get_post_meta( $post_id, $meta_key, $single ) ); + $this->assertSame( $expected_value, get_post_meta( $post_id, $meta_key, $single ) ); $this->assertArrayHasKey( $meta_key, $data['meta'] ); - $this->assertEquals( $expected_value, $data['meta'][ $meta_key ] ); + $this->assertSame( $expected_value, $data['meta'][ $meta_key ] ); } else { $this->assertEmpty( get_post_meta( $post_id, $meta_key, $single ) ); $this->assertArrayNotHasKey( $meta_key, $data['meta'] ); @@ -1332,7 +1332,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function data_update_value_return_success_with_same_value() { @@ -1359,7 +1359,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $data = $response->get_data(); $this->assertArrayHasKey( 'test\'slashed\'key', $data['meta'] ); - $this->assertEquals( 'Hello', $data['meta']['test\'slashed\'key'] ); + $this->assertSame( 'Hello', $data['meta']['test\'slashed\'key'] ); } /** @@ -1403,11 +1403,11 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $this->assertArrayHasKey( 'object', $data['meta'] ); $this->assertArrayHasKey( 'project', $data['meta']['object'] ); - $this->assertEquals( 'WordPress', $data['meta']['object']['project'] ); + $this->assertSame( 'WordPress', $data['meta']['object']['project'] ); $meta = get_post_meta( self::$post_id, 'object', true ); $this->assertArrayHasKey( 'project', $meta ); - $this->assertEquals( 'WordPress', $meta['project'] ); + $this->assertSame( 'WordPress', $meta['project'] ); } /** @@ -1458,20 +1458,20 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $this->assertCount( 2, $data['meta']['object'] ); $this->assertArrayHasKey( 'project', $data['meta']['object'][0] ); - $this->assertEquals( 'WordPress', $data['meta']['object'][0]['project'] ); + $this->assertSame( 'WordPress', $data['meta']['object'][0]['project'] ); $this->assertArrayHasKey( 'project', $data['meta']['object'][1] ); - $this->assertEquals( 'bbPress', $data['meta']['object'][1]['project'] ); + $this->assertSame( 'bbPress', $data['meta']['object'][1]['project'] ); $meta = get_post_meta( self::$post_id, 'object' ); $this->assertCount( 2, $meta ); $this->assertArrayHasKey( 'project', $meta[0] ); - $this->assertEquals( 'WordPress', $meta[0]['project'] ); + $this->assertSame( 'WordPress', $meta[0]['project'] ); $this->assertArrayHasKey( 'project', $meta[1] ); - $this->assertEquals( 'bbPress', $meta[1]['project'] ); + $this->assertSame( 'bbPress', $meta[1]['project'] ); } /** @@ -1510,10 +1510,10 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $data = $response->get_data(); $this->assertArrayHasKey( 'list', $data['meta'] ); - $this->assertEquals( array( 'WordPress', 'bbPress' ), $data['meta']['list'] ); + $this->assertSame( array( 'WordPress', 'bbPress' ), $data['meta']['list'] ); $meta = get_post_meta( self::$post_id, 'list', true ); - $this->assertEquals( array( 'WordPress', 'bbPress' ), $meta ); + $this->assertSame( array( 'WordPress', 'bbPress' ), $meta ); } /** @@ -1581,7 +1581,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $this->assertArrayHasKey( 'list_of_objects', $data['meta'] ); $this->assertCount( 2, $data['meta']['list_of_objects'] ); - $this->assertEquals( + $this->assertSame( array( array( 'version' => '5.2', @@ -1595,7 +1595,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $data['meta']['list_of_objects'][0] ); - $this->assertEquals( + $this->assertSame( array( array( 'version' => '4.9', @@ -1609,7 +1609,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $this->assertCount( 2, $meta ); - $this->assertEquals( + $this->assertSame( array( array( 'version' => '5.2', @@ -1623,7 +1623,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $meta[0] ); - $this->assertEquals( + $this->assertSame( array( array( 'version' => '4.9', @@ -1703,7 +1703,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $this->assertArrayHasKey( 'object', $data['meta'] ); $this->assertCount( 2, $data['meta']['object'] ); - $this->assertEquals( array( 'project' => 'bbPress' ), $data['meta']['object'][0] ); + $this->assertSame( array( 'project' => 'bbPress' ), $data['meta']['object'][0] ); $this->assertNull( $data['meta']['object'][1] ); } @@ -1739,7 +1739,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $data = $response->get_data(); $this->assertArrayHasKey( 'object', $data['meta'] ); - $this->assertEquals( array( 'project' => 'WordPress' ), $data['meta']['object'] ); + $this->assertSame( array( 'project' => 'WordPress' ), $data['meta']['object'] ); } /** @@ -1781,7 +1781,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 500, $response->get_status() ); + $this->assertSame( 500, $response->get_status() ); } /** @@ -1827,7 +1827,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 500, $response->get_status() ); + $this->assertSame( 500, $response->get_status() ); } /** @@ -1868,7 +1868,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); } /** @@ -1912,10 +1912,10 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( $value, $response->get_data()['meta']['object'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( $value, $response->get_data()['meta']['object'] ); - $this->assertEquals( $value, get_post_meta( self::$post_id, 'object', true ) ); + $this->assertSame( $value, get_post_meta( self::$post_id, 'object', true ) ); } /** @@ -1961,7 +1961,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); } /** @@ -2088,19 +2088,19 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( 'object', $data['meta'] ); $this->assertCount( 2, $data['meta']['object'] ); - $this->assertEquals( array( 'project' => 'WordPress' ), $data['meta']['object'][0] ); - $this->assertEquals( array( 'project' => 'BuddyPress' ), $data['meta']['object'][1] ); + $this->assertSame( array( 'project' => 'WordPress' ), $data['meta']['object'][0] ); + $this->assertSame( array( 'project' => 'BuddyPress' ), $data['meta']['object'][1] ); $meta = get_post_meta( self::$post_id, 'object' ); $this->assertCount( 2, $meta ); - $this->assertEquals( array( 'project' => 'WordPress' ), $meta[0] ); - $this->assertEquals( array( 'project' => 'BuddyPress' ), $meta[1] ); + $this->assertSame( array( 'project' => 'WordPress' ), $meta[0] ); + $this->assertSame( array( 'project' => 'BuddyPress' ), $meta[1] ); } /** @@ -2141,19 +2141,19 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( 'list', $data['meta'] ); $this->assertCount( 2, $data['meta']['list'] ); - $this->assertEquals( array( 'WordPress', 'bbPress' ), $data['meta']['list'][0] ); - $this->assertEquals( array( 'BuddyPress' ), $data['meta']['list'][1] ); + $this->assertSame( array( 'WordPress', 'bbPress' ), $data['meta']['list'][0] ); + $this->assertSame( array( 'BuddyPress' ), $data['meta']['list'][1] ); $meta = get_post_meta( self::$post_id, 'list' ); $this->assertCount( 2, $meta ); - $this->assertEquals( array( 'WordPress', 'bbPress' ), $meta[0] ); - $this->assertEquals( array( 'BuddyPress' ), $meta[1] ); + $this->assertSame( array( 'WordPress', 'bbPress' ), $meta[0] ); + $this->assertSame( array( 'BuddyPress' ), $meta[1] ); } /** @@ -2191,10 +2191,10 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( array( 'WordCamp' ), $data['meta']['list'] ); + $this->assertSame( array( 'WordCamp' ), $data['meta']['list'] ); } /** @@ -2234,10 +2234,10 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( array( 'project' => 'WordCamp' ), $data['meta']['object'] ); + $this->assertSame( array( 'project' => 'WordCamp' ), $data['meta']['object'] ); } /** @@ -2332,7 +2332,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { rest_get_server()->dispatch( $request ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } /** @@ -2358,7 +2358,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { update_post_meta( self::$post_id, 'items', array( '1', '2', '3' ) ); $response = rest_get_server()->dispatch( new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ) ); - $this->assertEquals( array( 1, 2, 3 ), $response->get_data()['meta']['items'] ); + $this->assertSame( array( 1, 2, 3 ), $response->get_data()['meta']['items'] ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $request->set_body_params( @@ -2370,7 +2370,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertSame( array( 1, 2, 3 ), get_post_meta( self::$post_id, 'items', true ) ); } @@ -2407,7 +2407,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertSame( array( 1, 2, 3 ), get_post_meta( self::$post_id, 'items', true ) ); } @@ -2444,7 +2444,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertSame( array( 1, 2, 3 ), get_post_meta( self::$post_id, 'items', true ) ); } @@ -2480,7 +2480,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { rest_get_server()->dispatch( $request ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } /** @@ -2507,7 +2507,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { update_post_meta( self::$post_id, 'items', array( '1', '0' ) ); $response = rest_get_server()->dispatch( new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ) ); - $this->assertEquals( array( true, false ), $response->get_data()['meta']['items'] ); + $this->assertSame( array( true, false ), $response->get_data()['meta']['items'] ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $request->set_body_params( @@ -2519,7 +2519,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertSame( array( true, false ), get_post_meta( self::$post_id, 'items', true ) ); } @@ -2556,7 +2556,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertSame( array( true, false ), get_post_meta( self::$post_id, 'items', true ) ); } @@ -2593,7 +2593,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertSame( array( true, false ), get_post_meta( self::$post_id, 'items', true ) ); } @@ -2630,7 +2630,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertSame( array( false, true ), get_post_meta( self::$post_id, 'items', true ) ); } @@ -2665,8 +2665,8 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( '0', get_post_meta( self::$post_id, 'boolean', true ) ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( '0', get_post_meta( self::$post_id, 'boolean', true ) ); } /** @@ -2698,8 +2698,8 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( array( 2, 3 ), $response->get_data()['meta']['multi_integer'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( array( 2, 3 ), $response->get_data()['meta']['multi_integer'] ); $this->assertFalse( get_metadata_by_mid( 'post', $mid1 ) ); $this->assertNotFalse( get_metadata_by_mid( 'post', $mid2 ) ); @@ -2735,7 +2735,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertEquals( array( 0 ), $response->get_data()['meta']['multi_boolean'] ); $this->assertFalse( get_metadata_by_mid( 'post', $mid1 ) ); @@ -2783,8 +2783,8 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( array( array( 'a' => 'anaconda' ), array( 'a' => 'alpaca' ), @@ -2815,14 +2815,14 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); $meta = (array) $data['meta']; $this->assertArrayHasKey( $meta_key, $meta ); - $this->assertEquals( $expected, $meta[ $meta_key ] ); + $this->assertSame( $expected, $meta[ $meta_key ] ); } public function data_get_default_data() { @@ -2981,7 +2981,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { ); $response = rest_do_request( '/wp/v2/posts/' . self::$post_id ); - $this->assertEquals( 'Hello World', $response->get_data()['meta']['greeting'] ); + $this->assertSame( 'Hello World', $response->get_data()['meta']['greeting'] ); } /** @@ -2993,7 +2993,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $schema = $response->get_data()['schema']['properties']['meta']['properties']['with_default']; $this->assertArrayHasKey( 'default', $schema ); - $this->assertEquals( 'Goodnight Moon', $schema['default'] ); + $this->assertSame( 'Goodnight Moon', $schema['default'] ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php b/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php index 3280a06217..fbd3383258 100644 --- a/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php +++ b/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php @@ -22,13 +22,13 @@ class WP_Test_REST_Post_Statuses_Controller extends WP_Test_REST_Controller_Test $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/statuses' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'embed', 'view', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/statuses/publish' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'embed', 'view', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); } @@ -38,8 +38,8 @@ class WP_Test_REST_Post_Statuses_Controller extends WP_Test_REST_Controller_Test $data = $response->get_data(); $statuses = get_post_stati( array( 'public' => true ), 'objects' ); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( 'publish', $data['publish']['slug'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( 'publish', $data['publish']['slug'] ); } public function test_get_items_logged_in() { @@ -50,7 +50,7 @@ class WP_Test_REST_Post_Statuses_Controller extends WP_Test_REST_Controller_Test $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 6, count( $data ) ); + $this->assertSame( 6, count( $data ) ); $this->assertEqualSets( array( 'publish', @@ -106,21 +106,21 @@ class WP_Test_REST_Post_Statuses_Controller extends WP_Test_REST_Controller_Test /** Post statuses can't be created */ $request = new WP_REST_Request( 'POST', '/wp/v2/statuses' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_update_item() { /** Post statuses can't be updated */ $request = new WP_REST_Request( 'POST', '/wp/v2/statuses/draft' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_delete_item() { /** Post statuses can't be deleted */ $request = new WP_REST_Request( 'DELETE', '/wp/v2/statuses/draft' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_prepare_item() { @@ -139,7 +139,7 @@ class WP_Test_REST_Post_Statuses_Controller extends WP_Test_REST_Controller_Test $request->set_param( 'context', 'edit' ); $request->set_param( '_fields', 'id,name' ); $response = $endpoint->prepare_item_for_response( $obj, $request ); - $this->assertEquals( + $this->assertSame( array( // 'id' doesn't exist in this context. 'name', @@ -153,7 +153,7 @@ class WP_Test_REST_Post_Statuses_Controller extends WP_Test_REST_Controller_Test $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 8, count( $properties ) ); + $this->assertSame( 8, count( $properties ) ); $this->assertArrayHasKey( 'name', $properties ); $this->assertArrayHasKey( 'private', $properties ); $this->assertArrayHasKey( 'protected', $properties ); @@ -189,7 +189,7 @@ class WP_Test_REST_Post_Statuses_Controller extends WP_Test_REST_Controller_Test $data = $response->get_data(); $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); - $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] ); + $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/statuses/publish' ); @@ -205,24 +205,24 @@ class WP_Test_REST_Post_Statuses_Controller extends WP_Test_REST_Controller_Test } protected function check_post_status_obj( $status_obj, $data, $links ) { - $this->assertEquals( $status_obj->label, $data['name'] ); - $this->assertEquals( $status_obj->private, $data['private'] ); - $this->assertEquals( $status_obj->protected, $data['protected'] ); - $this->assertEquals( $status_obj->public, $data['public'] ); - $this->assertEquals( $status_obj->publicly_queryable, $data['queryable'] ); - $this->assertEquals( $status_obj->show_in_admin_all_list, $data['show_in_list'] ); - $this->assertEquals( $status_obj->name, $data['slug'] ); + $this->assertSame( $status_obj->label, $data['name'] ); + $this->assertSame( $status_obj->private, $data['private'] ); + $this->assertSame( $status_obj->protected, $data['protected'] ); + $this->assertSame( $status_obj->public, $data['public'] ); + $this->assertSame( $status_obj->publicly_queryable, $data['queryable'] ); + $this->assertSame( $status_obj->show_in_admin_all_list, $data['show_in_list'] ); + $this->assertSame( $status_obj->name, $data['slug'] ); $this->assertEqualSets( array( 'archives', ), array_keys( $links ) ); - $this->assertEquals( $status_obj->date_floating, $data['date_floating'] ); + $this->assertSame( $status_obj->date_floating, $data['date_floating'] ); } protected function check_post_status_object_response( $response ) { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $obj = get_post_status_object( 'publish' ); $this->check_post_status_obj( $obj, $data, $response->get_links() ); diff --git a/tests/phpunit/tests/rest-api/rest-post-types-controller.php b/tests/phpunit/tests/rest-api/rest-post-types-controller.php index b321058639..727aa00d88 100644 --- a/tests/phpunit/tests/rest-api/rest-post-types-controller.php +++ b/tests/phpunit/tests/rest-api/rest-post-types-controller.php @@ -22,13 +22,13 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/types' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/types/post' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); } @@ -38,10 +38,10 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas $data = $response->get_data(); $post_types = get_post_types( array( 'show_in_rest' => true ), 'objects' ); - $this->assertEquals( count( $post_types ), count( $data ) ); - $this->assertEquals( $post_types['post']->name, $data['post']['slug'] ); + $this->assertSame( count( $post_types ), count( $data ) ); + $this->assertSame( $post_types['post']->name, $data['post']['slug'] ); $this->check_post_type_obj( 'view', $post_types['post'], $data['post'], $data['post']['_links'] ); - $this->assertEquals( $post_types['page']->name, $data['page']['slug'] ); + $this->assertSame( $post_types['page']->name, $data['page']['slug'] ); $this->check_post_type_obj( 'view', $post_types['page'], $data['page'], $data['page']['_links'] ); $this->assertFalse( isset( $data['revision'] ) ); } @@ -59,7 +59,7 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $this->check_post_type_object_response( 'view', $response ); $data = $response->get_data(); - $this->assertEquals( array( 'category', 'post_tag' ), $data['taxonomies'] ); + $this->assertSame( array( 'category', 'post_tag' ), $data['taxonomies'] ); } public function test_get_item_page() { @@ -67,7 +67,7 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $this->check_post_type_object_response( 'view', $response, 'page' ); $data = $response->get_data(); - $this->assertEquals( array(), $data['taxonomies'] ); + $this->assertSame( array(), $data['taxonomies'] ); } public function test_get_item_invalid_type() { @@ -97,21 +97,21 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas /** Post types can't be created */ $request = new WP_REST_Request( 'POST', '/wp/v2/types' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_update_item() { /** Post types can't be updated */ $request = new WP_REST_Request( 'POST', '/wp/v2/types/post' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_delete_item() { /** Post types can't be deleted */ $request = new WP_REST_Request( 'DELETE', '/wp/v2/types/post' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_prepare_item() { @@ -130,7 +130,7 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'context', 'edit' ); $request->set_param( '_fields', 'id,name' ); $response = $endpoint->prepare_item_for_response( $obj, $request ); - $this->assertEquals( + $this->assertSame( array( // 'id' doesn't exist in this context. 'name', @@ -144,7 +144,7 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 10, count( $properties ) ); + $this->assertSame( 10, count( $properties ) ); $this->assertArrayHasKey( 'capabilities', $properties ); $this->assertArrayHasKey( 'description', $properties ); $this->assertArrayHasKey( 'hierarchical', $properties ); @@ -182,7 +182,7 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas $data = $response->get_data(); $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); - $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] ); + $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/types/post' ); @@ -198,25 +198,25 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas } protected function check_post_type_obj( $context, $post_type_obj, $data, $links ) { - $this->assertEquals( $post_type_obj->label, $data['name'] ); - $this->assertEquals( $post_type_obj->name, $data['slug'] ); - $this->assertEquals( $post_type_obj->description, $data['description'] ); - $this->assertEquals( $post_type_obj->hierarchical, $data['hierarchical'] ); - $this->assertEquals( $post_type_obj->rest_base, $data['rest_base'] ); + $this->assertSame( $post_type_obj->label, $data['name'] ); + $this->assertSame( $post_type_obj->name, $data['slug'] ); + $this->assertSame( $post_type_obj->description, $data['description'] ); + $this->assertSame( $post_type_obj->hierarchical, $data['hierarchical'] ); + $this->assertSame( $post_type_obj->rest_base, $data['rest_base'] ); $links = test_rest_expand_compact_links( $links ); - $this->assertEquals( rest_url( 'wp/v2/types' ), $links['collection'][0]['href'] ); + $this->assertSame( rest_url( 'wp/v2/types' ), $links['collection'][0]['href'] ); $this->assertArrayHasKey( 'https://api.w.org/items', $links ); if ( 'edit' === $context ) { - $this->assertEquals( $post_type_obj->cap, $data['capabilities'] ); - $this->assertEquals( $post_type_obj->labels, $data['labels'] ); + $this->assertSame( $post_type_obj->cap, $data['capabilities'] ); + $this->assertSame( $post_type_obj->labels, $data['labels'] ); if ( in_array( $post_type_obj->name, array( 'post', 'page' ), true ) ) { $viewable = true; } else { $viewable = is_post_type_viewable( $post_type_obj ); } - $this->assertEquals( $viewable, $data['viewable'] ); - $this->assertEquals( get_all_post_type_supports( $post_type_obj->name ), $data['supports'] ); + $this->assertSame( $viewable, $data['viewable'] ); + $this->assertSame( get_all_post_type_supports( $post_type_obj->name ), $data['supports'] ); } else { $this->assertFalse( isset( $data['capabilities'] ) ); $this->assertFalse( isset( $data['viewable'] ) ); @@ -226,7 +226,7 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas } protected function check_post_type_object_response( $context, $response, $post_type = 'post' ) { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $obj = get_post_type_object( $post_type ); $this->check_post_type_obj( $context, $obj, $data, $response->get_links() ); diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index 7bec6cc516..a565fce6b3 100644 --- a/tests/phpunit/tests/rest-api/rest-posts-controller.php +++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php @@ -129,7 +129,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te global $wpdb; $expected_clause = str_replace( '{posts}', $wpdb->posts, $pattern ); $this->assertCount( 1, $this->posts_clauses ); - $this->assertEquals( $expected_clause, $wpdb->remove_placeholder_escape( $this->posts_clauses[0][ $clause ] ) ); + $this->assertSame( $expected_clause, $wpdb->remove_placeholder_escape( $this->posts_clauses[0][ $clause ] ) ); } public function assertPostsOrderedBy( $pattern ) { @@ -154,14 +154,14 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); } public function test_registered_query_params() { @@ -170,7 +170,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $keys = array_keys( $data['endpoints'][0]['args'] ); sort( $keys ); - $this->assertEquals( + $this->assertSame( array( 'after', 'author', @@ -204,7 +204,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $keys = array_keys( $data['endpoints'][0]['args'] ); sort( $keys ); - $this->assertEquals( array( 'context', 'id', 'password' ), $keys ); + $this->assertSame( array( 'context', 'id', 'password' ), $keys ); } /** @@ -217,7 +217,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $headers = $response->get_headers(); $this->assertNotEmpty( $headers['Allow'] ); - $this->assertEquals( $headers['Allow'], 'GET' ); + $this->assertSame( $headers['Allow'], 'GET' ); wp_set_current_user( self::$editor_id ); @@ -227,7 +227,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $headers = $response->get_headers(); $this->assertNotEmpty( $headers['Allow'] ); - $this->assertEquals( $headers['Allow'], 'GET, POST, PUT, PATCH, DELETE' ); + $this->assertSame( $headers['Allow'], 'GET, POST, PUT, PATCH, DELETE' ); } public function test_get_items() { @@ -252,7 +252,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $this->assertEmpty( $response->get_data() ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_get_items_author_query() { @@ -265,26 +265,26 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'per_page', self::$per_page ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( $total_posts, count( $response->get_data() ) ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( $total_posts, count( $response->get_data() ) ); // Limit to editor and author. $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'author', array( self::$editor_id, self::$author_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); + $this->assertSame( 2, count( $data ) ); $this->assertEqualSets( array( self::$editor_id, self::$author_id ), wp_list_pluck( $data, 'author' ) ); // Limit to editor. $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'author', self::$editor_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( self::$editor_id, $data[0]['author'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( self::$editor_id, $data[0]['author'] ); } public function test_get_items_author_exclude_query() { @@ -297,17 +297,17 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'per_page', self::$per_page ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( $total_posts, count( $response->get_data() ) ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( $total_posts, count( $response->get_data() ) ); // Exclude editor and author. $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'per_page', self::$per_page ); $request->set_param( 'author_exclude', array( self::$editor_id, self::$author_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $total_posts - 2, count( $data ) ); + $this->assertSame( $total_posts - 2, count( $data ) ); $this->assertNotEquals( self::$editor_id, $data[0]['author'] ); $this->assertNotEquals( self::$author_id, $data[0]['author'] ); @@ -316,9 +316,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'per_page', self::$per_page ); $request->set_param( 'author_exclude', self::$editor_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $total_posts - 1, count( $data ) ); + $this->assertSame( $total_posts - 1, count( $data ) ); $this->assertNotEquals( self::$editor_id, $data[0]['author'] ); $this->assertNotEquals( self::$editor_id, $data[1]['author'] ); @@ -349,16 +349,16 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'include', array( $id1, $id2 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( $id2, $data[0]['id'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( $id2, $data[0]['id'] ); $this->assertPostsOrderedBy( '{posts}.post_date DESC' ); // 'orderby' => 'include'. $request->set_param( 'orderby', 'include' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( $id1, $data[0]['id'] ); $this->assertPostsOrderedBy( "FIELD({posts}.ID,$id1,$id2)" ); // Invalid 'include' should error. @@ -395,10 +395,10 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( self::$author_id, $data[0]['author'] ); - $this->assertEquals( self::$editor_id, $data[1]['author'] ); - $this->assertEquals( self::$editor_id, $data[2]['author'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( self::$author_id, $data[0]['author'] ); + $this->assertSame( self::$editor_id, $data[1]['author'] ); + $this->assertSame( self::$editor_id, $data[2]['author'] ); $this->assertPostsOrderedBy( '{posts}.post_author DESC' ); } @@ -419,10 +419,10 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( $id1, $data[0]['id'] ); - $this->assertEquals( $id3, $data[1]['id'] ); - $this->assertEquals( $id2, $data[2]['id'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( $id1, $data[0]['id'] ); + $this->assertSame( $id3, $data[1]['id'] ); + $this->assertSame( $id2, $data[2]['id'] ); $this->assertPostsOrderedBy( '{posts}.post_modified DESC' ); } @@ -455,12 +455,12 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( $id3, $data[0]['id'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( $id3, $data[0]['id'] ); // Check ordering. Default ORDER is DESC. - $this->assertEquals( $id1, $data[0]['parent'] ); - $this->assertEquals( 0, $data[1]['parent'] ); - $this->assertEquals( 0, $data[2]['parent'] ); + $this->assertSame( $id1, $data[0]['parent'] ); + $this->assertSame( 0, $data[1]['parent'] ); + $this->assertSame( 0, $data[2]['parent'] ); $this->assertPostsOrderedBy( '{posts}.post_parent DESC' ); } @@ -507,14 +507,14 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'per_page', self::$per_page ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( $total_posts, count( $response->get_data() ) ); + $this->assertSame( $total_posts, count( $response->get_data() ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'search', 'Search Result' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( 'Search Result', $data[0]['title']['rendered'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( 'Search Result', $data[0]['title']['rendered'] ); } public function test_get_items_slug_query() { @@ -534,10 +534,10 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'slug', 'apple' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( 'Apple', $data[0]['title']['rendered'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( 'Apple', $data[0]['title']['rendered'] ); } public function test_get_items_multiple_slugs_array_query() { @@ -563,15 +563,15 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'slug', array( 'banana', 'peach' ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); + $this->assertSame( 2, count( $data ) ); $titles = array( $data[0]['title']['rendered'], $data[1]['title']['rendered'], ); sort( $titles ); - $this->assertEquals( array( 'Banana', 'Peach' ), $titles ); + $this->assertSame( array( 'Banana', 'Peach' ), $titles ); } public function test_get_items_multiple_slugs_string_query() { @@ -597,15 +597,15 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'slug', 'apple,banana' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); + $this->assertSame( 2, count( $data ) ); $titles = array( $data[0]['title']['rendered'], $data[1]['title']['rendered'], ); sort( $titles ); - $this->assertEquals( array( 'Apple', 'Banana' ), $titles ); + $this->assertSame( array( 'Apple', 'Banana' ), $titles ); } public function test_get_items_status_query() { @@ -617,8 +617,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'per_page', self::$per_page ); $request->set_param( 'status', 'publish' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( self::$total_posts, count( $response->get_data() ) ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( self::$total_posts, count( $response->get_data() ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'status', 'draft' ); @@ -630,8 +630,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'status', 'draft' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 1, count( $response->get_data() ) ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 1, count( $response->get_data() ) ); } public function test_get_items_multiple_statuses_string_query() { @@ -646,15 +646,15 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'status', 'draft,private' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); + $this->assertSame( 2, count( $data ) ); $statuses = array( $data[0]['status'], $data[1]['status'], ); sort( $statuses ); - $this->assertEquals( array( 'draft', 'private' ), $statuses ); + $this->assertSame( array( 'draft', 'private' ), $statuses ); } public function test_get_items_multiple_statuses_array_query() { @@ -669,15 +669,15 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'status', array( 'draft', 'pending' ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); + $this->assertSame( 2, count( $data ) ); $statuses = array( $data[0]['status'], $data[1]['status'], ); sort( $statuses ); - $this->assertEquals( array( 'draft', 'pending' ), $statuses ); + $this->assertSame( array( 'draft', 'pending' ), $statuses ); } public function test_get_items_multiple_statuses_one_invalid_query() { @@ -724,7 +724,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $all_data = $response->get_data(); foreach ( $all_data as $post ) { @@ -765,14 +765,14 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'orderby', 'title' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'Apple Sauce', $data[0]['title']['rendered'] ); + $this->assertSame( 'Apple Sauce', $data[0]['title']['rendered'] ); $this->assertPostsOrderedBy( '{posts}.post_title DESC' ); // 'order' => 'asc'. $request->set_param( 'order', 'asc' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'Apple Cobbler', $data[0]['title']['rendered'] ); + $this->assertSame( 'Apple Cobbler', $data[0]['title']['rendered'] ); $this->assertPostsOrderedBy( '{posts}.post_title ASC' ); // 'order' => 'asc,id' should error. @@ -826,9 +826,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); // Default ORDER is DESC. - $this->assertEquals( $id3, $data[0]['id'] ); - $this->assertEquals( $id2, $data[1]['id'] ); - $this->assertEquals( $id1, $data[2]['id'] ); + $this->assertSame( $id3, $data[0]['id'] ); + $this->assertSame( $id2, $data[1]['id'] ); + $this->assertSame( $id1, $data[2]['id'] ); $this->assertPostsOrderedBy( '{posts}.ID DESC' ); } @@ -856,8 +856,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); // Default ORDER is DESC. - $this->assertEquals( 'xyz', $data[0]['slug'] ); - $this->assertEquals( 'abc', $data[1]['slug'] ); + $this->assertSame( 'xyz', $data[0]['slug'] ); + $this->assertSame( 'abc', $data[1]['slug'] ); $this->assertPostsOrderedBy( '{posts}.post_name DESC' ); } @@ -880,9 +880,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'taco', $data[0]['slug'] ); - $this->assertEquals( 'chalupa', $data[1]['slug'] ); - $this->assertEquals( 'burrito', $data[2]['slug'] ); + $this->assertSame( 'taco', $data[0]['slug'] ); + $this->assertSame( 'chalupa', $data[1]['slug'] ); + $this->assertSame( 'burrito', $data[2]['slug'] ); } public function test_get_items_with_orderby_relevance() { @@ -905,11 +905,11 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'orderby', 'relevance' ); $request->set_param( 'search', 'relevant' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertCount( 2, $data ); - $this->assertEquals( $id1, $data[0]['id'] ); - $this->assertEquals( $id2, $data[1]['id'] ); + $this->assertSame( $id1, $data[0]['id'] ); + $this->assertSame( $id2, $data[1]['id'] ); $this->assertPostsOrderedBy( '{posts}.post_title LIKE \'%relevant%\' DESC, {posts}.post_date DESC' ); } @@ -933,11 +933,11 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'orderby', 'relevance' ); $request->set_param( 'search', 'relevant content' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertCount( 2, $data ); - $this->assertEquals( $id1, $data[0]['id'] ); - $this->assertEquals( $id2, $data[1]['id'] ); + $this->assertSame( $id1, $data[0]['id'] ); + $this->assertSame( $id2, $data[1]['id'] ); $this->assertPostsOrderedBy( '(CASE WHEN {posts}.post_title LIKE \'%relevant content%\' THEN 1 WHEN {posts}.post_title LIKE \'%relevant%\' AND {posts}.post_title LIKE \'%content%\' THEN 2 WHEN {posts}.post_title LIKE \'%relevant%\' OR {posts}.post_title LIKE \'%content%\' THEN 3 WHEN {posts}.post_excerpt LIKE \'%relevant content%\' THEN 4 WHEN {posts}.post_content LIKE \'%relevant content%\' THEN 5 ELSE 6 END), {posts}.post_date DESC' ); } @@ -983,7 +983,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( $id1, $data[0]['id'] ); } public function test_get_items_tags_exclude_query() { @@ -1004,9 +1004,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( $total_posts - 1, $data ); - $this->assertEquals( $id4, $data[0]['id'] ); - $this->assertEquals( $id3, $data[1]['id'] ); - $this->assertEquals( $id2, $data[2]['id'] ); + $this->assertSame( $id4, $data[0]['id'] ); + $this->assertSame( $id3, $data[1]['id'] ); + $this->assertSame( $id2, $data[2]['id'] ); } public function test_get_items_tags_and_categories_query() { @@ -1052,8 +1052,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( 2, $data ); - $this->assertEquals( $id2, $data[0]['id'] ); - $this->assertEquals( $id1, $data[1]['id'] ); + $this->assertSame( $id2, $data[0]['id'] ); + $this->assertSame( $id1, $data[1]['id'] ); } public function test_get_items_tags_and_categories_exclude_query() { @@ -1073,7 +1073,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertEquals( $id2, $data[0]['id'] ); + $this->assertSame( $id2, $data[0]['id'] ); $request->set_param( 'tags_exclude', array( 'my-tag' ) ); $response = rest_get_server()->dispatch( $request ); @@ -1108,9 +1108,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( $total_posts - 1, $data ); - $this->assertEquals( $id4, $data[0]['id'] ); - $this->assertEquals( $id2, $data[1]['id'] ); - $this->assertEquals( $id1, $data[2]['id'] ); + $this->assertSame( $id4, $data[0]['id'] ); + $this->assertSame( $id2, $data[1]['id'] ); + $this->assertSame( $id1, $data[2]['id'] ); } /** @@ -1122,9 +1122,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'include', self::$post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertCount( 1, $response->get_data() ); - $this->assertEquals( self::$post_id, $response->get_data()[0]['id'] ); + $this->assertSame( self::$post_id, $response->get_data()[0]['id'] ); } public function test_get_items_sticky() { @@ -1141,7 +1141,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $posts = $response->get_data(); $post = $posts[0]; - $this->assertEquals( $id2, $post['id'] ); + $this->assertSame( $id2, $post['id'] ); $request->set_param( 'sticky', 'nothanks' ); $response = rest_get_server()->dispatch( $request ); @@ -1179,7 +1179,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $posts = $response->get_data(); $post = $posts[0]; - $this->assertEquals( $id1, $post['id'] ); + $this->assertSame( $id1, $post['id'] ); $this->assertPostsWhere( " AND {posts}.ID IN ($id1) AND {posts}.post_type = 'post' AND (({posts}.post_status = 'publish'))" ); } @@ -1236,7 +1236,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $posts = $response->get_data(); $post = $posts[0]; - $this->assertEquals( $id1, $post['id'] ); + $this->assertSame( $id1, $post['id'] ); $this->assertPostsWhere( " AND {posts}.ID NOT IN ($id2) AND {posts}.post_type = 'post' AND (({posts}.post_status = 'publish'))" ); } @@ -1301,8 +1301,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_posts, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_posts, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $next_link = add_query_arg( array( 'page' => 2, @@ -1320,8 +1320,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'page', 3 ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_posts, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_posts, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( 'page' => 2, @@ -1342,8 +1342,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'page', $total_pages ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_posts, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_posts, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( 'page' => $total_pages - 1, @@ -1371,8 +1371,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_posts, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_posts, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( 'per_page' => 5, @@ -1415,7 +1415,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $draft_id, $data[0]['id'] ); + $this->assertSame( $draft_id, $data[0]['id'] ); } /** @@ -1438,9 +1438,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertCount( 1, $data ); - $this->assertEquals( $private_post_id, $data[0]['id'] ); + $this->assertSame( $private_post_id, $data[0]['id'] ); } public function test_get_items_invalid_per_page() { @@ -1487,7 +1487,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertEquals( $post2, $data[0]['id'] ); + $this->assertSame( $post2, $data[0]['id'] ); } public function test_get_items_all_post_formats() { @@ -1497,7 +1497,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $formats = array_values( get_post_format_slugs() ); - $this->assertEquals( $formats, $data['schema']['properties']['format']['enum'] ); + $this->assertSame( $formats, $data['schema']['properties']['format']['enum'] ); } public function test_get_item() { @@ -1513,23 +1513,23 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $links = $response->get_links(); - $this->assertEquals( rest_url( '/wp/v2/posts/' . self::$post_id ), $links['self'][0]['href'] ); - $this->assertEquals( rest_url( '/wp/v2/posts' ), $links['collection'][0]['href'] ); + $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id ), $links['self'][0]['href'] ); + $this->assertSame( rest_url( '/wp/v2/posts' ), $links['collection'][0]['href'] ); $this->assertArrayNotHasKey( 'embeddable', $links['self'][0]['attributes'] ); - $this->assertEquals( rest_url( '/wp/v2/types/' . get_post_type( self::$post_id ) ), $links['about'][0]['href'] ); + $this->assertSame( rest_url( '/wp/v2/types/' . get_post_type( self::$post_id ) ), $links['about'][0]['href'] ); $replies_url = rest_url( '/wp/v2/comments' ); $replies_url = add_query_arg( 'post', self::$post_id, $replies_url ); - $this->assertEquals( $replies_url, $links['replies'][0]['href'] ); + $this->assertSame( $replies_url, $links['replies'][0]['href'] ); - $this->assertEquals( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] ); - $this->assertEquals( 0, $links['version-history'][0]['attributes']['count'] ); + $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] ); + $this->assertSame( 0, $links['version-history'][0]['attributes']['count'] ); $this->assertFalse( isset( $links['predecessor-version'] ) ); $attachments_url = rest_url( '/wp/v2/media' ); $attachments_url = add_query_arg( 'parent', self::$post_id, $attachments_url ); - $this->assertEquals( $attachments_url, $links['https://api.w.org/attachment'][0]['href'] ); + $this->assertSame( $attachments_url, $links['https://api.w.org/attachment'][0]['href'] ); $term_links = $links['https://api.w.org/term']; $tag_link = null; @@ -1549,10 +1549,10 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $this->assertNull( $format_link ); $tags_url = add_query_arg( 'post', self::$post_id, rest_url( '/wp/v2/tags' ) ); - $this->assertEquals( $tags_url, $tag_link['href'] ); + $this->assertSame( $tags_url, $tag_link['href'] ); $category_url = add_query_arg( 'post', self::$post_id, rest_url( '/wp/v2/categories' ) ); - $this->assertEquals( $category_url, $cat_link['href'] ); + $this->assertSame( $category_url, $cat_link['href'] ); } public function test_get_item_links_predecessor() { @@ -1570,11 +1570,11 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $links = $response->get_links(); - $this->assertEquals( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] ); - $this->assertEquals( 1, $links['version-history'][0]['attributes']['count'] ); + $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] ); + $this->assertSame( 1, $links['version-history'][0]['attributes']['count'] ); - $this->assertEquals( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions/' . $revision_1->ID ), $links['predecessor-version'][0]['href'] ); - $this->assertEquals( $revision_1->ID, $links['predecessor-version'][0]['attributes']['id'] ); + $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions/' . $revision_1->ID ), $links['predecessor-version'][0]['href'] ); + $this->assertSame( $revision_1->ID, $links['predecessor-version'][0]['attributes']['id'] ); } public function test_get_item_links_no_author() { @@ -1591,7 +1591,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); $links = $response->get_links(); - $this->assertEquals( rest_url( '/wp/v2/users/' . self::$author_id ), $links['author'][0]['href'] ); + $this->assertSame( rest_url( '/wp/v2/users/' . self::$author_id ), $links['author'][0]['href'] ); } public function test_get_post_draft_status_not_authenicated() { @@ -1672,9 +1672,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $this->check_get_post_response( $response, 'view' ); $data = $response->get_data(); - $this->assertEquals( '', $data['content']['rendered'] ); + $this->assertSame( '', $data['content']['rendered'] ); $this->assertTrue( $data['content']['protected'] ); - $this->assertEquals( '', $data['excerpt']['rendered'] ); + $this->assertSame( '', $data['excerpt']['rendered'] ); $this->assertTrue( $data['excerpt']['protected'] ); } @@ -1696,9 +1696,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $this->check_get_post_response( $response, 'view' ); $data = $response->get_data(); - $this->assertEquals( wpautop( $post->post_content ), $data['content']['rendered'] ); + $this->assertSame( wpautop( $post->post_content ), $data['content']['rendered'] ); $this->assertTrue( $data['content']['protected'] ); - $this->assertEquals( wpautop( $post->post_excerpt ), $data['excerpt']['rendered'] ); + $this->assertSame( wpautop( $post->post_excerpt ), $data['excerpt']['rendered'] ); $this->assertTrue( $data['excerpt']['protected'] ); } @@ -1731,9 +1731,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->check_get_post_response( $response, 'view' ); - $this->assertEquals( '', $data['content']['rendered'] ); + $this->assertSame( '', $data['content']['rendered'] ); $this->assertTrue( $data['content']['protected'] ); - $this->assertEquals( '', $data['excerpt']['rendered'] ); + $this->assertSame( '', $data['excerpt']['rendered'] ); $this->assertTrue( $data['excerpt']['protected'] ); } @@ -1811,7 +1811,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); // Private status. wp_update_post( @@ -1823,7 +1823,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 401, $response->get_status() ); + $this->assertSame( 401, $response->get_status() ); } public function test_prepare_item() { @@ -1845,7 +1845,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( '_fields', 'id,slug' ); $obj = get_post( self::$post_id ); $response = $endpoint->prepare_item_for_response( $obj, $request ); - $this->assertEquals( + $this->assertSame( array( 'id', 'slug', @@ -1878,7 +1878,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te remove_filter( 'the_content', $filter_content ); - $this->assertEquals( + $this->assertSame( array( 'id' => self::$post_id, 'content' => array( @@ -1914,7 +1914,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te remove_filter( 'the_content', $filter_content ); - $this->assertEquals( + $this->assertSame( array( 'id' => $post->ID, 'content' => array( @@ -2029,17 +2029,17 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te update_option( 'timezone_string', '' ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); $post = get_post( $data['id'] ); - $this->assertEquals( $results['date'], $data['date'] ); + $this->assertSame( $results['date'], $data['date'] ); $post_date = str_replace( 'T', ' ', $results['date'] ); - $this->assertEquals( $post_date, $post->post_date ); + $this->assertSame( $post_date, $post->post_date ); - $this->assertEquals( $results['date_gmt'], $data['date_gmt'] ); + $this->assertSame( $results['date_gmt'], $data['date_gmt'] ); $post_date_gmt = str_replace( 'T', ' ', $results['date_gmt'] ); - $this->assertEquals( $post_date_gmt, $post->post_date_gmt ); + $this->assertSame( $post_date_gmt, $post->post_date_gmt ); } /** @@ -2070,8 +2070,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te remove_filter( 'theme_post_templates', array( $this, 'filter_theme_post_templates' ) ); - $this->assertEquals( 'post-my-test-template.php', $data['template'] ); - $this->assertEquals( 'post-my-test-template.php', $post_template ); + $this->assertSame( 'post-my-test-template.php', $data['template'] ); + $this->assertSame( 'post-my-test-template.php', $post_template ); } /** @@ -2113,8 +2113,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $post_template = get_page_template_slug( get_post( $data['id'] ) ); - $this->assertEquals( '', $data['template'] ); - $this->assertEquals( '', $post_template ); + $this->assertSame( '', $data['template'] ); + $this->assertSame( '', $post_template ); } public function test_rest_create_item() { @@ -2160,11 +2160,11 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); $post = get_post( $data['id'] ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); $this->assertNotEquals( '0000-00-00T00:00:00', $data['date_gmt'] ); $this->check_create_post_response( $response ); @@ -2185,9 +2185,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( true, $new_data['sticky'] ); + $this->assertTrue( $new_data['sticky'] ); $post = get_post( $new_data['id'] ); - $this->assertEquals( true, is_sticky( $post->ID ) ); + $this->assertTrue( is_sticky( $post->ID ) ); } public function test_create_post_sticky_as_contributor() { @@ -2250,14 +2250,14 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $new_post = get_post( $data['id'] ); - $this->assertEquals( 'draft', $data['status'] ); - $this->assertEquals( 'draft', $new_post->post_status ); + $this->assertSame( 'draft', $data['status'] ); + $this->assertSame( 'draft', $new_post->post_status ); // Confirm dates are shimmed for gmt_offset. $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_modified ) + ( get_option( 'gmt_offset' ) * 3600 ) ); $post_date_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $new_post->post_date ) + ( get_option( 'gmt_offset' ) * 3600 ) ); - $this->assertEquals( mysql_to_rfc3339( $post_modified_gmt ), $data['modified_gmt'] ); - $this->assertEquals( mysql_to_rfc3339( $post_date_gmt ), $data['date_gmt'] ); + $this->assertSame( mysql_to_rfc3339( $post_modified_gmt ), $data['modified_gmt'] ); + $this->assertSame( mysql_to_rfc3339( $post_date_gmt ), $data['date_gmt'] ); } public function test_create_post_private() { @@ -2274,8 +2274,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $new_post = get_post( $data['id'] ); - $this->assertEquals( 'private', $data['status'] ); - $this->assertEquals( 'private', $new_post->post_status ); + $this->assertSame( 'private', $data['status'] ); + $this->assertSame( 'private', $new_post->post_status ); } public function test_create_post_private_without_permission() { @@ -2350,8 +2350,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $new_post = get_post( $data['id'] ); - $this->assertEquals( 'gallery', $data['format'] ); - $this->assertEquals( 'gallery', get_post_format( $new_post->ID ) ); + $this->assertSame( 'gallery', $data['format'] ); + $this->assertSame( 'gallery', get_post_format( $new_post->ID ) ); } public function test_create_post_with_standard_format() { @@ -2368,7 +2368,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $new_post = get_post( $data['id'] ); - $this->assertEquals( 'standard', $data['format'] ); + $this->assertSame( 'standard', $data['format'] ); $this->assertFalse( get_post_format( $new_post->ID ) ); } @@ -2403,10 +2403,10 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'link', $data['format'] ); + $this->assertSame( 'link', $data['format'] ); } public function test_create_update_post_with_featured_media() { @@ -2433,8 +2433,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $new_post = get_post( $data['id'] ); - $this->assertEquals( $this->attachment_id, $data['featured_media'] ); - $this->assertEquals( $this->attachment_id, (int) get_post_thumbnail_id( $new_post->ID ) ); + $this->assertSame( $this->attachment_id, $data['featured_media'] ); + $this->assertSame( $this->attachment_id, (int) get_post_thumbnail_id( $new_post->ID ) ); $request = new WP_REST_Request( 'POST', '/wp/v2/posts/' . $new_post->ID ); $params = $this->set_post_data( @@ -2445,8 +2445,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 0, $data['featured_media'] ); - $this->assertEquals( 0, (int) get_post_thumbnail_id( $new_post->ID ) ); + $this->assertSame( 0, $data['featured_media'] ); + $this->assertSame( 0, (int) get_post_thumbnail_id( $new_post->ID ) ); } public function test_create_post_invalid_author() { @@ -2492,7 +2492,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'testing', $data['password'] ); + $this->assertSame( 'testing', $data['password'] ); } public function test_create_post_with_falsey_password() { @@ -2508,7 +2508,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( '0', $data['password'] ); + $this->assertSame( '0', $data['password'] ); } public function test_create_post_with_empty_string_password_and_sticky() { @@ -2524,9 +2524,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( '', $data['password'] ); + $this->assertSame( '', $data['password'] ); } public function test_create_post_with_password_and_sticky_fails() { @@ -2560,8 +2560,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $new_post = get_post( $data['id'] ); $time = gmmktime( 2, 0, 0, 1, 1, 2010 ); - $this->assertEquals( '2010-01-01T02:00:00', $data['date'] ); - $this->assertEquals( $time, strtotime( $new_post->post_date ) ); + $this->assertSame( '2010-01-01T02:00:00', $data['date'] ); + $this->assertSame( $time, strtotime( $new_post->post_date ) ); } public function test_create_post_custom_date_with_timezone() { @@ -2580,11 +2580,11 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $new_post = get_post( $data['id'] ); $time = gmmktime( 12, 0, 0, 1, 1, 2010 ); - $this->assertEquals( '2010-01-01T12:00:00', $data['date'] ); - $this->assertEquals( '2010-01-01T12:00:00', $data['modified'] ); + $this->assertSame( '2010-01-01T12:00:00', $data['date'] ); + $this->assertSame( '2010-01-01T12:00:00', $data['modified'] ); - $this->assertEquals( $time, strtotime( $new_post->post_date ) ); - $this->assertEquals( $time, strtotime( $new_post->post_modified ) ); + $this->assertSame( $time, strtotime( $new_post->post_date ) ); + $this->assertSame( $time, strtotime( $new_post->post_modified ) ); } public function test_create_post_with_db_error() { @@ -2652,7 +2652,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( "Rob O'Rourke's Diary", $data['title']['raw'] ); + $this->assertSame( "Rob O'Rourke's Diary", $data['title']['raw'] ); } public function test_create_post_with_categories() { @@ -2673,7 +2673,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array( $category['term_id'] ), $data['categories'] ); + $this->assertSame( array( $category['term_id'] ), $data['categories'] ); } public function test_create_post_with_categories_as_csv() { @@ -2692,7 +2692,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array( $category['term_id'], $category2['term_id'] ), $data['categories'] ); + $this->assertSame( array( $category['term_id'], $category2['term_id'] ), $data['categories'] ); } public function test_create_post_with_invalid_categories() { @@ -2711,7 +2711,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array(), $data['categories'] ); + $this->assertSame( array(), $data['categories'] ); } /** @@ -2757,14 +2757,14 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $this->check_update_post_response( $response ); $new_data = $response->get_data(); - $this->assertEquals( self::$post_id, $new_data['id'] ); - $this->assertEquals( $params['title'], $new_data['title']['raw'] ); - $this->assertEquals( $params['content'], $new_data['content']['raw'] ); - $this->assertEquals( $params['excerpt'], $new_data['excerpt']['raw'] ); + $this->assertSame( self::$post_id, $new_data['id'] ); + $this->assertSame( $params['title'], $new_data['title']['raw'] ); + $this->assertSame( $params['content'], $new_data['content']['raw'] ); + $this->assertSame( $params['excerpt'], $new_data['excerpt']['raw'] ); $post = get_post( self::$post_id ); - $this->assertEquals( $params['title'], $post->post_title ); - $this->assertEquals( $params['content'], $post->post_content ); - $this->assertEquals( $params['excerpt'], $post->post_excerpt ); + $this->assertSame( $params['title'], $post->post_title ); + $this->assertSame( $params['content'], $post->post_content ); + $this->assertSame( $params['excerpt'], $post->post_excerpt ); } public function test_update_item_no_change() { @@ -2795,14 +2795,14 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $this->check_update_post_response( $response ); $new_data = $response->get_data(); - $this->assertEquals( self::$post_id, $new_data['id'] ); - $this->assertEquals( $params['title'], $new_data['title']['raw'] ); - $this->assertEquals( $params['content'], $new_data['content']['raw'] ); - $this->assertEquals( $params['excerpt'], $new_data['excerpt']['raw'] ); + $this->assertSame( self::$post_id, $new_data['id'] ); + $this->assertSame( $params['title'], $new_data['title']['raw'] ); + $this->assertSame( $params['content'], $new_data['content']['raw'] ); + $this->assertSame( $params['excerpt'], $new_data['excerpt']['raw'] ); $post = get_post( self::$post_id ); - $this->assertEquals( $params['title'], $post->post_title ); - $this->assertEquals( $params['content'], $post->post_content ); - $this->assertEquals( $params['excerpt'], $post->post_excerpt ); + $this->assertSame( $params['title'], $post->post_title ); + $this->assertSame( $params['content'], $post->post_content ); + $this->assertSame( $params['excerpt'], $post->post_excerpt ); } /** @@ -2837,8 +2837,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $new_data = $response->get_data(); // Verify the post is set to the future date. - $this->assertEquals( $new_data['date_gmt'], $future_date ); - $this->assertEquals( $new_data['date'], $future_date ); + $this->assertSame( $new_data['date_gmt'], $future_date ); + $this->assertSame( $new_data['date'], $future_date ); $this->assertNotEquals( $new_data['date_gmt'], $new_data['modified_gmt'] ); $this->assertNotEquals( $new_data['date'], $new_data['modified'] ); @@ -2858,11 +2858,11 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te // Verify the date field values are reset in the API response. $this->check_update_post_response( $response ); $new_data = $response->get_data(); - $this->assertEquals( $new_data['date_gmt'], $new_data['date'] ); + $this->assertSame( $new_data['date_gmt'], $new_data['date'] ); $this->assertNotEquals( $new_data['date_gmt'], $future_date ); $post = get_post( $post_id, 'ARRAY_A' ); - $this->assertEquals( $post['post_date_gmt'], '0000-00-00 00:00:00' ); + $this->assertSame( $post['post_date_gmt'], '0000-00-00 00:00:00' ); $this->assertNotEquals( $new_data['date_gmt'], $future_date ); $this->assertNotEquals( $new_data['date'], $future_date ); } @@ -2878,14 +2878,14 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $this->check_update_post_response( $response ); $new_data = $response->get_data(); - $this->assertEquals( self::$post_id, $new_data['id'] ); - $this->assertEquals( $params['title']['raw'], $new_data['title']['raw'] ); - $this->assertEquals( $params['content']['raw'], $new_data['content']['raw'] ); - $this->assertEquals( $params['excerpt']['raw'], $new_data['excerpt']['raw'] ); + $this->assertSame( self::$post_id, $new_data['id'] ); + $this->assertSame( $params['title']['raw'], $new_data['title']['raw'] ); + $this->assertSame( $params['content']['raw'], $new_data['content']['raw'] ); + $this->assertSame( $params['excerpt']['raw'], $new_data['excerpt']['raw'] ); $post = get_post( self::$post_id ); - $this->assertEquals( $params['title']['raw'], $post->post_title ); - $this->assertEquals( $params['content']['raw'], $post->post_content ); - $this->assertEquals( $params['excerpt']['raw'], $post->post_excerpt ); + $this->assertSame( $params['title']['raw'], $post->post_title ); + $this->assertSame( $params['content']['raw'], $post->post_content ); + $this->assertSame( $params['excerpt']['raw'], $post->post_excerpt ); } public function test_update_post_without_extra_params() { @@ -2968,8 +2968,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $new_post = get_post( $data['id'] ); - $this->assertEquals( 'gallery', $data['format'] ); - $this->assertEquals( 'gallery', get_post_format( $new_post->ID ) ); + $this->assertSame( 'gallery', $data['format'] ); + $this->assertSame( 'gallery', get_post_format( $new_post->ID ) ); } public function test_update_post_with_standard_format() { @@ -2986,7 +2986,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $new_post = get_post( $data['id'] ); - $this->assertEquals( 'standard', $data['format'] ); + $this->assertSame( 'standard', $data['format'] ); $this->assertFalse( get_post_format( $new_post->ID ) ); } @@ -3021,10 +3021,10 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te ); $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'link', $data['format'] ); + $this->assertSame( 'link', $data['format'] ); } public function test_update_post_ignore_readonly() { @@ -3047,12 +3047,12 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $new_post = get_post( $data['id'] ); - $this->assertEquals( $new_content, $data['content']['raw'] ); - $this->assertEquals( $new_content, $new_post->post_content ); + $this->assertSame( $new_content, $data['content']['raw'] ); + $this->assertSame( $new_content, $new_post->post_content ); // The modified date should equal the current time. - $this->assertEquals( gmdate( 'Y-m-d', strtotime( mysql_to_rfc3339( $expected_modified ) ) ), gmdate( 'Y-m-d', strtotime( $data['modified'] ) ) ); - $this->assertEquals( gmdate( 'Y-m-d', strtotime( $expected_modified ) ), gmdate( 'Y-m-d', strtotime( $new_post->post_modified ) ) ); + $this->assertSame( gmdate( 'Y-m-d', strtotime( mysql_to_rfc3339( $expected_modified ) ) ), gmdate( 'Y-m-d', strtotime( $data['modified'] ) ) ); + $this->assertSame( gmdate( 'Y-m-d', strtotime( $expected_modified ) ), gmdate( 'Y-m-d', strtotime( $new_post->post_modified ) ) ); } /** @@ -3076,17 +3076,17 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te update_option( 'timezone_string', '' ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $post = get_post( $data['id'] ); - $this->assertEquals( $results['date'], $data['date'] ); + $this->assertSame( $results['date'], $data['date'] ); $post_date = str_replace( 'T', ' ', $results['date'] ); - $this->assertEquals( $post_date, $post->post_date ); + $this->assertSame( $post_date, $post->post_date ); - $this->assertEquals( $results['date_gmt'], $data['date_gmt'] ); + $this->assertSame( $results['date_gmt'], $data['date_gmt'] ); $post_date_gmt = str_replace( 'T', ' ', $results['date_gmt'] ); - $this->assertEquals( $post_date_gmt, $post->post_date_gmt ); + $this->assertSame( $post_date_gmt, $post->post_date_gmt ); } public function test_update_post_with_invalid_date() { @@ -3144,29 +3144,29 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te wp_cache_delete( $post_id, 'posts' ); $post = get_post( $post_id ); - $this->assertEquals( $post->post_date, '2016-02-23 12:00:00' ); - $this->assertEquals( $post->post_date_gmt, '0000-00-00 00:00:00' ); + $this->assertSame( $post->post_date, '2016-02-23 12:00:00' ); + $this->assertSame( $post->post_date_gmt, '0000-00-00 00:00:00' ); $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( '2016-02-23T12:00:00', $data['date'] ); - $this->assertEquals( '2016-02-23T18:00:00', $data['date_gmt'] ); + $this->assertSame( '2016-02-23T12:00:00', $data['date'] ); + $this->assertSame( '2016-02-23T18:00:00', $data['date_gmt'] ); $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $post_id ) ); $request->set_param( 'date', '2016-02-23T13:00:00' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( '2016-02-23T13:00:00', $data['date'] ); - $this->assertEquals( '2016-02-23T19:00:00', $data['date_gmt'] ); + $this->assertSame( '2016-02-23T13:00:00', $data['date'] ); + $this->assertSame( '2016-02-23T19:00:00', $data['date_gmt'] ); $post = get_post( $post_id ); - $this->assertEquals( $post->post_date, '2016-02-23 13:00:00' ); - $this->assertEquals( $post->post_date_gmt, '2016-02-23 19:00:00' ); + $this->assertSame( $post->post_date, '2016-02-23 13:00:00' ); + $this->assertSame( $post->post_date_gmt, '2016-02-23 19:00:00' ); update_option( 'timezone_string', '' ); } @@ -3184,9 +3184,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( 'sample-slug', $new_data['slug'] ); + $this->assertSame( 'sample-slug', $new_data['slug'] ); $post = get_post( $new_data['id'] ); - $this->assertEquals( 'sample-slug', $post->post_name ); + $this->assertSame( 'sample-slug', $post->post_name ); } public function test_update_post_slug_accented_chars() { @@ -3202,9 +3202,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( 'test-accented-charaecters', $new_data['slug'] ); + $this->assertSame( 'test-accented-charaecters', $new_data['slug'] ); $post = get_post( $new_data['id'] ); - $this->assertEquals( 'test-accented-charaecters', $post->post_name ); + $this->assertSame( 'test-accented-charaecters', $post->post_name ); } public function test_update_post_sticky() { @@ -3220,9 +3220,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( true, $new_data['sticky'] ); + $this->assertTrue( $new_data['sticky'] ); $post = get_post( $new_data['id'] ); - $this->assertEquals( true, is_sticky( $post->ID ) ); + $this->assertTrue( is_sticky( $post->ID ) ); // Updating another field shouldn't change sticky status. $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); @@ -3235,9 +3235,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( true, $new_data['sticky'] ); + $this->assertTrue( $new_data['sticky'] ); $post = get_post( $new_data['id'] ); - $this->assertEquals( true, is_sticky( $post->ID ) ); + $this->assertTrue( is_sticky( $post->ID ) ); } public function test_update_post_excerpt() { @@ -3252,7 +3252,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( 'An Excerpt', $new_data['excerpt']['raw'] ); + $this->assertSame( 'An Excerpt', $new_data['excerpt']['raw'] ); } public function test_update_post_empty_excerpt() { @@ -3267,7 +3267,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( '', $new_data['excerpt']['raw'] ); + $this->assertSame( '', $new_data['excerpt']['raw'] ); } public function test_update_post_content() { @@ -3282,7 +3282,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( 'Some Content', $new_data['content']['raw'] ); + $this->assertSame( 'Some Content', $new_data['content']['raw'] ); } public function test_update_post_empty_content() { @@ -3297,7 +3297,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( '', $new_data['content']['raw'] ); + $this->assertSame( '', $new_data['content']['raw'] ); } public function test_update_post_with_empty_password() { @@ -3319,7 +3319,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( '', $data['password'] ); + $this->assertSame( '', $data['password'] ); } public function test_update_post_with_password_and_sticky_fails() { @@ -3389,7 +3389,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( "Rob O'Rourke's Diary", $new_data['title']['raw'] ); + $this->assertSame( "Rob O'Rourke's Diary", $new_data['title']['raw'] ); } public function test_update_post_with_categories() { @@ -3409,7 +3409,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( array( $category['term_id'] ), $new_data['categories'] ); + $this->assertSame( array( $category['term_id'] ), $new_data['categories'] ); $categories_path = ''; $links = $response->get_links(); foreach ( $links['https://api.w.org/term'] as $link ) { @@ -3426,7 +3426,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertEquals( 'Test Category', $data[0]['name'] ); + $this->assertSame( 'Test Category', $data[0]['name'] ); } public function test_update_post_with_empty_categories() { @@ -3445,7 +3445,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( array(), $new_data['categories'] ); + $this->assertSame( array(), $new_data['categories'] ); } /** @@ -3499,8 +3499,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $post_template = get_page_template_slug( get_post( $data['id'] ) ); - $this->assertEquals( 'post-my-test-template.php', $data['template'] ); - $this->assertEquals( 'post-my-test-template.php', $post_template ); + $this->assertSame( 'post-my-test-template.php', $data['template'] ); + $this->assertSame( 'post-my-test-template.php', $post_template ); } /** @@ -3530,8 +3530,8 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $post_template = get_page_template_slug( get_post( $data['id'] ) ); - $this->assertEquals( '', $data['template'] ); - $this->assertEquals( '', $post_template ); + $this->assertSame( '', $data['template'] ); + $this->assertSame( '', $post_template ); } /** @@ -3554,13 +3554,13 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_body_params( $params ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $post_template = get_page_template_slug( get_post( $data['id'] ) ); - $this->assertEquals( 'post-my-invalid-template.php', $post_template ); - $this->assertEquals( 'post-my-invalid-template.php', $data['template'] ); + $this->assertSame( 'post-my-invalid-template.php', $post_template ); + $this->assertSame( 'post-my-invalid-template.php', $data['template'] ); } public function verify_post_roundtrip( $input = array(), $expected_output = array() ) { @@ -3570,22 +3570,22 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( $name, $value ); } $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $actual_output = $response->get_data(); // Compare expected API output to actual API output. - $this->assertEquals( $expected_output['title']['raw'], $actual_output['title']['raw'] ); - $this->assertEquals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); - $this->assertEquals( $expected_output['content']['raw'], $actual_output['content']['raw'] ); - $this->assertEquals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); - $this->assertEquals( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] ); - $this->assertEquals( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) ); + $this->assertSame( $expected_output['title']['raw'], $actual_output['title']['raw'] ); + $this->assertSame( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); + $this->assertSame( $expected_output['content']['raw'], $actual_output['content']['raw'] ); + $this->assertSame( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); + $this->assertSame( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] ); + $this->assertSame( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) ); // Compare expected API output to WP internal values. $post = get_post( $actual_output['id'] ); - $this->assertEquals( $expected_output['title']['raw'], $post->post_title ); - $this->assertEquals( $expected_output['content']['raw'], $post->post_content ); - $this->assertEquals( $expected_output['excerpt']['raw'], $post->post_excerpt ); + $this->assertSame( $expected_output['title']['raw'], $post->post_title ); + $this->assertSame( $expected_output['content']['raw'], $post->post_content ); + $this->assertSame( $expected_output['excerpt']['raw'], $post->post_excerpt ); // Update the post. $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', $actual_output['id'] ) ); @@ -3593,22 +3593,22 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( $name, $value ); } $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $actual_output = $response->get_data(); // Compare expected API output to actual API output. - $this->assertEquals( $expected_output['title']['raw'], $actual_output['title']['raw'] ); - $this->assertEquals( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); - $this->assertEquals( $expected_output['content']['raw'], $actual_output['content']['raw'] ); - $this->assertEquals( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); - $this->assertEquals( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] ); - $this->assertEquals( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) ); + $this->assertSame( $expected_output['title']['raw'], $actual_output['title']['raw'] ); + $this->assertSame( $expected_output['title']['rendered'], trim( $actual_output['title']['rendered'] ) ); + $this->assertSame( $expected_output['content']['raw'], $actual_output['content']['raw'] ); + $this->assertSame( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); + $this->assertSame( $expected_output['excerpt']['raw'], $actual_output['excerpt']['raw'] ); + $this->assertSame( $expected_output['excerpt']['rendered'], trim( $actual_output['excerpt']['rendered'] ) ); // Compare expected API output to WP internal values. $post = get_post( $actual_output['id'] ); - $this->assertEquals( $expected_output['title']['raw'], $post->post_title ); - $this->assertEquals( $expected_output['content']['raw'], $post->post_content ); - $this->assertEquals( $expected_output['excerpt']['raw'], $post->post_excerpt ); + $this->assertSame( $expected_output['title']['raw'], $post->post_title ); + $this->assertSame( $expected_output['content']['raw'], $post->post_content ); + $this->assertSame( $expected_output['excerpt']['raw'], $post->post_excerpt ); } public static function post_roundtrip_provider() { @@ -3806,10 +3806,10 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'force', 'false' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'Deleted post', $data['title']['raw'] ); - $this->assertEquals( 'trash', $data['status'] ); + $this->assertSame( 'Deleted post', $data['title']['raw'] ); + $this->assertSame( 'trash', $data['status'] ); } public function test_delete_item_skip_trash() { @@ -3821,7 +3821,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request['force'] = true; $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertTrue( $data['deleted'] ); $this->assertNotEmpty( $data['previous'] ); @@ -3834,7 +3834,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/posts/%d', $post_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $response = rest_get_server()->dispatch( $request ); $this->assertErrorResponse( 'rest_already_trashed', $response, 410 ); } @@ -3889,7 +3889,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 26, count( $properties ) ); + $this->assertSame( 26, count( $properties ) ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'comment_status', $properties ); $this->assertArrayHasKey( 'content', $properties ); @@ -3968,7 +3968,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 'type', ); - $this->assertEquals( $expected_keys, $keys ); + $this->assertSame( $expected_keys, $keys ); } public function test_get_post_edit_context_properties() { @@ -4009,7 +4009,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 'type', ); - $this->assertEquals( $expected_keys, $keys ); + $this->assertSame( $expected_keys, $keys ); } public function test_get_post_embed_context_properties() { @@ -4031,7 +4031,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 'type', ); - $this->assertEquals( $expected_keys, $keys ); + $this->assertSame( $expected_keys, $keys ); } public function test_status_array_enum_args() { @@ -4040,10 +4040,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $list_posts_args = $data['routes']['/wp/v2/posts']['endpoints'][0]['args']; $status_arg = $list_posts_args['status']; - $this->assertEquals( 'array', $status_arg['type'] ); - $this->assertEquals( + $this->assertSame( 'array', $status_arg['type'] ); + $this->assertSame( array( - 'type' => 'string', 'enum' => array( 'publish', 'future', @@ -4059,6 +4058,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 'request-completed', 'any', ), + 'type' => 'string', ), $status_arg['items'] ); @@ -4088,7 +4088,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); - $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] ); + $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); wp_set_current_user( 1 ); @@ -4571,7 +4571,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'context', 'edit' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertArrayNotHasKey( 'permalink_template', $data ); $this->assertArrayNotHasKey( 'generated_slug', $data ); } @@ -4595,16 +4595,16 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'context', 'edit' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( $expected_permalink_template, $data['permalink_template'] ); - $this->assertEquals( 'permalink-template', $data['generated_slug'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( $expected_permalink_template, $data['permalink_template'] ); + $this->assertSame( 'permalink-template', $data['generated_slug'] ); // Neither 'permalink_template' and 'generated_slug' are expected for context=view. $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $post_id ); $request->set_param( 'context', 'view' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertArrayNotHasKey( 'permalink_template', $data ); $this->assertArrayNotHasKey( 'generated_slug', $data ); @@ -4625,7 +4625,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te ) ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); $get = new WP_REST_Request( 'GET', "/wp/v2/posts/{$post->ID}" ); $get->set_query_params( array( 'context' => 'edit' ) ); @@ -4642,7 +4642,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $this->assertEquals( strtotime( $get_body['date'] ), strtotime( $body['date'] ), 'The dates should be equal', 2 ); $this->assertEquals( strtotime( $get_body['date_gmt'] ), strtotime( $body['date_gmt'] ), 'The dates should be equal', 2 ); - $this->assertEquals( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', get_post( $post->ID )->post_date_gmt ); } /** @@ -4661,7 +4661,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te ) ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); $get = new WP_REST_Request( 'GET', "/wp/v2/posts/{$post->ID}" ); $get->set_query_params( array( 'context' => 'edit' ) ); @@ -4702,7 +4702,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te ) ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); $get = new WP_REST_Request( 'GET', "/wp/v2/posts/{$post->ID}" ); $get->set_query_params( array( 'context' => 'edit' ) ); @@ -4859,7 +4859,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $properties = $data['schema']['properties']['content']['properties']; $this->assertArrayHasKey( 'new_prop', $properties ); - $this->assertEquals( array( 'new_context' ), $properties['new_prop']['context'] ); + $this->assertSame( array( 'new_context' ), $properties['new_prop']['context'] ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-request-validation.php b/tests/phpunit/tests/rest-api/rest-request-validation.php index 14ea7541f7..aab01f2902 100644 --- a/tests/phpunit/tests/rest-api/rest-request-validation.php +++ b/tests/phpunit/tests/rest-api/rest-request-validation.php @@ -26,13 +26,13 @@ class WP_Test_REST_Request_Validation extends WP_Test_REST_TestCase { ) ); $ret = rest_validate_request_arg( 1, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (inclusive) and 10 (inclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (inclusive) and 10 (inclusive)', $ret->get_error_message() ); $ret = rest_validate_request_arg( 2, $request, 'minmaxrange' ); $this->assertTrue( $ret ); $ret = rest_validate_request_arg( 10, $request, 'minmaxrange' ); $this->assertTrue( $ret ); $ret = rest_validate_request_arg( 11, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (inclusive) and 10 (inclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (inclusive) and 10 (inclusive)', $ret->get_error_message() ); } public function test_validate_within_min_max_range_min_exclusive() { @@ -51,9 +51,9 @@ class WP_Test_REST_Request_Validation extends WP_Test_REST_TestCase { ) ); $ret = rest_validate_request_arg( 1, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (exclusive) and 10 (inclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (exclusive) and 10 (inclusive)', $ret->get_error_message() ); $ret = rest_validate_request_arg( 2, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (exclusive) and 10 (inclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (exclusive) and 10 (inclusive)', $ret->get_error_message() ); $ret = rest_validate_request_arg( 3, $request, 'minmaxrange' ); $this->assertTrue( $ret ); $ret = rest_validate_request_arg( 9, $request, 'minmaxrange' ); @@ -61,7 +61,7 @@ class WP_Test_REST_Request_Validation extends WP_Test_REST_TestCase { $ret = rest_validate_request_arg( 10, $request, 'minmaxrange' ); $this->assertTrue( $ret ); $ret = rest_validate_request_arg( 11, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (exclusive) and 10 (inclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (exclusive) and 10 (inclusive)', $ret->get_error_message() ); } public function test_validate_within_min_max_range_max_exclusive() { @@ -80,7 +80,7 @@ class WP_Test_REST_Request_Validation extends WP_Test_REST_TestCase { ) ); $ret = rest_validate_request_arg( 1, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (inclusive) and 10 (exclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (inclusive) and 10 (exclusive)', $ret->get_error_message() ); $ret = rest_validate_request_arg( 2, $request, 'minmaxrange' ); $this->assertTrue( $ret ); $ret = rest_validate_request_arg( 3, $request, 'minmaxrange' ); @@ -88,9 +88,9 @@ class WP_Test_REST_Request_Validation extends WP_Test_REST_TestCase { $ret = rest_validate_request_arg( 9, $request, 'minmaxrange' ); $this->assertTrue( $ret ); $ret = rest_validate_request_arg( 10, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (inclusive) and 10 (exclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (inclusive) and 10 (exclusive)', $ret->get_error_message() ); $ret = rest_validate_request_arg( 11, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (inclusive) and 10 (exclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (inclusive) and 10 (exclusive)', $ret->get_error_message() ); } public function test_validate_within_min_max_range_both_exclusive() { @@ -110,17 +110,17 @@ class WP_Test_REST_Request_Validation extends WP_Test_REST_TestCase { ) ); $ret = rest_validate_request_arg( 1, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (exclusive) and 10 (exclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (exclusive) and 10 (exclusive)', $ret->get_error_message() ); $ret = rest_validate_request_arg( 2, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (exclusive) and 10 (exclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (exclusive) and 10 (exclusive)', $ret->get_error_message() ); $ret = rest_validate_request_arg( 3, $request, 'minmaxrange' ); $this->assertTrue( $ret ); $ret = rest_validate_request_arg( 9, $request, 'minmaxrange' ); $this->assertTrue( $ret ); $ret = rest_validate_request_arg( 10, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (exclusive) and 10 (exclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (exclusive) and 10 (exclusive)', $ret->get_error_message() ); $ret = rest_validate_request_arg( 11, $request, 'minmaxrange' ); - $this->assertEquals( 'minmaxrange must be between 2 (exclusive) and 10 (exclusive)', $ret->get_error_message() ); + $this->assertSame( 'minmaxrange must be between 2 (exclusive) and 10 (exclusive)', $ret->get_error_message() ); } public function test_validate_greater_than_min_inclusive() { @@ -137,7 +137,7 @@ class WP_Test_REST_Request_Validation extends WP_Test_REST_TestCase { ) ); $ret = rest_validate_request_arg( 1, $request, 'greaterthanmin' ); - $this->assertEquals( 'greaterthanmin must be greater than or equal to 2', $ret->get_error_message() ); + $this->assertSame( 'greaterthanmin must be greater than or equal to 2', $ret->get_error_message() ); $ret = rest_validate_request_arg( 2, $request, 'greaterthanmin' ); $this->assertTrue( $ret ); } @@ -157,9 +157,9 @@ class WP_Test_REST_Request_Validation extends WP_Test_REST_TestCase { ) ); $ret = rest_validate_request_arg( 1, $request, 'greaterthanmin' ); - $this->assertEquals( 'greaterthanmin must be greater than 2', $ret->get_error_message() ); + $this->assertSame( 'greaterthanmin must be greater than 2', $ret->get_error_message() ); $ret = rest_validate_request_arg( 2, $request, 'greaterthanmin' ); - $this->assertEquals( 'greaterthanmin must be greater than 2', $ret->get_error_message() ); + $this->assertSame( 'greaterthanmin must be greater than 2', $ret->get_error_message() ); $ret = rest_validate_request_arg( 3, $request, 'greaterthanmin' ); $this->assertTrue( $ret ); } @@ -178,7 +178,7 @@ class WP_Test_REST_Request_Validation extends WP_Test_REST_TestCase { ) ); $ret = rest_validate_request_arg( 11, $request, 'lessthanmax' ); - $this->assertEquals( 'lessthanmax must be less than or equal to 10', $ret->get_error_message() ); + $this->assertSame( 'lessthanmax must be less than or equal to 10', $ret->get_error_message() ); $ret = rest_validate_request_arg( 10, $request, 'lessthanmax' ); $this->assertTrue( $ret ); } @@ -198,9 +198,9 @@ class WP_Test_REST_Request_Validation extends WP_Test_REST_TestCase { ) ); $ret = rest_validate_request_arg( 11, $request, 'lessthanmax' ); - $this->assertEquals( 'lessthanmax must be less than 10', $ret->get_error_message() ); + $this->assertSame( 'lessthanmax must be less than 10', $ret->get_error_message() ); $ret = rest_validate_request_arg( 10, $request, 'lessthanmax' ); - $this->assertEquals( 'lessthanmax must be less than 10', $ret->get_error_message() ); + $this->assertSame( 'lessthanmax must be less than 10', $ret->get_error_message() ); $ret = rest_validate_request_arg( 9, $request, 'lessthanmax' ); $this->assertTrue( $ret ); } diff --git a/tests/phpunit/tests/rest-api/rest-request.php b/tests/phpunit/tests/rest-api/rest-request.php index 2a78db4660..bf3d65ea3c 100644 --- a/tests/phpunit/tests/rest-api/rest-request.php +++ b/tests/phpunit/tests/rest-api/rest-request.php @@ -23,7 +23,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->set_header( 'Content-Type', $value ); - $this->assertEquals( $value, $this->request->get_header( 'Content-Type' ) ); + $this->assertSame( $value, $this->request->get_header( 'Content-Type' ) ); } public function test_header_missing() { @@ -33,7 +33,7 @@ class Tests_REST_Request extends WP_UnitTestCase { public function test_remove_header() { $this->request->add_header( 'Test-Header', 'value' ); - $this->assertEquals( 'value', $this->request->get_header( 'Test-Header' ) ); + $this->assertSame( 'value', $this->request->get_header( 'Test-Header' ) ); $this->request->remove_header( 'Test-Header' ); $this->assertNull( $this->request->get_header( 'Test-Header' ) ); @@ -45,8 +45,8 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->add_header( 'Accept', $value1 ); $this->request->add_header( 'Accept', $value2 ); - $this->assertEquals( $value1 . ',' . $value2, $this->request->get_header( 'Accept' ) ); - $this->assertEquals( array( $value1, $value2 ), $this->request->get_header_as_array( 'Accept' ) ); + $this->assertSame( $value1 . ',' . $value2, $this->request->get_header( 'Accept' ) ); + $this->assertSame( array( $value1, $value2 ), $this->request->get_header_as_array( 'Accept' ) ); } public static function header_provider() { @@ -66,7 +66,7 @@ class Tests_REST_Request extends WP_UnitTestCase { * @param string $expected Expected canonicalized version. */ public function test_header_canonicalization( $original, $expected ) { - $this->assertEquals( $expected, $this->request->canonicalize_header_name( $original ) ); + $this->assertSame( $expected, $this->request->canonicalize_header_name( $original ) ); } public static function content_type_provider() { @@ -96,10 +96,10 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->set_header( 'Content-Type', $header ); $parsed = $this->request->get_content_type(); - $this->assertEquals( $value, $parsed['value'] ); - $this->assertEquals( $type, $parsed['type'] ); - $this->assertEquals( $subtype, $parsed['subtype'] ); - $this->assertEquals( $parameters, $parsed['parameters'] ); + $this->assertSame( $value, $parsed['value'] ); + $this->assertSame( $type, $parsed['type'] ); + $this->assertSame( $subtype, $parsed['subtype'] ); + $this->assertSame( $parameters, $parsed['parameters'] ); } protected function request_with_parameters() { @@ -144,7 +144,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->set_method( 'GET' ); // Check that query takes precedence. - $this->assertEquals( 'query', $this->request->get_param( 'source' ) ); + $this->assertSame( 'query', $this->request->get_param( 'source' ) ); // Check that the correct arguments are parsed (and that falling through // the stack works). @@ -165,7 +165,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->set_attributes( array( 'accept_json' => true ) ); // Check that POST takes precedence. - $this->assertEquals( 'body', $this->request->get_param( 'source' ) ); + $this->assertSame( 'body', $this->request->get_param( 'source' ) ); // Check that the correct arguments are parsed (and that falling through // the stack works). @@ -186,7 +186,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->set_attributes( array( 'accept_json' => true ) ); // Check that JSON takes precedence. - $this->assertEquals( 'json', $this->request->get_param( 'source' ) ); + $this->assertSame( 'json', $this->request->get_param( 'source' ) ); // Check that the correct arguments are parsed (and that falling through // the stack works). @@ -208,7 +208,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->set_body( '{ this is not json }' ); // Check that JSON is ignored. - $this->assertEquals( 'body', $this->request->get_param( 'source' ) ); + $this->assertSame( 'body', $this->request->get_param( 'source' ) ); // Check that the correct arguments are parsed (and that falling through // the stack works). @@ -252,7 +252,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->set_body_params( array() ); $this->request->set_body( http_build_query( $data ) ); foreach ( $data as $key => $expected_value ) { - $this->assertEquals( $expected_value, $this->request->get_param( $key ) ); + $this->assertSame( $expected_value, $this->request->get_param( $key ) ); } } @@ -274,7 +274,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->set_body( wp_json_encode( $data ) ); foreach ( $data as $key => $expected_value ) { - $this->assertEquals( $expected_value, $this->request->get_param( $key ) ); + $this->assertSame( $expected_value, $this->request->get_param( $key ) ); } } @@ -296,7 +296,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->set_body( wp_json_encode( $data ) ); foreach ( $data as $key => $expected_value ) { - $this->assertEquals( $expected_value, $this->request->get_param( $key ) ); + $this->assertSame( $expected_value, $this->request->get_param( $key ) ); } } @@ -307,12 +307,12 @@ class Tests_REST_Request extends WP_UnitTestCase { $expected = array( 'source' => 'body', + 'has_default_params' => true, 'has_url_params' => true, 'has_query_params' => true, 'has_body_params' => true, - 'has_default_params' => true, ); - $this->assertEquals( $expected, $this->request->get_params() ); + $this->assertSame( $expected, $this->request->get_params() ); } public function test_parameter_merging_with_numeric_keys() { @@ -326,7 +326,7 @@ class Tests_REST_Request extends WP_UnitTestCase { '1' => 'hello', '2' => 'goodbye', ); - $this->assertEquals( $expected, $this->request->get_params() ); + $this->assertSame( $expected, $this->request->get_params() ); } public function test_sanitize_params() { @@ -352,8 +352,8 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->request->sanitize_params(); - $this->assertEquals( 123, $this->request->get_param( 'someinteger' ) ); - $this->assertEquals( 0, $this->request->get_param( 'somestring' ) ); + $this->assertSame( 123, $this->request->get_param( 'someinteger' ) ); + $this->assertSame( 0, $this->request->get_param( 'somestring' ) ); } public function test_sanitize_params_error() { @@ -378,7 +378,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $valid = $this->request->sanitize_params(); $this->assertWPError( $valid ); - $this->assertEquals( 'rest_invalid_param', $valid->get_error_code() ); + $this->assertSame( 'rest_invalid_param', $valid->get_error_code() ); } public function test_sanitize_params_with_null_callback() { @@ -439,7 +439,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $valid = $this->request->has_valid_params(); $this->assertWPError( $valid ); - $this->assertEquals( 'rest_missing_callback_param', $valid->get_error_code() ); + $this->assertSame( 'rest_missing_callback_param', $valid->get_error_code() ); } public function test_has_valid_params_required_flag_multiple() { @@ -459,7 +459,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $valid = $this->request->has_valid_params(); $this->assertWPError( $valid ); - $this->assertEquals( 'rest_missing_callback_param', $valid->get_error_code() ); + $this->assertSame( 'rest_missing_callback_param', $valid->get_error_code() ); $data = $valid->get_error_data( 'rest_missing_callback_param' ); @@ -487,7 +487,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $valid = $this->request->has_valid_params(); $this->assertWPError( $valid ); - $this->assertEquals( 'rest_invalid_param', $valid->get_error_code() ); + $this->assertSame( 'rest_invalid_param', $valid->get_error_code() ); } public function test_has_valid_params_json_error() { @@ -496,9 +496,9 @@ class Tests_REST_Request extends WP_UnitTestCase { $valid = $this->request->has_valid_params(); $this->assertWPError( $valid ); - $this->assertEquals( 'rest_invalid_json', $valid->get_error_code() ); + $this->assertSame( 'rest_invalid_json', $valid->get_error_code() ); $data = $valid->get_error_data(); - $this->assertEquals( JSON_ERROR_SYNTAX, $data['json_error_code'] ); + $this->assertSame( JSON_ERROR_SYNTAX, $data['json_error_code'] ); } @@ -534,7 +534,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $valid = $this->request->has_valid_params(); $this->assertWPError( $valid ); - $this->assertEquals( 'rest_invalid_param', $valid->get_error_code() ); + $this->assertSame( 'rest_invalid_param', $valid->get_error_code() ); $data = $valid->get_error_data( 'rest_invalid_param' ); @@ -567,8 +567,8 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->assertWPError( $valid ); $error_data = $valid->get_error_data(); - $this->assertEquals( array( 'someinteger', 'someotherparams' ), array_keys( $error_data['params'] ) ); - $this->assertEquals( 'This is not valid!', $error_data['params']['someotherparams'] ); + $this->assertSame( array( 'someinteger', 'someotherparams' ), array_keys( $error_data['params'] ) ); + $this->assertSame( 'This is not valid!', $error_data['params']['someotherparams'] ); } public function _return_wp_error_on_validate_callback() { @@ -594,10 +594,10 @@ class Tests_REST_Request extends WP_UnitTestCase { public function test_from_url( $permalink_structure, $original_url ) { update_option( 'permalink_structure', $permalink_structure ); $url = add_query_arg( 'foo', 'bar', rest_url( '/wp/v2/posts/1' ) ); - $this->assertEquals( $original_url, $url ); + $this->assertSame( $original_url, $url ); $request = WP_REST_Request::from_url( $url ); $this->assertInstanceOf( 'WP_REST_Request', $request ); - $this->assertEquals( '/wp/v2/posts/1', $request->get_route() ); + $this->assertSame( '/wp/v2/posts/1', $request->get_route() ); $this->assertEqualSets( array( 'foo' => 'bar', @@ -623,7 +623,7 @@ class Tests_REST_Request extends WP_UnitTestCase { public function test_set_param() { $request = new WP_REST_Request(); $request->set_param( 'param', 'value' ); - $this->assertEquals( 'value', $request->get_param( 'param' ) ); + $this->assertSame( 'value', $request->get_param( 'param' ) ); } public function test_set_param_follows_parameter_order() { @@ -637,15 +637,15 @@ class Tests_REST_Request extends WP_UnitTestCase { ) ) ); - $this->assertEquals( 'value', $request->get_param( 'param' ) ); - $this->assertEquals( + $this->assertSame( 'value', $request->get_param( 'param' ) ); + $this->assertSame( array( 'param' => 'value' ), $request->get_json_params() ); $request->set_param( 'param', 'new_value' ); - $this->assertEquals( 'new_value', $request->get_param( 'param' ) ); - $this->assertEquals( + $this->assertSame( 'new_value', $request->get_param( 'param' ) ); + $this->assertSame( array( 'param' => 'new_value' ), $request->get_json_params() ); @@ -672,10 +672,10 @@ class Tests_REST_Request extends WP_UnitTestCase { ); $request->set_param( 'param', 'new_value' ); - $this->assertEquals( 'new_value', $request->get_param( 'param' ) ); - $this->assertEquals( array(), $request->get_body_params() ); - $this->assertEquals( array( 'param' => 'new_value' ), $request->get_json_params() ); - $this->assertEquals( array( 'param' => 'new_value' ), $request->get_query_params() ); + $this->assertSame( 'new_value', $request->get_param( 'param' ) ); + $this->assertSame( array(), $request->get_body_params() ); + $this->assertSame( array( 'param' => 'new_value' ), $request->get_json_params() ); + $this->assertSame( array( 'param' => 'new_value' ), $request->get_query_params() ); } /** @@ -704,12 +704,12 @@ class Tests_REST_Request extends WP_UnitTestCase { ); $request->set_param( 'param_query', 'new_value' ); - $this->assertEquals( 'new_value', $request->get_param( 'param_query' ) ); - $this->assertEquals( array(), $request->get_body_params() ); - $this->assertEquals( array( 'param_body' => 'value_body' ), $request->get_json_params() ); - $this->assertEquals( array( 'param_query' => 'new_value' ), $request->get_query_params() ); + $this->assertSame( 'new_value', $request->get_param( 'param_query' ) ); + $this->assertSame( array(), $request->get_body_params() ); + $this->assertSame( array( 'param_body' => 'value_body' ), $request->get_json_params() ); + $this->assertSame( array( 'param_query' => 'new_value' ), $request->get_query_params() ); // Verify the default wasn't overwritten. - $this->assertEquals( $original_defaults, $request->get_default_params() ); + $this->assertSame( $original_defaults, $request->get_default_params() ); } /** @@ -733,10 +733,10 @@ class Tests_REST_Request extends WP_UnitTestCase { ); $request->set_param( 'param', null ); - $this->assertEquals( null, $request->get_param( 'param' ) ); - $this->assertEquals( array(), $request->get_body_params() ); - $this->assertEquals( array( 'param' => null ), $request->get_json_params() ); - $this->assertEquals( array( 'param' => null ), $request->get_query_params() ); + $this->assertNull( $request->get_param( 'param' ) ); + $this->assertSame( array(), $request->get_body_params() ); + $this->assertSame( array( 'param' => null ), $request->get_json_params() ); + $this->assertSame( array( 'param' => null ), $request->get_query_params() ); } /** @@ -760,10 +760,10 @@ class Tests_REST_Request extends WP_UnitTestCase { ); $request->set_param( 'param', 'new_value' ); - $this->assertEquals( 'new_value', $request->get_param( 'param' ) ); - $this->assertEquals( array(), $request->get_body_params() ); - $this->assertEquals( array( 'param' => 'new_value' ), $request->get_json_params() ); - $this->assertEquals( array( 'param' => 'new_value' ), $request->get_query_params() ); + $this->assertSame( 'new_value', $request->get_param( 'param' ) ); + $this->assertSame( array(), $request->get_body_params() ); + $this->assertSame( array( 'param' => 'new_value' ), $request->get_json_params() ); + $this->assertSame( array( 'param' => 'new_value' ), $request->get_query_params() ); } /** @@ -777,6 +777,6 @@ class Tests_REST_Request extends WP_UnitTestCase { $request->set_param( 'param', 'value' ); $this->assertTrue( $request->has_param( 'param' ) ); - $this->assertEquals( 'value', $request->get_param( 'param' ) ); + $this->assertSame( 'value', $request->get_param( 'param' ) ); } } diff --git a/tests/phpunit/tests/rest-api/rest-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-revisions-controller.php index 346ba801fe..f138662393 100644 --- a/tests/phpunit/tests/rest-api/rest-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-revisions-controller.php @@ -110,13 +110,13 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id . '/revisions' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_1->ID ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); } @@ -125,17 +125,17 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertCount( $this->total_revisions, $data ); // Reverse chronology. - $this->assertEquals( $this->revision_id3, $data[0]['id'] ); + $this->assertSame( $this->revision_id3, $data[0]['id'] ); $this->check_get_revision_response( $data[0], $this->revision_3 ); - $this->assertEquals( $this->revision_id2, $data[1]['id'] ); + $this->assertSame( $this->revision_id2, $data[1]['id'] ); $this->check_get_revision_response( $data[1], $this->revision_2 ); - $this->assertEquals( $this->revision_id1, $data[2]['id'] ); + $this->assertSame( $this->revision_id1, $data[2]['id'] ); $this->check_get_revision_response( $data[2], $this->revision_1 ); } @@ -168,7 +168,7 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->check_get_revision_response( $response, $this->revision_1 ); $fields = array( 'author', @@ -262,7 +262,7 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'DELETE', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 ); $request->set_param( 'force', true ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertNull( get_post( $this->revision_id1 ) ); } @@ -308,7 +308,7 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase wp_set_current_user( self::$editor_id ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . self::$post_id . '/revisions/' . $this->revision_id1 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->check_get_revision_response( $response, $this->revision_1 ); } @@ -320,7 +320,7 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( '_fields', 'id,slug' ); $revision = get_post( $this->revision_id1 ); $response = $endpoint->prepare_item_for_response( $revision, $request ); - $this->assertEquals( + $this->assertSame( array( 'id', 'slug', @@ -334,7 +334,7 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 12, count( $properties ) ); + $this->assertSame( 12, count( $properties ) ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'content', $properties ); $this->assertArrayHasKey( 'date', $properties ); @@ -386,7 +386,7 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase $data = $response->get_data(); $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); - $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] ); + $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); wp_set_current_user( 1 ); @@ -419,30 +419,30 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase $this->assertEquals( $revision->post_author, $response['author'] ); $rendered_content = apply_filters( 'the_content', $revision->post_content ); - $this->assertEquals( $rendered_content, $response['content']['rendered'] ); + $this->assertSame( $rendered_content, $response['content']['rendered'] ); - $this->assertEquals( mysql_to_rfc3339( $revision->post_date ), $response['date'] ); - $this->assertEquals( mysql_to_rfc3339( $revision->post_date_gmt ), $response['date_gmt'] ); + $this->assertSame( mysql_to_rfc3339( $revision->post_date ), $response['date'] ); + $this->assertSame( mysql_to_rfc3339( $revision->post_date_gmt ), $response['date_gmt'] ); $rendered_excerpt = apply_filters( 'the_excerpt', apply_filters( 'get_the_excerpt', $revision->post_excerpt, $revision ) ); - $this->assertEquals( $rendered_excerpt, $response['excerpt']['rendered'] ); + $this->assertSame( $rendered_excerpt, $response['excerpt']['rendered'] ); $rendered_guid = apply_filters( 'get_the_guid', $revision->guid, $revision->ID ); - $this->assertEquals( $rendered_guid, $response['guid']['rendered'] ); + $this->assertSame( $rendered_guid, $response['guid']['rendered'] ); - $this->assertEquals( $revision->ID, $response['id'] ); - $this->assertEquals( mysql_to_rfc3339( $revision->post_modified ), $response['modified'] ); - $this->assertEquals( mysql_to_rfc3339( $revision->post_modified_gmt ), $response['modified_gmt'] ); - $this->assertEquals( $revision->post_name, $response['slug'] ); + $this->assertSame( $revision->ID, $response['id'] ); + $this->assertSame( mysql_to_rfc3339( $revision->post_modified ), $response['modified'] ); + $this->assertSame( mysql_to_rfc3339( $revision->post_modified_gmt ), $response['modified_gmt'] ); + $this->assertSame( $revision->post_name, $response['slug'] ); $rendered_title = get_the_title( $revision->ID ); - $this->assertEquals( $rendered_title, $response['title']['rendered'] ); + $this->assertSame( $rendered_title, $response['title']['rendered'] ); $parent = get_post( $revision->post_parent ); $parent_controller = new WP_REST_Posts_Controller( $parent->post_type ); $parent_object = get_post_type_object( $parent->post_type ); $parent_base = ! empty( $parent_object->rest_base ) ? $parent_object->rest_base : $parent_object->name; - $this->assertEquals( rest_url( '/wp/v2/' . $parent_base . '/' . $revision->post_parent ), $links['parent'][0]['href'] ); + $this->assertSame( rest_url( '/wp/v2/' . $parent_base . '/' . $revision->post_parent ), $links['parent'][0]['href'] ); } public function test_get_item_sets_up_postdata() { @@ -453,8 +453,8 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase $post = get_post(); $parent_post_id = wp_is_post_revision( $post->ID ); - $this->assertEquals( $post->ID, $this->revision_id1 ); - $this->assertEquals( $parent_post_id, self::$post_id ); + $this->assertSame( $post->ID, $this->revision_id1 ); + $this->assertSame( $parent_post_id, self::$post_id ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-schema-sanitization.php b/tests/phpunit/tests/rest-api/rest-schema-sanitization.php index a755a22011..e91278bca5 100644 --- a/tests/phpunit/tests/rest-api/rest-schema-sanitization.php +++ b/tests/phpunit/tests/rest-api/rest-schema-sanitization.php @@ -16,7 +16,7 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'type' => 'number', ); $this->assertEquals( 1, rest_sanitize_value_from_schema( 1, $schema ) ); - $this->assertEquals( 1.10, rest_sanitize_value_from_schema( '1.10', $schema ) ); + $this->assertSame( 1.10, rest_sanitize_value_from_schema( '1.10', $schema ) ); $this->assertEquals( 1, rest_sanitize_value_from_schema( '1abc', $schema ) ); $this->assertEquals( 0, rest_sanitize_value_from_schema( 'abc', $schema ) ); $this->assertEquals( 0, rest_sanitize_value_from_schema( array(), $schema ) ); @@ -26,34 +26,34 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { $schema = array( 'type' => 'integer', ); - $this->assertEquals( 1, rest_sanitize_value_from_schema( 1, $schema ) ); - $this->assertEquals( 1, rest_sanitize_value_from_schema( '1.10', $schema ) ); - $this->assertEquals( 1, rest_sanitize_value_from_schema( '1abc', $schema ) ); - $this->assertEquals( 0, rest_sanitize_value_from_schema( 'abc', $schema ) ); - $this->assertEquals( 0, rest_sanitize_value_from_schema( array(), $schema ) ); + $this->assertSame( 1, rest_sanitize_value_from_schema( 1, $schema ) ); + $this->assertSame( 1, rest_sanitize_value_from_schema( '1.10', $schema ) ); + $this->assertSame( 1, rest_sanitize_value_from_schema( '1abc', $schema ) ); + $this->assertSame( 0, rest_sanitize_value_from_schema( 'abc', $schema ) ); + $this->assertSame( 0, rest_sanitize_value_from_schema( array(), $schema ) ); } public function test_type_string() { $schema = array( 'type' => 'string', ); - $this->assertEquals( 'Hello', rest_sanitize_value_from_schema( 'Hello', $schema ) ); - $this->assertEquals( '1.10', rest_sanitize_value_from_schema( '1.10', $schema ) ); - $this->assertEquals( '1.1', rest_sanitize_value_from_schema( 1.1, $schema ) ); - $this->assertEquals( '1', rest_sanitize_value_from_schema( 1, $schema ) ); + $this->assertSame( 'Hello', rest_sanitize_value_from_schema( 'Hello', $schema ) ); + $this->assertSame( '1.10', rest_sanitize_value_from_schema( '1.10', $schema ) ); + $this->assertSame( '1.1', rest_sanitize_value_from_schema( 1.1, $schema ) ); + $this->assertSame( '1', rest_sanitize_value_from_schema( 1, $schema ) ); } public function test_type_boolean() { $schema = array( 'type' => 'boolean', ); - $this->assertEquals( true, rest_sanitize_value_from_schema( '1', $schema ) ); - $this->assertEquals( true, rest_sanitize_value_from_schema( 'true', $schema ) ); - $this->assertEquals( true, rest_sanitize_value_from_schema( '100', $schema ) ); - $this->assertEquals( true, rest_sanitize_value_from_schema( 1, $schema ) ); - $this->assertEquals( false, rest_sanitize_value_from_schema( '0', $schema ) ); - $this->assertEquals( false, rest_sanitize_value_from_schema( 'false', $schema ) ); - $this->assertEquals( false, rest_sanitize_value_from_schema( 0, $schema ) ); + $this->assertTrue( rest_sanitize_value_from_schema( '1', $schema ) ); + $this->assertTrue( rest_sanitize_value_from_schema( 'true', $schema ) ); + $this->assertTrue( rest_sanitize_value_from_schema( '100', $schema ) ); + $this->assertTrue( rest_sanitize_value_from_schema( 1, $schema ) ); + $this->assertFalse( rest_sanitize_value_from_schema( '0', $schema ) ); + $this->assertFalse( rest_sanitize_value_from_schema( 'false', $schema ) ); + $this->assertFalse( rest_sanitize_value_from_schema( 0, $schema ) ); } public function test_format_email() { @@ -61,9 +61,9 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'type' => 'string', 'format' => 'email', ); - $this->assertEquals( 'email@example.com', rest_sanitize_value_from_schema( 'email@example.com', $schema ) ); - $this->assertEquals( 'a@b.c', rest_sanitize_value_from_schema( 'a@b.c', $schema ) ); - $this->assertEquals( 'invalid', rest_sanitize_value_from_schema( 'invalid', $schema ) ); + $this->assertSame( 'email@example.com', rest_sanitize_value_from_schema( 'email@example.com', $schema ) ); + $this->assertSame( 'a@b.c', rest_sanitize_value_from_schema( 'a@b.c', $schema ) ); + $this->assertSame( 'invalid', rest_sanitize_value_from_schema( 'invalid', $schema ) ); } public function test_format_ip() { @@ -72,9 +72,9 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'format' => 'ip', ); - $this->assertEquals( '127.0.0.1', rest_sanitize_value_from_schema( '127.0.0.1', $schema ) ); - $this->assertEquals( 'hello', rest_sanitize_value_from_schema( 'hello', $schema ) ); - $this->assertEquals( '2001:DB8:0:0:8:800:200C:417A', rest_sanitize_value_from_schema( '2001:DB8:0:0:8:800:200C:417A', $schema ) ); + $this->assertSame( '127.0.0.1', rest_sanitize_value_from_schema( '127.0.0.1', $schema ) ); + $this->assertSame( 'hello', rest_sanitize_value_from_schema( 'hello', $schema ) ); + $this->assertSame( '2001:DB8:0:0:8:800:200C:417A', rest_sanitize_value_from_schema( '2001:DB8:0:0:8:800:200C:417A', $schema ) ); } /** @@ -85,9 +85,9 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'type' => 'string', 'format' => 'hex-color', ); - $this->assertEquals( '#000000', rest_sanitize_value_from_schema( '#000000', $schema ) ); - $this->assertEquals( '#FFF', rest_sanitize_value_from_schema( '#FFF', $schema ) ); - $this->assertEquals( '', rest_sanitize_value_from_schema( 'WordPress', $schema ) ); + $this->assertSame( '#000000', rest_sanitize_value_from_schema( '#000000', $schema ) ); + $this->assertSame( '#FFF', rest_sanitize_value_from_schema( '#FFF', $schema ) ); + $this->assertSame( '', rest_sanitize_value_from_schema( 'WordPress', $schema ) ); } /** @@ -98,9 +98,9 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'type' => 'string', 'format' => 'uuid', ); - $this->assertEquals( '44', rest_sanitize_value_from_schema( 44, $schema ) ); - $this->assertEquals( 'hello', rest_sanitize_value_from_schema( 'hello', $schema ) ); - $this->assertEquals( + $this->assertSame( '44', rest_sanitize_value_from_schema( 44, $schema ) ); + $this->assertSame( 'hello', rest_sanitize_value_from_schema( 'hello', $schema ) ); + $this->assertSame( '123e4567-e89b-12d3-a456-426655440000', rest_sanitize_value_from_schema( '123e4567-e89b-12d3-a456-426655440000', $schema ) ); @@ -151,8 +151,8 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'type' => 'string', ), ); - $this->assertEquals( array( 'ribs', 'brisket' ), rest_sanitize_value_from_schema( array( 'ribs', 'brisket' ), $schema ) ); - $this->assertEquals( array( 'coleslaw' ), rest_sanitize_value_from_schema( array( 'coleslaw' ), $schema ) ); + $this->assertSame( array( 'ribs', 'brisket' ), rest_sanitize_value_from_schema( array( 'ribs', 'brisket' ), $schema ) ); + $this->assertSame( array( 'coleslaw' ), rest_sanitize_value_from_schema( array( 'coleslaw' ), $schema ) ); } public function test_type_array_with_enum_as_csv() { @@ -163,9 +163,9 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'type' => 'string', ), ); - $this->assertEquals( array( 'ribs', 'chicken' ), rest_sanitize_value_from_schema( 'ribs,chicken', $schema ) ); - $this->assertEquals( array( 'chicken', 'coleslaw' ), rest_sanitize_value_from_schema( 'chicken,coleslaw', $schema ) ); - $this->assertEquals( array( 'chicken', 'coleslaw' ), rest_sanitize_value_from_schema( 'chicken,coleslaw,', $schema ) ); + $this->assertSame( array( 'ribs', 'chicken' ), rest_sanitize_value_from_schema( 'ribs,chicken', $schema ) ); + $this->assertSame( array( 'chicken', 'coleslaw' ), rest_sanitize_value_from_schema( 'chicken,coleslaw', $schema ) ); + $this->assertSame( array( 'chicken', 'coleslaw' ), rest_sanitize_value_from_schema( 'chicken,coleslaw,', $schema ) ); } public function test_type_array_is_associative() { @@ -175,7 +175,7 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'type' => 'string', ), ); - $this->assertEquals( + $this->assertSame( array( '1', '2' ), rest_sanitize_value_from_schema( array( @@ -289,7 +289,7 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { $schema ) ); - $this->assertEquals( array( 'a' => array() ), rest_sanitize_value_from_schema( array( 'a' => null ), $schema ) ); + $this->assertSame( array( 'a' => array() ), rest_sanitize_value_from_schema( array( 'a' => null ), $schema ) ); } public function test_type_object_stdclass() { @@ -308,7 +308,7 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { * @ticket 42961 */ public function test_type_object_accepts_empty_string() { - $this->assertEquals( array(), rest_sanitize_value_from_schema( '', array( 'type' => 'object' ) ) ); + $this->assertSame( array(), rest_sanitize_value_from_schema( '', array( 'type' => 'object' ) ) ); } public function test_type_unknown() { @@ -317,9 +317,9 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { $schema = array( 'type' => 'lalala', ); - $this->assertEquals( 'Best lyrics', rest_sanitize_value_from_schema( 'Best lyrics', $schema ) ); - $this->assertEquals( 1.10, rest_sanitize_value_from_schema( 1.10, $schema ) ); - $this->assertEquals( 1, rest_sanitize_value_from_schema( 1, $schema ) ); + $this->assertSame( 'Best lyrics', rest_sanitize_value_from_schema( 'Best lyrics', $schema ) ); + $this->assertSame( 1.10, rest_sanitize_value_from_schema( 1.10, $schema ) ); + $this->assertSame( 1, rest_sanitize_value_from_schema( 1, $schema ) ); } public function test_no_type() { @@ -328,9 +328,9 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { $schema = array( 'type' => null, ); - $this->assertEquals( 'Nothing', rest_sanitize_value_from_schema( 'Nothing', $schema ) ); - $this->assertEquals( 1.10, rest_sanitize_value_from_schema( 1.10, $schema ) ); - $this->assertEquals( 1, rest_sanitize_value_from_schema( 1, $schema ) ); + $this->assertSame( 'Nothing', rest_sanitize_value_from_schema( 'Nothing', $schema ) ); + $this->assertSame( 1.10, rest_sanitize_value_from_schema( 1.10, $schema ) ); + $this->assertSame( 1, rest_sanitize_value_from_schema( 1, $schema ) ); } public function test_nullable_date() { @@ -340,8 +340,8 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { ); $this->assertNull( rest_sanitize_value_from_schema( null, $schema ) ); - $this->assertEquals( '2019-09-19T18:00:00', rest_sanitize_value_from_schema( '2019-09-19T18:00:00', $schema ) ); - $this->assertEquals( 'lalala', rest_sanitize_value_from_schema( 'lalala', $schema ) ); + $this->assertSame( '2019-09-19T18:00:00', rest_sanitize_value_from_schema( '2019-09-19T18:00:00', $schema ) ); + $this->assertSame( 'lalala', rest_sanitize_value_from_schema( 'lalala', $schema ) ); } /** @@ -352,8 +352,8 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'type' => 'array', 'format' => 'hex-color', ); - $this->assertEquals( array( '#fff' ), rest_sanitize_value_from_schema( '#fff', $schema ) ); - $this->assertEquals( array( '#qrst' ), rest_sanitize_value_from_schema( '#qrst', $schema ) ); + $this->assertSame( array( '#fff' ), rest_sanitize_value_from_schema( '#fff', $schema ) ); + $this->assertSame( array( '#qrst' ), rest_sanitize_value_from_schema( '#qrst', $schema ) ); } /** @@ -364,8 +364,8 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { $this->setExpectedIncorrectUsage( 'rest_sanitize_value_from_schema' ); $schema = array( 'format' => 'hex-color' ); - $this->assertEquals( '#abc', rest_sanitize_value_from_schema( '#abc', $schema ) ); - $this->assertEquals( '', rest_sanitize_value_from_schema( '#jkl', $schema ) ); + $this->assertSame( '#abc', rest_sanitize_value_from_schema( '#abc', $schema ) ); + $this->assertSame( '', rest_sanitize_value_from_schema( '#jkl', $schema ) ); } /** @@ -378,8 +378,8 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'format' => 'hex-color', 'type' => 'str', ); - $this->assertEquals( '#abc', rest_sanitize_value_from_schema( '#abc', $schema ) ); - $this->assertEquals( '', rest_sanitize_value_from_schema( '#jkl', $schema ) ); + $this->assertSame( '#abc', rest_sanitize_value_from_schema( '#abc', $schema ) ); + $this->assertSame( '', rest_sanitize_value_from_schema( '#jkl', $schema ) ); } public function test_object_or_string() { @@ -392,9 +392,9 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { ), ); - $this->assertEquals( 'My Value', rest_sanitize_value_from_schema( 'My Value', $schema ) ); - $this->assertEquals( array( 'raw' => 'My Value' ), rest_sanitize_value_from_schema( array( 'raw' => 'My Value' ), $schema ) ); - $this->assertEquals( array( 'raw' => '1' ), rest_sanitize_value_from_schema( array( 'raw' => 1 ), $schema ) ); + $this->assertSame( 'My Value', rest_sanitize_value_from_schema( 'My Value', $schema ) ); + $this->assertSame( array( 'raw' => 'My Value' ), rest_sanitize_value_from_schema( array( 'raw' => 'My Value' ), $schema ) ); + $this->assertSame( array( 'raw' => '1' ), rest_sanitize_value_from_schema( array( 'raw' => 1 ), $schema ) ); } public function test_object_or_bool() { @@ -415,15 +415,15 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { $this->assertFalse( rest_sanitize_value_from_schema( '0', $schema ) ); $this->assertFalse( rest_sanitize_value_from_schema( 0, $schema ) ); - $this->assertEquals( array( 'raw' => true ), rest_sanitize_value_from_schema( array( 'raw' => true ), $schema ) ); - $this->assertEquals( array( 'raw' => true ), rest_sanitize_value_from_schema( array( 'raw' => '1' ), $schema ) ); - $this->assertEquals( array( 'raw' => true ), rest_sanitize_value_from_schema( array( 'raw' => 1 ), $schema ) ); + $this->assertSame( array( 'raw' => true ), rest_sanitize_value_from_schema( array( 'raw' => true ), $schema ) ); + $this->assertSame( array( 'raw' => true ), rest_sanitize_value_from_schema( array( 'raw' => '1' ), $schema ) ); + $this->assertSame( array( 'raw' => true ), rest_sanitize_value_from_schema( array( 'raw' => 1 ), $schema ) ); - $this->assertEquals( array( 'raw' => false ), rest_sanitize_value_from_schema( array( 'raw' => false ), $schema ) ); - $this->assertEquals( array( 'raw' => false ), rest_sanitize_value_from_schema( array( 'raw' => '0' ), $schema ) ); - $this->assertEquals( array( 'raw' => false ), rest_sanitize_value_from_schema( array( 'raw' => 0 ), $schema ) ); + $this->assertSame( array( 'raw' => false ), rest_sanitize_value_from_schema( array( 'raw' => false ), $schema ) ); + $this->assertSame( array( 'raw' => false ), rest_sanitize_value_from_schema( array( 'raw' => '0' ), $schema ) ); + $this->assertSame( array( 'raw' => false ), rest_sanitize_value_from_schema( array( 'raw' => 0 ), $schema ) ); - $this->assertEquals( array( 'raw' => true ), rest_sanitize_value_from_schema( array( 'raw' => 'something non boolean' ), $schema ) ); + $this->assertSame( array( 'raw' => true ), rest_sanitize_value_from_schema( array( 'raw' => 'something non boolean' ), $schema ) ); } /** @@ -437,7 +437,7 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'type' => array( 'invalid', 'type' ), ); - $this->assertEquals( 'My Value', rest_sanitize_value_from_schema( 'My Value', $schema ) ); + $this->assertSame( 'My Value', rest_sanitize_value_from_schema( 'My Value', $schema ) ); } /** @@ -451,7 +451,7 @@ class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 'type' => array( 'object', 'type' ), ); - $this->assertEquals( 'My Value', rest_sanitize_value_from_schema( 'My Value', $schema ) ); + $this->assertSame( 'My Value', rest_sanitize_value_from_schema( 'My Value', $schema ) ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-schema-setup.php b/tests/phpunit/tests/rest-api/rest-schema-setup.php index 92551704c7..ffcbfd757b 100644 --- a/tests/phpunit/tests/rest-api/rest-schema-setup.php +++ b/tests/phpunit/tests/rest-api/rest-schema-setup.php @@ -132,7 +132,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase { '/wp/v2/block-directory/search', ); - $this->assertEquals( $expected_routes, $routes ); + $this->assertSame( $expected_routes, $routes ); } private function is_builtin_route( $route ) { @@ -441,7 +441,7 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase { $status = $response->get_status(); $data = $response->get_data(); - $this->assertEquals( + $this->assertSame( 200, $response->get_status(), "HTTP $status from $route[route]: " . json_encode( $data ) diff --git a/tests/phpunit/tests/rest-api/rest-schema-validation.php b/tests/phpunit/tests/rest-api/rest-schema-validation.php index d6d94ae686..4cb27010b8 100644 --- a/tests/phpunit/tests/rest-api/rest-schema-validation.php +++ b/tests/phpunit/tests/rest-api/rest-schema-validation.php @@ -390,7 +390,7 @@ class WP_Test_REST_Schema_Validation extends WP_UnitTestCase { $error = rest_validate_value_from_schema( 'some random string', $schema ); $this->assertWPError( $error ); - $this->assertEquals( 'Invalid date.', $error->get_error_message() ); + $this->assertSame( 'Invalid date.', $error->get_error_message() ); } public function test_object_or_string() { @@ -408,7 +408,7 @@ class WP_Test_REST_Schema_Validation extends WP_UnitTestCase { $error = rest_validate_value_from_schema( array( 'raw' => array( 'a list' ) ), $schema ); $this->assertWPError( $error ); - $this->assertEquals( '[raw] is not of type string.', $error->get_error_message() ); + $this->assertSame( '[raw] is not of type string.', $error->get_error_message() ); } /** @@ -427,7 +427,7 @@ class WP_Test_REST_Schema_Validation extends WP_UnitTestCase { $error = rest_validate_value_from_schema( 30, $schema, 'param' ); $this->assertWPError( $error ); - $this->assertEquals( 'param must be between 10 (inclusive) and 20 (inclusive)', $error->get_error_message() ); + $this->assertSame( 'param must be between 10 (inclusive) and 20 (inclusive)', $error->get_error_message() ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-search-controller.php b/tests/phpunit/tests/rest-api/rest-search-controller.php index 9a3982a701..a7c177676f 100644 --- a/tests/phpunit/tests/rest-api/rest-search-controller.php +++ b/tests/phpunit/tests/rest-api/rest-search-controller.php @@ -96,8 +96,8 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { $response = $this->do_request_with_params( array(), 'OPTIONS' ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); } /** @@ -110,7 +110,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { ) ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertEqualSets( array_merge( self::$my_title_post_ids, @@ -131,8 +131,8 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { ) ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 3, count( $response->get_data() ) ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 3, count( $response->get_data() ) ); } /** @@ -146,7 +146,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { ) ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertEqualSets( array_merge( self::$my_title_post_ids, @@ -169,7 +169,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { ) ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertEqualSets( array_merge( self::$my_title_post_ids, @@ -191,7 +191,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { ) ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertEqualSets( self::$my_title_page_ids, wp_list_pluck( $response->get_data(), 'id' ) @@ -239,7 +239,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { ) ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertEqualSets( array_merge( self::$my_title_post_ids, @@ -261,7 +261,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { ) ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertEqualSets( array_merge( self::$my_title_post_ids, @@ -282,7 +282,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { ) ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertEqualSets( self::$my_content_post_ids, wp_list_pluck( $response->get_data(), 'id' ) @@ -296,7 +296,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { /** The search controller does not allow getting individual item content */ $request = new WP_REST_Request( 'GET', '/wp/v2/search' . self::$my_title_post_ids[0] ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } /** @@ -306,7 +306,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { /** The search controller does not allow creating content */ $request = new WP_REST_Request( 'POST', '/wp/v2/search' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } /** @@ -316,7 +316,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { /** The search controller does not allow upading content */ $request = new WP_REST_Request( 'POST', '/wp/v2/search' . self::$my_title_post_ids[0] ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } /** @@ -326,7 +326,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { /** The search controller does not allow deleting content */ $request = new WP_REST_Request( 'DELETE', '/wp/v2/search' . self::$my_title_post_ids[0] ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } /** @@ -334,10 +334,10 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { */ public function test_prepare_item() { $response = $this->do_request_with_params(); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( + $this->assertSame( array( 'id', 'title', @@ -363,10 +363,10 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { '_fields' => 'id,title', ) ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( + $this->assertSame( array( 'id', 'title', @@ -448,7 +448,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { ); $response = $controller->prepare_item_for_response( 1, $request ); $data = $response->get_data(); - $this->assertEquals( + $this->assertSame( array( 'id', 'title', @@ -479,7 +479,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { ); $response = $controller->prepare_item_for_response( 1, $request ); $data = $response->get_data(); - $this->assertEquals( + $this->assertSame( array( 'id', 'title', @@ -495,7 +495,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { $controller = new WP_REST_Search_Controller( array( new WP_REST_Test_Search_Handler( 10 ) ) ); $params = $controller->get_collection_params(); - $this->assertEquals( 'test', $params[ WP_REST_Search_Controller::PROP_TYPE ]['default'] ); + $this->assertSame( 'test', $params[ WP_REST_Search_Controller::PROP_TYPE ]['default'] ); $this->assertEqualSets( array( 'test' ), $params[ WP_REST_Search_Controller::PROP_TYPE ]['enum'] ); $this->assertEqualSets( array( 'test_first_type', 'test_second_type', WP_REST_Search_Controller::TYPE_ANY ), $params[ WP_REST_Search_Controller::PROP_SUBTYPE ]['items']['enum'] ); } @@ -511,7 +511,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { $this->assertArrayHasKey( 'self', $data['_embedded'] ); $this->assertCount( 1, $data['_embedded']['self'] ); $this->assertArrayHasKey( WP_REST_Search_Controller::PROP_ID, $data['_embedded']['self'][0] ); - $this->assertEquals( $data[ WP_REST_Search_Controller::PROP_ID ], $data['_embedded']['self'][0][ WP_REST_Search_Controller::PROP_ID ] ); + $this->assertSame( $data[ WP_REST_Search_Controller::PROP_ID ], $data['_embedded']['self'][0][ WP_REST_Search_Controller::PROP_ID ] ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php index 5870e8cb07..decf35d7a4 100644 --- a/tests/phpunit/tests/rest-api/rest-server.php +++ b/tests/phpunit/tests/rest-api/rest-server.php @@ -49,15 +49,15 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { // The envelope should still be a response, but with defaults. $this->assertInstanceOf( 'WP_REST_Response', $envelope_response ); - $this->assertEquals( 200, $envelope_response->get_status() ); + $this->assertSame( 200, $envelope_response->get_status() ); $this->assertEmpty( $envelope_response->get_headers() ); $this->assertEmpty( $envelope_response->get_links() ); $enveloped = $envelope_response->get_data(); - $this->assertEquals( $data, $enveloped['body'] ); - $this->assertEquals( $status, $enveloped['status'] ); - $this->assertEquals( $headers, $enveloped['headers'] ); + $this->assertSame( $data, $enveloped['body'] ); + $this->assertSame( $status, $enveloped['status'] ); + $this->assertSame( $headers, $enveloped['headers'] ); } public function test_default_param() { @@ -80,7 +80,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', '/test-ns/test' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 'bar', $request['foo'] ); + $this->assertSame( 'bar', $request['foo'] ); } public function test_default_param_is_overridden() { @@ -125,7 +125,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $request->set_query_params( array() ); $response = rest_get_server()->dispatch( $request ); $this->assertInstanceOf( 'WP_REST_Response', $response ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertArrayNotHasKey( 'foo', (array) $request ); } @@ -146,7 +146,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { ); $request = new WP_REST_Request( 'GET', '/no-zero/test' ); rest_get_server()->dispatch( $request ); - $this->assertEquals( array( 'foo' => 'bar' ), $request->get_params() ); + $this->assertSame( array( 'foo' => 'bar' ), $request->get_params() ); } public function test_head_request_handled_by_get() { @@ -161,7 +161,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { ); $request = new WP_REST_Request( 'HEAD', '/head-request/test' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } /** @@ -189,7 +189,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { ); $request = new WP_REST_Request( 'HEAD', '/head-request/test' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_url_params_no_numeric_keys() { @@ -211,7 +211,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', '/test/some-value' ); rest_get_server()->dispatch( $request ); - $this->assertEquals( array( 'data' => 'some-value' ), $request->get_params() ); + $this->assertSame( array( 'data' => 'some-value' ), $request->get_params() ); } /** @@ -233,7 +233,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', '/test-ns/test', array() ); $result = rest_get_server()->dispatch( $request ); - $this->assertEquals( 403, $result->get_status() ); + $this->assertSame( 403, $result->get_status() ); } /** @@ -260,7 +260,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $result->get_status() ); + $this->assertSame( 200, $result->get_status() ); } /** @@ -288,7 +288,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $this->assertFalse( $result->get_status() !== 200 ); $sent_headers = $result->get_headers(); - $this->assertEquals( $sent_headers['Allow'], 'GET' ); + $this->assertSame( $sent_headers['Allow'], 'GET' ); } /** @@ -328,7 +328,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = apply_filters( 'rest_post_dispatch', $result, rest_get_server(), $request ); $sent_headers = $result->get_headers(); - $this->assertEquals( $sent_headers['Allow'], 'GET, POST' ); + $this->assertSame( $sent_headers['Allow'], 'GET, POST' ); } /** @@ -364,10 +364,10 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = rest_get_server()->dispatch( $request ); $result = apply_filters( 'rest_post_dispatch', $result, rest_get_server(), $request ); - $this->assertEquals( $result->get_status(), 403 ); + $this->assertSame( $result->get_status(), 403 ); $sent_headers = $result->get_headers(); - $this->assertEquals( $sent_headers['Allow'], 'POST' ); + $this->assertSame( $sent_headers['Allow'], 'POST' ); } public function test_allow_header_sent_on_options_request() { @@ -395,7 +395,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $headers = $result->get_headers(); - $this->assertEquals( 'GET', $headers['Allow'] ); + $this->assertSame( 'GET', $headers['Allow'] ); } public function permission_denied() { @@ -411,12 +411,12 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $this->assertInstanceOf( 'WP_REST_Response', $response ); // Make sure we default to a 500 error. - $this->assertEquals( 500, $response->get_status() ); + $this->assertSame( 500, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $code, $data['code'] ); - $this->assertEquals( $message, $data['message'] ); + $this->assertSame( $code, $data['code'] ); + $this->assertSame( $message, $data['message'] ); } public function test_error_to_response_with_status() { @@ -427,12 +427,12 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $response = rest_get_server()->error_to_response( $error ); $this->assertInstanceOf( 'WP_REST_Response', $response ); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( $code, $data['code'] ); - $this->assertEquals( $message, $data['message'] ); + $this->assertSame( $code, $data['code'] ); + $this->assertSame( $message, $data['message'] ); } public function test_error_to_response_to_error() { @@ -446,14 +446,14 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $response = rest_get_server()->error_to_response( $error ); $this->assertInstanceOf( 'WP_REST_Response', $response ); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); $error = $response->as_error(); $this->assertInstanceOf( 'WP_Error', $error ); - $this->assertEquals( $code, $error->get_error_code() ); - $this->assertEquals( $message, $error->get_error_message() ); - $this->assertEquals( $message2, $error->errors[ $code2 ][0] ); - $this->assertEquals( array( 'status' => 403 ), $error->error_data[ $code2 ] ); + $this->assertSame( $code, $error->get_error_code() ); + $this->assertSame( $message, $error->get_error_message() ); + $this->assertSame( $message2, $error->errors[ $code2 ][0] ); + $this->assertSame( array( 'status' => 403 ), $error->error_data[ $code2 ] ); } public function test_rest_error() { @@ -464,7 +464,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $expected = wp_json_encode( $data ); $response = rest_get_server()->json_error( 'wp-api-test-error', 'Message text' ); - $this->assertEquals( $expected, $response ); + $this->assertSame( $expected, $response ); } public function test_json_error_with_status() { @@ -484,7 +484,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $response = $stub->json_error( 'wp-api-test-error', 'Message text', 400 ); - $this->assertEquals( $expected, $response ); + $this->assertSame( $expected, $response ); } public function test_response_to_data_links() { @@ -498,13 +498,13 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $self = array( 'href' => 'http://example.com/', ); - $this->assertEquals( $self, $data['_links']['self'][0] ); + $this->assertSame( $self, $data['_links']['self'][0] ); $alternate = array( - 'href' => 'http://example.org/', 'type' => 'application/xml', + 'href' => 'http://example.org/', ); - $this->assertEquals( $alternate, $data['_links']['alternate'][0] ); + $this->assertSame( $alternate, $data['_links']['alternate'][0] ); } public function test_link_embedding() { @@ -537,7 +537,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $this->assertTrue( $alternate[1]['hello'] ); // Ensure the context is set to embed when requesting. - $this->assertEquals( 'embed', $alternate[1]['parameters']['context'] ); + $this->assertSame( 'embed', $alternate[1]['parameters']['context'] ); } public function test_link_curies() { @@ -652,7 +652,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $this->assertArrayHasKey( 'alternate', $data['_embedded'] ); $data = $data['_embedded']['alternate'][0]; - $this->assertEquals( 'yes', $data['parameters']['parsed_params'] ); + $this->assertSame( 'yes', $data['parameters']['parsed_params'] ); } /** @@ -684,9 +684,9 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $this->assertCount( 1, $up ); $up_data = $up[0]; - $this->assertEquals( 'wp-api-test-error', $up_data['code'] ); - $this->assertEquals( 'Test message', $up_data['message'] ); - $this->assertEquals( 403, $up_data['data']['status'] ); + $this->assertSame( 'wp-api-test-error', $up_data['code'] ); + $this->assertSame( 'Test message', $up_data['message'] ); + $this->assertSame( 403, $up_data['data']['status'] ); } /** @@ -712,7 +712,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $data = rest_get_server()->response_to_data( $response, true ); $this->assertArrayHasKey( 'post', $data['_embedded'] ); $this->assertCount( 1, $data['_embedded']['post'] ); - $this->assertEquals( 'My Awesome Title', $data['_embedded']['post'][0]['title']['rendered'] ); + $this->assertSame( 'My Awesome Title', $data['_embedded']['post'][0]['title']['rendered'] ); } /** @@ -802,7 +802,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $this->assertArrayNotHasKey( '_links', $data ); $this->assertArrayNotHasKey( '_embedded', $data ); - $this->assertEquals( 'data', $data['untouched'] ); + $this->assertSame( 'data', $data['untouched'] ); } public function embedded_response_callback( $request ) { @@ -833,10 +833,10 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $this->assertArrayNotHasKey( 'self', $data['_links'] ); $alternate = array( - 'href' => 'http://example.org/', 'type' => 'application/xml', + 'href' => 'http://example.org/', ); - $this->assertEquals( $alternate, $data['_links']['alternate'][0] ); + $this->assertSame( $alternate, $data['_links']['alternate'][0] ); } public function test_removing_links_for_href() { @@ -854,7 +854,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $self_not_filtered = array( 'href' => 'http://example.com/', ); - $this->assertEquals( $self_not_filtered, $data['_links']['self'][0] ); + $this->assertSame( $self_not_filtered, $data['_links']['self'][0] ); } /** @@ -954,7 +954,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { // Check the route. $this->assertArrayHasKey( '/test/example/some-route', $data['routes'] ); $route = $data['routes']['/test/example/some-route']; - $this->assertEquals( 'test/example', $route['namespace'] ); + $this->assertSame( 'test/example', $route['namespace'] ); $this->assertArrayHasKey( 'methods', $route ); $this->assertContains( 'GET', $route['methods'] ); $this->assertContains( 'DELETE', $route['methods'] ); @@ -994,7 +994,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $data = $index->get_data(); // Check top-level. - $this->assertEquals( 'test/example', $data['namespace'] ); + $this->assertSame( 'test/example', $data['namespace'] ); $this->assertArrayHasKey( 'routes', $data ); // Check we have the route we expect... @@ -1052,7 +1052,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { ) ); - $this->assertEquals( $expected, $actual['_links'] ); + $this->assertSame( $expected, $actual['_links'] ); } public function test_x_robot_tag_header_on_requests() { @@ -1061,7 +1061,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = rest_get_server()->serve_request( '/' ); $headers = rest_get_server()->sent_headers; - $this->assertEquals( 'noindex', $headers['X-Robots-Tag'] ); + $this->assertSame( 'noindex', $headers['X-Robots-Tag'] ); } /** @@ -1086,7 +1086,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = rest_get_server()->serve_request( '/' ); $headers = rest_get_server()->sent_headers; - $this->assertEquals( '<' . esc_url_raw( $api_root ) . '>; rel="https://api.w.org/"', $headers['Link'] ); + $this->assertSame( '<' . esc_url_raw( $api_root ) . '>; rel="https://api.w.org/"', $headers['Link'] ); } public function test_nocache_headers_on_authenticated_requests() { @@ -1103,7 +1103,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { } $this->assertTrue( isset( $headers[ $header ] ), sprintf( 'Header %s is not present in the response.', $header ) ); - $this->assertEquals( $value, $headers[ $header ] ); + $this->assertSame( $value, $headers[ $header ] ); } // Last-Modified should be unset as per #WP23021. @@ -1140,7 +1140,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = rest_get_server()->serve_request( '/test/data\\with\\slashes' ); $url_params = rest_get_server()->last_request->get_url_params(); - $this->assertEquals( 'data\\with\\slashes', $url_params['data'] ); + $this->assertSame( 'data\\with\\slashes', $url_params['data'] ); } public function test_serve_request_query_params_are_unslashed() { @@ -1168,7 +1168,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = rest_get_server()->serve_request( '/test' ); $query_params = rest_get_server()->last_request->get_query_params(); - $this->assertEquals( 'data\\with\\slashes', $query_params['data'] ); + $this->assertSame( 'data\\with\\slashes', $query_params['data'] ); } public function test_serve_request_body_params_are_unslashed() { @@ -1197,7 +1197,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = rest_get_server()->serve_request( '/test/data' ); $body_params = rest_get_server()->last_request->get_body_params(); - $this->assertEquals( 'data\\with\\slashes', $body_params['data'] ); + $this->assertSame( 'data\\with\\slashes', $body_params['data'] ); } public function test_serve_request_json_params_are_unslashed() { @@ -1225,7 +1225,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = rest_get_server()->serve_request( '/test' ); $json_params = rest_get_server()->last_request->get_json_params(); - $this->assertEquals( 'data\\with\\slashes', $json_params['data'] ); + $this->assertSame( 'data\\with\\slashes', $json_params['data'] ); } public function test_serve_request_file_params_are_unslashed() { @@ -1253,7 +1253,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = rest_get_server()->serve_request( '/test/data\\with\\slashes' ); $file_params = rest_get_server()->last_request->get_file_params(); - $this->assertEquals( 'data\\with\\slashes', $file_params['data']['name'] ); + $this->assertSame( 'data\\with\\slashes', $file_params['data']['name'] ); } public function test_serve_request_headers_are_unslashed() { @@ -1276,7 +1276,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $_SERVER['HTTP_X_MY_HEADER'] = wp_slash( 'data\\with\\slashes' ); $result = rest_get_server()->serve_request( '/test/data\\with\\slashes' ); - $this->assertEquals( 'data\\with\\slashes', rest_get_server()->last_request->get_header( 'x_my_header' ) ); + $this->assertSame( 'data\\with\\slashes', rest_get_server()->last_request->get_header( 'x_my_header' ) ); } public function filter_wp_rest_server_class() { @@ -1364,7 +1364,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } /** @@ -1386,7 +1386,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = rest_get_server()->serve_request( '/test-ns/test' ); $this->assertNull( $result ); - $this->assertEquals( '', rest_get_server()->sent_body ); + $this->assertSame( '', rest_get_server()->sent_body ); } /** @@ -1408,7 +1408,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $result = rest_get_server()->serve_request( '/test-ns/test' ); $this->assertNull( $result ); - $this->assertEquals( '', rest_get_server()->sent_body ); + $this->assertSame( '', rest_get_server()->sent_body ); } /** @@ -1510,7 +1510,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', '/test-ns/v1/test' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 204, $response->get_status(), '/test-ns/v1/test' ); + $this->assertSame( 204, $response->get_status(), '/test-ns/v1/test' ); } public function _validate_as_integer_123( $value, $request, $key ) { diff --git a/tests/phpunit/tests/rest-api/rest-settings-controller.php b/tests/phpunit/tests/rest-api/rest-settings-controller.php index 928266e4b1..1466a93f6e 100644 --- a/tests/phpunit/tests/rest-api/rest-settings-controller.php +++ b/tests/phpunit/tests/rest-api/rest-settings-controller.php @@ -67,7 +67,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase wp_set_current_user( self::$administrator ); $request = new WP_REST_Request( 'GET', '/wp/v2/settings/title' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_context_param() { @@ -76,14 +76,14 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase public function test_get_item_is_not_public_not_authenticated() { $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 401, $response->get_status() ); + $this->assertSame( 401, $response->get_status() ); } public function test_get_item_is_not_public_no_permission() { wp_set_current_user( self::$author ); $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 403, $response->get_status() ); + $this->assertSame( 403, $response->get_status() ); } public function test_get_items() { @@ -117,8 +117,8 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase sort( $expected ); sort( $actual ); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( $expected, $actual ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( $expected, $actual ); } public function test_get_item_value_is_cast_to_type() { @@ -128,8 +128,8 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 1, $data['posts_per_page'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 1, $data['posts_per_page'] ); } public function test_get_item_with_custom_setting() { @@ -154,16 +154,16 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertArrayHasKey( 'mycustomsettinginrest', $data ); - $this->assertEquals( 'validvalue1', $data['mycustomsettinginrest'] ); + $this->assertSame( 'validvalue1', $data['mycustomsettinginrest'] ); update_option( 'mycustomsetting', 'validvalue2' ); $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'validvalue2', $data['mycustomsettinginrest'] ); + $this->assertSame( 'validvalue2', $data['mycustomsettinginrest'] ); } public function test_get_item_with_custom_array_setting() { @@ -190,28 +190,28 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array( 1, 2 ), $data['mycustomsetting'] ); + $this->assertSame( array( 1, 2 ), $data['mycustomsetting'] ); // Empty array works as expected. update_option( 'mycustomsetting', array() ); $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array(), $data['mycustomsetting'] ); + $this->assertSame( array(), $data['mycustomsetting'] ); // Invalid value. update_option( 'mycustomsetting', array( array( 1 ) ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( null, $data['mycustomsetting'] ); + $this->assertNull( $data['mycustomsetting'] ); // No option value. delete_option( 'mycustomsetting' ); $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( null, $data['mycustomsetting'] ); + $this->assertNull( $data['mycustomsetting'] ); } public function test_get_item_with_custom_object_setting() { @@ -244,14 +244,14 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array( 'a' => 1 ), $data['mycustomsetting'] ); + $this->assertSame( array( 'a' => 1 ), $data['mycustomsetting'] ); // Empty array works as expected. update_option( 'mycustomsetting', array() ); $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array(), $data['mycustomsetting'] ); + $this->assertSame( array(), $data['mycustomsetting'] ); // Invalid value. update_option( @@ -264,7 +264,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( null, $data['mycustomsetting'] ); + $this->assertNull( $data['mycustomsetting'] ); } public function get_setting_custom_callback( $result, $name, $args ) { @@ -309,13 +309,13 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertArrayHasKey( 'mycustomsettinginrest1', $data ); - $this->assertEquals( 'unfiltered1', $data['mycustomsettinginrest1'] ); + $this->assertSame( 'unfiltered1', $data['mycustomsettinginrest1'] ); $this->assertArrayHasKey( 'mycustomsettinginrest2', $data ); - $this->assertEquals( 'unfiltered2', $data['mycustomsettinginrest2'] ); + $this->assertSame( 'unfiltered2', $data['mycustomsettinginrest2'] ); remove_all_filters( 'rest_pre_get_setting' ); } @@ -343,7 +343,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( null, $data['mycustomsettinginrest'] ); + $this->assertNull( $data['mycustomsettinginrest'] ); } public function test_get_item_with_invalid_object_array_in_options() { @@ -369,7 +369,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( null, $data['mycustomsettinginrest'] ); + $this->assertNull( $data['mycustomsettinginrest'] ); } @@ -383,9 +383,9 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 'The new title!', $data['title'] ); - $this->assertEquals( get_option( 'blogname' ), $data['title'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 'The new title!', $data['title'] ); + $this->assertSame( get_option( 'blogname' ), $data['title'] ); } public function update_setting_custom_callback( $result, $name, $value, $args ) { @@ -423,16 +423,16 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'mycustomsetting', array( '1', '2' ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array( 1, 2 ), $data['mycustomsetting'] ); - $this->assertEquals( array( 1, 2 ), get_option( 'mycustomsetting' ) ); + $this->assertSame( array( 1, 2 ), $data['mycustomsetting'] ); + $this->assertSame( array( 1, 2 ), get_option( 'mycustomsetting' ) ); // Setting an empty array. $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' ); $request->set_param( 'mycustomsetting', array() ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array(), $data['mycustomsetting'] ); - $this->assertEquals( array(), get_option( 'mycustomsetting' ) ); + $this->assertSame( array(), $data['mycustomsetting'] ); + $this->assertSame( array(), get_option( 'mycustomsetting' ) ); // Setting an invalid array. $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' ); @@ -513,16 +513,16 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'mycustomsetting', array( 'a' => 1 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array( 'a' => 1 ), $data['mycustomsetting'] ); - $this->assertEquals( array( 'a' => 1 ), get_option( 'mycustomsetting' ) ); + $this->assertSame( array( 'a' => 1 ), $data['mycustomsetting'] ); + $this->assertSame( array( 'a' => 1 ), get_option( 'mycustomsetting' ) ); // Setting an empty object. $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' ); $request->set_param( 'mycustomsetting', array() ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array(), $data['mycustomsetting'] ); - $this->assertEquals( array(), get_option( 'mycustomsetting' ) ); + $this->assertSame( array(), $data['mycustomsetting'] ); + $this->assertSame( array(), get_option( 'mycustomsetting' ) ); // Provide more keys. $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' ); @@ -552,11 +552,11 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'description', 'The old description!' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 'The old title!', $data['title'] ); - $this->assertEquals( 'The old description!', $data['description'] ); - $this->assertEquals( get_option( 'blogname' ), $data['title'] ); - $this->assertEquals( get_option( 'blogdescription' ), $data['description'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 'The old title!', $data['title'] ); + $this->assertSame( 'The old description!', $data['description'] ); + $this->assertSame( get_option( 'blogname' ), $data['title'] ); + $this->assertSame( get_option( 'blogdescription' ), $data['description'] ); add_filter( 'rest_pre_update_setting', array( $this, 'update_setting_custom_callback' ), 10, 4 ); @@ -566,11 +566,11 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 'The old title!', $data['title'] ); - $this->assertEquals( 'The new description!', $data['description'] ); - $this->assertEquals( get_option( 'blogname' ), $data['title'] ); - $this->assertEquals( get_option( 'blogdescription' ), $data['description'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 'The old title!', $data['title'] ); + $this->assertSame( 'The new description!', $data['description'] ); + $this->assertSame( get_option( 'blogname' ), $data['title'] ); + $this->assertSame( get_option( 'blogdescription' ), $data['description'] ); remove_all_filters( 'rest_pre_update_setting' ); } @@ -588,7 +588,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' ); $request->set_param( 'posts_per_page', 11 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_update_item_with_invalid_float_for_integer() { @@ -611,8 +611,8 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 10, $data['posts_per_page'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 10, $data['posts_per_page'] ); } public function test_update_item_with_invalid_enum() { @@ -650,7 +650,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase /** Settings can't be deleted */ $request = new WP_REST_Request( 'DELETE', '/wp/v2/settings/title' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_prepare_item() { diff --git a/tests/phpunit/tests/rest-api/rest-tags-controller.php b/tests/phpunit/tests/rest-api/rest-tags-controller.php index b3804fefeb..bec6ce3070 100644 --- a/tests/phpunit/tests/rest-api/rest-tags-controller.php +++ b/tests/phpunit/tests/rest-api/rest-tags-controller.php @@ -135,14 +135,14 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $tag1 = $this->factory->tag->create( array( 'name' => 'Season 5' ) ); $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/tags/' . $tag1 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); } @@ -152,7 +152,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $data = $response->get_data(); $keys = array_keys( $data['endpoints'][0]['args'] ); sort( $keys ); - $this->assertEquals( + $this->assertSame( array( 'context', 'exclude', @@ -200,9 +200,9 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'hide_empty', true ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( 'Season 5', $data[0]['name'] ); - $this->assertEquals( 'The Be Sharps', $data[1]['name'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( 'Season 5', $data[0]['name'] ); + $this->assertSame( 'The Be Sharps', $data[1]['name'] ); // Invalid 'hide_empty' should error. $request->set_param( 'hide_empty', 'nothanks' ); @@ -220,15 +220,15 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'include', array( $id2, $id1 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( $id1, $data[0]['id'] ); // 'orderby' => 'include'. $request->set_param( 'orderby', 'include' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( $id2, $data[0]['id'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( $id2, $data[0]['id'] ); // Invalid 'include' should error. $request->set_param( 'include', array( 'myterm' ) ); @@ -300,20 +300,20 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'order', 'desc' ); $request->set_param( 'per_page', 1 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( 'Zucchini', $data[0]['name'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( 'Zucchini', $data[0]['name'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); $request->set_param( 'orderby', 'name' ); $request->set_param( 'order', 'asc' ); $request->set_param( 'per_page', 2 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( 'Apple', $data[0]['name'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( 'Apple', $data[0]['name'] ); // Invalid 'orderby' should error. $request->set_param( 'orderby', 'invalid' ); @@ -329,21 +329,21 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { // Defaults to 'orderby' => 'name', 'order' => 'asc'. $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'Apple', $data[0]['name'] ); - $this->assertEquals( 'Banana', $data[1]['name'] ); - $this->assertEquals( 'Cantaloupe', $data[2]['name'] ); + $this->assertSame( 'Apple', $data[0]['name'] ); + $this->assertSame( 'Banana', $data[1]['name'] ); + $this->assertSame( 'Cantaloupe', $data[2]['name'] ); // 'orderby' => 'id', with default 'order' => 'asc'. $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); $request->set_param( 'orderby', 'id' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'Tag 0', $data[0]['name'] ); - $this->assertEquals( 'Tag 1', $data[1]['name'] ); - $this->assertEquals( 'Tag 2', $data[2]['name'] ); + $this->assertSame( 'Tag 0', $data[0]['name'] ); + $this->assertSame( 'Tag 1', $data[1]['name'] ); + $this->assertSame( 'Tag 2', $data[2]['name'] ); // 'orderby' => 'id', 'order' => 'desc'. $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); @@ -351,10 +351,10 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'order', 'desc' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 'Banana', $data[0]['name'] ); - $this->assertEquals( 'Apple', $data[1]['name'] ); - $this->assertEquals( 'Cantaloupe', $data[2]['name'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 'Banana', $data[0]['name'] ); + $this->assertSame( 'Apple', $data[1]['name'] ); + $this->assertSame( 'Cantaloupe', $data[2]['name'] ); } public function test_get_items_orderby_slugs() { @@ -367,10 +367,10 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'slug', array( 'taco', 'burrito', 'chalupa' ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 'taco', $data[0]['slug'] ); - $this->assertEquals( 'burrito', $data[1]['slug'] ); - $this->assertEquals( 'chalupa', $data[2]['slug'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( 'taco', $data[0]['slug'] ); + $this->assertSame( 'burrito', $data[1]['slug'] ); + $this->assertSame( 'chalupa', $data[2]['slug'] ); } public function test_get_items_post_args() { @@ -384,11 +384,11 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); $request->set_param( 'post', $post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( 'DC', $data[0]['name'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( 'DC', $data[0]['name'] ); // Invalid 'post' should error. $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); @@ -412,7 +412,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $i = 0; foreach ( $tags as $tag ) { - $this->assertEquals( $tag['name'], "Tag {$i}" ); + $this->assertSame( $tag['name'], "Tag {$i}" ); $i++; } @@ -425,7 +425,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $tags = $response->get_data(); foreach ( $tags as $tag ) { - $this->assertEquals( $tag['name'], "Tag {$i}" ); + $this->assertSame( $tag['name'], "Tag {$i}" ); $i++; } } @@ -436,7 +436,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); $request->set_param( 'post', $post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertCount( 0, $data ); @@ -471,11 +471,11 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/batman' ); $request->set_param( 'post', $post_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( 'Cape', $data[0]['name'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( 'Cape', $data[0]['name'] ); } public function test_get_items_search_args() { @@ -489,17 +489,17 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); $request->set_param( 'search', 'App' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( 'Apple', $data[0]['name'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( 'Apple', $data[0]['name'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); $request->set_param( 'search', 'Garbage' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 0, count( $data ) ); + $this->assertSame( 0, count( $data ) ); } public function test_get_items_slug_arg() { @@ -509,10 +509,10 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); $request->set_param( 'slug', 'apple' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( 'Apple', $data[0]['name'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( 'Apple', $data[0]['name'] ); } public function test_get_items_slug_array_arg() { @@ -531,11 +531,11 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $names = wp_list_pluck( $data, 'name' ); sort( $names ); - $this->assertEquals( array( 'Burrito', 'Enchilada', 'Taco' ), $names ); + $this->assertSame( array( 'Burrito', 'Enchilada', 'Taco' ), $names ); } public function test_get_items_slug_csv_arg() { @@ -547,11 +547,11 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); $request->set_param( 'slug', 'taco,burrito, enchilada' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $names = wp_list_pluck( $data, 'name' ); sort( $names ); - $this->assertEquals( array( 'Burrito', 'Enchilada', 'Taco' ), $names ); + $this->assertSame( array( 'Burrito', 'Enchilada', 'Taco' ), $names ); } public function test_get_terms_private_taxonomy() { @@ -582,8 +582,8 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_tags, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_tags, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $next_link = add_query_arg( array( 'page' => 2, @@ -601,8 +601,8 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'page', 3 ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_tags, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_tags, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( 'page' => 2, @@ -623,8 +623,8 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'page', $total_pages ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_tags, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_tags, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( 'page' => $total_pages - 1, @@ -639,8 +639,8 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'page', 100 ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_tags, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_tags, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( 'page' => $total_pages, @@ -756,13 +756,13 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'description', 'This term is so awesome.' ); $request->set_param( 'slug', 'so-awesome' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $headers = $response->get_headers(); $data = $response->get_data(); $this->assertContains( '/wp/v2/tags/' . $data['id'], $headers['Location'] ); - $this->assertEquals( 'My Awesome Term', $data['name'] ); - $this->assertEquals( 'This term is so awesome.', $data['description'] ); - $this->assertEquals( 'so-awesome', $data['slug'] ); + $this->assertSame( 'My Awesome Term', $data['name'] ); + $this->assertSame( 'This term is so awesome.', $data['description'] ); + $this->assertSame( 'so-awesome', $data['slug'] ); } public function test_create_item_contributor() { @@ -773,13 +773,13 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'description', 'This term is so awesome.' ); $request->set_param( 'slug', 'so-awesome' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $headers = $response->get_headers(); $data = $response->get_data(); $this->assertContains( '/wp/v2/tags/' . $data['id'], $headers['Location'] ); - $this->assertEquals( 'My Awesome Term', $data['name'] ); - $this->assertEquals( 'This term is so awesome.', $data['description'] ); - $this->assertEquals( 'so-awesome', $data['slug'] ); + $this->assertSame( 'My Awesome Term', $data['name'] ); + $this->assertSame( 'This term is so awesome.', $data['description'] ); + $this->assertSame( 'so-awesome', $data['slug'] ); } public function test_create_item_incorrect_permissions() { @@ -816,12 +816,12 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'name', 'My Awesome Term' ); $request->set_param( 'meta', array( 'test_tag_single' => 'hello' ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $headers = $response->get_headers(); $data = $response->get_data(); $this->assertContains( '/wp/v2/tags/' . $data['id'], $headers['Location'] ); - $this->assertEquals( 'My Awesome Term', $data['name'] ); - $this->assertEquals( 'hello', get_term_meta( $data['id'], 'test_tag_single', true ) ); + $this->assertSame( 'My Awesome Term', $data['name'] ); + $this->assertSame( 'hello', get_term_meta( $data['id'], 'test_tag_single', true ) ); } public function test_create_item_with_meta_wrong_id() { @@ -834,13 +834,13 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'meta', array( 'test_tag_single' => 'hello' ) ); $request->set_param( 'id', $existing_tag_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $headers = $response->get_headers(); $data = $response->get_data(); $this->assertContains( '/wp/v2/tags/' . $data['id'], $headers['Location'] ); - $this->assertEquals( 'My Awesome Term', $data['name'] ); - $this->assertEquals( '', get_term_meta( $existing_tag_id, 'test_tag_single', true ) ); - $this->assertEquals( 'hello', get_term_meta( $data['id'], 'test_tag_single', true ) ); + $this->assertSame( 'My Awesome Term', $data['name'] ); + $this->assertSame( '', get_term_meta( $existing_tag_id, 'test_tag_single', true ) ); + $this->assertSame( 'hello', get_term_meta( $data['id'], 'test_tag_single', true ) ); } public function test_update_item() { @@ -867,13 +867,13 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'New Name', $data['name'] ); - $this->assertEquals( 'New Description', $data['description'] ); - $this->assertEquals( 'new-slug', $data['slug'] ); - $this->assertEquals( 'just meta', $data['meta']['test_single'] ); - $this->assertEquals( 'tag-specific meta', $data['meta']['test_tag_single'] ); + $this->assertSame( 'New Name', $data['name'] ); + $this->assertSame( 'New Description', $data['description'] ); + $this->assertSame( 'new-slug', $data['slug'] ); + $this->assertSame( 'just meta', $data['meta']['test_single'] ); + $this->assertSame( 'tag-specific meta', $data['meta']['test_tag_single'] ); $this->assertFalse( isset( $data['meta']['test_cat_meta'] ) ); } @@ -884,16 +884,16 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'PUT', '/wp/v2/tags/' . $term->term_id ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $request->set_param( 'slug', $term->slug ); // Run twice to make sure that the update still succeeds // even if no DB rows are updated. $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_update_item_invalid_term() { @@ -931,9 +931,9 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); remove_filter( 'user_has_cap', array( $this, 'grant_edit_term' ), 10, 2 ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( 'New Name', $data['name'] ); + $this->assertSame( 'New Name', $data['name'] ); } public function grant_edit_term( $caps, $cap ) { @@ -986,17 +986,17 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( $name, $value ); } $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $actual_output = $response->get_data(); // Compare expected API output to actual API output. - $this->assertEquals( $expected_output['name'], $actual_output['name'] ); - $this->assertEquals( $expected_output['description'], $actual_output['description'] ); + $this->assertSame( $expected_output['name'], $actual_output['name'] ); + $this->assertSame( $expected_output['description'], $actual_output['description'] ); // Compare expected API output to WP internal values. $tag = get_term_by( 'id', $actual_output['id'], 'post_tag' ); - $this->assertEquals( $expected_output['name'], $tag->name ); - $this->assertEquals( $expected_output['description'], $tag->description ); + $this->assertSame( $expected_output['name'], $tag->name ); + $this->assertSame( $expected_output['description'], $tag->description ); // Update the tag. $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/tags/%d', $actual_output['id'] ) ); @@ -1004,23 +1004,23 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( $name, $value ); } $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $actual_output = $response->get_data(); // Compare expected API output to actual API output. - $this->assertEquals( $expected_output['name'], $actual_output['name'] ); - $this->assertEquals( $expected_output['description'], $actual_output['description'] ); + $this->assertSame( $expected_output['name'], $actual_output['name'] ); + $this->assertSame( $expected_output['description'], $actual_output['description'] ); // Compare expected API output to WP internal values. $tag = get_term_by( 'id', $actual_output['id'], 'post_tag' ); - $this->assertEquals( $expected_output['name'], $tag->name ); - $this->assertEquals( $expected_output['description'], $tag->description ); + $this->assertSame( $expected_output['name'], $tag->name ); + $this->assertSame( $expected_output['description'], $tag->description ); } public function test_tag_roundtrip_as_editor() { wp_set_current_user( self::$editor ); - $this->assertEquals( ! is_multisite(), current_user_can( 'unfiltered_html' ) ); + $this->assertSame( ! is_multisite(), current_user_can( 'unfiltered_html' ) ); $this->verify_tag_roundtrip( array( 'name' => '\o/ ¯\_(ツ)_/¯', @@ -1103,10 +1103,10 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'DELETE', '/wp/v2/tags/' . $term->term_id ); $request->set_param( 'force', true ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertTrue( $data['deleted'] ); - $this->assertEquals( 'Deleted Tag', $data['previous']['name'] ); + $this->assertSame( 'Deleted Tag', $data['previous']['name'] ); } public function test_delete_item_no_trash() { @@ -1156,10 +1156,10 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); remove_filter( 'map_meta_cap', array( $this, 'grant_delete_term' ), 10, 2 ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertTrue( $data['deleted'] ); - $this->assertEquals( 'Deleted Tag', $data['previous']['name'] ); + $this->assertSame( 'Deleted Tag', $data['previous']['name'] ); } public function grant_delete_term( $caps, $cap ) { @@ -1210,7 +1210,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( '_fields', 'id,name' ); $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' ); $response = $endpoint->prepare_item_for_response( $term, $request ); - $this->assertEquals( + $this->assertSame( array( 'id', 'name', @@ -1224,7 +1224,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 8, count( $properties ) ); + $this->assertSame( 8, count( $properties ) ); $this->assertArrayHasKey( 'id', $properties ); $this->assertArrayHasKey( 'count', $properties ); $this->assertArrayHasKey( 'description', $properties ); @@ -1233,7 +1233,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $this->assertArrayHasKey( 'name', $properties ); $this->assertArrayHasKey( 'slug', $properties ); $this->assertArrayHasKey( 'taxonomy', $properties ); - $this->assertEquals( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] ); + $this->assertSame( array_keys( get_taxonomies() ), $properties['taxonomy']['enum'] ); } public function test_get_item_schema_non_hierarchical() { @@ -1268,7 +1268,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); - $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] ); + $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); $tag_id = $this->factory->tag->create(); @@ -1376,7 +1376,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $create = new WP_REST_Request( 'POST', '/wp/v2/tags' ); $create->set_param( 'name', 'My New Term' ); $response = rest_get_server()->dispatch( $create ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( $edit_field, $data ); $this->assertArrayNotHasKey( $view_field, $data ); @@ -1384,7 +1384,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $update = new WP_REST_Request( 'PUT', '/wp/v2/tags/' . $data['id'] ); $update->set_param( 'name', 'My Awesome New Term' ); $response = rest_get_server()->dispatch( $update ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( $edit_field, $data ); $this->assertArrayNotHasKey( $view_field, $data ); @@ -1407,31 +1407,31 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { } protected function check_get_taxonomy_terms_response( $response ) { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $args = array( 'hide_empty' => false, ); $tags = get_terms( 'post_tag', $args ); - $this->assertEquals( count( $tags ), count( $data ) ); - $this->assertEquals( $tags[0]->term_id, $data[0]['id'] ); - $this->assertEquals( $tags[0]->name, $data[0]['name'] ); - $this->assertEquals( $tags[0]->slug, $data[0]['slug'] ); - $this->assertEquals( $tags[0]->taxonomy, $data[0]['taxonomy'] ); - $this->assertEquals( $tags[0]->description, $data[0]['description'] ); - $this->assertEquals( $tags[0]->count, $data[0]['count'] ); + $this->assertSame( count( $tags ), count( $data ) ); + $this->assertSame( $tags[0]->term_id, $data[0]['id'] ); + $this->assertSame( $tags[0]->name, $data[0]['name'] ); + $this->assertSame( $tags[0]->slug, $data[0]['slug'] ); + $this->assertSame( $tags[0]->taxonomy, $data[0]['taxonomy'] ); + $this->assertSame( $tags[0]->description, $data[0]['description'] ); + $this->assertSame( $tags[0]->count, $data[0]['count'] ); } protected function check_taxonomy_term( $term, $data, $links ) { - $this->assertEquals( $term->term_id, $data['id'] ); - $this->assertEquals( $term->name, $data['name'] ); - $this->assertEquals( $term->slug, $data['slug'] ); - $this->assertEquals( $term->description, $data['description'] ); - $this->assertEquals( get_term_link( $term ), $data['link'] ); - $this->assertEquals( $term->count, $data['count'] ); + $this->assertSame( $term->term_id, $data['id'] ); + $this->assertSame( $term->name, $data['name'] ); + $this->assertSame( $term->slug, $data['slug'] ); + $this->assertSame( $term->description, $data['description'] ); + $this->assertSame( get_term_link( $term ), $data['link'] ); + $this->assertSame( $term->count, $data['count'] ); $taxonomy = get_taxonomy( $term->taxonomy ); if ( $taxonomy->hierarchical ) { - $this->assertEquals( $term->parent, $data['parent'] ); + $this->assertSame( $term->parent, $data['parent'] ); } else { $this->assertFalse( isset( $data['parent'] ) ); } @@ -1446,12 +1446,12 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { } $this->assertEqualSets( $expected_links, array_keys( $links ) ); $this->assertContains( 'wp/v2/taxonomies/' . $term->taxonomy, $links['about'][0]['href'] ); - $this->assertEquals( add_query_arg( 'tags', $term->term_id, rest_url( 'wp/v2/posts' ) ), $links['https://api.w.org/post_type'][0]['href'] ); + $this->assertSame( add_query_arg( 'tags', $term->term_id, rest_url( 'wp/v2/posts' ) ), $links['https://api.w.org/post_type'][0]['href'] ); } protected function check_get_taxonomy_term_response( $response, $id ) { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $tag = get_term( $id, 'post_tag' ); diff --git a/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php b/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php index 009198ec13..d0a3509a02 100644 --- a/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php +++ b/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php @@ -37,13 +37,13 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/taxonomies' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/taxonomies/post_tag' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); $this->assertEqualSets( array( 'view', 'edit', 'embed' ), $data['endpoints'][0]['args']['context']['enum'] ); } @@ -52,14 +52,14 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $taxonomies = $this->get_public_taxonomies( get_taxonomies( '', 'objects' ) ); - $this->assertEquals( count( $taxonomies ), count( $data ) ); - $this->assertEquals( 'Categories', $data['category']['name'] ); - $this->assertEquals( 'category', $data['category']['slug'] ); - $this->assertEquals( true, $data['category']['hierarchical'] ); - $this->assertEquals( 'Tags', $data['post_tag']['name'] ); - $this->assertEquals( 'post_tag', $data['post_tag']['slug'] ); - $this->assertEquals( false, $data['post_tag']['hierarchical'] ); - $this->assertEquals( 'tags', $data['post_tag']['rest_base'] ); + $this->assertSame( count( $taxonomies ), count( $data ) ); + $this->assertSame( 'Categories', $data['category']['name'] ); + $this->assertSame( 'category', $data['category']['slug'] ); + $this->assertTrue( $data['category']['hierarchical'] ); + $this->assertSame( 'Tags', $data['post_tag']['name'] ); + $this->assertSame( 'post_tag', $data['post_tag']['slug'] ); + $this->assertFalse( $data['post_tag']['hierarchical'] ); + $this->assertSame( 'tags', $data['post_tag']['rest_base'] ); } public function test_get_items_context_edit() { @@ -69,14 +69,14 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $taxonomies = $this->get_public_taxonomies( get_taxonomies( '', 'objects' ) ); - $this->assertEquals( count( $taxonomies ), count( $data ) ); - $this->assertEquals( 'Categories', $data['category']['name'] ); - $this->assertEquals( 'category', $data['category']['slug'] ); - $this->assertEquals( true, $data['category']['hierarchical'] ); - $this->assertEquals( 'Tags', $data['post_tag']['name'] ); - $this->assertEquals( 'post_tag', $data['post_tag']['slug'] ); - $this->assertEquals( false, $data['post_tag']['hierarchical'] ); - $this->assertEquals( 'tags', $data['post_tag']['rest_base'] ); + $this->assertSame( count( $taxonomies ), count( $data ) ); + $this->assertSame( 'Categories', $data['category']['name'] ); + $this->assertSame( 'category', $data['category']['slug'] ); + $this->assertTrue( $data['category']['hierarchical'] ); + $this->assertSame( 'Tags', $data['post_tag']['name'] ); + $this->assertSame( 'post_tag', $data['post_tag']['slug'] ); + $this->assertFalse( $data['post_tag']['hierarchical'] ); + $this->assertSame( 'tags', $data['post_tag']['rest_base'] ); } public function test_get_items_invalid_permission_for_context() { @@ -98,9 +98,9 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies' ); $request->set_param( 'type', 'wingding' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertEquals( '{}', json_encode( $data ) ); + $this->assertSame( '{}', json_encode( $data ) ); } public function test_get_item() { @@ -153,21 +153,21 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas /** Taxonomies can't be created */ $request = new WP_REST_Request( 'POST', '/wp/v2/taxonomies' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_update_item() { /** Taxonomies can't be updated */ $request = new WP_REST_Request( 'POST', '/wp/v2/taxonomies/category' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_delete_item() { /** Taxonomies can't be deleted */ $request = new WP_REST_Request( 'DELETE', '/wp/v2/taxonomies/category' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 404, $response->get_status() ); + $this->assertSame( 404, $response->get_status() ); } public function test_prepare_item() { @@ -186,7 +186,7 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'context', 'edit' ); $request->set_param( '_fields', 'id,name' ); $response = $endpoint->prepare_item_for_response( $tax, $request ); - $this->assertEquals( + $this->assertSame( array( // 'id' doesn't exist in this context. 'name', @@ -208,10 +208,10 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas $types = $response->get_data()['types']; $this->assertArrayHasKey( 0, $types ); - $this->assertEquals( 'post', $types[0] ); + $this->assertSame( 'post', $types[0] ); $this->assertArrayHasKey( 1, $types ); - $this->assertEquals( 'attachment', $types[1] ); - $this->assertEquals( 2, count( $types ) ); + $this->assertSame( 'attachment', $types[1] ); + $this->assertSame( 2, count( $types ) ); } public function test_get_item_schema() { @@ -219,7 +219,7 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 10, count( $properties ) ); + $this->assertSame( 10, count( $properties ) ); $this->assertArrayHasKey( 'capabilities', $properties ); $this->assertArrayHasKey( 'description', $properties ); $this->assertArrayHasKey( 'hierarchical', $properties ); @@ -251,24 +251,24 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas } protected function check_taxonomy_object( $context, $tax_obj, $data, $links ) { - $this->assertEquals( $tax_obj->label, $data['name'] ); - $this->assertEquals( $tax_obj->name, $data['slug'] ); - $this->assertEquals( $tax_obj->description, $data['description'] ); - $this->assertEquals( $tax_obj->hierarchical, $data['hierarchical'] ); - $this->assertEquals( $tax_obj->rest_base, $data['rest_base'] ); - $this->assertEquals( rest_url( 'wp/v2/taxonomies' ), $links['collection'][0]['href'] ); + $this->assertSame( $tax_obj->label, $data['name'] ); + $this->assertSame( $tax_obj->name, $data['slug'] ); + $this->assertSame( $tax_obj->description, $data['description'] ); + $this->assertSame( $tax_obj->hierarchical, $data['hierarchical'] ); + $this->assertSame( $tax_obj->rest_base, $data['rest_base'] ); + $this->assertSame( rest_url( 'wp/v2/taxonomies' ), $links['collection'][0]['href'] ); $this->assertArrayHasKey( 'https://api.w.org/items', $links ); if ( 'edit' === $context ) { - $this->assertEquals( $tax_obj->cap, $data['capabilities'] ); - $this->assertEquals( $tax_obj->labels, $data['labels'] ); - $this->assertEquals( $tax_obj->show_tagcloud, $data['show_cloud'] ); + $this->assertSame( $tax_obj->cap, $data['capabilities'] ); + $this->assertSame( $tax_obj->labels, $data['labels'] ); + $this->assertSame( $tax_obj->show_tagcloud, $data['show_cloud'] ); - $this->assertEquals( $tax_obj->public, $data['visibility']['public'] ); - $this->assertEquals( $tax_obj->publicly_queryable, $data['visibility']['publicly_queryable'] ); - $this->assertEquals( $tax_obj->show_admin_column, $data['visibility']['show_admin_column'] ); - $this->assertEquals( $tax_obj->show_in_nav_menus, $data['visibility']['show_in_nav_menus'] ); - $this->assertEquals( $tax_obj->show_in_quick_edit, $data['visibility']['show_in_quick_edit'] ); - $this->assertEquals( $tax_obj->show_ui, $data['visibility']['show_ui'] ); + $this->assertSame( $tax_obj->public, $data['visibility']['public'] ); + $this->assertSame( $tax_obj->publicly_queryable, $data['visibility']['publicly_queryable'] ); + $this->assertSame( $tax_obj->show_admin_column, $data['visibility']['show_admin_column'] ); + $this->assertSame( $tax_obj->show_in_nav_menus, $data['visibility']['show_in_nav_menus'] ); + $this->assertSame( $tax_obj->show_in_quick_edit, $data['visibility']['show_in_quick_edit'] ); + $this->assertSame( $tax_obj->show_ui, $data['visibility']['show_ui'] ); } else { $this->assertFalse( isset( $data['capabilities'] ) ); $this->assertFalse( isset( $data['labels'] ) ); @@ -278,17 +278,17 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas } protected function check_taxonomy_object_response( $context, $response ) { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $category = get_taxonomy( 'category' ); $this->check_taxonomy_object( $context, $category, $data, $response->get_links() ); } protected function check_taxonomies_for_type_response( $type, $response ) { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $taxonomies = $this->get_public_taxonomies( get_object_taxonomies( $type, 'objects' ) ); - $this->assertEquals( count( $taxonomies ), count( $data ) ); + $this->assertSame( count( $taxonomies ), count( $data ) ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php index e266589468..9038e01998 100644 --- a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php @@ -214,14 +214,14 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/categories/%d', self::$category_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'test_single', $meta ); - $this->assertEquals( 'testvalue', $meta['test_single'] ); + $this->assertSame( 'testvalue', $meta['test_single'] ); } /** @@ -232,7 +232,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/categories/%d', self::$category_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; @@ -244,7 +244,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { add_term_meta( self::$category_id, 'test_multi', 'value2' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; $this->assertContains( 'value1', $meta['test_multi'] ); @@ -259,7 +259,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/categories/%d', self::$category_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; @@ -274,7 +274,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/categories/%d', self::$category_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; @@ -289,7 +289,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/categories/%d', self::$category_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; @@ -336,7 +336,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/categories/%d', self::$category_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $meta = (array) $data['meta']; @@ -351,7 +351,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $this->assertArrayHasKey( 'test_bool', $meta ); $this->assertInternalType( 'boolean', $meta['test_bool'] ); - $this->assertSame( true, $meta['test_bool'] ); + $this->assertTrue( $meta['test_bool'] ); } public function test_get_value_custom_name() { @@ -360,14 +360,14 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/categories/%d', self::$category_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'new_name', $meta ); - $this->assertEquals( 'janet', $meta['new_name'] ); + $this->assertSame( 'janet', $meta['new_name'] ); } /** @@ -389,17 +389,17 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_single', false ); $this->assertNotEmpty( $meta ); $this->assertCount( 1, $meta ); - $this->assertEquals( 'test_value', $meta[0] ); + $this->assertSame( 'test_value', $meta[0] ); $data = $response->get_data(); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'test_single', $meta ); - $this->assertEquals( 'test_value', $meta['test_single'] ); + $this->assertSame( 'test_value', $meta['test_single'] ); } /** @@ -408,7 +408,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { public function test_set_duplicate_single_value() { // Start with an existing metakey and value. $values = update_term_meta( self::$category_id, 'test_single', 'test_value' ); - $this->assertEquals( 'test_value', get_term_meta( self::$category_id, 'test_single', true ) ); + $this->assertSame( 'test_value', get_term_meta( self::$category_id, 'test_single', true ) ); $this->grant_write_permission(); @@ -421,16 +421,16 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_single', true ); $this->assertNotEmpty( $meta ); - $this->assertEquals( 'test_value', $meta ); + $this->assertSame( 'test_value', $meta ); $data = $response->get_data(); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'test_single', $meta ); - $this->assertEquals( 'test_value', $meta['test_single'] ); + $this->assertSame( 'test_value', $meta['test_single'] ); } /** @@ -539,12 +539,12 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_multi', false ); $this->assertNotEmpty( $meta ); $this->assertCount( 1, $meta ); - $this->assertEquals( 'val1', $meta[0] ); + $this->assertSame( 'val1', $meta[0] ); // Add another value. $data = array( @@ -555,7 +555,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_multi', false ); $this->assertNotEmpty( $meta ); @@ -583,7 +583,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_multi', false ); $this->assertNotEmpty( $meta ); @@ -690,7 +690,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, $data['meta']['my_meta_key'] ); + $this->assertSame( 1, $data['meta']['my_meta_key'] ); } public function test_set_value_csv() { @@ -716,7 +716,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( array( 1, 2, 3 ), $data['meta']['my_meta_key'] ); + $this->assertSame( array( 1, 2, 3 ), $data['meta']['my_meta_key'] ); } /** @@ -788,7 +788,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_custom_schema', false ); $this->assertNotEmpty( $meta ); @@ -817,7 +817,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_custom_schema_multi', false ); $this->assertNotEmpty( $meta ); @@ -833,7 +833,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_custom_schema_multi', false ); $this->assertNotEmpty( $meta ); @@ -861,17 +861,17 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_custom_name', false ); $this->assertNotEmpty( $meta ); $this->assertCount( 1, $meta ); - $this->assertEquals( 'janet', $meta[0] ); + $this->assertSame( 'janet', $meta[0] ); $data = $response->get_data(); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'new_name', $meta ); - $this->assertEquals( 'janet', $meta['new_name'] ); + $this->assertSame( 'janet', $meta['new_name'] ); } public function test_set_value_custom_name_multiple() { @@ -890,12 +890,12 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_custom_name_multi', false ); $this->assertNotEmpty( $meta ); $this->assertCount( 1, $meta ); - $this->assertEquals( 'janet', $meta[0] ); + $this->assertSame( 'janet', $meta[0] ); // Add another value. $data = array( @@ -906,7 +906,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_custom_name_multi', false ); $this->assertNotEmpty( $meta ); @@ -938,11 +938,11 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { // The meta value should not have changed. $current_value = get_term_meta( self::$category_id, 'test_single', true ); - $this->assertEquals( 'So I tied an onion to my belt, which was the style at the time.', $current_value ); + $this->assertSame( 'So I tied an onion to my belt, which was the style at the time.', $current_value ); // Ensure the term name update was not processed. $term_updated = get_term( self::$category_id ); - $this->assertEquals( $term_original->name, $term_updated->name ); + $this->assertSame( $term_original->name, $term_updated->name ); } /** @@ -967,17 +967,17 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { // The meta value should not have changed. $current_value = get_term_meta( self::$category_id, 'test_single', true ); - $this->assertEquals( 'Now, to take the ferry cost a nickel, and in those days, nickels had pictures of bumblebees on them.', $current_value ); + $this->assertSame( 'Now, to take the ferry cost a nickel, and in those days, nickels had pictures of bumblebees on them.', $current_value ); // Ensure the term name update was not processed. $term_updated = get_term( self::$category_id ); - $this->assertEquals( $term_original->name, $term_updated->name ); + $this->assertSame( $term_original->name, $term_updated->name ); } public function test_remove_multi_value_db_error() { add_term_meta( self::$category_id, 'test_multi', 'val1' ); $values = get_term_meta( self::$category_id, 'test_multi', false ); - $this->assertEquals( array( 'val1' ), $values ); + $this->assertSame( array( 'val1' ), $values ); $this->grant_write_permission(); @@ -1008,7 +1008,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { public function test_delete_value() { add_term_meta( self::$category_id, 'test_single', 'val1' ); $current = get_term_meta( self::$category_id, 'test_single', true ); - $this->assertEquals( 'val1', $current ); + $this->assertSame( 'val1', $current ); $this->grant_write_permission(); @@ -1021,7 +1021,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_single', false ); $this->assertEmpty( $meta ); @@ -1033,7 +1033,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { public function test_delete_value_blocked() { add_term_meta( self::$category_id, 'test_bad_auth', 'val1' ); $current = get_term_meta( self::$category_id, 'test_bad_auth', true ); - $this->assertEquals( 'val1', $current ); + $this->assertSame( 'val1', $current ); $this->grant_write_permission(); @@ -1049,7 +1049,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $this->assertErrorResponse( 'rest_cannot_delete', $response, 403 ); $meta = get_term_meta( self::$category_id, 'test_bad_auth', true ); - $this->assertEquals( 'val1', $meta ); + $this->assertSame( 'val1', $meta ); } /** @@ -1058,7 +1058,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { public function test_delete_value_db_error() { add_term_meta( self::$category_id, 'test_single', 'val1' ); $current = get_term_meta( self::$category_id, 'test_single', true ); - $this->assertEquals( 'val1', $current ); + $this->assertSame( 'val1', $current ); $this->grant_write_permission(); @@ -1087,7 +1087,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { public function test_delete_value_custom_name() { add_term_meta( self::$category_id, 'test_custom_name', 'janet' ); $current = get_term_meta( self::$category_id, 'test_custom_name', true ); - $this->assertEquals( 'janet', $current ); + $this->assertSame( 'janet', $current ); $this->grant_write_permission(); @@ -1100,7 +1100,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request->set_body_params( $data ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $meta = get_term_meta( self::$category_id, 'test_custom_name', false ); $this->assertEmpty( $meta ); @@ -1117,15 +1117,15 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $meta_schema = $schema['properties']['meta']['properties']; $this->assertArrayHasKey( 'test_single', $meta_schema ); - $this->assertEquals( 'string', $meta_schema['test_single']['type'] ); + $this->assertSame( 'string', $meta_schema['test_single']['type'] ); $this->assertArrayHasKey( 'test_multi', $meta_schema ); - $this->assertEquals( 'array', $meta_schema['test_multi']['type'] ); + $this->assertSame( 'array', $meta_schema['test_multi']['type'] ); $this->assertArrayHasKey( 'items', $meta_schema['test_multi'] ); - $this->assertEquals( 'string', $meta_schema['test_multi']['items']['type'] ); + $this->assertSame( 'string', $meta_schema['test_multi']['items']['type'] ); $this->assertArrayHasKey( 'test_custom_schema', $meta_schema ); - $this->assertEquals( 'number', $meta_schema['test_custom_schema']['type'] ); + $this->assertSame( 'number', $meta_schema['test_custom_schema']['type'] ); $this->assertArrayNotHasKey( 'test_no_rest', $meta_schema ); $this->assertArrayNotHasKey( 'test_rest_disabled', $meta_schema ); @@ -1152,7 +1152,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/%s/%d', $endpoint, $term_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); @@ -1166,7 +1166,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { } $this->assertArrayHasKey( $meta_key, $data['meta'] ); - $this->assertEquals( $expected_value, $data['meta'][ $meta_key ] ); + $this->assertSame( $expected_value, $data['meta'][ $meta_key ] ); } else { $this->assertArrayNotHasKey( $meta_key, $data['meta'] ); } @@ -1212,12 +1212,12 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $response = rest_get_server()->dispatch( $request ); if ( ! $can_write ) { - $this->assertEquals( 403, $response->get_status() ); + $this->assertSame( 403, $response->get_status() ); $this->assertEmpty( get_term_meta( $term_id, $meta_key, $single ) ); return; } - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); @@ -1229,9 +1229,9 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $expected_value = array( $expected_value ); } - $this->assertEquals( $expected_value, get_term_meta( $term_id, $meta_key, $single ) ); + $this->assertSame( $expected_value, get_term_meta( $term_id, $meta_key, $single ) ); $this->assertArrayHasKey( $meta_key, $data['meta'] ); - $this->assertEquals( $expected_value, $data['meta'][ $meta_key ] ); + $this->assertSame( $expected_value, $data['meta'][ $meta_key ] ); } else { $this->assertEmpty( get_term_meta( $term_id, $meta_key, $single ) ); $this->assertArrayNotHasKey( $meta_key, $data['meta'] ); @@ -1275,7 +1275,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/categories/%d', self::$category_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); diff --git a/tests/phpunit/tests/rest-api/rest-themes-controller.php b/tests/phpunit/tests/rest-api/rest-themes-controller.php index 8ebf661b62..94697c0000 100644 --- a/tests/phpunit/tests/rest-api/rest-themes-controller.php +++ b/tests/phpunit/tests/rest-api/rest-themes-controller.php @@ -78,9 +78,9 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { } $this->assertArrayHasKey( 'X-WP-Total', $headers ); - $this->assertEquals( 1, $headers['X-WP-Total'] ); + $this->assertSame( 1, $headers['X-WP-Total'] ); $this->assertArrayHasKey( 'X-WP-TotalPages', $headers ); - $this->assertEquals( 1, $headers['X-WP-TotalPages'] ); + $this->assertSame( 1, $headers['X-WP-TotalPages'] ); } /** @@ -146,7 +146,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { public function test_get_items() { $response = self::perform_active_theme_request(); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->check_get_theme_response( $response ); @@ -198,7 +198,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { wp_set_current_user( $user->ID ); $response = self::perform_active_theme_request(); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } /** @@ -208,7 +208,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { */ public function test_prepare_item() { $response = self::perform_active_theme_request(); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->check_get_theme_response( $response ); } @@ -221,7 +221,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $response = self::perform_active_theme_request( 'OPTIONS' ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 14, count( $properties ) ); + $this->assertSame( 14, count( $properties ) ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'raw', $properties['author']['properties'] ); @@ -529,7 +529,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $response = self::perform_active_theme_request(); $result = $response->get_data(); $this->assertArrayHasKey( 'theme_supports', $result[0] ); - $this->assertEquals( array( $wordpress_blue ), $result[0]['theme_supports']['editor-color-palette'] ); + $this->assertSame( array( $wordpress_blue ), $result[0]['theme_supports']['editor-color-palette'] ); } /** @@ -574,10 +574,10 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { public function test_theme_supports_custom_logo() { remove_theme_support( 'custom-logo' ); $wordpress_logo = array( - 'height' => 100, 'width' => 400, - 'flex-height' => true, + 'height' => 100, 'flex-width' => true, + 'flex-height' => true, 'header-text' => array( 'site-title', 'site-description' ), 'unlink-homepage-logo' => false, ); @@ -585,7 +585,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $response = self::perform_active_theme_request(); $result = $response->get_data(); $this->assertArrayHasKey( 'theme_supports', $result[0] ); - $this->assertEquals( $wordpress_logo, $result[0]['theme_supports']['custom-logo'] ); + $this->assertSame( $wordpress_logo, $result[0]['theme_supports']['custom-logo'] ); } /** @@ -633,7 +633,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $this->assertArrayHasKey( 'theme_supports', $result[0] ); $expected = array_diff_key( $wordpress_header, array_flip( $excluded ) ); - $this->assertEquals( $expected, $result[0]['theme_supports']['custom-header'] ); + $this->assertSame( $expected, $result[0]['theme_supports']['custom-header'] ); } /** @@ -677,7 +677,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $this->assertArrayHasKey( 'theme_supports', $result[0] ); $expected = array_diff_key( $background, array_flip( $excluded ) ); - $this->assertEquals( $expected, $result[0]['theme_supports']['custom-background'] ); + $this->assertSame( $expected, $result[0]['theme_supports']['custom-background'] ); } /** @@ -710,7 +710,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $response = self::perform_active_theme_request(); $result = $response->get_data(); $this->assertArrayHasKey( 'theme_supports', $result[0] ); - $this->assertEquals( $html5, $result[0]['theme_supports']['html5'] ); + $this->assertSame( $html5, $result[0]['theme_supports']['html5'] ); } /** @@ -895,7 +895,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $response = self::perform_active_theme_request(); $result = $response->get_data(); $this->assertArrayHasKey( 'theme_supports', $result[0] ); - $this->assertEquals( array( $gradient ), $result[0]['theme_supports']['editor-gradient-presets'] ); + $this->assertSame( array( $gradient ), $result[0]['theme_supports']['editor-gradient-presets'] ); } /** @@ -995,7 +995,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $response = self::perform_active_theme_request(); $result = $response->get_data(); $this->assertTrue( isset( $result[0]['theme_supports'] ) ); - $this->assertEquals( array( 'post' ), $result[0]['theme_supports']['post-thumbnails'] ); + $this->assertSame( array( 'post' ), $result[0]['theme_supports']['post-thumbnails'] ); } /** @@ -1021,7 +1021,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $response = self::perform_active_theme_request(); $result = $response->get_data(); $this->assertTrue( isset( $result[0]['theme_supports'] ) ); - $this->assertEquals( array( 'a', 'b', 'c' ), $result[0]['theme_supports']['test-feature'] ); + $this->assertSame( array( 'a', 'b', 'c' ), $result[0]['theme_supports']['test-feature'] ); } /** @@ -1049,7 +1049,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $data = $response->get_data(); $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); - $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] ); + $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); $response = self::perform_active_theme_request( 'GET' ); $data = $response->get_data(); diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index 6132813268..0b6129c7db 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -168,14 +168,14 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); // Single. $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/users/' . self::$user ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'view', $data['endpoints'][0]['args']['context']['default'] ); - $this->assertEquals( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); + $this->assertSame( 'view', $data['endpoints'][0]['args']['context']['default'] ); + $this->assertSame( array( 'view', 'embed', 'edit' ), $data['endpoints'][0]['args']['context']['enum'] ); } public function test_registered_query_params() { @@ -184,7 +184,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $data = $response->get_data(); $keys = array_keys( $data['endpoints'][0]['args'] ); sort( $keys ); - $this->assertEquals( + $this->assertSame( array( 'context', 'exclude', @@ -210,7 +210,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'context', 'view' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $all_data = $response->get_data(); $data = $all_data[0]; @@ -225,7 +225,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'context', 'edit' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $all_data = $response->get_data(); $data = $all_data[0]; @@ -239,7 +239,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'context', 'edit' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 401, $response->get_status() ); + $this->assertSame( 401, $response->get_status() ); // Test with a user logged in but without sufficient capabilities; // capability in question: 'list_users'. @@ -249,7 +249,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'context', 'edit' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 403, $response->get_status() ); + $this->assertSame( 403, $response->get_status() ); } public function test_get_items_unauthenticated_includes_authors_of_post_types_shown_in_rest() { @@ -313,8 +313,8 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_users, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_users, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $next_link = add_query_arg( array( 'page' => 2, @@ -332,8 +332,8 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'page', 3 ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_users, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_users, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( 'page' => 2, @@ -354,8 +354,8 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'page', $total_pages ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_users, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_users, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( 'page' => $total_pages - 1, @@ -370,8 +370,8 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'page', 100 ); $response = rest_get_server()->dispatch( $request ); $headers = $response->get_headers(); - $this->assertEquals( $total_users, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); + $this->assertSame( $total_users, $headers['X-WP-Total'] ); + $this->assertSame( $total_pages, $headers['X-WP-TotalPages'] ); $prev_link = add_query_arg( array( 'page' => $total_pages, @@ -387,12 +387,12 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 10, count( $response->get_data() ) ); + $this->assertSame( 10, count( $response->get_data() ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'per_page', 5 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 5, count( $response->get_data() ) ); + $this->assertSame( 5, count( $response->get_data() ) ); } public function test_get_items_page() { @@ -402,7 +402,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'per_page', 5 ); $request->set_param( 'page', 2 ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 5, count( $response->get_data() ) ); + $this->assertSame( 5, count( $response->get_data() ) ); $prev_link = add_query_arg( array( 'per_page' => 5, @@ -427,7 +427,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'per_page', 1 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $high_id, $data[0]['id'] ); + $this->assertSame( $high_id, $data[0]['id'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'orderby', 'name' ); @@ -435,7 +435,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'per_page', 1 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $low_id, $data[0]['id'] ); + $this->assertSame( $low_id, $data[0]['id'] ); } public function test_get_items_orderby_url() { @@ -451,7 +451,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'include', array( $low_id, $high_id ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $high_id, $data[0]['id'] ); + $this->assertSame( $high_id, $data[0]['id'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'orderby', 'url' ); @@ -460,7 +460,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'include', array( $low_id, $high_id ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $low_id, $data[0]['id'] ); + $this->assertSame( $low_id, $data[0]['id'] ); } public function test_get_items_orderby_slug() { @@ -476,7 +476,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'include', array( $low_id, $high_id ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $high_id, $data[0]['id'] ); + $this->assertSame( $high_id, $data[0]['id'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'orderby', 'slug' ); @@ -485,7 +485,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'include', array( $low_id, $high_id ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $low_id, $data[0]['id'] ); + $this->assertSame( $low_id, $data[0]['id'] ); } public function test_get_items_orderby_slugs() { @@ -501,9 +501,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'taco', $data[0]['slug'] ); - $this->assertEquals( 'burrito', $data[1]['slug'] ); - $this->assertEquals( 'chalupa', $data[2]['slug'] ); + $this->assertSame( 'taco', $data[0]['slug'] ); + $this->assertSame( 'burrito', $data[1]['slug'] ); + $this->assertSame( 'chalupa', $data[2]['slug'] ); } public function test_get_items_orderby_email() { @@ -519,7 +519,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'include', array( $low_id, $high_id ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $high_id, $data[0]['id'] ); + $this->assertSame( $high_id, $data[0]['id'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'orderby', 'email' ); @@ -528,7 +528,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'include', array( $low_id, $high_id ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( $low_id, $data[0]['id'] ); + $this->assertSame( $low_id, $data[0]['id'] ); } public function test_get_items_orderby_email_unauthenticated() { @@ -598,15 +598,15 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'include', array( $id2, $id1 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( $id1, $data[0]['id'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( $id1, $data[0]['id'] ); // 'orderby' => 'include'. $request->set_param( 'orderby', 'include' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 2, count( $data ) ); - $this->assertEquals( $id2, $data[0]['id'] ); + $this->assertSame( 2, count( $data ) ); + $this->assertSame( $id2, $data[0]['id'] ); // Invalid 'include' should error. $request->set_param( 'include', 'invalid' ); @@ -618,7 +618,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { wp_set_current_user( 0 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 0, count( $data ) ); + $this->assertSame( 0, count( $data ) ); } @@ -655,14 +655,14 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'search', 'yololololo' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 0, count( $response->get_data() ) ); + $this->assertSame( 0, count( $response->get_data() ) ); $yolo_id = $this->factory->user->create( array( 'display_name' => 'yololololo' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'search', 'yololololo' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 1, count( $response->get_data() ) ); + $this->assertSame( 1, count( $response->get_data() ) ); // Default to wildcard search. $adam_id = $this->factory->user->create( array( @@ -675,8 +675,8 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'search', 'ada' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( $adam_id, $data[0]['id'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( $adam_id, $data[0]['id'] ); } public function test_get_items_slug_query() { @@ -699,8 +699,8 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'slug', 'foo' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( $id2, $data[0]['id'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( $id2, $data[0]['id'] ); } public function test_get_items_slug_array_query() { @@ -743,10 +743,10 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'orderby', 'slug' ); $request->set_param( 'order', 'asc' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $slugs = wp_list_pluck( $data, 'slug' ); - $this->assertEquals( array( 'burrito', 'enchilada', 'taco' ), $slugs ); + $this->assertSame( array( 'burrito', 'enchilada', 'taco' ), $slugs ); } public function test_get_items_slug_csv_query() { @@ -782,10 +782,10 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'orderby', 'slug' ); $request->set_param( 'order', 'desc' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $slugs = wp_list_pluck( $data, 'slug' ); - $this->assertEquals( array( 'taco', 'enchilada', 'burrito' ), $slugs ); + $this->assertSame( array( 'taco', 'enchilada', 'burrito' ), $slugs ); } /** @@ -812,15 +812,15 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'roles', 'author,subscriber' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 3, count( $data ) ); - $this->assertEquals( $tango, $data[1]['id'] ); - $this->assertEquals( $yolo, $data[2]['id'] ); + $this->assertSame( 3, count( $data ) ); + $this->assertSame( $tango, $data[1]['id'] ); + $this->assertSame( $yolo, $data[2]['id'] ); $request->set_param( 'roles', 'author' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( $yolo, $data[0]['id'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( $yolo, $data[0]['id'] ); wp_set_current_user( 0 ); @@ -849,15 +849,15 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'roles', 'ilovesteak,author' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 1, count( $data ) ); - $this->assertEquals( $lolz, $data[0]['id'] ); + $this->assertSame( 1, count( $data ) ); + $this->assertSame( $lolz, $data[0]['id'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'roles', 'steakisgood' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 0, count( $data ) ); - $this->assertEquals( array(), $data ); + $this->assertSame( 0, count( $data ) ); + $this->assertSame( array(), $data ); } public function test_get_items_who_author_query() { @@ -867,7 +867,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'search', 'subscriber' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertCount( 1, $response->get_data() ); // Second request should exclude subscriber. @@ -875,7 +875,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'who', 'authors' ); $request->set_param( 'search', 'subscriber' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->assertCount( 0, $response->get_data() ); } @@ -929,7 +929,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( '_fields', 'id,name' ); $user = get_user_by( 'id', get_current_user_id() ); $response = $this->endpoint->prepare_item_for_response( $user, $request ); - $this->assertEquals( + $this->assertSame( array( 'id', 'name', @@ -952,7 +952,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $user = get_user_by( 'id', self::$editor ); // Ignore the subdomain, since get_avatar_url() randomly sets // the Gravatar server when building the URL string. - $this->assertEquals( substr( get_avatar_url( $user->user_email ), 9 ), substr( $data['avatar_urls'][96], 9 ) ); + $this->assertSame( substr( get_avatar_url( $user->user_email ), 9 ), substr( $data['avatar_urls'][96], 9 ) ); } public function test_get_user_invalid_id() { @@ -1004,7 +1004,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { public function test_can_get_item_author_of_rest_true_public_true_unauthenticated() { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_true'] ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_can_get_item_author_of_rest_true_public_true_authenticated() { @@ -1012,13 +1012,13 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_true'] ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_can_get_item_author_of_rest_true_public_false() { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$authors['r_true_p_false'] ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_cannot_get_item_author_of_rest_false_public_true_unauthenticated() { @@ -1044,7 +1044,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { public function test_can_get_item_author_of_post() { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$editor ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_cannot_get_item_author_of_draft() { @@ -1084,7 +1084,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', $this->author_id ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 401, $response->get_status() ); + $this->assertSame( 401, $response->get_status() ); $this->post_id = $this->factory->post->create( array( @@ -1134,14 +1134,14 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/users/me' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $this->check_get_user_response( $response, 'view' ); $headers = $response->get_headers(); $this->assertArrayNotHasKey( 'Location', $headers ); $links = $response->get_links(); - $this->assertEquals( rest_url( 'wp/v2/users/' . self::$user ), $links['self'][0]['href'] ); + $this->assertSame( rest_url( 'wp/v2/users/' . self::$user ), $links['self'][0]['href'] ); } public function test_get_current_user_without_permission() { @@ -1175,8 +1175,8 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 'http://example.com', $data['url'] ); - $this->assertEquals( array( 'editor' ), $data['roles'] ); + $this->assertSame( 'http://example.com', $data['url'] ); + $this->assertSame( array( 'editor' ), $data['roles'] ); $this->check_add_edit_user_response( $response ); } @@ -1214,13 +1214,13 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $this->assertInternalType( 'array', $data['additional_errors'] ); $this->assertCount( 1, $data['additional_errors'] ); $error = $data['additional_errors'][0]; - $this->assertEquals( 'user_name', $error['code'] ); - $this->assertEquals( 'Usernames can only contain lowercase letters (a-z) and numbers.', $error['message'] ); + $this->assertSame( 'user_name', $error['code'] ); + $this->assertSame( 'Usernames can only contain lowercase letters (a-z) and numbers.', $error['message'] ); } else { $this->assertInternalType( 'array', $data['data']['params'] ); $errors = $data['data']['params']; $this->assertInternalType( 'string', $errors['username'] ); - $this->assertEquals( 'This username is invalid because it uses illegal characters. Please enter a valid username.', $errors['username'] ); + $this->assertSame( 'This username is invalid because it uses illegal characters. Please enter a valid username.', $errors['username'] ); } } @@ -1260,7 +1260,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $this->assertInternalType( 'array', $data['data']['params'] ); $errors = $data['data']['params']; $this->assertInternalType( 'string', $errors['username'] ); - $this->assertEquals( 'Sorry, that username is not allowed.', $errors['username'] ); + $this->assertSame( 'Sorry, that username is not allowed.', $errors['username'] ); } /** @@ -1388,9 +1388,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { // Check the code matches one we know. $this->assertContains( $error['code'], array( 'user_name', 'user_email' ) ); if ( 'user_name' === $error['code'] ) { - $this->assertEquals( 'Sorry, that username already exists!', $error['message'] ); + $this->assertSame( 'Sorry, that username already exists!', $error['message'] ); } else { - $this->assertEquals( 'Sorry, that email address is already used!', $error['message'] ); + $this->assertSame( 'Sorry, that email address is already used!', $error['message'] ); } } } @@ -1524,17 +1524,17 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { // Check that the name has been updated correctly. $new_data = $response->get_data(); - $this->assertEquals( 'New Name', $new_data['first_name'] ); + $this->assertSame( 'New Name', $new_data['first_name'] ); $user = get_userdata( $user_id ); - $this->assertEquals( 'New Name', $user->first_name ); + $this->assertSame( 'New Name', $user->first_name ); - $this->assertEquals( 'http://google.com', $new_data['url'] ); - $this->assertEquals( 'http://google.com', $user->user_url ); - $this->assertEquals( 'de_DE', $user->locale ); + $this->assertSame( 'http://google.com', $new_data['url'] ); + $this->assertSame( 'http://google.com', $user->user_url ); + $this->assertSame( 'de_DE', $user->locale ); // Check that we haven't inadvertently changed the user's password, // as per https://core.trac.wordpress.org/ticket/21429 - $this->assertEquals( $pw_before, $user->user_pass ); + $this->assertSame( $pw_before, $user->user_pass ); } public function test_update_item_no_change() { @@ -1550,10 +1550,10 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { // Run twice to make sure that the update still succeeds // even if no DB rows are updated. $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } public function test_update_item_existing_email() { @@ -1578,7 +1578,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'email', 'testjson@example.com' ); $response = rest_get_server()->dispatch( $request ); $this->assertInstanceOf( 'WP_Error', $response->as_error() ); - $this->assertEquals( 'rest_user_invalid_email', $response->as_error()->get_error_code() ); + $this->assertSame( 'rest_user_invalid_email', $response->as_error()->get_error_code() ); } /** @@ -1596,8 +1596,8 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( $updated_email_with_case_change, $data['email'] ); + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( $updated_email_with_case_change, $data['email'] ); } /** @@ -1616,7 +1616,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertEquals( 400, $response->get_status() ); + $this->assertSame( 400, $response->get_status() ); $this->assertSame( 'rest_user_invalid_email', $data['code'] ); } @@ -1636,7 +1636,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'locale', 'klingon' ); $response = rest_get_server()->dispatch( $request ); $this->assertInstanceOf( 'WP_Error', $response->as_error() ); - $this->assertEquals( 'rest_invalid_param', $response->as_error()->get_error_code() ); + $this->assertSame( 'rest_invalid_param', $response->as_error()->get_error_code() ); } public function test_update_item_en_US_locale() { @@ -1657,7 +1657,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $this->check_add_edit_user_response( $response, true ); $user = get_userdata( $user_id ); - $this->assertEquals( 'en_US', $user->locale ); + $this->assertSame( 'en_US', $user->locale ); } /** @@ -1682,9 +1682,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $this->check_add_edit_user_response( $response, true ); $data = $response->get_data(); - $this->assertEquals( get_locale(), $data['locale'] ); + $this->assertSame( get_locale(), $data['locale'] ); $user = get_userdata( $user_id ); - $this->assertEquals( '', $user->locale ); + $this->assertSame( '', $user->locale ); } public function test_update_item_username_attempt() { @@ -1709,7 +1709,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'username', 'test_json_user' ); $response = rest_get_server()->dispatch( $request ); $this->assertInstanceOf( 'WP_Error', $response->as_error() ); - $this->assertEquals( 'rest_user_invalid_argument', $response->as_error()->get_error_code() ); + $this->assertSame( 'rest_user_invalid_argument', $response->as_error()->get_error_code() ); } public function test_update_item_existing_nicename() { @@ -1734,7 +1734,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'slug', 'test_json_user' ); $response = rest_get_server()->dispatch( $request ); $this->assertInstanceOf( 'WP_Error', $response->as_error() ); - $this->assertEquals( 'rest_user_invalid_slug', $response->as_error()->get_error_code() ); + $this->assertSame( 'rest_user_invalid_slug', $response->as_error()->get_error_code() ); } public function test_json_update_user() { @@ -1771,15 +1771,15 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { // Check that the name has been updated correctly. $new_data = $response->get_data(); - $this->assertEquals( 'JSON Name', $new_data['first_name'] ); - $this->assertEquals( 'New Last', $new_data['last_name'] ); + $this->assertSame( 'JSON Name', $new_data['first_name'] ); + $this->assertSame( 'New Last', $new_data['last_name'] ); $user = get_userdata( $user_id ); - $this->assertEquals( 'JSON Name', $user->first_name ); - $this->assertEquals( 'New Last', $user->last_name ); + $this->assertSame( 'JSON Name', $user->first_name ); + $this->assertSame( 'New Last', $user->last_name ); // Check that we haven't inadvertently changed the user's password, // as per https://core.trac.wordpress.org/ticket/21429 - $this->assertEquals( $pw_before, $user->user_pass ); + $this->assertSame( $pw_before, $user->user_pass ); } public function test_update_user_role() { @@ -1795,7 +1795,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $new_data = $response->get_data(); - $this->assertEquals( 'editor', $new_data['roles'][0] ); + $this->assertSame( 'editor', $new_data['roles'][0] ); $this->assertNotEquals( 'administrator', $new_data['roles'][0] ); $user = get_userdata( $user_id ); @@ -1816,7 +1816,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $new_data = $response->get_data(); - $this->assertEquals( array( 'author', 'editor' ), $new_data['roles'] ); + $this->assertSame( array( 'author', 'editor' ), $new_data['roles'] ); $user = get_userdata( $user_id ); $this->assertArrayHasKey( 'author', $user->caps ); @@ -1890,7 +1890,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( 'editor', $new_data['roles'][0] ); + $this->assertSame( 'editor', $new_data['roles'][0] ); $this->assertNotEquals( 'administrator', $new_data['roles'][0] ); $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); @@ -1904,7 +1904,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $new_data = $response->get_data(); - $this->assertEquals( 'editor', $new_data['roles'][0] ); + $this->assertSame( 'editor', $new_data['roles'][0] ); $this->assertNotEquals( 'administrator', $new_data['roles'][0] ); } @@ -2012,10 +2012,10 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', $user_id ) ); $request->set_param( 'roles', array( 'editor' ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $new_data = $response->get_data(); - $this->assertEquals( 'editor', $new_data['roles'][0] ); + $this->assertSame( 'editor', $new_data['roles'][0] ); } /** @@ -2044,10 +2044,10 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { */ $this->assertErrorResponse( 'rest_cannot_edit', $response, 403 ); } else { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $new_data = $response->get_data(); - $this->assertEquals( 'editor', $new_data['roles'][0] ); + $this->assertSame( 'editor', $new_data['roles'][0] ); } } @@ -2078,27 +2078,27 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { } $request->set_param( 'email', 'cbg@androidsdungeon.com' ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); $actual_output = $response->get_data(); // Compare expected API output to actual API output. - $this->assertEquals( $expected_output['username'], $actual_output['username'] ); - $this->assertEquals( $expected_output['name'], $actual_output['name'] ); - $this->assertEquals( $expected_output['first_name'], $actual_output['first_name'] ); - $this->assertEquals( $expected_output['last_name'], $actual_output['last_name'] ); - $this->assertEquals( $expected_output['url'], $actual_output['url'] ); - $this->assertEquals( $expected_output['description'], $actual_output['description'] ); - $this->assertEquals( $expected_output['nickname'], $actual_output['nickname'] ); + $this->assertSame( $expected_output['username'], $actual_output['username'] ); + $this->assertSame( $expected_output['name'], $actual_output['name'] ); + $this->assertSame( $expected_output['first_name'], $actual_output['first_name'] ); + $this->assertSame( $expected_output['last_name'], $actual_output['last_name'] ); + $this->assertSame( $expected_output['url'], $actual_output['url'] ); + $this->assertSame( $expected_output['description'], $actual_output['description'] ); + $this->assertSame( $expected_output['nickname'], $actual_output['nickname'] ); // Compare expected API output to WP internal values. $user = get_userdata( $actual_output['id'] ); - $this->assertEquals( $expected_output['username'], $user->user_login ); - $this->assertEquals( $expected_output['name'], $user->display_name ); - $this->assertEquals( $expected_output['first_name'], $user->first_name ); - $this->assertEquals( $expected_output['last_name'], $user->last_name ); - $this->assertEquals( $expected_output['url'], $user->user_url ); - $this->assertEquals( $expected_output['description'], $user->description ); - $this->assertEquals( $expected_output['nickname'], $user->nickname ); + $this->assertSame( $expected_output['username'], $user->user_login ); + $this->assertSame( $expected_output['name'], $user->display_name ); + $this->assertSame( $expected_output['first_name'], $user->first_name ); + $this->assertSame( $expected_output['last_name'], $user->last_name ); + $this->assertSame( $expected_output['url'], $user->user_url ); + $this->assertSame( $expected_output['description'], $user->description ); + $this->assertSame( $expected_output['nickname'], $user->nickname ); $this->assertTrue( wp_check_password( addslashes( $expected_output['password'] ), $user->user_pass ) ); $user_id = $actual_output['id']; @@ -2112,38 +2112,38 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { } } $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $actual_output = $response->get_data(); // Compare expected API output to actual API output. if ( isset( $expected_output['username'] ) ) { - $this->assertEquals( $expected_output['username'], $actual_output['username'] ); + $this->assertSame( $expected_output['username'], $actual_output['username'] ); } - $this->assertEquals( $expected_output['name'], $actual_output['name'] ); - $this->assertEquals( $expected_output['first_name'], $actual_output['first_name'] ); - $this->assertEquals( $expected_output['last_name'], $actual_output['last_name'] ); - $this->assertEquals( $expected_output['url'], $actual_output['url'] ); - $this->assertEquals( $expected_output['description'], $actual_output['description'] ); - $this->assertEquals( $expected_output['nickname'], $actual_output['nickname'] ); + $this->assertSame( $expected_output['name'], $actual_output['name'] ); + $this->assertSame( $expected_output['first_name'], $actual_output['first_name'] ); + $this->assertSame( $expected_output['last_name'], $actual_output['last_name'] ); + $this->assertSame( $expected_output['url'], $actual_output['url'] ); + $this->assertSame( $expected_output['description'], $actual_output['description'] ); + $this->assertSame( $expected_output['nickname'], $actual_output['nickname'] ); // Compare expected API output to WP internal values. $user = get_userdata( $actual_output['id'] ); if ( isset( $expected_output['username'] ) ) { - $this->assertEquals( $expected_output['username'], $user->user_login ); + $this->assertSame( $expected_output['username'], $user->user_login ); } - $this->assertEquals( $expected_output['name'], $user->display_name ); - $this->assertEquals( $expected_output['first_name'], $user->first_name ); - $this->assertEquals( $expected_output['last_name'], $user->last_name ); - $this->assertEquals( $expected_output['url'], $user->user_url ); - $this->assertEquals( $expected_output['description'], $user->description ); - $this->assertEquals( $expected_output['nickname'], $user->nickname ); + $this->assertSame( $expected_output['name'], $user->display_name ); + $this->assertSame( $expected_output['first_name'], $user->first_name ); + $this->assertSame( $expected_output['last_name'], $user->last_name ); + $this->assertSame( $expected_output['url'], $user->user_url ); + $this->assertSame( $expected_output['description'], $user->description ); + $this->assertSame( $expected_output['nickname'], $user->nickname ); $this->assertTrue( wp_check_password( addslashes( $expected_output['password'] ), $user->user_pass ) ); } public function test_user_roundtrip_as_editor() { wp_set_current_user( self::$editor ); - $this->assertEquals( ! is_multisite(), current_user_can( 'unfiltered_html' ) ); + $this->assertSame( ! is_multisite(), current_user_can( 'unfiltered_html' ) ); $this->verify_user_roundtrip( array( 'id' => self::$editor, @@ -2296,10 +2296,10 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { return; } - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertTrue( $data['deleted'] ); - $this->assertEquals( 'Deleted User', $data['previous']['name'] ); + $this->assertSame( 'Deleted User', $data['previous']['name'] ); } public function test_delete_item_no_trash() { @@ -2355,10 +2355,10 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { return; } - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertTrue( $data['deleted'] ); - $this->assertEquals( 'Deleted User', $data['previous']['name'] ); + $this->assertSame( 'Deleted User', $data['previous']['name'] ); } public function test_delete_current_item_no_trash() { @@ -2459,7 +2459,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { return; } - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); // Check that the post has been updated correctly. $post = get_post( $test_post ); @@ -2527,7 +2527,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { } $test_post = get_post( $test_post ); - $this->assertEquals( 'trash', $test_post->post_status ); + $this->assertSame( 'trash', $test_post->post_status ); } public function test_delete_user_reassign_passed_as_string_false_trashes_post() { @@ -2555,7 +2555,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { } $test_post = get_post( $test_post ); - $this->assertEquals( 'trash', $test_post->post_status ); + $this->assertSame( 'trash', $test_post->post_status ); } public function test_delete_user_reassign_passed_as_empty_string_trashes_post() { @@ -2583,7 +2583,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { } $test_post = get_post( $test_post ); - $this->assertEquals( 'trash', $test_post->post_status ); + $this->assertSame( 'trash', $test_post->post_status ); } public function test_delete_user_reassign_passed_as_0_reassigns_author() { @@ -2620,7 +2620,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertEquals( 19, count( $properties ) ); + $this->assertSame( 19, count( $properties ) ); $this->assertArrayHasKey( 'avatar_urls', $properties ); $this->assertArrayHasKey( 'capabilities', $properties ); $this->assertArrayHasKey( 'description', $properties ); @@ -2684,7 +2684,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $data = $response->get_data(); $this->assertArrayHasKey( 'my_custom_int', $data['schema']['properties'] ); - $this->assertEquals( $schema, $data['schema']['properties']['my_custom_int'] ); + $this->assertSame( $schema, $data['schema']['properties']['my_custom_int'] ); wp_set_current_user( 1 ); @@ -2909,14 +2909,14 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/users/%d', self::$user ) ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); $meta = (array) $data['meta']; $this->assertArrayHasKey( $meta_key, $meta ); - $this->assertEquals( $expected, $meta[ $meta_key ] ); + $this->assertSame( $expected, $meta[ $meta_key ] ); } public function data_get_default_data() { @@ -3021,25 +3021,25 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { } protected function check_user_data( $user, $data, $context, $links ) { - $this->assertEquals( $user->ID, $data['id'] ); - $this->assertEquals( $user->display_name, $data['name'] ); - $this->assertEquals( $user->user_url, $data['url'] ); - $this->assertEquals( $user->description, $data['description'] ); - $this->assertEquals( get_author_posts_url( $user->ID ), $data['link'] ); + $this->assertSame( $user->ID, $data['id'] ); + $this->assertSame( $user->display_name, $data['name'] ); + $this->assertSame( $user->user_url, $data['url'] ); + $this->assertSame( $user->description, $data['description'] ); + $this->assertSame( get_author_posts_url( $user->ID ), $data['link'] ); $this->assertArrayHasKey( 'avatar_urls', $data ); - $this->assertEquals( $user->user_nicename, $data['slug'] ); + $this->assertSame( $user->user_nicename, $data['slug'] ); if ( 'edit' === $context ) { - $this->assertEquals( $user->first_name, $data['first_name'] ); - $this->assertEquals( $user->last_name, $data['last_name'] ); - $this->assertEquals( $user->nickname, $data['nickname'] ); - $this->assertEquals( $user->user_email, $data['email'] ); + $this->assertSame( $user->first_name, $data['first_name'] ); + $this->assertSame( $user->last_name, $data['last_name'] ); + $this->assertSame( $user->nickname, $data['nickname'] ); + $this->assertSame( $user->user_email, $data['email'] ); $this->assertEquals( (object) $user->allcaps, $data['capabilities'] ); $this->assertEquals( (object) $user->caps, $data['extra_capabilities'] ); - $this->assertEquals( gmdate( 'c', strtotime( $user->user_registered ) ), $data['registered_date'] ); - $this->assertEquals( $user->user_login, $data['username'] ); - $this->assertEquals( $user->roles, $data['roles'] ); - $this->assertEquals( get_user_locale( $user ), $data['locale'] ); + $this->assertSame( gmdate( 'c', strtotime( $user->user_registered ) ), $data['registered_date'] ); + $this->assertSame( $user->user_login, $data['username'] ); + $this->assertSame( $user->roles, $data['roles'] ); + $this->assertSame( get_user_locale( $user ), $data['locale'] ); } if ( 'edit' !== $context ) { @@ -3067,7 +3067,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { } protected function check_get_user_response( $response, $context = 'view' ) { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $userdata = get_userdata( $data['id'] ); @@ -3076,9 +3076,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { protected function check_add_edit_user_response( $response, $update = false ) { if ( $update ) { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } else { - $this->assertEquals( 201, $response->get_status() ); + $this->assertSame( 201, $response->get_status() ); } $data = $response->get_data(); diff --git a/tests/phpunit/tests/rewrite.php b/tests/phpunit/tests/rewrite.php index c6ddedd914..0b653f9d28 100644 --- a/tests/phpunit/tests/rewrite.php +++ b/tests/phpunit/tests/rewrite.php @@ -88,20 +88,20 @@ class Tests_Rewrite extends WP_UnitTestCase { function test_url_to_postid() { $id = self::factory()->post->create(); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); $id = self::factory()->post->create( array( 'post_type' => 'page' ) ); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); } function test_url_to_postid_set_url_scheme_https_to_http() { $post_id = self::factory()->post->create(); $permalink = get_permalink( $post_id ); - $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); + $this->assertSame( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); $post_id = self::factory()->post->create( array( 'post_type' => 'page' ) ); $permalink = get_permalink( $post_id ); - $this->assertEquals( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); + $this->assertSame( $post_id, url_to_postid( set_url_scheme( $permalink, 'https' ) ) ); } function test_url_to_postid_set_url_scheme_http_to_https() { @@ -115,8 +115,8 @@ class Tests_Rewrite extends WP_UnitTestCase { $page_permalink = get_permalink( $page_id ); $page_url_to_id = url_to_postid( set_url_scheme( $page_permalink, 'http' ) ); - $this->assertEquals( $post_id, $post_url_to_id ); - $this->assertEquals( $page_id, $page_url_to_id ); + $this->assertSame( $post_id, $post_url_to_id ); + $this->assertSame( $page_id, $page_url_to_id ); } /** @@ -148,7 +148,7 @@ class Tests_Rewrite extends WP_UnitTestCase { $this->assertSame( 'https', parse_url( $network_home, PHP_URL_SCHEME ) ); // Test that the url_to_postid() call matched. - $this->assertEquals( $post_id, $url_to_postid ); + $this->assertSame( $post_id, $url_to_postid ); } /** @@ -177,7 +177,7 @@ class Tests_Rewrite extends WP_UnitTestCase { register_post_type( $post_type, array( 'public' => true ) ); $id = self::factory()->post->create( array( 'post_type' => $post_type ) ); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); _unregister_post_type( $post_type ); } @@ -198,8 +198,8 @@ class Tests_Rewrite extends WP_UnitTestCase { ) ); - $this->assertEquals( $parent_id, url_to_postid( get_permalink( $parent_id ) ) ); - $this->assertEquals( $child_id, url_to_postid( get_permalink( $child_id ) ) ); + $this->assertSame( $parent_id, url_to_postid( get_permalink( $parent_id ) ) ); + $this->assertSame( $child_id, url_to_postid( get_permalink( $child_id ) ) ); } function test_url_to_postid_hierarchical_with_matching_leaves() { @@ -239,10 +239,10 @@ class Tests_Rewrite extends WP_UnitTestCase { ) ); - $this->assertEquals( home_url( 'parent/child1/grandchild/' ), get_permalink( $grandchild_id_1 ) ); - $this->assertEquals( home_url( 'parent/child2/grandchild/' ), get_permalink( $grandchild_id_2 ) ); - $this->assertEquals( $grandchild_id_1, url_to_postid( get_permalink( $grandchild_id_1 ) ) ); - $this->assertEquals( $grandchild_id_2, url_to_postid( get_permalink( $grandchild_id_2 ) ) ); + $this->assertSame( home_url( 'parent/child1/grandchild/' ), get_permalink( $grandchild_id_1 ) ); + $this->assertSame( home_url( 'parent/child2/grandchild/' ), get_permalink( $grandchild_id_2 ) ); + $this->assertSame( $grandchild_id_1, url_to_postid( get_permalink( $grandchild_id_1 ) ) ); + $this->assertSame( $grandchild_id_2, url_to_postid( get_permalink( $grandchild_id_2 ) ) ); } function test_url_to_postid_home_has_path() { @@ -256,16 +256,16 @@ class Tests_Rewrite extends WP_UnitTestCase { 'post_name' => 'examp', ) ); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); - $this->assertEquals( $id, url_to_postid( site_url( '/example/examp' ) ) ); - $this->assertEquals( $id, url_to_postid( '/example/examp/' ) ); - $this->assertEquals( $id, url_to_postid( '/example/examp' ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( site_url( '/example/examp' ) ) ); + $this->assertSame( $id, url_to_postid( '/example/examp/' ) ); + $this->assertSame( $id, url_to_postid( '/example/examp' ) ); - $this->assertEquals( 0, url_to_postid( site_url( '/example/ex' ) ) ); - $this->assertEquals( 0, url_to_postid( '/example/ex' ) ); - $this->assertEquals( 0, url_to_postid( '/example/ex/' ) ); - $this->assertEquals( 0, url_to_postid( '/example-page/example/' ) ); - $this->assertEquals( 0, url_to_postid( '/example-page/ex/' ) ); + $this->assertSame( 0, url_to_postid( site_url( '/example/ex' ) ) ); + $this->assertSame( 0, url_to_postid( '/example/ex' ) ); + $this->assertSame( 0, url_to_postid( '/example/ex/' ) ); + $this->assertSame( 0, url_to_postid( '/example-page/example/' ) ); + $this->assertSame( 0, url_to_postid( '/example-page/ex/' ) ); } /** @@ -276,10 +276,10 @@ class Tests_Rewrite extends WP_UnitTestCase { update_option( 'home', $home_url ); $this->go_to( $home_url ); - $this->assertEquals( array(), $GLOBALS['wp']->query_vars ); + $this->assertSame( array(), $GLOBALS['wp']->query_vars ); $this->go_to( $home_url . 'page' ); - $this->assertEquals( + $this->assertSame( array( 'page' => '', 'pagename' => 'page', @@ -297,10 +297,10 @@ class Tests_Rewrite extends WP_UnitTestCase { update_option( 'home', $home_url ); $this->go_to( $home_url ); - $this->assertEquals( array(), $GLOBALS['wp']->query_vars ); + $this->assertSame( array(), $GLOBALS['wp']->query_vars ); $this->go_to( $home_url . 'page' ); - $this->assertEquals( + $this->assertSame( array( 'page' => '', 'pagename' => 'page', @@ -316,7 +316,7 @@ class Tests_Rewrite extends WP_UnitTestCase { ), $GLOBALS['wp']->query_vars ); - $this->assertEquals( + $this->assertSame( array( 'page' => '', 'pagename' => 'match/page', @@ -337,7 +337,7 @@ class Tests_Rewrite extends WP_UnitTestCase { _unregister_post_type( 'foo' ); - $this->assertEquals( array(), $GLOBALS['wp']->query_vars ); + $this->assertSame( array(), $GLOBALS['wp']->query_vars ); } function test_url_to_postid_dupe_path() { @@ -351,10 +351,10 @@ class Tests_Rewrite extends WP_UnitTestCase { ) ); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); - $this->assertEquals( $id, url_to_postid( site_url( '/example/example/' ) ) ); - $this->assertEquals( $id, url_to_postid( '/example/example/' ) ); - $this->assertEquals( $id, url_to_postid( '/example/example' ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( site_url( '/example/example/' ) ) ); + $this->assertSame( $id, url_to_postid( '/example/example/' ) ); + $this->assertSame( $id, url_to_postid( '/example/example' ) ); } /** @@ -373,7 +373,7 @@ class Tests_Rewrite extends WP_UnitTestCase { // This url should NOT return a post ID. $badurl = site_url( '/example-collision' ); - $this->assertEquals( 0, url_to_postid( $badurl ) ); + $this->assertSame( 0, url_to_postid( $badurl ) ); } /** @@ -394,7 +394,7 @@ class Tests_Rewrite extends WP_UnitTestCase { // This url should NOT return a post ID. $badurl = network_home_url( '/example-collision' ); - $this->assertEquals( 0, url_to_postid( $badurl ) ); + $this->assertSame( 0, url_to_postid( $badurl ) ); restore_current_blog(); } @@ -413,7 +413,7 @@ class Tests_Rewrite extends WP_UnitTestCase { ); $post_id = self::factory()->post->create( array( 'post_title' => get_post( $page_id )->post_title ) ); - $this->assertEquals( $post_id, url_to_postid( get_permalink( $post_id ) ) ); + $this->assertSame( $post_id, url_to_postid( get_permalink( $post_id ) ) ); } /** diff --git a/tests/phpunit/tests/rewrite/numericSlugs.php b/tests/phpunit/tests/rewrite/numericSlugs.php index 2cf315f0d0..98f1368d42 100644 --- a/tests/phpunit/tests/rewrite/numericSlugs.php +++ b/tests/phpunit/tests/rewrite/numericSlugs.php @@ -75,7 +75,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { array( 'ID' => $id ) ); - $this->assertEquals( '2015', url_to_postid( get_permalink( '2015' ) ) ); + $this->assertSame( 2015, url_to_postid( get_permalink( '2015' ) ) ); } public function test_go_to_year_segment_collision_with_title() { @@ -109,7 +109,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { ) ); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); } public function test_go_to_month_segment_collision_without_title() { @@ -145,7 +145,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { ) ); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); } public function test_go_to_month_segment_collision_without_title_no_leading_zero() { @@ -181,7 +181,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { ) ); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); } public function test_go_to_month_segment_collision_with_title() { @@ -215,7 +215,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { ) ); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); } public function test_go_to_month_segment_collision_with_title_no_leading_zero() { @@ -249,7 +249,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { ) ); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); } public function test_go_to_day_segment_collision_without_title() { @@ -285,7 +285,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { ) ); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); } public function test_go_to_day_segment_collision_with_title() { @@ -319,7 +319,7 @@ class Tests_Rewrite_NumericSlugs extends WP_UnitTestCase { ) ); - $this->assertEquals( $id, url_to_postid( get_permalink( $id ) ) ); + $this->assertSame( $id, url_to_postid( get_permalink( $id ) ) ); } public function test_numeric_slug_permalink_conflicts_should_only_be_resolved_for_the_main_query() { diff --git a/tests/phpunit/tests/rewrite/oldSlugRedirect.php b/tests/phpunit/tests/rewrite/oldSlugRedirect.php index afc8865348..2bd27398ad 100644 --- a/tests/phpunit/tests/rewrite/oldSlugRedirect.php +++ b/tests/phpunit/tests/rewrite/oldSlugRedirect.php @@ -51,7 +51,7 @@ class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase { $this->go_to( $old_permalink ); wp_old_slug_redirect(); - $this->assertEquals( $permalink, $this->old_slug_redirect_url ); + $this->assertSame( $permalink, $this->old_slug_redirect_url ); } public function test_old_slug_redirect_attachment() { @@ -92,7 +92,7 @@ class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase { $this->go_to( $old_permalink ); wp_old_slug_redirect(); - $this->assertEquals( $permalink, $this->old_slug_redirect_url ); + $this->assertSame( $permalink, $this->old_slug_redirect_url ); } public function test_old_slug_redirect_paged() { @@ -116,7 +116,7 @@ class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase { $this->go_to( $old_permalink ); wp_old_slug_redirect(); - $this->assertEquals( $permalink, $this->old_slug_redirect_url ); + $this->assertSame( $permalink, $this->old_slug_redirect_url ); } /** @@ -141,7 +141,7 @@ class Tests_Rewrite_OldSlugRedirect extends WP_UnitTestCase { $permalink = user_trailingslashit( get_permalink( $new_post_id ) ); - $this->assertEquals( $old_permalink, $permalink ); + $this->assertSame( $old_permalink, $permalink ); $this->go_to( $old_permalink ); wp_old_slug_redirect(); diff --git a/tests/phpunit/tests/shortcode.php b/tests/phpunit/tests/shortcode.php index ab9d4ef57f..ec53317af4 100644 --- a/tests/phpunit/tests/shortcode.php +++ b/tests/phpunit/tests/shortcode.php @@ -97,19 +97,19 @@ class Tests_Shortcode extends WP_UnitTestCase { function test_noatts() { do_shortcode( '[test-shortcode-tag /]' ); - $this->assertEquals( '', $this->atts ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( '', $this->atts ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_one_att() { do_shortcode( '[test-shortcode-tag foo="asdf" /]' ); - $this->assertEquals( array( 'foo' => 'asdf' ), $this->atts ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( array( 'foo' => 'asdf' ), $this->atts ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_not_a_tag() { $out = do_shortcode( '[not-a-shortcode-tag]' ); - $this->assertEquals( '[not-a-shortcode-tag]', $out ); + $this->assertSame( '[not-a-shortcode-tag]', $out ); } /** @@ -117,28 +117,28 @@ class Tests_Shortcode extends WP_UnitTestCase { */ function test_tag_hyphen_not_tag() { $out = do_shortcode( '[dumptag-notreal]' ); - $this->assertEquals( '[dumptag-notreal]', $out ); + $this->assertSame( '[dumptag-notreal]', $out ); } function test_tag_underscore_not_tag() { $out = do_shortcode( '[dumptag_notreal]' ); - $this->assertEquals( '[dumptag_notreal]', $out ); + $this->assertSame( '[dumptag_notreal]', $out ); } function test_tag_not_tag() { $out = do_shortcode( '[dumptagnotreal]' ); - $this->assertEquals( '[dumptagnotreal]', $out ); + $this->assertSame( '[dumptagnotreal]', $out ); } /** * @ticket 17657 */ function test_tag_hyphen() { - $this->assertEquals( '_shortcode_hyphen', do_shortcode( '[hyphen]' ) ); - $this->assertEquals( '_shortcode_hyphen_foo', do_shortcode( '[hyphen-foo]' ) ); - $this->assertEquals( '_shortcode_hyphen_foo_bar', do_shortcode( '[hyphen-foo-bar]' ) ); - $this->assertEquals( '[hyphen-baz]', do_shortcode( '[hyphen-baz]' ) ); - $this->assertEquals( '[hyphen-foo-bar-baz]', do_shortcode( '[hyphen-foo-bar-baz]' ) ); + $this->assertSame( '_shortcode_hyphen', do_shortcode( '[hyphen]' ) ); + $this->assertSame( '_shortcode_hyphen_foo', do_shortcode( '[hyphen-foo]' ) ); + $this->assertSame( '_shortcode_hyphen_foo_bar', do_shortcode( '[hyphen-foo-bar]' ) ); + $this->assertSame( '[hyphen-baz]', do_shortcode( '[hyphen-baz]' ) ); + $this->assertSame( '[hyphen-foo-bar-baz]', do_shortcode( '[hyphen-foo-bar-baz]' ) ); } /** @@ -156,86 +156,86 @@ class Tests_Shortcode extends WP_UnitTestCase { '-foo-bar-baz' => '-foo-bar-baz', 'foo--bar' => 'foo--bar', ); - $this->assertEquals( $expected_attrs, $this->atts ); + $this->assertSame( $expected_attrs, $this->atts ); } function test_two_atts() { do_shortcode( '[test-shortcode-tag foo="asdf" bar="bing" /]' ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'asdf', 'bar' => 'bing', ), $this->atts ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_noatts_enclosing() { do_shortcode( '[test-shortcode-tag]content[/test-shortcode-tag]' ); - $this->assertEquals( '', $this->atts ); - $this->assertEquals( 'content', $this->content ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( '', $this->atts ); + $this->assertSame( 'content', $this->content ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_one_att_enclosing() { do_shortcode( '[test-shortcode-tag foo="bar"]content[/test-shortcode-tag]' ); - $this->assertEquals( array( 'foo' => 'bar' ), $this->atts ); - $this->assertEquals( 'content', $this->content ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( array( 'foo' => 'bar' ), $this->atts ); + $this->assertSame( 'content', $this->content ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_two_atts_enclosing() { do_shortcode( '[test-shortcode-tag foo="bar" baz="bing"]content[/test-shortcode-tag]' ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'bar', 'baz' => 'bing', ), $this->atts ); - $this->assertEquals( 'content', $this->content ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( 'content', $this->content ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_unclosed() { $out = do_shortcode( '[test-shortcode-tag]' ); - $this->assertEquals( '', $out ); - $this->assertEquals( '', $this->atts ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( '', $out ); + $this->assertSame( '', $this->atts ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_positional_atts_num() { $out = do_shortcode( '[test-shortcode-tag 123]' ); - $this->assertEquals( '', $out ); - $this->assertEquals( array( 0 => '123' ), $this->atts ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( '', $out ); + $this->assertSame( array( 0 => '123' ), $this->atts ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_positional_atts_url() { $out = do_shortcode( '[test-shortcode-tag http://www.youtube.com/watch?v=eBGIQ7ZuuiU]' ); - $this->assertEquals( '', $out ); - $this->assertEquals( array( 0 => 'http://www.youtube.com/watch?v=eBGIQ7ZuuiU' ), $this->atts ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( '', $out ); + $this->assertSame( array( 0 => 'http://www.youtube.com/watch?v=eBGIQ7ZuuiU' ), $this->atts ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_positional_atts_quotes() { $out = do_shortcode( '[test-shortcode-tag "something in quotes" "something else"]' ); - $this->assertEquals( '', $out ); - $this->assertEquals( + $this->assertSame( '', $out ); + $this->assertSame( array( 0 => 'something in quotes', 1 => 'something else', ), $this->atts ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_positional_atts_mixed() { $out = do_shortcode( '[test-shortcode-tag 123 https://wordpress.org/ 0 "foo" bar]' ); - $this->assertEquals( '', $out ); - $this->assertEquals( + $this->assertSame( '', $out ); + $this->assertSame( array( 0 => '123', 1 => 'https://wordpress.org/', @@ -245,13 +245,13 @@ class Tests_Shortcode extends WP_UnitTestCase { ), $this->atts ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_positional_and_named_atts() { $out = do_shortcode( '[test-shortcode-tag 123 url=https://wordpress.org/ foo bar="baz"]' ); - $this->assertEquals( '', $out ); - $this->assertEquals( + $this->assertSame( '', $out ); + $this->assertSame( array( 0 => '123', 'url' => 'https://wordpress.org/', @@ -260,24 +260,24 @@ class Tests_Shortcode extends WP_UnitTestCase { ), $this->atts ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } function test_footag_default() { $out = do_shortcode( '[footag]' ); - $this->assertEquals( 'foo = ', $out ); + $this->assertSame( 'foo = ', $out ); } function test_footag_val() { $val = rand_str(); $out = do_shortcode( '[footag foo="' . $val . '"]' ); - $this->assertEquals( 'foo = ' . $val, $out ); + $this->assertSame( 'foo = ' . $val, $out ); } function test_nested_tags() { $out = do_shortcode( '[baztag][dumptag abc="foo" def=123 https://wordpress.org/][/baztag]' ); $expected = "content = abc = foo\ndef = 123\n0 = https://wordpress.org\n"; - $this->assertEquals( $expected, $out ); + $this->assertSame( $expected, $out ); } /** @@ -285,35 +285,35 @@ class Tests_Shortcode extends WP_UnitTestCase { */ function test_tag_escaped() { $out = do_shortcode( '[[footag]] [[bartag foo="bar"]]' ); - $this->assertEquals( '[footag] [bartag foo="bar"]', $out ); + $this->assertSame( '[footag] [bartag foo="bar"]', $out ); $out = do_shortcode( '[[footag /]] [[bartag foo="bar" /]]' ); - $this->assertEquals( '[footag /] [bartag foo="bar" /]', $out ); + $this->assertSame( '[footag /] [bartag foo="bar" /]', $out ); $out = do_shortcode( '[[baztag foo="bar"]the content[/baztag]]' ); - $this->assertEquals( '[baztag foo="bar"]the content[/baztag]', $out ); + $this->assertSame( '[baztag foo="bar"]the content[/baztag]', $out ); // Double escaped. $out = do_shortcode( '[[[footag]]] [[[bartag foo="bar"]]]' ); - $this->assertEquals( '[[footag]] [[bartag foo="bar"]]', $out ); + $this->assertSame( '[[footag]] [[bartag foo="bar"]]', $out ); } function test_tag_not_escaped() { // These have square brackets on either end but aren't actually escaped. $out = do_shortcode( '[[footag] [bartag foo="bar"]]' ); - $this->assertEquals( '[foo = foo = bar]', $out ); + $this->assertSame( '[foo = foo = bar]', $out ); $out = do_shortcode( '[[footag /] [bartag foo="bar" /]]' ); - $this->assertEquals( '[foo = foo = bar]', $out ); + $this->assertSame( '[foo = foo = bar]', $out ); $out = do_shortcode( '[[baztag foo="bar"]the content[/baztag]' ); - $this->assertEquals( '[content = the content', $out ); + $this->assertSame( '[content = the content', $out ); $out = do_shortcode( '[[not-a-tag]]' ); - $this->assertEquals( '[[not-a-tag]]', $out ); + $this->assertSame( '[[not-a-tag]]', $out ); $out = do_shortcode( '[[[footag] [bartag foo="bar"]]]' ); - $this->assertEquals( '[[foo = foo = bar]]', $out ); + $this->assertSame( '[[foo = foo = bar]]', $out ); } function test_mixed_tags() { @@ -350,7 +350,7 @@ more content EOF; $out = do_shortcode( $in ); - $this->assertEquals( strip_ws( $expected ), strip_ws( $out ) ); + $this->assertSame( strip_ws( $expected ), strip_ws( $out ) ); } /** @@ -359,14 +359,14 @@ EOF; function test_utf8_whitespace_1() { // NO-BREAK SPACE: U+00A0. do_shortcode( "[test-shortcode-tag foo=\"bar\" \xC2\xA0baz=\"123\"]" ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'bar', 'baz' => '123', ), $this->atts ); - $this->assertEquals( '', $this->content ); + $this->assertSame( '', $this->content ); } /** @@ -375,14 +375,14 @@ EOF; function test_utf8_whitespace_2() { // ZERO WIDTH SPACE: U+200B. do_shortcode( "[test-shortcode-tag foo=\"bar\" \xE2\x80\x8Babc=\"def\"]" ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'bar', 'abc' => 'def', ), $this->atts ); - $this->assertEquals( '', $this->content ); + $this->assertSame( '', $this->content ); } /** @@ -391,7 +391,7 @@ EOF; function test_shortcode_unautop() { // A blank line is added at the end, so test with it already there. $test_string = "[footag]\n"; - $this->assertEquals( $test_string, shortcode_unautop( wpautop( $test_string ) ) ); + $this->assertSame( $test_string, shortcode_unautop( wpautop( $test_string ) ) ); } function data_test_strip_shortcodes() { @@ -418,7 +418,7 @@ EOF; * @param string $content Content to run strip_shortcodes() on. */ function test_strip_shortcodes( $expected, $content ) { - $this->assertEquals( $expected, strip_shortcodes( $content ) ); + $this->assertSame( $expected, strip_shortcodes( $content ) ); } /** @@ -426,7 +426,7 @@ EOF; */ function test_strip_shortcodes_filter() { add_filter( 'strip_shortcodes_tagnames', array( $this, '_filter_strip_shortcodes_tagnames' ) ); - $this->assertEquals( 'beforemiddle [footag]after', strip_shortcodes( 'before[gallery]middle [footag]after' ) ); + $this->assertSame( 'beforemiddle [footag]after', strip_shortcodes( 'before[gallery]middle [footag]after' ) ); remove_filter( 'strip_shortcodes_tagnames', array( $this, '_filter_strip_shortcodes_tagnames' ) ); } @@ -462,21 +462,21 @@ EOF; add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts' ), 10, 3 ); do_shortcode( '[bartag foo="foo1" /]' ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'foo1', 'baz' => 'default baz', ), $this->filter_atts_out ); - $this->assertEquals( + $this->assertSame( array( 'foo' => 'no foo', 'baz' => 'default baz', ), $this->filter_atts_pairs ); - $this->assertEquals( array( 'foo' => 'foo1' ), $this->filter_atts_atts ); + $this->assertSame( array( 'foo' => 'foo1' ), $this->filter_atts_atts ); remove_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts' ), 10, 3 ); } @@ -485,11 +485,11 @@ EOF; add_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts2' ), 10, 3 ); $out = do_shortcode( '[bartag foo="foo1" baz="baz1" /]' ); - $this->assertEquals( array( 'foo' => 'no foo' ), $this->filter_atts_out ); - $this->assertEquals( 'foo = no foo', $out ); + $this->assertSame( array( 'foo' => 'no foo' ), $this->filter_atts_out ); + $this->assertSame( 'foo = no foo', $out ); $out = do_shortcode( '[bartag foo="foo2" /]' ); - $this->assertEquals( 'foo = foo2', $out ); + $this->assertSame( 'foo = foo2', $out ); remove_filter( 'shortcode_atts_bartag', array( $this, '_filter_atts2' ), 10, 3 ); } @@ -512,7 +512,7 @@ EOF; $output = '[gallery ids="37,15,11"]'; foreach ( $input as $in ) { - $this->assertEquals( $output, shortcode_unautop( $in ) ); + $this->assertSame( $output, shortcode_unautop( $in ) ); } } @@ -522,7 +522,7 @@ EOF; * @dataProvider data_escaping */ function test_escaping( $input, $output ) { - return $this->assertEquals( $output, do_shortcode( $input ) ); + return $this->assertSame( $output, do_shortcode( $input ) ); } function data_escaping() { @@ -600,7 +600,7 @@ EOF; * @dataProvider data_escaping2 */ function test_escaping2( $input, $output ) { - return $this->assertEquals( $output, strip_shortcodes( $input ) ); + return $this->assertSame( $output, strip_shortcodes( $input ) ); } function data_escaping2() { @@ -671,7 +671,7 @@ EOF; function sub_registration( $input, $expected ) { add_shortcode( $input, '' ); $actual = shortcode_exists( $input ); - $test = $this->assertEquals( $expected, $actual ); + $test = $this->assertSame( $expected, $actual ); if ( $actual ) { remove_shortcode( $input ); } @@ -765,7 +765,7 @@ EOF; function test_unnamed_attribute() { $out = do_shortcode( '[dumptag=https://wordpress.org/]' ); $expected = "0 = =https://wordpress.org\n"; - $this->assertEquals( $expected, $out ); + $this->assertSame( $expected, $out ); } /** @@ -774,7 +774,7 @@ EOF; function test_smilies_arent_converted() { $out = apply_filters( 'the_content', '[img alt="Hello :-) World"]' ); $expected = "<img alt=\"Hello :-) World\" />\n"; - $this->assertEquals( $expected, $out ); + $this->assertSame( $expected, $out ); } /** @@ -924,7 +924,7 @@ EOF; */ function test_empty_single_quote_attribute() { $out = do_shortcode( '[test-shortcode-tag a="foo" b=\'bar\' c=baz foo \'bar\' "baz" ]test empty atts[/test-shortcode-tag]' ); - $this->assertEquals( + $this->assertSame( array( 'a' => 'foo', 'b' => 'bar', @@ -942,15 +942,15 @@ EOF; */ function test_positional_atts_single_quotes() { $out = do_shortcode( "[test-shortcode-tag 'something in quotes' 'something else']" ); - $this->assertEquals( '', $out ); - $this->assertEquals( + $this->assertSame( '', $out ); + $this->assertSame( array( 0 => 'something in quotes', 1 => 'something else', ), $this->atts ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } /** @@ -958,8 +958,8 @@ EOF; */ function test_positional_atts_mixed_quotes() { $out = do_shortcode( "[test-shortcode-tag 'something in quotes' \"something else\" 123 foo bar='baz' example=\"test\" ]" ); - $this->assertEquals( '', $out ); - $this->assertEquals( + $this->assertSame( '', $out ); + $this->assertSame( array( 0 => 'something in quotes', 1 => 'something else', @@ -970,6 +970,6 @@ EOF; ), $this->atts ); - $this->assertEquals( 'test-shortcode-tag', $this->tagname ); + $this->assertSame( 'test-shortcode-tag', $this->tagname ); } } diff --git a/tests/phpunit/tests/sitemaps/functions.php b/tests/phpunit/tests/sitemaps/functions.php index 7ab5c5490f..2a2d0da204 100644 --- a/tests/phpunit/tests/sitemaps/functions.php +++ b/tests/phpunit/tests/sitemaps/functions.php @@ -15,9 +15,9 @@ class Test_Sitemaps_Functions extends WP_UnitTestCase { $expected_taxonomies = wp_sitemaps_get_max_urls( 'term' ); $expected_users = wp_sitemaps_get_max_urls( 'user' ); - $this->assertEquals( $expected_posts, 300, 'Can not confirm max URL number for posts.' ); - $this->assertEquals( $expected_taxonomies, 50, 'Can not confirm max URL number for taxonomies.' ); - $this->assertEquals( $expected_users, 1, 'Can not confirm max URL number for users.' ); + $this->assertSame( $expected_posts, 300, 'Can not confirm max URL number for posts.' ); + $this->assertSame( $expected_taxonomies, 50, 'Can not confirm max URL number for taxonomies.' ); + $this->assertSame( $expected_users, 1, 'Can not confirm max URL number for users.' ); } /** @@ -52,7 +52,7 @@ class Test_Sitemaps_Functions extends WP_UnitTestCase { 'users' => 'WP_Sitemaps_Users', ); - $this->assertEquals( array_keys( $expected ), array_keys( $sitemaps ), 'Unable to confirm default sitemap types are registered.' ); + $this->assertSame( array_keys( $expected ), array_keys( $sitemaps ), 'Unable to confirm default sitemap types are registered.' ); foreach ( $expected as $name => $provider ) { $this->assertTrue( is_a( $sitemaps[ $name ], $provider ), "Default $name sitemap is not a $provider object." ); diff --git a/tests/phpunit/tests/sitemaps/sitemaps-posts.php b/tests/phpunit/tests/sitemaps/sitemaps-posts.php index d102518587..a5be317ce4 100644 --- a/tests/phpunit/tests/sitemaps/sitemaps-posts.php +++ b/tests/phpunit/tests/sitemaps/sitemaps-posts.php @@ -24,7 +24,7 @@ class Test_WP_Sitemaps_Posts extends WP_UnitTestCase { ), ); - $this->assertEquals( $expected, $post_list ); + $this->assertSame( $expected, $post_list ); } /** @@ -37,7 +37,7 @@ class Test_WP_Sitemaps_Posts extends WP_UnitTestCase { add_filter( 'wp_sitemaps_post_types', '__return_empty_array' ); $subtypes = $posts_provider->get_object_subtypes(); - $this->assertEquals( array(), $subtypes, 'Could not filter posts subtypes.' ); + $this->assertSame( array(), $subtypes, 'Could not filter posts subtypes.' ); } /** @@ -51,7 +51,7 @@ class Test_WP_Sitemaps_Posts extends WP_UnitTestCase { $url_list = $posts_provider->get_url_list( 1, 'page' ); - $this->assertEquals( array(), $url_list ); + $this->assertSame( array(), $url_list ); update_option( 'show_on_front', 'posts' ); diff --git a/tests/phpunit/tests/sitemaps/sitemaps-taxonomies.php b/tests/phpunit/tests/sitemaps/sitemaps-taxonomies.php index 7b1600c07c..bc43c8a227 100644 --- a/tests/phpunit/tests/sitemaps/sitemaps-taxonomies.php +++ b/tests/phpunit/tests/sitemaps/sitemaps-taxonomies.php @@ -114,7 +114,7 @@ class Test_WP_Sitemaps_Taxonomies extends WP_UnitTestCase { // Clean up. unregister_taxonomy_for_object_type( $taxonomy, 'post' ); - $this->assertEquals( $expected, $post_list, 'Custom taxonomy term links are not visible.' ); + $this->assertSame( $expected, $post_list, 'Custom taxonomy term links are not visible.' ); } /** @@ -216,6 +216,6 @@ class Test_WP_Sitemaps_Taxonomies extends WP_UnitTestCase { add_filter( 'wp_sitemaps_taxonomies', '__return_empty_array' ); $subtypes = $taxonomies_provider->get_object_subtypes(); - $this->assertEquals( array(), $subtypes, 'Could not filter taxonomies subtypes.' ); + $this->assertSame( array(), $subtypes, 'Could not filter taxonomies subtypes.' ); } } diff --git a/tests/phpunit/tests/sitemaps/sitemaps.php b/tests/phpunit/tests/sitemaps/sitemaps.php index a2f134053a..436a35f4b9 100644 --- a/tests/phpunit/tests/sitemaps/sitemaps.php +++ b/tests/phpunit/tests/sitemaps/sitemaps.php @@ -224,7 +224,7 @@ class Test_Sitemaps extends WP_UnitTestCase { $expected = $this->_get_expected_url_list( 'post', self::$posts ); - $this->assertEquals( $expected, $post_list ); + $this->assertSame( $expected, $post_list ); } /** @@ -240,7 +240,7 @@ class Test_Sitemaps extends WP_UnitTestCase { $expected = $this->_get_expected_url_list( 'page', self::$pages ); - $this->assertEquals( $expected, $post_list ); + $this->assertSame( $expected, $post_list ); } /** @@ -261,7 +261,7 @@ class Test_Sitemaps extends WP_UnitTestCase { ) ); - $this->assertEquals( $expected, $post_list ); + $this->assertSame( $expected, $post_list ); } /** @@ -306,7 +306,7 @@ class Test_Sitemaps extends WP_UnitTestCase { // Clean up. unregister_post_type( $post_type ); - $this->assertEquals( $expected, $post_list, 'Custom post type posts are not visible.' ); + $this->assertSame( $expected, $post_list, 'Custom post type posts are not visible.' ); } /** @@ -393,7 +393,7 @@ class Test_Sitemaps extends WP_UnitTestCase { $sitemaps = wp_get_sitemap_providers(); - $this->assertEquals( $sitemaps['test_sitemap'], self::$test_provider, 'Can not confirm sitemap registration is working.' ); + $this->assertSame( $sitemaps['test_sitemap'], self::$test_provider, 'Can not confirm sitemap registration is working.' ); } /** diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index e8fcffc8d9..62480b4d2b 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -5,11 +5,11 @@ */ class Tests_Taxonomy extends WP_UnitTestCase { function test_get_post_taxonomies() { - $this->assertEquals( array( 'category', 'post_tag', 'post_format' ), get_object_taxonomies( 'post' ) ); + $this->assertSame( array( 'category', 'post_tag', 'post_format' ), get_object_taxonomies( 'post' ) ); } function test_get_link_taxonomies() { - $this->assertEquals( array( 'link_category' ), get_object_taxonomies( 'link' ) ); + $this->assertSame( array( 'link_category' ), get_object_taxonomies( 'link' ) ); } /** @@ -17,10 +17,10 @@ class Tests_Taxonomy extends WP_UnitTestCase { */ function test_get_unknown_taxonomies() { // Taxonomies for an unknown object type. - $this->assertEquals( array(), get_object_taxonomies( rand_str() ) ); - $this->assertEquals( array(), get_object_taxonomies( '' ) ); - $this->assertEquals( array(), get_object_taxonomies( 0 ) ); - $this->assertEquals( array(), get_object_taxonomies( null ) ); + $this->assertSame( array(), get_object_taxonomies( rand_str() ) ); + $this->assertSame( array(), get_object_taxonomies( '' ) ); + $this->assertSame( array(), get_object_taxonomies( 0 ) ); + $this->assertSame( array(), get_object_taxonomies( null ) ); } function test_get_post_taxonomy() { @@ -29,7 +29,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { // Should return an object with the correct taxonomy object type. $this->assertTrue( is_object( $tax ) ); $this->assertTrue( is_array( $tax->object_type ) ); - $this->assertEquals( array( 'post' ), $tax->object_type ); + $this->assertSame( array( 'post' ), $tax->object_type ); } } @@ -38,7 +38,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { $taxes = get_the_taxonomies( $post_id ); $this->assertNotEmpty( $taxes ); - $this->assertEquals( array( 'category' ), array_keys( $taxes ) ); + $this->assertSame( array( 'category' ), array_keys( $taxes ) ); $id = self::factory()->tag->create(); wp_set_post_tags( $post_id, array( $id ) ); @@ -46,7 +46,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { $taxes = get_the_taxonomies( $post_id ); $this->assertNotEmpty( $taxes ); $this->assertCount( 2, $taxes ); - $this->assertEquals( array( 'category', 'post_tag' ), array_keys( $taxes ) ); + $this->assertSame( array( 'category', 'post_tag' ), array_keys( $taxes ) ); } /** @@ -56,11 +56,11 @@ class Tests_Taxonomy extends WP_UnitTestCase { $post_id = self::factory()->post->create(); $taxes = get_the_taxonomies( $post_id, array( 'term_template' => '%2$s' ) ); - $this->assertEquals( 'Categories: Uncategorized.', $taxes['category'] ); + $this->assertSame( 'Categories: Uncategorized.', $taxes['category'] ); $taxes = get_the_taxonomies( $post_id, array( 'term_template' => '<span class="foo"><a href="%1$s">%2$s</a></span>' ) ); $link = get_category_link( 1 ); - $this->assertEquals( 'Categories: <span class="foo"><a href="' . $link . '">Uncategorized</a></span>.', $taxes['category'] ); + $this->assertSame( 'Categories: <span class="foo"><a href="' . $link . '">Uncategorized</a></span>.', $taxes['category'] ); } function test_the_taxonomies() { @@ -90,7 +90,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { ), ) ); - $this->assertEquals( 'Categories: Uncategorized.', $output ); + $this->assertSame( 'Categories: Uncategorized.', $output ); $output = get_echo( 'the_taxonomies', @@ -102,7 +102,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { ) ); $link = get_category_link( 1 ); - $this->assertEquals( 'Categories: <span class="foo"><a href="' . $link . '">Uncategorized</a></span>.', $output ); + $this->assertSame( 'Categories: <span class="foo"><a href="' . $link . '">Uncategorized</a></span>.', $output ); } function test_get_link_taxonomy() { @@ -111,7 +111,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { // Should return an object with the correct taxonomy object type. $this->assertTrue( is_object( $tax ) ); $this->assertTrue( is_array( $tax->object_type ) ); - $this->assertEquals( array( 'link' ), $tax->object_type ); + $this->assertSame( array( 'link' ), $tax->object_type ); } } @@ -285,11 +285,11 @@ class Tests_Taxonomy extends WP_UnitTestCase { public function test_get_objects_in_term_should_return_invalid_taxonomy_error() { $terms = get_objects_in_term( 1, 'invalid_taxonomy' ); $this->assertInstanceOf( 'WP_Error', $terms ); - $this->assertEquals( 'invalid_taxonomy', $terms->get_error_code() ); + $this->assertSame( 'invalid_taxonomy', $terms->get_error_code() ); } public function test_get_objects_in_term_should_return_empty_array() { - $this->assertEquals( array(), get_objects_in_term( 1, 'post_tag' ) ); + $this->assertSame( array(), get_objects_in_term( 1, 'post_tag' ) ); } public function test_get_objects_in_term_should_return_objects_ids() { @@ -429,7 +429,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { 'taxonomy' => 'category', 'cat_name' => 'Updated Name', ); - $this->assertEquals( 1, wp_insert_category( $cat ) ); + $this->assertSame( 1, wp_insert_category( $cat ) ); } function test_insert_category_force_error_handle() { @@ -447,7 +447,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { 'taxonomy' => 'force_error', 'cat_name' => 'Error', ); - $this->assertEquals( 0, wp_insert_category( $cat, false ) ); + $this->assertSame( 0, wp_insert_category( $cat, false ) ); } public function test_get_ancestors_taxonomy_non_hierarchical() { @@ -963,7 +963,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { $terms_obj = get_the_terms( $updated_post_id, $taxonomy_name ); $problematic_term = current( wp_list_pluck( $terms_obj, 'name' ) ); - $this->assertEquals( $problematic_term, $term_name ); + $this->assertSame( $problematic_term, $term_name ); } /** diff --git a/tests/phpunit/tests/template.php b/tests/phpunit/tests/template.php index 7178d7a3cd..981a72b4f5 100644 --- a/tests/phpunit/tests/template.php +++ b/tests/phpunit/tests/template.php @@ -231,7 +231,7 @@ class Tests_Template extends WP_UnitTestCase { } public function test_front_page_template_hierarchy_with_posts_on_front() { - $this->assertEquals( 'posts', get_option( 'show_on_front' ) ); + $this->assertSame( 'posts', get_option( 'show_on_front' ) ); $this->assertTemplateHierarchy( home_url(), array( @@ -461,7 +461,7 @@ class Tests_Template extends WP_UnitTestCase { $this->go_to( $url ); $hierarchy = $this->get_template_hierarchy(); - $this->assertEquals( $expected, $hierarchy, $message ); + $this->assertSame( $expected, $hierarchy, $message ); } protected static function get_query_template_conditions() { diff --git a/tests/phpunit/tests/term.php b/tests/phpunit/tests/term.php index 38979c1739..9454bd0e87 100644 --- a/tests/phpunit/tests/term.php +++ b/tests/phpunit/tests/term.php @@ -101,19 +101,19 @@ class Tests_Term extends WP_UnitTestCase { $tags = self::factory()->tag->create_many( 5 ); $tt = wp_add_object_terms( $posts[0], $tags[1], 'post_tag' ); - $this->assertEquals( 1, count( $tt ) ); - $this->assertEquals( array( $tags[1] ), wp_get_object_terms( $posts[0], 'post_tag', array( 'fields' => 'ids' ) ) ); + $this->assertSame( 1, count( $tt ) ); + $this->assertSame( array( $tags[1] ), wp_get_object_terms( $posts[0], 'post_tag', array( 'fields' => 'ids' ) ) ); $three_tags = array( $tags[0], $tags[1], $tags[2] ); $tt = wp_add_object_terms( $posts[1], $three_tags, 'post_tag' ); - $this->assertEquals( 3, count( $tt ) ); - $this->assertEquals( $three_tags, wp_get_object_terms( $posts[1], 'post_tag', array( 'fields' => 'ids' ) ) ); + $this->assertSame( 3, count( $tt ) ); + $this->assertSame( $three_tags, wp_get_object_terms( $posts[1], 'post_tag', array( 'fields' => 'ids' ) ) ); $this->assertTrue( wp_remove_object_terms( $posts[0], $tags[1], 'post_tag' ) ); $this->assertFalse( wp_remove_object_terms( $posts[0], $tags[0], 'post_tag' ) ); $this->assertInstanceOf( 'WP_Error', wp_remove_object_terms( $posts[0], $tags[1], 'non_existing_taxonomy' ) ); $this->assertTrue( wp_remove_object_terms( $posts[1], $three_tags, 'post_tag' ) ); - $this->assertEquals( 0, count( wp_get_object_terms( $posts[1], 'post_tag' ) ) ); + $this->assertSame( 0, count( wp_get_object_terms( $posts[1], 'post_tag' ) ) ); foreach ( $tags as $term_id ) { $this->assertTrue( wp_delete_term( $term_id, 'post_tag' ) ); @@ -177,7 +177,7 @@ class Tests_Term extends WP_UnitTestCase { $post = get_post( $post_id ); $this->assertInternalType( 'array', $post->post_category ); - $this->assertEquals( 1, count( $post->post_category ) ); + $this->assertSame( 1, count( $post->post_category ) ); $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] ); $term1 = wp_insert_term( 'Foo', 'category' ); @@ -185,26 +185,26 @@ class Tests_Term extends WP_UnitTestCase { $term3 = wp_insert_term( 'Baz', 'category' ); wp_set_post_categories( $post_id, array( $term1['term_id'], $term2['term_id'] ) ); - $this->assertEquals( 2, count( $post->post_category ) ); - $this->assertEquals( array( $term2['term_id'], $term1['term_id'] ), $post->post_category ); + $this->assertSame( 2, count( $post->post_category ) ); + $this->assertSame( array( $term2['term_id'], $term1['term_id'] ), $post->post_category ); wp_set_post_categories( $post_id, $term3['term_id'], true ); - $this->assertEquals( array( $term2['term_id'], $term3['term_id'], $term1['term_id'] ), $post->post_category ); + $this->assertSame( array( $term2['term_id'], $term3['term_id'], $term1['term_id'] ), $post->post_category ); $term4 = wp_insert_term( 'Burrito', 'category' ); wp_set_post_categories( $post_id, $term4['term_id'] ); - $this->assertEquals( array( $term4['term_id'] ), $post->post_category ); + $this->assertSame( array( $term4['term_id'] ), $post->post_category ); wp_set_post_categories( $post_id, array( $term1['term_id'], $term2['term_id'] ), true ); - $this->assertEquals( array( $term2['term_id'], $term4['term_id'], $term1['term_id'] ), $post->post_category ); + $this->assertSame( array( $term2['term_id'], $term4['term_id'], $term1['term_id'] ), $post->post_category ); wp_set_post_categories( $post_id, array(), true ); - $this->assertEquals( 1, count( $post->post_category ) ); + $this->assertSame( 1, count( $post->post_category ) ); $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] ); wp_set_post_categories( $post_id, array() ); - $this->assertEquals( 1, count( $post->post_category ) ); + $this->assertSame( 1, count( $post->post_category ) ); $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] ); } @@ -224,7 +224,7 @@ class Tests_Term extends WP_UnitTestCase { $term = wp_insert_term( 'Foo', 'category' ); wp_set_post_categories( $post_id, $term['term_id'] ); - $this->assertEquals( $term['term_id'], $post->post_category[0] ); + $this->assertSame( $term['term_id'], $post->post_category[0] ); wp_set_post_categories( $post_id, array() ); $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] ); @@ -243,10 +243,10 @@ class Tests_Term extends WP_UnitTestCase { function test_sanitize_term_field() { $term = wp_insert_term( 'foo', $this->taxonomy ); - $this->assertEquals( 0, sanitize_term_field( 'parent', 0, $term['term_id'], $this->taxonomy, 'raw' ) ); - $this->assertEquals( 1, sanitize_term_field( 'parent', 1, $term['term_id'], $this->taxonomy, 'raw' ) ); - $this->assertEquals( 0, sanitize_term_field( 'parent', -1, $term['term_id'], $this->taxonomy, 'raw' ) ); - $this->assertEquals( 0, sanitize_term_field( 'parent', '', $term['term_id'], $this->taxonomy, 'raw' ) ); + $this->assertSame( 0, sanitize_term_field( 'parent', 0, $term['term_id'], $this->taxonomy, 'raw' ) ); + $this->assertSame( 1, sanitize_term_field( 'parent', 1, $term['term_id'], $this->taxonomy, 'raw' ) ); + $this->assertSame( 0, sanitize_term_field( 'parent', -1, $term['term_id'], $this->taxonomy, 'raw' ) ); + $this->assertSame( 0, sanitize_term_field( 'parent', '', $term['term_id'], $this->taxonomy, 'raw' ) ); } /** diff --git a/tests/phpunit/tests/term/cache.php b/tests/phpunit/tests/term/cache.php index 959c206f38..4361c34893 100644 --- a/tests/phpunit/tests/term/cache.php +++ b/tests/phpunit/tests/term/cache.php @@ -19,14 +19,14 @@ class Tests_Term_Cache extends WP_UnitTestCase { $term_id1_child = self::factory()->category->create( array( 'parent' => $term_id1 ) ); $hierarchy = _get_term_hierarchy( 'category' ); - $this->assertEquals( array( $term_id1 => array( $term_id1_child ) ), $hierarchy ); + $this->assertSame( array( $term_id1 => array( $term_id1_child ) ), $hierarchy ); // Add another Parent => Child. $term_id2 = self::factory()->category->create(); $term_id2_child = self::factory()->category->create( array( 'parent' => $term_id2 ) ); $hierarchy = _get_term_hierarchy( 'category' ); - $this->assertEquals( + $this->assertSame( array( $term_id1 => array( $term_id1_child ), $term_id2 => array( $term_id2_child ), @@ -45,7 +45,7 @@ class Tests_Term_Cache extends WP_UnitTestCase { $post = get_post( $post_id ); $cats1 = get_the_category( $post->ID ); - $this->assertEquals( $term->name, reset( $cats1 )->name ); + $this->assertSame( $term->name, reset( $cats1 )->name ); wp_update_term( $term->term_id, 'category', array( 'name' => 'Bar' ) ); $cats2 = get_the_category( $post->ID ); @@ -83,11 +83,11 @@ class Tests_Term_Cache extends WP_UnitTestCase { } $terms = get_terms( $tax, array( 'hide_empty' => false ) ); - $this->assertEquals( $i, count( $terms ) ); + $this->assertSame( $i, count( $terms ) ); if ( $i > 1 ) { $hierarchy = _get_term_hierarchy( $tax ); $this->assertNotEmpty( $hierarchy ); - $this->assertEquals( $children, count( $hierarchy, COUNT_RECURSIVE ) - count( $hierarchy ) ); + $this->assertSame( $children, count( $hierarchy, COUNT_RECURSIVE ) - count( $hierarchy ) ); } if ( 0 === ( $i % 3 ) ) { @@ -125,7 +125,7 @@ class Tests_Term_Cache extends WP_UnitTestCase { // No new queries should have fired. $this->assertSame( $num_queries, $wpdb->num_queries ); - $this->assertEquals( $term_object, $term_object_2 ); + $this->assertSame( $term_object, $term_object_2 ); } public function test_get_term_should_update_term_cache_when_passed_a_valid_term_identifier() { @@ -257,16 +257,16 @@ class Tests_Term_Cache extends WP_UnitTestCase { $term = get_term_by( 'slug', 'burrito', 'post_tag' ); $num_queries++; - $this->assertEquals( 'Taco', $term->name ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( 'Taco', $term->name ); + $this->assertSame( $num_queries, $wpdb->num_queries ); // This should now hit cache. $term = get_term_by( 'slug', 'burrito', 'post_tag' ); - $this->assertEquals( 'Taco', $term->name ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( 'Taco', $term->name ); + $this->assertSame( $num_queries, $wpdb->num_queries ); $this->assertEquals( get_term( $term_id, 'post_tag' ), $term ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); } /** @@ -288,13 +288,13 @@ class Tests_Term_Cache extends WP_UnitTestCase { $term = get_term_by( 'slug', 'burrito', 'post_tag' ); $num_queries++; - $this->assertEquals( 'Taco', $term->name ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( 'Taco', $term->name ); + $this->assertSame( $num_queries, $wpdb->num_queries ); // This should now hit cache. $term = get_term_by( 'slug', 'burrito', 'post_tag' ); - $this->assertEquals( 'Taco', $term->name ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( 'Taco', $term->name ); + $this->assertSame( $num_queries, $wpdb->num_queries ); // Update the tag which invalidates the cache. wp_update_term( $term_id, 'post_tag', array( 'name' => 'No Taco' ) ); @@ -303,8 +303,8 @@ class Tests_Term_Cache extends WP_UnitTestCase { // This should not hit cache. $term = get_term_by( 'slug', 'burrito', 'post_tag' ); $num_queries++; - $this->assertEquals( 'No Taco', $term->name ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( 'No Taco', $term->name ); + $this->assertSame( $num_queries, $wpdb->num_queries ); } /** @@ -326,14 +326,14 @@ class Tests_Term_Cache extends WP_UnitTestCase { get_term_by( 'name', 'Burrito', 'post_tag' ); $num_queries++; - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); // This should now hit cache. $term = get_term_by( 'name', 'Burrito', 'post_tag' ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); $this->assertEquals( get_term( $term_id, 'post_tag' ), $term ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); } /** @@ -355,11 +355,11 @@ class Tests_Term_Cache extends WP_UnitTestCase { get_term_by( 'name', 'Burrito', 'post_tag' ); $num_queries++; - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); // This should now hit cache. get_term_by( 'name', 'Burrito', 'post_tag' ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); // Update the tag which invalidates the cache. wp_update_term( $term_id, 'post_tag', array( 'slug' => 'taco' ) ); @@ -368,7 +368,7 @@ class Tests_Term_Cache extends WP_UnitTestCase { // This should not hit cache. get_term_by( 'name', 'burrito', 'post_tag' ); $num_queries++; - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); } /** @@ -393,7 +393,7 @@ class Tests_Term_Cache extends WP_UnitTestCase { // Verify the term is cached. $term2 = get_term_by( 'name', 'Burrito', 'post_tag' ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); $this->assertEquals( $term1, $term2 ); $suspend = wp_suspend_cache_invalidation(); @@ -404,7 +404,7 @@ class Tests_Term_Cache extends WP_UnitTestCase { // Verify that the cached term still matches the initial cached term. $term3 = get_term_by( 'name', 'Burrito', 'post_tag' ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); $this->assertEquals( $term1, $term3 ); // Verify that last changed has not been updated as part of an invalidation routine. @@ -435,12 +435,12 @@ class Tests_Term_Cache extends WP_UnitTestCase { $num_queries++; $this->assertTrue( $term instanceof WP_Term ); $this->assertSame( $term_id, $term->term_id ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); $term_meta = get_term_meta( $term_id, 'foo', true ); $num_queries++; $this->assertSame( $term_meta, 'bar' ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( $num_queries, $wpdb->num_queries ); } /** diff --git a/tests/phpunit/tests/term/getEditTermLink.php b/tests/phpunit/tests/term/getEditTermLink.php index 3eea826b11..887b55bf86 100644 --- a/tests/phpunit/tests/term/getEditTermLink.php +++ b/tests/phpunit/tests/term/getEditTermLink.php @@ -20,7 +20,7 @@ class Tests_Term_GetEditTermLink extends WP_UnitTestCase { $actual = get_edit_term_link( $term1, 'wptests_tax' ); $expected = 'http://' . WP_TESTS_DOMAIN . '/wp-admin/term.php?taxonomy=wptests_tax&tag_ID=' . $term1 . '&post_type=post'; - $this->assertEquals( $expected, $actual ); + $this->assertSame( $expected, $actual ); } /** diff --git a/tests/phpunit/tests/term/getTerm.php b/tests/phpunit/tests/term/getTerm.php index 4a2b9b0ffb..22ae4d527e 100644 --- a/tests/phpunit/tests/term/getTerm.php +++ b/tests/phpunit/tests/term/getTerm.php @@ -72,11 +72,11 @@ class Tests_Term_GetTerm extends WP_UnitTestCase { } public function test_passing_term_string_that_casts_to_int_0_should_return_null() { - $this->assertSame( null, get_term( 'abc', 'wptests_tax' ) ); + $this->assertNull( get_term( 'abc', 'wptests_tax' ) ); } public function test_should_return_null_for_invalid_term_id() { - $this->assertSame( null, get_term( 99999999, 'wptests_tax' ) ); + $this->assertNull( get_term( 99999999, 'wptests_tax' ) ); } public function test_cache_should_be_populated_by_successful_fetch() { diff --git a/tests/phpunit/tests/term/getTermBy.php b/tests/phpunit/tests/term/getTermBy.php index d1eda875c8..037bef0419 100644 --- a/tests/phpunit/tests/term/getTermBy.php +++ b/tests/phpunit/tests/term/getTermBy.php @@ -232,7 +232,7 @@ class Tests_Term_GetTermBy extends WP_UnitTestCase { get_term_by( 'name', 'burrito', 'post_tag' ); remove_filter( 'get_terms', array( $action, 'filter' ) ); - $this->assertEquals( 0, $action->get_call_count() ); + $this->assertSame( 0, $action->get_call_count() ); } /** diff --git a/tests/phpunit/tests/term/getTermParentsList.php b/tests/phpunit/tests/term/getTermParentsList.php index a8f2bc6f05..8d660bbb50 100644 --- a/tests/phpunit/tests/term/getTermParentsList.php +++ b/tests/phpunit/tests/term/getTermParentsList.php @@ -34,7 +34,7 @@ class Tests_Terms_GetTermsParentsList extends WP_UnitTestCase { } public function test_should_return_empty_for_invalid_id() { - $this->assertEquals( '', get_term_parents_list( 99999999, 'wptests_tax' ) ); + $this->assertSame( '', get_term_parents_list( 99999999, 'wptests_tax' ) ); } public function test_should_return_wp_error_for_invalid_taxonomy() { diff --git a/tests/phpunit/tests/term/getTerms.php b/tests/phpunit/tests/term/getTerms.php index a22f90a7a9..52fd7cf098 100644 --- a/tests/phpunit/tests/term/getTerms.php +++ b/tests/phpunit/tests/term/getTerms.php @@ -115,18 +115,18 @@ class Tests_Term_getTerms extends WP_UnitTestCase { // last_changed and num_queries should bump. $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) ); - $this->assertEquals( 3, count( $terms ) ); + $this->assertSame( 3, count( $terms ) ); $time1 = wp_cache_get( 'last_changed', 'terms' ); $this->assertNotEmpty( $time1 ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); $num_queries = $wpdb->num_queries; // Again. last_changed and num_queries should remain the same. $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) ); - $this->assertEquals( 3, count( $terms ) ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'terms' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( 3, count( $terms ) ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); } /** @@ -144,17 +144,17 @@ class Tests_Term_getTerms extends WP_UnitTestCase { // num_queries should bump, last_changed should remain the same. $terms = get_terms( 'post_tag', array( 'number' => 2 ) ); - $this->assertEquals( 2, count( $terms ) ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'terms' ) ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( 2, count( $terms ) ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); $num_queries = $wpdb->num_queries; // Again. last_changed and num_queries should remain the same. $terms = get_terms( 'post_tag', array( 'number' => 2 ) ); - $this->assertEquals( 2, count( $terms ) ); - $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'terms' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( 2, count( $terms ) ); + $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); } /** @@ -179,17 +179,17 @@ class Tests_Term_getTerms extends WP_UnitTestCase { // last_changed and num_queries should bump after a term is deleted. $terms = get_terms( 'post_tag' ); - $this->assertEquals( 2, count( $terms ) ); - $this->assertEquals( $time2, wp_cache_get( 'last_changed', 'terms' ) ); - $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); + $this->assertSame( 2, count( $terms ) ); + $this->assertSame( $time2, wp_cache_get( 'last_changed', 'terms' ) ); + $this->assertSame( $num_queries + 1, $wpdb->num_queries ); $num_queries = $wpdb->num_queries; // Again. last_changed and num_queries should remain the same. $terms = get_terms( 'post_tag' ); - $this->assertEquals( 2, count( $terms ) ); - $this->assertEquals( $time2, wp_cache_get( 'last_changed', 'terms' ) ); - $this->assertEquals( $num_queries, $wpdb->num_queries ); + $this->assertSame( 2, count( $terms ) ); + $this->assertSame( $time2, wp_cache_get( 'last_changed', 'terms' ) ); + $this->assertSame( $num_queries, $wpdb->num_queries ); // @todo Repeat with term insert and update. } @@ -200,7 +200,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { function test_get_terms_should_allow_arbitrary_indexed_taxonomies_array() { $term_id = self::factory()->tag->create(); $terms = get_terms( array( '111' => 'post_tag' ), array( 'hide_empty' => false ) ); - $this->assertEquals( $term_id, reset( $terms )->term_id ); + $this->assertSame( $term_id, reset( $terms )->term_id ); } /** @@ -300,7 +300,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { 'hide_empty' => false, ) ); - $this->assertEquals( array( $term_id1, $term_id2 ), wp_list_pluck( $inc_terms, 'term_id' ) ); + $this->assertSame( array( $term_id1, $term_id2 ), wp_list_pluck( $inc_terms, 'term_id' ) ); $exc_terms = get_terms( 'post_tag', @@ -309,7 +309,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { 'hide_empty' => false, ) ); - $this->assertEquals( array(), wp_list_pluck( $exc_terms, 'term_id' ) ); + $this->assertSame( array(), wp_list_pluck( $exc_terms, 'term_id' ) ); // These should not generate query errors. get_terms( @@ -363,7 +363,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $terms[1] ), wp_list_pluck( $found, 'term_id' ) ); + $this->assertSame( array( $terms[1] ), wp_list_pluck( $found, 'term_id' ) ); _unregister_taxonomy( 'wptests_tax' ); } @@ -388,7 +388,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { 'hide_empty' => false, ) ); - $this->assertEquals( array( $term_id1, $term_id11, $term_id2, $term_id22 ), $terms ); + $this->assertSame( array( $term_id1, $term_id11, $term_id2, $term_id22 ), $terms ); $terms = get_terms( 'category', @@ -399,7 +399,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $term_id2, $term_id22 ), $terms ); + $this->assertSame( array( $term_id2, $term_id22 ), $terms ); } @@ -547,7 +547,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { wp_set_post_terms( $id, $cheddar, $tax ); } $term = get_term( $cheddar, $tax ); - $this->assertEquals( 2, $term->count ); + $this->assertSame( 2, $term->count ); $brie = self::factory()->term->create( array( @@ -559,7 +559,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { $post_id = self::factory()->post->create(); wp_set_post_terms( $post_id, $brie, $tax ); $term = get_term( $brie, $tax ); - $this->assertEquals( 1, $term->count ); + $this->assertSame( 1, $term->count ); $crackers = self::factory()->term->create( array( @@ -580,7 +580,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { wp_set_post_terms( $id, $butter, $tax ); } $term = get_term( $butter, $tax ); - $this->assertEquals( 1, $term->count ); + $this->assertSame( 1, $term->count ); $multigrain = self::factory()->term->create( array( @@ -594,7 +594,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { wp_set_post_terms( $id, $multigrain, $tax ); } $term = get_term( $multigrain, $tax ); - $this->assertEquals( 1, $term->count ); + $this->assertSame( 1, $term->count ); $fruit = self::factory()->term->create( array( @@ -617,8 +617,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { 'cache_domain' => $tax, ) ); - $this->assertEquals( 2, count( $terms ) ); - $this->assertEquals( wp_list_pluck( $terms, 'name' ), array( 'Cheese', 'Crackers' ) ); + $this->assertSame( 2, count( $terms ) ); + $this->assertSame( wp_list_pluck( $terms, 'name' ), array( 'Cheese', 'Crackers' ) ); } /** @@ -651,7 +651,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { $post_id = self::factory()->post->create(); wp_set_post_terms( $post_id, $spread, $tax ); $term = get_term( $spread, $tax ); - $this->assertEquals( 1, $term->count ); + $this->assertSame( 1, $term->count ); $terms = get_terms( $tax, @@ -660,8 +660,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { 'cache_domain' => $tax, ) ); - $this->assertEquals( 1, count( $terms ) ); - $this->assertEquals( array( 'Cheese' ), wp_list_pluck( $terms, 'name' ) ); + $this->assertSame( 1, count( $terms ) ); + $this->assertSame( array( 'Cheese' ), wp_list_pluck( $terms, 'name' ) ); _unregister_taxonomy( $tax ); } @@ -687,7 +687,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { $post_id = self::factory()->post->create(); wp_set_post_terms( $post_id, $t[7], $tax ); $term = get_term( $t[7], $tax ); - $this->assertEquals( 1, $term->count ); + $this->assertSame( 1, $term->count ); $terms = get_terms( $tax, @@ -696,8 +696,8 @@ class Tests_Term_getTerms extends WP_UnitTestCase { 'cache_domain' => $tax, ) ); - $this->assertEquals( 1, count( $terms ) ); - $this->assertEquals( array( 'term1' ), wp_list_pluck( $terms, 'name' ) ); + $this->assertSame( 1, count( $terms ) ); + $this->assertSame( array( 'term1' ), wp_list_pluck( $terms, 'name' ) ); _unregister_taxonomy( $tax ); } @@ -716,7 +716,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { 'hide_empty' => false, ) ); - $this->assertEquals( 1, count( $terms ) ); + $this->assertSame( 1, count( $terms ) ); } /** @@ -748,7 +748,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( array( $child => 'Test 1', $child2 => 'Test 2', @@ -787,7 +787,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( + $this->assertSame( array( $child => 'test-1', $child2 => 'test-2', @@ -860,7 +860,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { $term = wp_update_term( $term['term_id'], 'category', array( 'parent' => $term['term_id'] ) ); $term = get_term( $term['term_id'], 'category' ); - $this->assertEquals( $term->term_id, $term->parent ); + $this->assertSame( $term->term_id, $term->parent ); $this->assertInternalType( 'array', get_term_children( $term->term_id, 'category' ) ); add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); @@ -917,7 +917,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t1 ), $found ); + $this->assertSame( array( $t1 ), $found ); } /** @@ -937,7 +937,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t1, $t3 ), $found ); + $this->assertSame( array( $t1, $t3 ), $found ); } /** @@ -956,7 +956,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t1 ), $found ); + $this->assertSame( array( $t1 ), $found ); } /** @@ -1837,7 +1837,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { _unregister_taxonomy( 'wptests_tax' ); - $this->assertEquals( array( $t4, $t1, $t2 ), $found ); + $this->assertSame( array( $t4, $t1, $t2 ), $found ); } /** @@ -1883,7 +1883,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { _unregister_taxonomy( 'wptests_tax' ); - $this->assertEquals( array( $t2, $t1, $t4, $t3 ), $found ); + $this->assertSame( array( $t2, $t1, $t4, $t3 ), $found ); } /** @@ -1919,7 +1919,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t1, $t2, $t3 ), $found ); + $this->assertSame( array( $t1, $t2, $t3 ), $found ); } /** @@ -2308,7 +2308,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ); // Verify that there are no children. - $this->assertEquals( 0, count( $terms ) ); + $this->assertSame( 0, count( $terms ) ); } /** @@ -2374,7 +2374,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ); // Verify that there are no children. - $this->assertEquals( 0, count( $terms ) ); + $this->assertSame( 0, count( $terms ) ); } public function test_hierarchical_true_with_child_of_should_return_grandchildren() { @@ -2487,7 +2487,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ); // 'hierarchical=false' means that descendants are not fetched. - $this->assertEquals( 0, count( $terms ) ); + $this->assertSame( 0, count( $terms ) ); } /** @@ -2626,11 +2626,11 @@ class Tests_Term_getTerms extends WP_UnitTestCase { foreach ( $found as $f ) { if ( $t1 === $f->term_id ) { - $this->assertEquals( 1, $f->count ); + $this->assertSame( 1, $f->count ); } elseif ( $t2 === $f->term_id ) { - $this->assertEquals( 2, $f->count ); + $this->assertSame( 2, $f->count ); } else { - $this->assertEquals( 1, $f->count ); + $this->assertSame( 1, $f->count ); } } } diff --git a/tests/phpunit/tests/term/getTheTerms.php b/tests/phpunit/tests/term/getTheTerms.php index 54450a7c81..fb4d61a00f 100644 --- a/tests/phpunit/tests/term/getTheTerms.php +++ b/tests/phpunit/tests/term/getTheTerms.php @@ -22,7 +22,7 @@ class Tests_Term_GetTheTerms extends WP_UnitTestCase { // Cache should be empty after a set. $tt_1 = wp_set_object_terms( $post_id, $terms_1, $this->taxonomy ); - $this->assertEquals( 3, count( $tt_1 ) ); + $this->assertSame( 3, count( $tt_1 ) ); $this->assertFalse( wp_cache_get( $post_id, $this->taxonomy . '_relationships' ) ); // wp_get_object_terms() does not prime the cache. @@ -43,7 +43,7 @@ class Tests_Term_GetTheTerms extends WP_UnitTestCase { // Cache should be empty after a set. $tt_2 = wp_set_object_terms( $post_id, $terms_2, $this->taxonomy ); - $this->assertEquals( 2, count( $tt_2 ) ); + $this->assertSame( 2, count( $tt_2 ) ); $this->assertFalse( wp_cache_get( $post_id, $this->taxonomy . '_relationships' ) ); } @@ -62,8 +62,8 @@ class Tests_Term_GetTheTerms extends WP_UnitTestCase { $tt_1 = wp_set_object_terms( $post_id, $tag_id, 'post_tag' ); $terms = get_the_terms( $post_id, 'post_tag' ); - $this->assertEquals( $tag_id, $terms[0]->term_id ); - $this->assertEquals( 'My Amazing Tag', $terms[0]->description ); + $this->assertSame( $tag_id, $terms[0]->term_id ); + $this->assertSame( 'My Amazing Tag', $terms[0]->description ); $_updated = wp_update_term( $tag_id, @@ -74,12 +74,12 @@ class Tests_Term_GetTheTerms extends WP_UnitTestCase { ); $_new_term = get_term( $tag_id, 'post_tag' ); - $this->assertEquals( $tag_id, $_new_term->term_id ); - $this->assertEquals( 'This description is even more amazing!', $_new_term->description ); + $this->assertSame( $tag_id, $_new_term->term_id ); + $this->assertSame( 'This description is even more amazing!', $_new_term->description ); $terms = get_the_terms( $post_id, 'post_tag' ); - $this->assertEquals( $tag_id, $terms[0]->term_id ); - $this->assertEquals( 'This description is even more amazing!', $terms[0]->description ); + $this->assertSame( $tag_id, $terms[0]->term_id ); + $this->assertSame( 'This description is even more amazing!', $terms[0]->description ); } /** diff --git a/tests/phpunit/tests/term/meta.php b/tests/phpunit/tests/term/meta.php index 256ed19676..744fd0ba37 100644 --- a/tests/phpunit/tests/term/meta.php +++ b/tests/phpunit/tests/term/meta.php @@ -87,7 +87,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { add_term_meta( $t, 'foo', 'baz' ); $found = get_term_meta( $t, 'foo', true ); - $this->assertEquals( 'bar', $found ); + $this->assertSame( 'bar', $found ); } public function test_update_should_pass_to_add_when_no_value_exists_for_key() { @@ -494,9 +494,9 @@ class Tests_Term_Meta extends WP_UnitTestCase { // Reset global so subsequent data tests do not get polluted. $GLOBALS['wp_meta_keys'] = array(); - $this->assertEquals( 'term', $this->last_register_meta_call['object_type'] ); - $this->assertEquals( $meta_key, $this->last_register_meta_call['meta_key'] ); - $this->assertEquals( $args, $this->last_register_meta_call['args'] ); + $this->assertSame( 'term', $this->last_register_meta_call['object_type'] ); + $this->assertSame( $meta_key, $this->last_register_meta_call['meta_key'] ); + $this->assertSame( $args, $this->last_register_meta_call['args'] ); } public function data_register_term_meta() { diff --git a/tests/phpunit/tests/term/query.php b/tests/phpunit/tests/term/query.php index 67ac3c7d34..a600999b40 100644 --- a/tests/phpunit/tests/term/query.php +++ b/tests/phpunit/tests/term/query.php @@ -480,11 +480,11 @@ class Tests_Term_Query extends WP_UnitTestCase { $post_id = self::factory()->post->create(); wp_set_object_terms( $post_id, array( $term_ids[0], $term_ids[1] ), 'wptests_tax' ); $terms = get_the_terms( $post_id, 'wptests_tax' ); - $this->assertEquals( array( $term_ids[0], $term_ids[1] ), wp_list_pluck( $terms, 'term_id' ) ); + $this->assertSame( array( $term_ids[0], $term_ids[1] ), wp_list_pluck( $terms, 'term_id' ) ); // Flip the order. wp_set_object_terms( $post_id, array( $term_ids[1], $term_ids[0] ), 'wptests_tax' ); $terms = get_the_terms( $post_id, 'wptests_tax' ); - $this->assertEquals( array( $term_ids[1], $term_ids[0] ), wp_list_pluck( $terms, 'term_id' ) ); + $this->assertSame( array( $term_ids[1], $term_ids[0] ), wp_list_pluck( $terms, 'term_id' ) ); } /** @@ -510,11 +510,11 @@ class Tests_Term_Query extends WP_UnitTestCase { $post_id = self::factory()->post->create(); wp_set_object_terms( $post_id, array( $term_ids[0], $term_ids[1] ), 'wptests_tax' ); $terms = wp_get_object_terms( $post_id, array( 'category', 'wptests_tax' ) ); - $this->assertEquals( array( $term_ids[0], $term_ids[1], 1 ), wp_list_pluck( $terms, 'term_id' ) ); + $this->assertSame( array( $term_ids[0], $term_ids[1], 1 ), wp_list_pluck( $terms, 'term_id' ) ); // Flip the order. wp_set_object_terms( $post_id, array( $term_ids[1], $term_ids[0] ), 'wptests_tax' ); $terms = wp_get_object_terms( $post_id, array( 'category', 'wptests_tax' ) ); - $this->assertEquals( array( $term_ids[1], $term_ids[0], 1 ), wp_list_pluck( $terms, 'term_id' ) ); + $this->assertSame( array( $term_ids[1], $term_ids[0], 1 ), wp_list_pluck( $terms, 'term_id' ) ); } /** diff --git a/tests/phpunit/tests/term/slashes.php b/tests/phpunit/tests/term/slashes.php index e384d68499..ea04097bbe 100644 --- a/tests/phpunit/tests/term/slashes.php +++ b/tests/phpunit/tests/term/slashes.php @@ -39,8 +39,8 @@ class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { ) ); $term = get_term( $insert['term_id'], $taxonomy ); - $this->assertEquals( wp_unslash( $this->slash_1 ), $term->name ); - $this->assertEquals( wp_unslash( $this->slash_3 ), $term->description ); + $this->assertSame( wp_unslash( $this->slash_1 ), $term->name ); + $this->assertSame( wp_unslash( $this->slash_3 ), $term->description ); $insert = wp_insert_term( $this->slash_3, @@ -51,8 +51,8 @@ class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { ) ); $term = get_term( $insert['term_id'], $taxonomy ); - $this->assertEquals( wp_unslash( $this->slash_3 ), $term->name ); - $this->assertEquals( wp_unslash( $this->slash_5 ), $term->description ); + $this->assertSame( wp_unslash( $this->slash_3 ), $term->name ); + $this->assertSame( wp_unslash( $this->slash_5 ), $term->description ); $insert = wp_insert_term( $this->slash_2, @@ -63,8 +63,8 @@ class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { ) ); $term = get_term( $insert['term_id'], $taxonomy ); - $this->assertEquals( wp_unslash( $this->slash_2 ), $term->name ); - $this->assertEquals( wp_unslash( $this->slash_4 ), $term->description ); + $this->assertSame( wp_unslash( $this->slash_2 ), $term->name ); + $this->assertSame( wp_unslash( $this->slash_4 ), $term->description ); } } @@ -93,8 +93,8 @@ class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { ); $term = get_term( $id, $taxonomy ); - $this->assertEquals( wp_unslash( $this->slash_1 ), $term->name ); - $this->assertEquals( wp_unslash( $this->slash_3 ), $term->description ); + $this->assertSame( wp_unslash( $this->slash_1 ), $term->name ); + $this->assertSame( wp_unslash( $this->slash_3 ), $term->description ); $update = wp_update_term( $id, @@ -105,8 +105,8 @@ class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { ) ); $term = get_term( $id, $taxonomy ); - $this->assertEquals( wp_unslash( $this->slash_3 ), $term->name ); - $this->assertEquals( wp_unslash( $this->slash_5 ), $term->description ); + $this->assertSame( wp_unslash( $this->slash_3 ), $term->name ); + $this->assertSame( wp_unslash( $this->slash_5 ), $term->description ); $update = wp_update_term( $id, @@ -117,8 +117,8 @@ class Tests_Term_Slashes extends WP_Ajax_UnitTestCase { ) ); $term = get_term( $id, $taxonomy ); - $this->assertEquals( wp_unslash( $this->slash_2 ), $term->name ); - $this->assertEquals( wp_unslash( $this->slash_4 ), $term->description ); + $this->assertSame( wp_unslash( $this->slash_2 ), $term->name ); + $this->assertSame( wp_unslash( $this->slash_4 ), $term->description ); } } } diff --git a/tests/phpunit/tests/term/splitSharedTerm.php b/tests/phpunit/tests/term/splitSharedTerm.php index ff540f68db..e3563fd348 100644 --- a/tests/phpunit/tests/term/splitSharedTerm.php +++ b/tests/phpunit/tests/term/splitSharedTerm.php @@ -100,7 +100,7 @@ class Tests_Term_SplitSharedTerm extends WP_UnitTestCase { ) ); - $this->assertEquals( $this->terms['t2_child']['term_taxonomy_id'], $children[0]->term_taxonomy_id ); + $this->assertSame( $this->terms['t2_child']['term_taxonomy_id'], $children[0]->term_taxonomy_id ); } /** @@ -115,7 +115,7 @@ class Tests_Term_SplitSharedTerm extends WP_UnitTestCase { ) ); - $this->assertEquals( $this->terms['t2_child']['term_taxonomy_id'], $children[0]->term_taxonomy_id ); + $this->assertSame( $this->terms['t2_child']['term_taxonomy_id'], $children[0]->term_taxonomy_id ); } /** @@ -156,7 +156,7 @@ class Tests_Term_SplitSharedTerm extends WP_UnitTestCase { $new_term_id = _split_shared_term( $t1['term_id'], $t3['term_taxonomy_id'] ); $t2_children = get_term_children( $t2['term_id'], 'wptests_tax_4' ); - $this->assertEquals( array( $new_term_id ), $t2_children ); + $this->assertSame( array( $new_term_id ), $t2_children ); } /** @@ -180,12 +180,12 @@ class Tests_Term_SplitSharedTerm extends WP_UnitTestCase { array( '%d' ) ); - $this->assertEquals( $t1['term_id'], get_option( 'default_category', -1 ) ); + $this->assertSame( $t1['term_id'], get_option( 'default_category', -1 ) ); $new_term_id = _split_shared_term( $t1['term_id'], $t1['term_taxonomy_id'] ); $this->assertNotEquals( $new_term_id, $t1['term_id'] ); - $this->assertEquals( $new_term_id, get_option( 'default_category', -1 ) ); + $this->assertSame( $new_term_id, get_option( 'default_category', -1 ) ); } /** @@ -252,7 +252,7 @@ class Tests_Term_SplitSharedTerm extends WP_UnitTestCase { $new_term_id = _split_shared_term( $shared_term_id, $nav_term->term_taxonomy_id ); $locations = get_nav_menu_locations(); - $this->assertEquals( $new_term_id, $locations['foo'] ); + $this->assertSame( $new_term_id, $locations['foo'] ); } /** @@ -301,7 +301,7 @@ class Tests_Term_SplitSharedTerm extends WP_UnitTestCase { $this->assertSame( 'Updated Foo Menu', $menu->description ); $menu_items = wp_get_nav_menu_items( $new_nav_menu_id ); - $this->assertEquals( array( $cat_menu_item ), wp_list_pluck( $menu_items, 'ID' ) ); + $this->assertSame( array( $cat_menu_item ), wp_list_pluck( $menu_items, 'ID' ) ); } public function test_wp_get_split_terms() { @@ -317,6 +317,6 @@ class Tests_Term_SplitSharedTerm extends WP_UnitTestCase { public function test_wp_get_split_term() { $found = wp_get_split_term( $this->terms['t1']['term_id'], 'wptests_tax_3' ); - $this->assertEquals( $this->terms['t3']['term_id'], $found ); + $this->assertSame( $this->terms['t3']['term_id'], $found ); } } diff --git a/tests/phpunit/tests/term/taxQuery.php b/tests/phpunit/tests/term/taxQuery.php index b464dba3f0..495a21ea5f 100644 --- a/tests/phpunit/tests/term/taxQuery.php +++ b/tests/phpunit/tests/term/taxQuery.php @@ -94,7 +94,7 @@ class Tests_Term_Tax_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( array( 'foo' ), $tq->queries[0]['terms'] ); + $this->assertSame( array( 'foo' ), $tq->queries[0]['terms'] ); } /** @@ -237,7 +237,7 @@ class Tests_Term_Tax_Query extends WP_UnitTestCase { ); $tq->transform_query( $tq->queries[0], 'term_id' ); - $this->assertEquals( array( $t1 ), $tq->queries[0]['terms'] ); + $this->assertSame( array( $t1 ), $tq->queries[0]['terms'] ); $this->assertSame( 'term_id', $tq->queries[0]['field'] ); } diff --git a/tests/phpunit/tests/term/termExists.php b/tests/phpunit/tests/term/termExists.php index 27aa2791df..0cf7d79250 100644 --- a/tests/phpunit/tests/term/termExists.php +++ b/tests/phpunit/tests/term/termExists.php @@ -150,7 +150,7 @@ class Tests_TermExists extends WP_UnitTestCase { _unregister_taxonomy( 'foo' ); - $this->assertSame( null, $found ); + $this->assertNull( $found ); } public function test_term_exists_taxonomy_nonempty_parent_nonempty_match_name() { @@ -273,8 +273,8 @@ class Tests_TermExists extends WP_UnitTestCase { function test_term_exists_unknown() { $this->assertNull( term_exists( rand_str() ) ); - $this->assertEquals( 0, term_exists( 0 ) ); - $this->assertEquals( 0, term_exists( '' ) ); - $this->assertEquals( 0, term_exists( null ) ); + $this->assertSame( 0, term_exists( 0 ) ); + $this->assertNull( term_exists( '' ) ); + $this->assertNull( term_exists( null ) ); } } diff --git a/tests/phpunit/tests/term/wpDeleteTerm.php b/tests/phpunit/tests/term/wpDeleteTerm.php index 2385c8d08d..83855e17cd 100644 --- a/tests/phpunit/tests/term/wpDeleteTerm.php +++ b/tests/phpunit/tests/term/wpDeleteTerm.php @@ -28,11 +28,11 @@ class Tests_Term_WpDeleteTerm extends WP_UnitTestCase { add_action( 'delete_term', array( $this, 'catch_deleted_term' ), 10, 5 ); wp_delete_term( $terms[0], 'wptests_tax' ); - $this->assertEquals( 1, $this->deleted_term->count ); + $this->assertSame( 1, $this->deleted_term->count ); $this->assertSame( $this->object_ids, array( "$post_id" ) ); wp_delete_term( $terms[1], 'wptests_tax' ); - $this->assertEquals( 0, $this->deleted_term->count ); + $this->assertSame( 0, $this->deleted_term->count ); $this->assertSame( $this->object_ids, array() ); } diff --git a/tests/phpunit/tests/term/wpGetObjectTerms.php b/tests/phpunit/tests/term/wpGetObjectTerms.php index c998c88c28..660b9e3d2a 100644 --- a/tests/phpunit/tests/term/wpGetObjectTerms.php +++ b/tests/phpunit/tests/term/wpGetObjectTerms.php @@ -20,7 +20,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { // Set the initial terms. $tt_1 = wp_set_object_terms( $post_id, $terms_1, $this->taxonomy ); - $this->assertEquals( 3, count( $tt_1 ) ); + $this->assertSame( 3, count( $tt_1 ) ); // Make sure they're correct. $terms = wp_get_object_terms( @@ -31,7 +31,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { 'orderby' => 'term_id', ) ); - $this->assertEquals( $terms_1_slugs, $terms ); + $this->assertSame( $terms_1_slugs, $terms ); } /** @@ -47,7 +47,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { $terms = wp_get_object_terms( array( $post_id1, $post_id2 ), 'category' ); $this->assertCount( 2, $terms ); - $this->assertEquals( array( $cat_id, $cat_id2 ), wp_list_pluck( $terms, 'term_id' ) ); + $this->assertSame( array( $cat_id, $cat_id2 ), wp_list_pluck( $terms, 'term_id' ) ); $terms2 = wp_get_object_terms( array( $post_id1, $post_id2 ), @@ -58,7 +58,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ); $this->assertCount( 3, $terms2 ); - $this->assertEquals( array( $cat_id, $cat_id, $cat_id2 ), wp_list_pluck( $terms2, 'term_id' ) ); + $this->assertSame( array( $cat_id, $cat_id, $cat_id2 ), wp_list_pluck( $terms2, 'term_id' ) ); } /** @@ -149,7 +149,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t1, $t3, $t2 ), $found ); + $this->assertSame( array( $t1, $t3, $t2 ), $found ); } public function test_orderby_count() { @@ -187,7 +187,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t2, $t1, $t3 ), $found ); + $this->assertSame( array( $t2, $t1, $t3 ), $found ); } public function test_orderby_slug() { @@ -223,7 +223,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t1, $t3, $t2 ), $found ); + $this->assertSame( array( $t1, $t3, $t2 ), $found ); } public function test_orderby_term_group() { @@ -262,7 +262,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t1, $t3, $t2 ), $found ); + $this->assertSame( array( $t1, $t3, $t2 ), $found ); } public function test_orderby_term_order() { @@ -326,7 +326,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t1, $t3, $t2 ), $found ); + $this->assertSame( array( $t1, $t3, $t2 ), $found ); } /** @@ -371,7 +371,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t1, $t3, $t2 ), $found ); + $this->assertSame( array( $t1, $t3, $t2 ), $found ); } /** @@ -412,7 +412,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t1, $t3, $t2 ), $found ); + $this->assertSame( array( $t1, $t3, $t2 ), $found ); } /** @@ -458,7 +458,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t1, $t3, $t2 ), $found ); + $this->assertSame( array( $t1, $t3, $t2 ), $found ); } public function test_order_desc() { @@ -495,7 +495,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t2, $t3, $t1 ), $found ); + $this->assertSame( array( $t2, $t3, $t1 ), $found ); } /** @@ -546,7 +546,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { ) ); - $this->assertEquals( array( $t3 ), $found ); + $this->assertSame( array( $t3 ), $found ); } /** @@ -927,7 +927,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { $found = wp_get_object_terms( $p, $this->taxonomy, 'orderby=name&fields=ids' ); - $this->assertEquals( array( $t1, $t3, $t2 ), $found ); + $this->assertSame( array( $t1, $t3, $t2 ), $found ); } /** @@ -946,11 +946,11 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { // Test directly. $get_object_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'names' ) ); - $this->assertEquals( $terms, $get_object_terms ); + $this->assertSame( $terms, $get_object_terms ); // Test metabox taxonomy (admin advanced edit). $terms_to_edit = get_terms_to_edit( $post_id, $taxonomy ); - $this->assertEquals( implode( ',', $terms ), $terms_to_edit ); + $this->assertSame( implode( ',', $terms ), $terms_to_edit ); } function filter_wp_get_object_terms_args( $args, $object_ids, $taxonomies ) { diff --git a/tests/phpunit/tests/term/wpInsertTerm.php b/tests/phpunit/tests/term/wpInsertTerm.php index 8299dca198..a28d3c4065 100644 --- a/tests/phpunit/tests/term/wpInsertTerm.php +++ b/tests/phpunit/tests/term/wpInsertTerm.php @@ -211,7 +211,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $term7 = self::factory()->tag->create( array( 'name' => 'T$$$$' ) ); $this->assertWPError( $term7 ); $this->assertNotEmpty( $term7->errors ); - $this->assertEquals( $term6, $term7->error_data['term_exists'] ); + $this->assertSame( $term6, $term7->error_data['term_exists'] ); $terms = array_map( 'get_tag', array( $term3, $term4, $term5, $term6 ) ); $this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) ); @@ -224,7 +224,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $term12 = self::factory()->tag->create( array( 'name' => '$$$$' ) ); $this->assertWPError( $term12 ); $this->assertNotEmpty( $term12->errors ); - $this->assertEquals( $term11, $term12->error_data['term_exists'] ); + $this->assertSame( $term11, $term12->error_data['term_exists'] ); $terms = array_map( 'get_tag', array( $term8, $term9, $term10, $term11 ) ); $this->assertCount( 4, array_unique( wp_list_pluck( $terms, 'slug' ) ) ); @@ -817,8 +817,8 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { ); _unregister_taxonomy( 'wptests_tax' ); - $this->assertSame( false, wp_cache_get( 'all_ids', 'wptests_tax' ) ); - $this->assertSame( false, wp_cache_get( 'get', 'wptests_tax' ) ); + $this->assertFalse( wp_cache_get( 'all_ids', 'wptests_tax' ) ); + $this->assertFalse( wp_cache_get( 'get', 'wptests_tax' ) ); $cached_children = get_option( 'wptests_tax_children' ); $this->assertNotEmpty( $cached_children[ $t ] ); @@ -904,8 +904,8 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $this->assertInternalType( 'int', $term ); $this->assertInternalType( 'array', $object_ids ); // Pesky string $this->assertInternalType( 'int', $tt_id ); - $this->assertEquals( $term, $deleted_term->term_id ); - $this->assertEquals( $taxonomy, $deleted_term->taxonomy ); + $this->assertSame( $term, $deleted_term->term_id ); + $this->assertSame( $taxonomy, $deleted_term->taxonomy ); $this->assertEquals( $tt_id, $deleted_term->term_taxonomy_id ); $this->assertEmpty( $object_ids ); } diff --git a/tests/phpunit/tests/term/wpSetObjectTerms.php b/tests/phpunit/tests/term/wpSetObjectTerms.php index c3d146b34d..79e7f35b05 100644 --- a/tests/phpunit/tests/term/wpSetObjectTerms.php +++ b/tests/phpunit/tests/term/wpSetObjectTerms.php @@ -113,19 +113,19 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { foreach ( $ids as $id ) { $tt = wp_set_object_terms( $id, array_values( $term_id ), $this->taxonomy ); // Should return three term taxonomy IDs. - $this->assertEquals( 3, count( $tt ) ); + $this->assertSame( 3, count( $tt ) ); } // Each term should be associated with every post. foreach ( $term_id as $term => $id ) { $actual = get_objects_in_term( $id, $this->taxonomy ); - $this->assertEquals( $ids, array_map( 'intval', $actual ) ); + $this->assertSame( $ids, array_map( 'intval', $actual ) ); } // Each term should have a count of 5. foreach ( array_keys( $term_id ) as $term ) { $t = get_term_by( 'name', $term, $this->taxonomy ); - $this->assertEquals( 5, $t->count ); + $this->assertSame( 5, $t->count ); } } @@ -141,7 +141,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { foreach ( $ids as $id ) { $tt = wp_set_object_terms( $id, $terms, $this->taxonomy ); // Should return three term taxonomy IDs. - $this->assertEquals( 3, count( $tt ) ); + $this->assertSame( 3, count( $tt ) ); // Remember which term has which term_id. for ( $i = 0; $i < 3; $i++ ) { $term = get_term_by( 'name', $terms[ $i ], $this->taxonomy ); @@ -152,13 +152,13 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { // Each term should be associated with every post. foreach ( $term_id as $term => $id ) { $actual = get_objects_in_term( $id, $this->taxonomy ); - $this->assertEquals( $ids, array_map( 'intval', $actual ) ); + $this->assertSame( $ids, array_map( 'intval', $actual ) ); } // Each term should have a count of 5. foreach ( $terms as $term ) { $t = get_term_by( 'name', $term, $this->taxonomy ); - $this->assertEquals( 5, $t->count ); + $this->assertSame( 5, $t->count ); } } @@ -268,7 +268,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { // Set the initial terms. $tt_1 = wp_set_object_terms( $post_id, $terms_1, $this->taxonomy ); - $this->assertEquals( 3, count( $tt_1 ) ); + $this->assertSame( 3, count( $tt_1 ) ); // Make sure they're correct. $terms = wp_get_object_terms( @@ -279,11 +279,11 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { 'orderby' => 'term_id', ) ); - $this->assertEquals( $terms_1, $terms ); + $this->assertSame( $terms_1, $terms ); // Change the terms. $tt_2 = wp_set_object_terms( $post_id, $terms_2, $this->taxonomy ); - $this->assertEquals( 2, count( $tt_2 ) ); + $this->assertSame( 2, count( $tt_2 ) ); // Make sure they're correct. $terms = wp_get_object_terms( @@ -294,10 +294,10 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { 'orderby' => 'term_id', ) ); - $this->assertEquals( $terms_2, $terms ); + $this->assertSame( $terms_2, $terms ); // Make sure the term taxonomy ID for 'bar' matches. - $this->assertEquals( $tt_1[1], $tt_2[0] ); + $this->assertSame( $tt_1[1], $tt_2[0] ); } @@ -312,7 +312,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { // Set the initial terms. $tt_1 = wp_set_object_terms( $post_id, $terms_1, $this->taxonomy ); - $this->assertEquals( 3, count( $tt_1 ) ); + $this->assertSame( 3, count( $tt_1 ) ); // Make sure they're correct. $terms = wp_get_object_terms( @@ -323,11 +323,11 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { 'orderby' => 'term_id', ) ); - $this->assertEquals( $terms_1, $terms ); + $this->assertSame( $terms_1, $terms ); // Change the terms. $tt_2 = wp_set_object_terms( $post_id, $terms_2, $this->taxonomy ); - $this->assertEquals( 2, count( $tt_2 ) ); + $this->assertSame( 2, count( $tt_2 ) ); // Make sure they're correct. $terms = wp_get_object_terms( @@ -338,7 +338,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { 'orderby' => 'term_id', ) ); - $this->assertEquals( $terms_2, $terms ); + $this->assertSame( $terms_2, $terms ); // Make sure the term taxonomy ID for 'bar' matches. $this->assertEquals( $tt_1[1], $tt_2[0] ); diff --git a/tests/phpunit/tests/term/wpUniqueTermSlug.php b/tests/phpunit/tests/term/wpUniqueTermSlug.php index 75501edab6..c2efa334a1 100644 --- a/tests/phpunit/tests/term/wpUniqueTermSlug.php +++ b/tests/phpunit/tests/term/wpUniqueTermSlug.php @@ -20,7 +20,7 @@ class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { ); $actual = wp_unique_term_slug( 'bar', $term ); - $this->assertEquals( 'bar', $actual ); + $this->assertSame( 'bar', $actual ); } public function test_nonunique_slug_in_different_taxonomy_should_be_unchanged() { @@ -42,7 +42,7 @@ class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { $term2_object = get_term( $term2, 'wptests_tax1' ); $actual = wp_unique_term_slug( 'bar', $term2_object ); - $this->assertEquals( 'bar', $actual ); + $this->assertSame( 'bar', $actual ); } public function test_nonunique_slug_in_same_nonhierarchical_taxonomy_should_be_changed() { @@ -64,7 +64,7 @@ class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { $term2_object = get_term( $term2, 'wptests_tax1' ); $actual = wp_unique_term_slug( 'bar', $term2_object ); - $this->assertEquals( 'bar-2', $actual ); + $this->assertSame( 'bar-2', $actual ); } public function test_nonunique_slug_in_same_hierarchical_taxonomy_with_same_parent_should_be_suffixed_with_parent_slug() { @@ -95,7 +95,7 @@ class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { $term2_object = get_term( $term2, 'wptests_tax2' ); $actual = wp_unique_term_slug( 'bar', $term2_object ); - $this->assertEquals( 'bar-parent-term', $actual ); + $this->assertSame( 'bar-parent-term', $actual ); } public function test_nonunique_slug_in_same_hierarchical_taxonomy_at_different_level_of_hierarchy_should_be_suffixed_with_number() { @@ -125,7 +125,7 @@ class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase { $term2_object = get_term( $term2, 'wptests_tax2' ); $actual = wp_unique_term_slug( 'bar', $term2_object ); - $this->assertEquals( 'bar-2', $actual ); + $this->assertSame( 'bar-2', $actual ); } /** diff --git a/tests/phpunit/tests/term/wpUpdateTerm.php b/tests/phpunit/tests/term/wpUpdateTerm.php index 5de6d83c59..2f4b23120d 100644 --- a/tests/phpunit/tests/term/wpUpdateTerm.php +++ b/tests/phpunit/tests/term/wpUpdateTerm.php @@ -115,7 +115,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { $this->assertSame( 'missing_parent', $found->get_error_code() ); $term = get_term( $t, 'wptests_tax' ); - $this->assertEquals( 0, $term->parent ); + $this->assertSame( 0, $term->parent ); _unregister_taxonomy( 'wptests_tax' ); } @@ -680,8 +680,8 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { ); _unregister_taxonomy( 'wptests_tax' ); - $this->assertSame( false, wp_cache_get( 'all_ids', 'wptests_tax' ) ); - $this->assertSame( false, wp_cache_get( 'get', 'wptests_tax' ) ); + $this->assertFalse( wp_cache_get( 'all_ids', 'wptests_tax' ) ); + $this->assertFalse( wp_cache_get( 'get', 'wptests_tax' ) ); $cached_children = get_option( 'wptests_tax_children' ); $this->assertNotEmpty( $cached_children[ $t2 ] ); diff --git a/tests/phpunit/tests/theme.php b/tests/phpunit/tests/theme.php index b0b0d1b55c..2214a45550 100644 --- a/tests/phpunit/tests/theme.php +++ b/tests/phpunit/tests/theme.php @@ -49,10 +49,10 @@ class Tests_Theme extends WP_UnitTestCase { function test_wp_get_themes_default() { $themes = wp_get_themes(); $this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_slug ] ); - $this->assertEquals( $this->theme_name, $themes[ $this->theme_slug ]->get( 'Name' ) ); + $this->assertSame( $this->theme_name, $themes[ $this->theme_slug ]->get( 'Name' ) ); $single_theme = wp_get_theme( $this->theme_slug ); - $this->assertEquals( $single_theme->get( 'Name' ), $themes[ $this->theme_slug ]->get( 'Name' ) ); + $this->assertSame( $single_theme->get( 'Name' ), $themes[ $this->theme_slug ]->get( 'Name' ) ); $this->assertEquals( $themes[ $this->theme_slug ], $single_theme ); } @@ -63,11 +63,11 @@ class Tests_Theme extends WP_UnitTestCase { function test_get_themes_default() { $themes = get_themes(); $this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_name ] ); - $this->assertEquals( $themes[ $this->theme_name ], get_theme( $this->theme_name ) ); + $this->assertSame( $themes[ $this->theme_name ], get_theme( $this->theme_name ) ); - $this->assertEquals( $this->theme_name, $themes[ $this->theme_name ]['Name'] ); - $this->assertEquals( $this->theme_name, $themes[ $this->theme_name ]->Name ); - $this->assertEquals( $this->theme_name, $themes[ $this->theme_name ]->name ); + $this->assertSame( $this->theme_name, $themes[ $this->theme_name ]['Name'] ); + $this->assertSame( $this->theme_name, $themes[ $this->theme_name ]->Name ); + $this->assertSame( $this->theme_name, $themes[ $this->theme_name ]->name ); } /** @@ -81,7 +81,7 @@ class Tests_Theme extends WP_UnitTestCase { // WP_Theme implements ArrayAccess. Even ArrayObject returns false for is_array(). $this->assertFalse( is_array( $theme ) ); $this->assertInstanceOf( 'WP_Theme', $theme ); - $this->assertEquals( $theme, $themes[ $name ] ); + $this->assertSame( $theme, $themes[ $name ] ); } } @@ -92,7 +92,7 @@ class Tests_Theme extends WP_UnitTestCase { $this->assertFalse( $theme->errors() ); $_theme = wp_get_theme( $theme->get_stylesheet() ); // This primes internal WP_Theme caches for the next assertion (headers_sanitized, textdomain_loaded). - $this->assertEquals( $theme->get( 'Name' ), $_theme->get( 'Name' ) ); + $this->assertSame( $theme->get( 'Name' ), $_theme->get( 'Name' ) ); $this->assertEquals( $theme, $_theme ); } } @@ -109,7 +109,7 @@ class Tests_Theme extends WP_UnitTestCase { continue; } - $this->assertEquals( $theme['Name'], $k ); + $this->assertSame( $theme['Name'], $k ); $this->assertNotEmpty( $theme['Title'] ); // Important attributes should all be set. @@ -162,7 +162,7 @@ class Tests_Theme extends WP_UnitTestCase { $this->assertTrue( is_dir( $dir . $theme['Template Dir'] ) ); $this->assertTrue( is_dir( $dir . $theme['Stylesheet Dir'] ) ); - $this->assertEquals( 'publish', $theme['Status'] ); + $this->assertSame( 'publish', $theme['Status'] ); $this->assertTrue( is_file( $dir . $theme['Stylesheet Dir'] . '/' . $theme['Screenshot'] ) ); $this->assertTrue( is_readable( $dir . $theme['Stylesheet Dir'] . '/' . $theme['Screenshot'] ) ); @@ -172,21 +172,21 @@ class Tests_Theme extends WP_UnitTestCase { function test_wp_get_theme_contents() { $theme = wp_get_theme( $this->theme_slug ); - $this->assertEquals( $this->theme_name, $theme->get( 'Name' ) ); + $this->assertSame( $this->theme_name, $theme->get( 'Name' ) ); $this->assertNotEmpty( $theme->get( 'Description' ) ); $this->assertNotEmpty( $theme->get( 'Author' ) ); $this->assertNotEmpty( $theme->get( 'Version' ) ); $this->assertNotEmpty( $theme->get( 'AuthorURI' ) ); $this->assertNotEmpty( $theme->get( 'ThemeURI' ) ); - $this->assertEquals( $this->theme_slug, $theme->get_stylesheet() ); - $this->assertEquals( $this->theme_slug, $theme->get_template() ); + $this->assertSame( $this->theme_slug, $theme->get_stylesheet() ); + $this->assertSame( $this->theme_slug, $theme->get_template() ); - $this->assertEquals( 'publish', $theme->get( 'Status' ) ); + $this->assertSame( 'publish', $theme->get( 'Status' ) ); - $this->assertEquals( WP_CONTENT_DIR . '/themes/' . $this->theme_slug, $theme->get_stylesheet_directory(), 'get_stylesheet_directory' ); - $this->assertEquals( WP_CONTENT_DIR . '/themes/' . $this->theme_slug, $theme->get_template_directory(), 'get_template_directory' ); - $this->assertEquals( content_url( 'themes/' . $this->theme_slug ), $theme->get_stylesheet_directory_uri(), 'get_stylesheet_directory_uri' ); - $this->assertEquals( content_url( 'themes/' . $this->theme_slug ), $theme->get_template_directory_uri(), 'get_template_directory_uri' ); + $this->assertSame( WP_CONTENT_DIR . '/themes/' . $this->theme_slug, $theme->get_stylesheet_directory(), 'get_stylesheet_directory' ); + $this->assertSame( WP_CONTENT_DIR . '/themes/' . $this->theme_slug, $theme->get_template_directory(), 'get_template_directory' ); + $this->assertSame( content_url( 'themes/' . $this->theme_slug ), $theme->get_stylesheet_directory_uri(), 'get_stylesheet_directory_uri' ); + $this->assertSame( content_url( 'themes/' . $this->theme_slug ), $theme->get_template_directory_uri(), 'get_template_directory_uri' ); } /** @@ -205,7 +205,7 @@ class Tests_Theme extends WP_UnitTestCase { function test_default_themes_have_textdomain() { foreach ( $this->default_themes as $theme ) { if ( wp_get_theme( $theme )->exists() ) { - $this->assertEquals( $theme, wp_get_theme( $theme )->get( 'TextDomain' ) ); + $this->assertSame( $theme, wp_get_theme( $theme )->get( 'TextDomain' ) ); } } } @@ -227,12 +227,12 @@ class Tests_Theme extends WP_UnitTestCase { preg_match( '#Copyright (\d+) WordPress.org#', $readme, $matches ); if ( $matches ) { - $this->assertEquals( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." ); + $this->assertSame( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." ); } preg_match( '#Copyright 20\d\d-(\d+) WordPress.org#', $readme, $matches ); if ( $matches ) { - $this->assertEquals( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." ); + $this->assertSame( $this_year, trim( $matches[1] ), "Bundled themes readme.txt's year needs to be updated to $this_year." ); } } } @@ -277,11 +277,11 @@ class Tests_Theme extends WP_UnitTestCase { switch_theme( $theme['Stylesheet'] ); } - $this->assertEquals( $name, get_current_theme() ); + $this->assertSame( $name, get_current_theme() ); // Make sure the various get_* functions return the correct values. - $this->assertEquals( $theme['Template'], get_template() ); - $this->assertEquals( $theme['Stylesheet'], get_stylesheet() ); + $this->assertSame( $theme['Template'], get_template() ); + $this->assertSame( $theme['Stylesheet'], get_stylesheet() ); $root_fs = get_theme_root(); $this->assertTrue( is_dir( $root_fs ) ); @@ -289,42 +289,42 @@ class Tests_Theme extends WP_UnitTestCase { $root_uri = get_theme_root_uri(); $this->assertTrue( ! empty( $root_uri ) ); - $this->assertEquals( $root_fs . '/' . get_stylesheet(), get_stylesheet_directory() ); - $this->assertEquals( $root_uri . '/' . get_stylesheet(), get_stylesheet_directory_uri() ); - $this->assertEquals( $root_uri . '/' . get_stylesheet() . '/style.css', get_stylesheet_uri() ); - // $this->assertEquals( $root_uri . '/' . get_stylesheet(), get_locale_stylesheet_uri() ); + $this->assertSame( $root_fs . '/' . get_stylesheet(), get_stylesheet_directory() ); + $this->assertSame( $root_uri . '/' . get_stylesheet(), get_stylesheet_directory_uri() ); + $this->assertSame( $root_uri . '/' . get_stylesheet() . '/style.css', get_stylesheet_uri() ); + // $this->assertSame( $root_uri . '/' . get_stylesheet(), get_locale_stylesheet_uri() ); - $this->assertEquals( $root_fs . '/' . get_template(), get_template_directory() ); - $this->assertEquals( $root_uri . '/' . get_template(), get_template_directory_uri() ); + $this->assertSame( $root_fs . '/' . get_template(), get_template_directory() ); + $this->assertSame( $root_uri . '/' . get_template(), get_template_directory_uri() ); // get_query_template() // Template file that doesn't exist. - $this->assertEquals( '', get_query_template( rand_str() ) ); + $this->assertSame( '', get_query_template( rand_str() ) ); // Template files that do exist. /* foreach ( $theme['Template Files'] as $path ) { $file = basename($path, '.php'); FIXME: untestable because get_query_template() uses TEMPLATEPATH. - $this->assertEquals('', get_query_template($file)); + $this->assertSame('', get_query_template($file)); } */ // These are kind of tautologies but at least exercise the code. - $this->assertEquals( get_404_template(), get_query_template( '404' ) ); - $this->assertEquals( get_archive_template(), get_query_template( 'archive' ) ); - $this->assertEquals( get_author_template(), get_query_template( 'author' ) ); - $this->assertEquals( get_category_template(), get_query_template( 'category' ) ); - $this->assertEquals( get_date_template(), get_query_template( 'date' ) ); - $this->assertEquals( get_home_template(), get_query_template( 'home', array( 'home.php', 'index.php' ) ) ); - $this->assertEquals( get_privacy_policy_template(), get_query_template( 'privacy_policy', array( 'privacy-policy.php' ) ) ); - $this->assertEquals( get_page_template(), get_query_template( 'page' ) ); - $this->assertEquals( get_search_template(), get_query_template( 'search' ) ); - $this->assertEquals( get_single_template(), get_query_template( 'single' ) ); - $this->assertEquals( get_attachment_template(), get_query_template( 'attachment' ) ); + $this->assertSame( get_404_template(), get_query_template( '404' ) ); + $this->assertSame( get_archive_template(), get_query_template( 'archive' ) ); + $this->assertSame( get_author_template(), get_query_template( 'author' ) ); + $this->assertSame( get_category_template(), get_query_template( 'category' ) ); + $this->assertSame( get_date_template(), get_query_template( 'date' ) ); + $this->assertSame( get_home_template(), get_query_template( 'home', array( 'home.php', 'index.php' ) ) ); + $this->assertSame( get_privacy_policy_template(), get_query_template( 'privacy_policy', array( 'privacy-policy.php' ) ) ); + $this->assertSame( get_page_template(), get_query_template( 'page' ) ); + $this->assertSame( get_search_template(), get_query_template( 'search' ) ); + $this->assertSame( get_single_template(), get_query_template( 'single' ) ); + $this->assertSame( get_attachment_template(), get_query_template( 'attachment' ) ); - $this->assertEquals( get_tag_template(), get_query_template( 'tag' ) ); + $this->assertSame( get_tag_template(), get_query_template( 'tag' ) ); // nb: This probably doesn't run because WP_INSTALLING is defined. $this->assertTrue( validate_current_theme() ); @@ -340,13 +340,13 @@ class Tests_Theme extends WP_UnitTestCase { update_option( 'stylesheet', $style ); $theme = wp_get_theme(); - $this->assertEquals( $style, (string) $theme ); + $this->assertSame( $style, (string) $theme ); $this->assertNotFalse( $theme->errors() ); $this->assertFalse( $theme->exists() ); // These return the bogus name - perhaps not ideal behaviour? - $this->assertEquals( $template, get_template() ); - $this->assertEquals( $style, get_stylesheet() ); + $this->assertSame( $template, get_template() ); + $this->assertSame( $style, get_stylesheet() ); } /** @@ -379,10 +379,10 @@ class Tests_Theme extends WP_UnitTestCase { 'data' => $data, ) ); - $this->assertEquals( get_post( $wp_customize->changeset_post_id() )->post_date, get_post( $nav_created_post_ids[0] )->post_date ); - $this->assertEquals( get_post( $wp_customize->changeset_post_id() )->post_date, get_post( $nav_created_post_ids[1] )->post_date ); - $this->assertEquals( 'auto-draft', get_post_status( $nav_created_post_ids[0] ) ); - $this->assertEquals( 'auto-draft', get_post_status( $nav_created_post_ids[1] ) ); + $this->assertSame( get_post( $wp_customize->changeset_post_id() )->post_date, get_post( $nav_created_post_ids[0] )->post_date ); + $this->assertSame( get_post( $wp_customize->changeset_post_id() )->post_date, get_post( $nav_created_post_ids[1] )->post_date ); + $this->assertSame( 'auto-draft', get_post_status( $nav_created_post_ids[0] ) ); + $this->assertSame( 'auto-draft', get_post_status( $nav_created_post_ids[1] ) ); // Stubs transition to drafts when changeset is saved as a draft. $wp_customize->save_changeset_post( @@ -391,8 +391,8 @@ class Tests_Theme extends WP_UnitTestCase { 'data' => $data, ) ); - $this->assertEquals( 'draft', get_post_status( $nav_created_post_ids[0] ) ); - $this->assertEquals( 'draft', get_post_status( $nav_created_post_ids[1] ) ); + $this->assertSame( 'draft', get_post_status( $nav_created_post_ids[0] ) ); + $this->assertSame( 'draft', get_post_status( $nav_created_post_ids[1] ) ); // Status remains unchanged for stub that the user broke out of the changeset. wp_update_post( @@ -407,13 +407,13 @@ class Tests_Theme extends WP_UnitTestCase { 'data' => $data, ) ); - $this->assertEquals( 'draft', get_post_status( $nav_created_post_ids[0] ) ); - $this->assertEquals( 'private', get_post_status( $nav_created_post_ids[1] ) ); + $this->assertSame( 'draft', get_post_status( $nav_created_post_ids[0] ) ); + $this->assertSame( 'private', get_post_status( $nav_created_post_ids[1] ) ); // Draft stub is trashed when the changeset is trashed. $wp_customize->trash_changeset_post( $wp_customize->changeset_post_id() ); - $this->assertEquals( 'trash', get_post_status( $nav_created_post_ids[0] ) ); - $this->assertEquals( 'private', get_post_status( $nav_created_post_ids[1] ) ); + $this->assertSame( 'trash', get_post_status( $nav_created_post_ids[0] ) ); + $this->assertSame( 'private', get_post_status( $nav_created_post_ids[1] ) ); } /** @@ -452,10 +452,10 @@ class Tests_Theme extends WP_UnitTestCase { register_theme_feature( 'test-feature', $args ); $actual = get_registered_theme_feature( 'test-feature' ); - $this->assertEquals( 'array', $actual['type'] ); + $this->assertSame( 'array', $actual['type'] ); $this->assertTrue( $actual['variadic'] ); - $this->assertEquals( 'My Feature', $actual['description'] ); - $this->assertEquals( array( 'type' => 'string' ), $actual['show_in_rest']['schema']['items'] ); + $this->assertSame( 'My Feature', $actual['description'] ); + $this->assertSame( array( 'type' => 'string' ), $actual['show_in_rest']['schema']['items'] ); } /** @@ -532,7 +532,7 @@ class Tests_Theme extends WP_UnitTestCase { ); $actual = get_registered_theme_feature( 'test-feature' )['show_in_rest']['schema']['type']; - $this->assertEquals( 'array', $actual ); + $this->assertSame( 'array', $actual ); } /** @@ -632,7 +632,7 @@ class Tests_Theme extends WP_UnitTestCase { $registered = register_theme_feature( 'test-feature', $args ); $this->assertWPError( $registered ); - $this->assertEquals( $error_code, $registered->get_error_code() ); + $this->assertSame( $error_code, $registered->get_error_code() ); } public function _dp_register_theme_support_validation() { diff --git a/tests/phpunit/tests/theme/WPTheme.php b/tests/phpunit/tests/theme/WPTheme.php index b06ac49628..c1583cd640 100644 --- a/tests/phpunit/tests/theme/WPTheme.php +++ b/tests/phpunit/tests/theme/WPTheme.php @@ -36,38 +36,38 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase { $theme = new WP_Theme( 'theme1', $this->theme_root ); // Meta. - $this->assertEquals( 'My Theme', $theme->get( 'Name' ) ); - $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) ); - $this->assertEquals( 'An example theme', $theme->get( 'Description' ) ); - $this->assertEquals( 'Minnie Bannister', $theme->get( 'Author' ) ); - $this->assertEquals( 'http://example.com/', $theme->get( 'AuthorURI' ) ); - $this->assertEquals( '1.3', $theme->get( 'Version' ) ); - $this->assertEquals( '', $theme->get( 'Template' ) ); - $this->assertEquals( 'publish', $theme->get( 'Status' ) ); - $this->assertEquals( array(), $theme->get( 'Tags' ) ); + $this->assertSame( 'My Theme', $theme->get( 'Name' ) ); + $this->assertSame( 'http://example.org/', $theme->get( 'ThemeURI' ) ); + $this->assertSame( 'An example theme', $theme->get( 'Description' ) ); + $this->assertSame( 'Minnie Bannister', $theme->get( 'Author' ) ); + $this->assertSame( 'http://example.com/', $theme->get( 'AuthorURI' ) ); + $this->assertSame( '1.3', $theme->get( 'Version' ) ); + $this->assertSame( '', $theme->get( 'Template' ) ); + $this->assertSame( 'publish', $theme->get( 'Status' ) ); + $this->assertSame( array(), $theme->get( 'Tags' ) ); // Important. - $this->assertEquals( 'theme1', $theme->get_stylesheet() ); - $this->assertEquals( 'theme1', $theme->get_template() ); + $this->assertSame( 'theme1', $theme->get_stylesheet() ); + $this->assertSame( 'theme1', $theme->get_template() ); } function test_new_WP_Theme_subdir() { $theme = new WP_Theme( 'subdir/theme2', $this->theme_root ); // Meta. - $this->assertEquals( 'My Subdir Theme', $theme->get( 'Name' ) ); - $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) ); - $this->assertEquals( 'An example theme in a sub directory', $theme->get( 'Description' ) ); - $this->assertEquals( 'Mr. WordPress', $theme->get( 'Author' ) ); - $this->assertEquals( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) ); - $this->assertEquals( '0.1', $theme->get( 'Version' ) ); - $this->assertEquals( '', $theme->get( 'Template' ) ); - $this->assertEquals( 'publish', $theme->get( 'Status' ) ); - $this->assertEquals( array(), $theme->get( 'Tags' ) ); + $this->assertSame( 'My Subdir Theme', $theme->get( 'Name' ) ); + $this->assertSame( 'http://example.org/', $theme->get( 'ThemeURI' ) ); + $this->assertSame( 'An example theme in a sub directory', $theme->get( 'Description' ) ); + $this->assertSame( 'Mr. WordPress', $theme->get( 'Author' ) ); + $this->assertSame( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) ); + $this->assertSame( '0.1', $theme->get( 'Version' ) ); + $this->assertSame( '', $theme->get( 'Template' ) ); + $this->assertSame( 'publish', $theme->get( 'Status' ) ); + $this->assertSame( array(), $theme->get( 'Tags' ) ); // Important. - $this->assertEquals( 'subdir/theme2', $theme->get_stylesheet() ); - $this->assertEquals( 'subdir/theme2', $theme->get_template() ); + $this->assertSame( 'subdir/theme2', $theme->get_stylesheet() ); + $this->assertSame( 'subdir/theme2', $theme->get_template() ); } /** @@ -78,19 +78,19 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase { $theme = new WP_Theme( 'theme2', $this->theme_root . '/subdir' ); // Meta. - $this->assertEquals( 'My Subdir Theme', $theme->get( 'Name' ) ); - $this->assertEquals( 'http://example.org/', $theme->get( 'ThemeURI' ) ); - $this->assertEquals( 'An example theme in a sub directory', $theme->get( 'Description' ) ); - $this->assertEquals( 'Mr. WordPress', $theme->get( 'Author' ) ); - $this->assertEquals( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) ); - $this->assertEquals( '0.1', $theme->get( 'Version' ) ); - $this->assertEquals( '', $theme->get( 'Template' ) ); - $this->assertEquals( 'publish', $theme->get( 'Status' ) ); - $this->assertEquals( array(), $theme->get( 'Tags' ) ); + $this->assertSame( 'My Subdir Theme', $theme->get( 'Name' ) ); + $this->assertSame( 'http://example.org/', $theme->get( 'ThemeURI' ) ); + $this->assertSame( 'An example theme in a sub directory', $theme->get( 'Description' ) ); + $this->assertSame( 'Mr. WordPress', $theme->get( 'Author' ) ); + $this->assertSame( 'http://wordpress.org/', $theme->get( 'AuthorURI' ) ); + $this->assertSame( '0.1', $theme->get( 'Version' ) ); + $this->assertSame( '', $theme->get( 'Template' ) ); + $this->assertSame( 'publish', $theme->get( 'Status' ) ); + $this->assertSame( array(), $theme->get( 'Tags' ) ); // Important. - $this->assertEquals( 'subdir/theme2', $theme->get_stylesheet() ); - $this->assertEquals( 'subdir/theme2', $theme->get_template() ); + $this->assertSame( 'subdir/theme2', $theme->get_stylesheet() ); + $this->assertSame( 'subdir/theme2', $theme->get_template() ); } /** @@ -99,15 +99,15 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase { function test_wp_theme_uris_with_spaces() { $theme = new WP_Theme( 'theme with spaces', $this->theme_root . '/subdir' ); // Make sure subdir/ is considered part of the stylesheet, as we must avoid encoding /'s. - $this->assertEquals( 'subdir/theme with spaces', $theme->get_stylesheet() ); + $this->assertSame( 'subdir/theme with spaces', $theme->get_stylesheet() ); // Check that in a URI path, we have raw URL encoding (spaces become %20). // Don't try to verify the complete URI path. get_theme_root_uri() breaks down quickly. - $this->assertEquals( 'theme%20with%20spaces', basename( $theme->get_stylesheet_directory_uri() ) ); - $this->assertEquals( 'theme%20with%20spaces', basename( $theme->get_template_directory_uri() ) ); + $this->assertSame( 'theme%20with%20spaces', basename( $theme->get_stylesheet_directory_uri() ) ); + $this->assertSame( 'theme%20with%20spaces', basename( $theme->get_template_directory_uri() ) ); // Check that wp_customize_url() uses URL encoding, as it is a query arg (spaces become +). - $this->assertEquals( admin_url( 'customize.php?theme=theme+with+spaces' ), wp_customize_url( 'theme with spaces' ) ); + $this->assertSame( admin_url( 'customize.php?theme=theme+with+spaces' ), wp_customize_url( 'theme with spaces' ) ); } /** @@ -118,8 +118,8 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase { add_filter( 'stylesheet', $callback ); add_filter( 'template', $callback ); - $this->assertEquals( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_stylesheet_directory_uri() ); - $this->assertEquals( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_template_directory_uri() ); + $this->assertSame( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_stylesheet_directory_uri() ); + $this->assertSame( get_theme_root_uri() . '/subdir/theme%20with%20spaces', get_template_directory_uri() ); remove_filter( 'stylesheet', $callback ); remove_filter( 'template', $callback ); @@ -134,7 +134,7 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase { */ function test_display_method_on_get_method_failure() { $theme = new WP_Theme( 'nonexistent', $this->theme_root ); - $this->assertEquals( 'nonexistent', $theme->get( 'Name' ) ); + $this->assertSame( 'nonexistent', $theme->get( 'Name' ) ); $this->assertFalse( $theme->get( 'AuthorURI' ) ); $this->assertFalse( $theme->get( 'Tags' ) ); $this->assertFalse( $theme->display( 'Tags' ) ); @@ -147,7 +147,7 @@ class Tests_Theme_WPTheme extends WP_UnitTestCase { $theme = new WP_Theme( 'child-parent-itself', $this->theme_root ); $errors = $theme->errors(); $this->assertWPError( $errors ); - $this->assertEquals( 'theme_child_invalid', $errors->get_error_code() ); + $this->assertSame( 'theme_child_invalid', $errors->get_error_code() ); } diff --git a/tests/phpunit/tests/theme/customHeader.php b/tests/phpunit/tests/theme/customHeader.php index 23689787e2..229b85dec1 100644 --- a/tests/phpunit/tests/theme/customHeader.php +++ b/tests/phpunit/tests/theme/customHeader.php @@ -62,7 +62,7 @@ class Tests_Theme_Custom_Header extends WP_UnitTestCase { $image = get_header_image(); $this->assertTrue( has_header_image() ); - $this->assertEquals( $default, $image ); + $this->assertSame( $default, $image ); } function test_get_header_image_from_theme_mod() { @@ -72,7 +72,7 @@ class Tests_Theme_Custom_Header extends WP_UnitTestCase { set_theme_mod( 'header_image', $custom ); $image = get_header_image(); - $this->assertEquals( $custom, $image ); + $this->assertSame( $custom, $image ); $this->assertTrue( has_header_image() ); set_theme_mod( 'header_image', 'remove-header' ); @@ -129,7 +129,7 @@ class Tests_Theme_Custom_Header extends WP_UnitTestCase { // The container should always be returned in the Customizer preview. $this->_set_customize_previewing( true ); $html = get_custom_header_markup(); - $this->assertEquals( '<div id="wp-custom-header" class="wp-custom-header"></div>', $html ); + $this->assertSame( '<div id="wp-custom-header" class="wp-custom-header"></div>', $html ); } function test_get_custom_header_markup_with_registered_default_image() { @@ -147,7 +147,7 @@ class Tests_Theme_Custom_Header extends WP_UnitTestCase { $this->assertFalse( has_header_video() ); set_theme_mod( 'header_video', self::$header_video_id ); $this->assertTrue( has_header_video() ); - $this->assertEquals( wp_get_attachment_url( self::$header_video_id ), get_header_video_url() ); + $this->assertSame( wp_get_attachment_url( self::$header_video_id ), get_header_video_url() ); } function test_get_external_header_video_url() { @@ -157,7 +157,7 @@ class Tests_Theme_Custom_Header extends WP_UnitTestCase { $this->assertFalse( has_header_video() ); set_theme_mod( 'external_header_video', $external ); $this->assertTrue( has_header_video() ); - $this->assertEquals( $external, get_header_video_url() ); + $this->assertSame( $external, get_header_video_url() ); } function test_get_header_video_url_prefers_local_video() { @@ -166,7 +166,7 @@ class Tests_Theme_Custom_Header extends WP_UnitTestCase { set_theme_mod( 'header_video', self::$header_video_id ); set_theme_mod( 'external_header_video', $external ); - $this->assertEquals( wp_get_attachment_url( self::$header_video_id ), get_header_video_url() ); + $this->assertSame( wp_get_attachment_url( self::$header_video_id ), get_header_video_url() ); } function test_get_custom_header_markup_with_video_and_without_an_image() { @@ -182,7 +182,7 @@ class Tests_Theme_Custom_Header extends WP_UnitTestCase { $html = get_custom_header_markup(); $this->assertTrue( has_header_video() ); $this->assertTrue( has_custom_header() ); - $this->assertEquals( '<div id="wp-custom-header" class="wp-custom-header"></div>', $html ); + $this->assertSame( '<div id="wp-custom-header" class="wp-custom-header"></div>', $html ); } function test_header_script_is_not_enqueued_by_the_custom_header_markup_without_video() { diff --git a/tests/phpunit/tests/theme/getAllowedFilters.php b/tests/phpunit/tests/theme/getAllowedFilters.php index 00f198a237..212d44ccb9 100644 --- a/tests/phpunit/tests/theme/getAllowedFilters.php +++ b/tests/phpunit/tests/theme/getAllowedFilters.php @@ -21,8 +21,8 @@ if ( is_multisite() ) : WP_Theme::get_allowed( $blog_id ); remove_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ) ); - $this->assertEquals( 2, count( $this->filter_network_allowed_themes_args ) ); - $this->assertEquals( $blog_id, $this->filter_network_allowed_themes_args[1] ); + $this->assertSame( 2, count( $this->filter_network_allowed_themes_args ) ); + $this->assertSame( $blog_id, $this->filter_network_allowed_themes_args[1] ); } /** @@ -39,7 +39,7 @@ if ( is_multisite() ) : $expected = $this->default_allowed + array( 'allow-on-network' => true ); - $this->assertEquals( $expected, $allowed ); + $this->assertSame( $expected, $allowed ); } /** @@ -56,7 +56,7 @@ if ( is_multisite() ) : $expected = $this->default_allowed + array( 'network-allowed-theme' => true ); - $this->assertEquals( $expected, $allowed ); + $this->assertSame( $expected, $allowed ); } /** @@ -73,7 +73,7 @@ if ( is_multisite() ) : $expected = $this->default_allowed + array( 'site-allowed-theme' => true ); - $this->assertEquals( $expected, $allowed ); + $this->assertSame( $expected, $allowed ); } public function filter_allowed_themes( $allowed_themes ) { diff --git a/tests/phpunit/tests/theme/getThemeStarterContent.php b/tests/phpunit/tests/theme/getThemeStarterContent.php index b4ff34cdaf..a0425c8748 100644 --- a/tests/phpunit/tests/theme/getThemeStarterContent.php +++ b/tests/phpunit/tests/theme/getThemeStarterContent.php @@ -148,14 +148,14 @@ class Tests_WP_Theme_Get_Theme_Starter_Content extends WP_UnitTestCase { $this->assertInternalType( 'array', $widget[1] ); $this->assertArrayHasKey( 'title', $widget[1] ); } - $this->assertEquals( 'text', $hydrated_starter_content['widgets']['sidebar-1'][1][0], 'Core content extended' ); - $this->assertEquals( 'Our Story', $hydrated_starter_content['widgets']['sidebar-1'][1][1]['title'], 'Core content extended' ); + $this->assertSame( 'text', $hydrated_starter_content['widgets']['sidebar-1'][1][0], 'Core content extended' ); + $this->assertSame( 'Our Story', $hydrated_starter_content['widgets']['sidebar-1'][1][1]['title'], 'Core content extended' ); foreach ( $hydrated_starter_content['nav_menus']['top']['items'] as $nav_menu_item ) { $this->assertInternalType( 'array', $nav_menu_item ); $this->assertTrue( ! empty( $nav_menu_item['object_id'] ) || ! empty( $nav_menu_item['url'] ) ); } - $this->assertEquals( 'Email Us', $hydrated_starter_content['nav_menus']['top']['items'][4]['title'], 'Core content extended' ); + $this->assertSame( 'Email Us', $hydrated_starter_content['nav_menus']['top']['items'][4]['title'], 'Core content extended' ); foreach ( $hydrated_starter_content['posts'] as $key => $post ) { $this->assertInternalType( 'string', $key ); @@ -164,9 +164,9 @@ class Tests_WP_Theme_Get_Theme_Starter_Content extends WP_UnitTestCase { $this->assertArrayHasKey( 'post_type', $post ); $this->assertArrayHasKey( 'post_title', $post ); } - $this->assertEquals( 'Extended', $hydrated_starter_content['posts']['blog']['post_excerpt'], 'Core content extended' ); - $this->assertEquals( 'blog.php', $hydrated_starter_content['posts']['blog']['template'], 'Core content extended' ); - $this->assertEquals( '{{featured-image-logo}}', $hydrated_starter_content['posts']['custom']['thumbnail'], 'Core content extended' ); + $this->assertSame( 'Extended', $hydrated_starter_content['posts']['blog']['post_excerpt'], 'Core content extended' ); + $this->assertSame( 'blog.php', $hydrated_starter_content['posts']['blog']['template'], 'Core content extended' ); + $this->assertSame( '{{featured-image-logo}}', $hydrated_starter_content['posts']['custom']['thumbnail'], 'Core content extended' ); } /** @@ -189,7 +189,7 @@ class Tests_WP_Theme_Get_Theme_Starter_Content extends WP_UnitTestCase { $starter_content = get_theme_starter_content(); $this->assertCount( 2, $starter_content['widgets']['sidebar-1'] ); - $this->assertEquals( 'Filtered Widget', $starter_content['widgets']['sidebar-1'][1][1]['title'] ); + $this->assertSame( 'Filtered Widget', $starter_content['widgets']['sidebar-1'][1][1]['title'] ); } /** diff --git a/tests/phpunit/tests/theme/support.php b/tests/phpunit/tests/theme/support.php index 79b2be4a1e..25100c46ac 100644 --- a/tests/phpunit/tests/theme/support.php +++ b/tests/phpunit/tests/theme/support.php @@ -25,7 +25,7 @@ class Tests_Theme_Support extends WP_UnitTestCase { add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) ); $this->assertTrue( current_theme_supports( 'admin-bar' ) ); - $this->assertEquals( + $this->assertSame( array( 0 => array( 'callback' => '__return_false' ) ), get_theme_support( 'admin-bar' ) ); @@ -61,7 +61,7 @@ class Tests_Theme_Support extends WP_UnitTestCase { add_theme_support( 'post-thumbnails', array( 'page' ) ); $this->assertTrue( current_theme_supports( 'post-thumbnails', 'post' ) ); $this->assertFalse( current_theme_supports( 'post-thumbnails', 'book' ) ); - $this->assertEquals( + $this->assertSame( array( 0 => array( 'post', 'page' ) ), get_theme_support( 'post-thumbnails' ) ); diff --git a/tests/phpunit/tests/theme/themeDir.php b/tests/phpunit/tests/theme/themeDir.php index a8cfd87f47..ae02c39008 100644 --- a/tests/phpunit/tests/theme/themeDir.php +++ b/tests/phpunit/tests/theme/themeDir.php @@ -46,28 +46,28 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { function test_theme_default() { $themes = get_themes(); $theme = get_theme( 'WordPress Default' ); - $this->assertEquals( $themes['WordPress Default'], $theme ); + $this->assertSame( $themes['WordPress Default'], $theme ); $this->assertFalse( empty( $theme ) ); // echo gen_tests_array( 'theme', $theme ); - $this->assertEquals( 'WordPress Default', $theme['Name'] ); - $this->assertEquals( 'WordPress Default', $theme['Title'] ); - $this->assertEquals( 'The default WordPress theme based on the famous <a href="http://binarybonsai.com/kubrick/">Kubrick</a>.', $theme['Description'] ); - $this->assertEquals( '<a href="http://binarybonsai.com/">Michael Heilemann</a>', $theme['Author'] ); - $this->assertEquals( '1.6', $theme['Version'] ); - $this->assertEquals( 'default', $theme['Template'] ); - $this->assertEquals( 'default', $theme['Stylesheet'] ); + $this->assertSame( 'WordPress Default', $theme['Name'] ); + $this->assertSame( 'WordPress Default', $theme['Title'] ); + $this->assertSame( 'The default WordPress theme based on the famous <a href="http://binarybonsai.com/kubrick/">Kubrick</a>.', $theme['Description'] ); + $this->assertSame( '<a href="http://binarybonsai.com/">Michael Heilemann</a>', $theme['Author'] ); + $this->assertSame( '1.6', $theme['Version'] ); + $this->assertSame( 'default', $theme['Template'] ); + $this->assertSame( 'default', $theme['Stylesheet'] ); $this->assertContains( $this->theme_root . '/default/functions.php', $theme['Template Files'] ); $this->assertContains( $this->theme_root . '/default/index.php', $theme['Template Files'] ); $this->assertContains( $this->theme_root . '/default/style.css', $theme['Stylesheet Files'] ); - $this->assertEquals( $this->theme_root . '/default', $theme['Template Dir'] ); - $this->assertEquals( $this->theme_root . '/default', $theme['Stylesheet Dir'] ); - $this->assertEquals( 'publish', $theme['Status'] ); - $this->assertEquals( '', $theme['Parent Theme'] ); + $this->assertSame( $this->theme_root . '/default', $theme['Template Dir'] ); + $this->assertSame( $this->theme_root . '/default', $theme['Stylesheet Dir'] ); + $this->assertSame( 'publish', $theme['Status'] ); + $this->assertSame( '', $theme['Parent Theme'] ); } /** @@ -81,27 +81,27 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { // echo gen_tests_array( 'theme', $theme ); - $this->assertEquals( 'Sandbox', $theme['Name'] ); - $this->assertEquals( 'Sandbox', $theme['Title'] ); - $this->assertEquals( 'A theme with powerful, semantic CSS selectors and the ability to add new skins.', $theme['Description'] ); - $this->assertEquals( '<a href="http://andy.wordpress.com/">Andy Skelton</a> & <a href="http://www.plaintxt.org/">Scott Allan Wallick</a>', $theme['Author'] ); - $this->assertEquals( '0.6.1-wpcom', $theme['Version'] ); - $this->assertEquals( 'sandbox', $theme['Template'] ); - $this->assertEquals( 'sandbox', $theme['Stylesheet'] ); + $this->assertSame( 'Sandbox', $theme['Name'] ); + $this->assertSame( 'Sandbox', $theme['Title'] ); + $this->assertSame( 'A theme with powerful, semantic CSS selectors and the ability to add new skins.', $theme['Description'] ); + $this->assertSame( '<a href="http://andy.wordpress.com/">Andy Skelton</a> & <a href="http://www.plaintxt.org/">Scott Allan Wallick</a>', $theme['Author'] ); + $this->assertSame( '0.6.1-wpcom', $theme['Version'] ); + $this->assertSame( 'sandbox', $theme['Template'] ); + $this->assertSame( 'sandbox', $theme['Stylesheet'] ); $template_files = $theme['Template Files']; - $this->assertEquals( $this->theme_root . '/sandbox/functions.php', reset( $template_files ) ); - $this->assertEquals( $this->theme_root . '/sandbox/index.php', next( $template_files ) ); + $this->assertSame( $this->theme_root . '/sandbox/functions.php', reset( $template_files ) ); + $this->assertSame( $this->theme_root . '/sandbox/index.php', next( $template_files ) ); $stylesheet_files = $theme['Stylesheet Files']; - $this->assertEquals( $this->theme_root . '/sandbox/style.css', reset( $stylesheet_files ) ); + $this->assertSame( $this->theme_root . '/sandbox/style.css', reset( $stylesheet_files ) ); - $this->assertEquals( $this->theme_root . '/sandbox', $theme['Template Dir'] ); - $this->assertEquals( $this->theme_root . '/sandbox', $theme['Stylesheet Dir'] ); - $this->assertEquals( 'publish', $theme['Status'] ); - $this->assertEquals( '', $theme['Parent Theme'] ); + $this->assertSame( $this->theme_root . '/sandbox', $theme['Template Dir'] ); + $this->assertSame( $this->theme_root . '/sandbox', $theme['Stylesheet Dir'] ); + $this->assertSame( 'publish', $theme['Status'] ); + $this->assertSame( '', $theme['Parent Theme'] ); } @@ -118,22 +118,22 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { // echo gen_tests_array( 'theme', $theme ); - $this->assertEquals( 'Stylesheet Only', $theme['Name'] ); - $this->assertEquals( 'Stylesheet Only', $theme['Title'] ); - $this->assertEquals( 'A three-column widget-ready theme in dark blue.', $theme['Description'] ); - $this->assertEquals( '<a href="http://www.example.com/">Henry Crun</a>', $theme['Author'] ); - $this->assertEquals( '1.0', $theme['Version'] ); - $this->assertEquals( 'sandbox', $theme['Template'] ); - $this->assertEquals( 'stylesheetonly', $theme['Stylesheet'] ); + $this->assertSame( 'Stylesheet Only', $theme['Name'] ); + $this->assertSame( 'Stylesheet Only', $theme['Title'] ); + $this->assertSame( 'A three-column widget-ready theme in dark blue.', $theme['Description'] ); + $this->assertSame( '<a href="http://www.example.com/">Henry Crun</a>', $theme['Author'] ); + $this->assertSame( '1.0', $theme['Version'] ); + $this->assertSame( 'sandbox', $theme['Template'] ); + $this->assertSame( 'stylesheetonly', $theme['Stylesheet'] ); $this->assertContains( $this->theme_root . '/sandbox/functions.php', $theme['Template Files'] ); $this->assertContains( $this->theme_root . '/sandbox/index.php', $theme['Template Files'] ); $this->assertContains( $this->theme_root . '/stylesheetonly/style.css', $theme['Stylesheet Files'] ); - $this->assertEquals( $this->theme_root . '/sandbox', $theme['Template Dir'] ); - $this->assertEquals( $this->theme_root . '/stylesheetonly', $theme['Stylesheet Dir'] ); - $this->assertEquals( 'publish', $theme['Status'] ); - $this->assertEquals( 'Sandbox', $theme['Parent Theme'] ); + $this->assertSame( $this->theme_root . '/sandbox', $theme['Template Dir'] ); + $this->assertSame( $this->theme_root . '/stylesheetonly', $theme['Stylesheet Dir'] ); + $this->assertSame( 'publish', $theme['Status'] ); + $this->assertSame( 'Sandbox', $theme['Parent Theme'] ); } @@ -169,7 +169,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { sort( $theme_names ); sort( $expected ); - $this->assertEquals( $expected, $theme_names ); + $this->assertSame( $expected, $theme_names ); } /** @@ -192,7 +192,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { ), ); - $this->assertEquals( $expected, get_broken_themes() ); + $this->assertSame( $expected, get_broken_themes() ); } function test_wp_get_theme_with_non_default_theme_root() { @@ -219,17 +219,17 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { function test_get_theme_data_top_level() { $theme_data = get_theme_data( DIR_TESTDATA . '/themedir1/theme1/style.css' ); - $this->assertEquals( 'My Theme', $theme_data['Name'] ); - $this->assertEquals( 'http://example.org/', $theme_data['URI'] ); - $this->assertEquals( 'An example theme', $theme_data['Description'] ); - $this->assertEquals( '<a href="http://example.com/">Minnie Bannister</a>', $theme_data['Author'] ); - $this->assertEquals( 'http://example.com/', $theme_data['AuthorURI'] ); - $this->assertEquals( '1.3', $theme_data['Version'] ); - $this->assertEquals( '', $theme_data['Template'] ); - $this->assertEquals( 'publish', $theme_data['Status'] ); - $this->assertEquals( array(), $theme_data['Tags'] ); - $this->assertEquals( 'My Theme', $theme_data['Title'] ); - $this->assertEquals( 'Minnie Bannister', $theme_data['AuthorName'] ); + $this->assertSame( 'My Theme', $theme_data['Name'] ); + $this->assertSame( 'http://example.org/', $theme_data['URI'] ); + $this->assertSame( 'An example theme', $theme_data['Description'] ); + $this->assertSame( '<a href="http://example.com/">Minnie Bannister</a>', $theme_data['Author'] ); + $this->assertSame( 'http://example.com/', $theme_data['AuthorURI'] ); + $this->assertSame( '1.3', $theme_data['Version'] ); + $this->assertSame( '', $theme_data['Template'] ); + $this->assertSame( 'publish', $theme_data['Status'] ); + $this->assertSame( array(), $theme_data['Tags'] ); + $this->assertSame( 'My Theme', $theme_data['Title'] ); + $this->assertSame( 'Minnie Bannister', $theme_data['AuthorName'] ); } /** @@ -238,17 +238,17 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase { function test_get_theme_data_subdir() { $theme_data = get_theme_data( $this->theme_root . '/subdir/theme2/style.css' ); - $this->assertEquals( 'My Subdir Theme', $theme_data['Name'] ); - $this->assertEquals( 'http://example.org/', $theme_data['URI'] ); - $this->assertEquals( 'An example theme in a sub directory', $theme_data['Description'] ); - $this->assertEquals( '<a href="http://wordpress.org/">Mr. WordPress</a>', $theme_data['Author'] ); - $this->assertEquals( 'http://wordpress.org/', $theme_data['AuthorURI'] ); - $this->assertEquals( '0.1', $theme_data['Version'] ); - $this->assertEquals( '', $theme_data['Template'] ); - $this->assertEquals( 'publish', $theme_data['Status'] ); - $this->assertEquals( array(), $theme_data['Tags'] ); - $this->assertEquals( 'My Subdir Theme', $theme_data['Title'] ); - $this->assertEquals( 'Mr. WordPress', $theme_data['AuthorName'] ); + $this->assertSame( 'My Subdir Theme', $theme_data['Name'] ); + $this->assertSame( 'http://example.org/', $theme_data['URI'] ); + $this->assertSame( 'An example theme in a sub directory', $theme_data['Description'] ); + $this->assertSame( '<a href="http://wordpress.org/">Mr. WordPress</a>', $theme_data['Author'] ); + $this->assertSame( 'http://wordpress.org/', $theme_data['AuthorURI'] ); + $this->assertSame( '0.1', $theme_data['Version'] ); + $this->assertSame( '', $theme_data['Template'] ); + $this->assertSame( 'publish', $theme_data['Status'] ); + $this->assertSame( array(), $theme_data['Tags'] ); + $this->assertSame( 'My Subdir Theme', $theme_data['Title'] ); + $this->assertSame( 'Mr. WordPress', $theme_data['AuthorName'] ); } /** diff --git a/tests/phpunit/tests/upload.php b/tests/phpunit/tests/upload.php index 719a756403..8fe2f9e91d 100644 --- a/tests/phpunit/tests/upload.php +++ b/tests/phpunit/tests/upload.php @@ -24,10 +24,10 @@ class Tests_Upload extends WP_UnitTestCase { $info = wp_upload_dir(); $subdir = gmstrftime( '/%Y/%m' ); - $this->assertEquals( get_option( 'siteurl' ) . '/wp-content/uploads' . $subdir, $info['url'] ); - $this->assertEquals( ABSPATH . 'wp-content/uploads' . $subdir, $info['path'] ); - $this->assertEquals( $subdir, $info['subdir'] ); - $this->assertEquals( false, $info['error'] ); + $this->assertSame( get_option( 'siteurl' ) . '/wp-content/uploads' . $subdir, $info['url'] ); + $this->assertSame( ABSPATH . 'wp-content/uploads' . $subdir, $info['path'] ); + $this->assertSame( $subdir, $info['subdir'] ); + $this->assertFalse( $info['error'] ); } function test_upload_dir_relative() { @@ -36,10 +36,10 @@ class Tests_Upload extends WP_UnitTestCase { $info = _wp_upload_dir(); $subdir = gmstrftime( '/%Y/%m' ); - $this->assertEquals( get_option( 'siteurl' ) . '/foo/bar' . $subdir, $info['url'] ); - $this->assertEquals( ABSPATH . 'foo/bar' . $subdir, $info['path'] ); - $this->assertEquals( $subdir, $info['subdir'] ); - $this->assertEquals( false, $info['error'] ); + $this->assertSame( get_option( 'siteurl' ) . '/foo/bar' . $subdir, $info['url'] ); + $this->assertSame( ABSPATH . 'foo/bar' . $subdir, $info['path'] ); + $this->assertSame( $subdir, $info['subdir'] ); + $this->assertFalse( $info['error'] ); } /** @@ -59,10 +59,10 @@ class Tests_Upload extends WP_UnitTestCase { $info = _wp_upload_dir(); $subdir = gmstrftime( '/%Y/%m' ); - $this->assertEquals( '/baz' . $subdir, $info['url'] ); - $this->assertEquals( $path . $subdir, $info['path'] ); - $this->assertEquals( $subdir, $info['subdir'] ); - $this->assertEquals( false, $info['error'] ); + $this->assertSame( '/baz' . $subdir, $info['url'] ); + $this->assertSame( $path . $subdir, $info['path'] ); + $this->assertSame( $subdir, $info['subdir'] ); + $this->assertFalse( $info['error'] ); } function test_upload_dir_no_yearnum() { @@ -71,10 +71,10 @@ class Tests_Upload extends WP_UnitTestCase { // Use `_wp_upload_dir()` directly to bypass caching and work with the changed options. $info = _wp_upload_dir(); - $this->assertEquals( get_option( 'siteurl' ) . '/wp-content/uploads', $info['url'] ); - $this->assertEquals( ABSPATH . 'wp-content/uploads', $info['path'] ); - $this->assertEquals( '', $info['subdir'] ); - $this->assertEquals( false, $info['error'] ); + $this->assertSame( get_option( 'siteurl' ) . '/wp-content/uploads', $info['url'] ); + $this->assertSame( ABSPATH . 'wp-content/uploads', $info['path'] ); + $this->assertSame( '', $info['subdir'] ); + $this->assertFalse( $info['error'] ); } function test_upload_path_absolute() { @@ -85,10 +85,10 @@ class Tests_Upload extends WP_UnitTestCase { $info = _wp_upload_dir(); $subdir = gmstrftime( '/%Y/%m' ); - $this->assertEquals( 'http://' . WP_TESTS_DOMAIN . '/asdf' . $subdir, $info['url'] ); - $this->assertEquals( ABSPATH . 'wp-content/uploads' . $subdir, $info['path'] ); - $this->assertEquals( $subdir, $info['subdir'] ); - $this->assertEquals( false, $info['error'] ); + $this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/asdf' . $subdir, $info['url'] ); + $this->assertSame( ABSPATH . 'wp-content/uploads' . $subdir, $info['path'] ); + $this->assertSame( $subdir, $info['subdir'] ); + $this->assertFalse( $info['error'] ); } function test_upload_dir_empty() { @@ -100,10 +100,10 @@ class Tests_Upload extends WP_UnitTestCase { $info = _wp_upload_dir(); $subdir = gmstrftime( '/%Y/%m' ); - $this->assertEquals( get_option( 'siteurl' ) . '/wp-content/uploads' . $subdir, $info['url'] ); - $this->assertEquals( ABSPATH . 'wp-content/uploads' . $subdir, $info['path'] ); - $this->assertEquals( $subdir, $info['subdir'] ); - $this->assertEquals( false, $info['error'] ); + $this->assertSame( get_option( 'siteurl' ) . '/wp-content/uploads' . $subdir, $info['url'] ); + $this->assertSame( ABSPATH . 'wp-content/uploads' . $subdir, $info['path'] ); + $this->assertSame( $subdir, $info['subdir'] ); + $this->assertFalse( $info['error'] ); } } diff --git a/tests/phpunit/tests/url.php b/tests/phpunit/tests/url.php index 19e58a16ee..0e02963725 100644 --- a/tests/phpunit/tests/url.php +++ b/tests/phpunit/tests/url.php @@ -77,8 +77,8 @@ class Tests_URL extends WP_UnitTestCase { $siteurl_https = set_url_scheme( $siteurl_http, 'https' ); $admin_url_https = admin_url( $url ); - $this->assertEquals( $siteurl_http . $expected, $admin_url_http ); - $this->assertEquals( $siteurl_https . $expected, $admin_url_https ); + $this->assertSame( $siteurl_http . $expected, $admin_url_http ); + $this->assertSame( $siteurl_https . $expected, $admin_url_https ); } function data_admin_urls() { @@ -145,8 +145,8 @@ class Tests_URL extends WP_UnitTestCase { $homeurl_https = set_url_scheme( $homeurl_http, 'https' ); $home_url_https = home_url( $url ); - $this->assertEquals( $homeurl_http . $expected, $home_url_http ); - $this->assertEquals( $homeurl_https . $expected, $home_url_https ); + $this->assertSame( $homeurl_http . $expected, $home_url_http ); + $this->assertSame( $homeurl_https . $expected, $home_url_https ); } function data_home_urls() { @@ -207,17 +207,17 @@ class Tests_URL extends WP_UnitTestCase { // home_url() should return http when in the admin. $_SERVER['HTTPS'] = 'on'; - $this->assertEquals( $home, home_url() ); + $this->assertSame( $home, home_url() ); $_SERVER['HTTPS'] = 'off'; - $this->assertEquals( $home, home_url() ); + $this->assertSame( $home, home_url() ); // If not in the admin, is_ssl() should determine the scheme. set_current_screen( 'front' ); - $this->assertEquals( $home, home_url() ); + $this->assertSame( $home, home_url() ); $_SERVER['HTTPS'] = 'on'; $home = str_replace( 'http://', 'https://', $home ); - $this->assertEquals( $home, home_url() ); + $this->assertSame( $home, home_url() ); // Test with https in home. update_option( 'home', set_url_scheme( $home, 'https' ) ); @@ -228,18 +228,18 @@ class Tests_URL extends WP_UnitTestCase { // home_url() should return whatever scheme is set in the home option when in the admin. $_SERVER['HTTPS'] = 'on'; - $this->assertEquals( $home, home_url() ); + $this->assertSame( $home, home_url() ); $_SERVER['HTTPS'] = 'off'; - $this->assertEquals( $home, home_url() ); + $this->assertSame( $home, home_url() ); // If not in the admin, is_ssl() should determine the scheme unless https hard-coded in home. set_current_screen( 'front' ); - $this->assertEquals( $home, home_url() ); + $this->assertSame( $home, home_url() ); $_SERVER['HTTPS'] = 'on'; - $this->assertEquals( $home, home_url() ); + $this->assertSame( $home, home_url() ); $_SERVER['HTTPS'] = 'off'; - $this->assertEquals( $home, home_url() ); + $this->assertSame( $home, home_url() ); update_option( 'home', set_url_scheme( $home, 'http' ) ); @@ -254,19 +254,19 @@ class Tests_URL extends WP_UnitTestCase { $home = network_home_url(); // home_url() should return http when in the admin. - $this->assertEquals( 0, strpos( $home, 'http://' ) ); + $this->assertSame( 0, strpos( $home, 'http://' ) ); $_SERVER['HTTPS'] = 'on'; - $this->assertEquals( $home, network_home_url() ); + $this->assertSame( $home, network_home_url() ); $_SERVER['HTTPS'] = 'off'; - $this->assertEquals( $home, network_home_url() ); + $this->assertSame( $home, network_home_url() ); // If not in the admin, is_ssl() should determine the scheme. set_current_screen( 'front' ); - $this->assertEquals( $home, network_home_url() ); + $this->assertSame( $home, network_home_url() ); $_SERVER['HTTPS'] = 'on'; $home = str_replace( 'http://', 'https://', $home ); - $this->assertEquals( $home, network_home_url() ); + $this->assertSame( $home, network_home_url() ); $GLOBALS['current_screen'] = $screen; } @@ -307,27 +307,27 @@ class Tests_URL extends WP_UnitTestCase { $forced_admin = force_ssl_admin(); $i = 0; foreach ( $links as $link ) { - $this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'https' ) ); - $this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'http' ) ); - $this->assertEquals( $relative_links[ $i ], set_url_scheme( $link, 'relative' ) ); + $this->assertSame( $https_links[ $i ], set_url_scheme( $link, 'https' ) ); + $this->assertSame( $http_links[ $i ], set_url_scheme( $link, 'http' ) ); + $this->assertSame( $relative_links[ $i ], set_url_scheme( $link, 'relative' ) ); $_SERVER['HTTPS'] = 'on'; - $this->assertEquals( $https_links[ $i ], set_url_scheme( $link ) ); + $this->assertSame( $https_links[ $i ], set_url_scheme( $link ) ); $_SERVER['HTTPS'] = 'off'; - $this->assertEquals( $http_links[ $i ], set_url_scheme( $link ) ); + $this->assertSame( $http_links[ $i ], set_url_scheme( $link ) ); force_ssl_admin( true ); - $this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'admin' ) ); - $this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'login_post' ) ); - $this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'login' ) ); - $this->assertEquals( $https_links[ $i ], set_url_scheme( $link, 'rpc' ) ); + $this->assertSame( $https_links[ $i ], set_url_scheme( $link, 'admin' ) ); + $this->assertSame( $https_links[ $i ], set_url_scheme( $link, 'login_post' ) ); + $this->assertSame( $https_links[ $i ], set_url_scheme( $link, 'login' ) ); + $this->assertSame( $https_links[ $i ], set_url_scheme( $link, 'rpc' ) ); force_ssl_admin( false ); - $this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'admin' ) ); - $this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'login_post' ) ); - $this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'login' ) ); - $this->assertEquals( $http_links[ $i ], set_url_scheme( $link, 'rpc' ) ); + $this->assertSame( $http_links[ $i ], set_url_scheme( $link, 'admin' ) ); + $this->assertSame( $http_links[ $i ], set_url_scheme( $link, 'login_post' ) ); + $this->assertSame( $http_links[ $i ], set_url_scheme( $link, 'login' ) ); + $this->assertSame( $http_links[ $i ], set_url_scheme( $link, 'rpc' ) ); $i++; } @@ -348,16 +348,16 @@ class Tests_URL extends WP_UnitTestCase { $p = get_adjacent_post(); $this->assertInstanceOf( 'WP_Post', $p ); - $this->assertEquals( $post_id, $p->ID ); + $this->assertSame( $post_id, $p->ID ); // The same again to make sure a cached query returns the same result. $p = get_adjacent_post(); $this->assertInstanceOf( 'WP_Post', $p ); - $this->assertEquals( $post_id, $p->ID ); + $this->assertSame( $post_id, $p->ID ); // Test next. $p = get_adjacent_post( false, '', false ); - $this->assertEquals( '', $p ); + $this->assertSame( '', $p ); unset( $GLOBALS['post'] ); $this->assertNull( get_adjacent_post() ); @@ -398,7 +398,7 @@ class Tests_URL extends WP_UnitTestCase { $GLOBALS['post'] = get_post( $p2 ); $p = get_adjacent_post(); - $this->assertEquals( $p1, $p->ID ); + $this->assertSame( $p1, $p->ID ); $GLOBALS['post'] = $orig_post; wp_set_current_user( $old_uid ); @@ -436,7 +436,7 @@ class Tests_URL extends WP_UnitTestCase { $GLOBALS['post'] = get_post( $p2 ); $p = get_adjacent_post(); - $this->assertEquals( $p1, $p->ID ); + $this->assertSame( $p1, $p->ID ); $GLOBALS['post'] = $orig_post; wp_set_current_user( $old_uid ); @@ -480,7 +480,7 @@ class Tests_URL extends WP_UnitTestCase { $GLOBALS['post'] = get_post( $p3 ); $p = get_adjacent_post(); - $this->assertEquals( $p1, $p->ID ); + $this->assertSame( $p1, $p->ID ); $GLOBALS['post'] = $orig_post; wp_set_current_user( $old_uid ); @@ -506,11 +506,11 @@ class Tests_URL extends WP_UnitTestCase { ); foreach ( $functions as $function ) { - $this->assertEquals( + $this->assertSame( call_user_func( $function, '/' ) . '../', call_user_func( $function, '../' ) ); - $this->assertEquals( + $this->assertSame( call_user_func( $function, '/' ) . 'something...here', call_user_func( $function, 'something...here' ) ); @@ -518,11 +518,11 @@ class Tests_URL extends WP_UnitTestCase { // These functions accept a blog ID argument. foreach ( array( 'get_site_url', 'get_home_url', 'get_admin_url' ) as $function ) { - $this->assertEquals( + $this->assertSame( call_user_func( $function, null, '/' ) . '../', call_user_func( $function, null, '../' ) ); - $this->assertEquals( + $this->assertSame( call_user_func( $function, null, '/' ) . 'something...here', call_user_func( $function, null, 'something...here' ) ); diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php index d3e9a581e5..a21ff18330 100644 --- a/tests/phpunit/tests/user.php +++ b/tests/phpunit/tests/user.php @@ -101,12 +101,12 @@ class Tests_User extends WP_UnitTestCase { // Set and get. update_user_option( self::$author_id, $key, $val ); - $this->assertEquals( $val, get_user_option( $key, self::$author_id ) ); + $this->assertSame( $val, get_user_option( $key, self::$author_id ) ); // Change and get again. $val2 = rand_str(); update_user_option( self::$author_id, $key, $val2 ); - $this->assertEquals( $val2, get_user_option( $key, self::$author_id ) ); + $this->assertSame( $val2, get_user_option( $key, self::$author_id ) ); } /** @@ -117,29 +117,29 @@ class Tests_User extends WP_UnitTestCase { $val = 'value1'; // Get a meta key that doesn't exist. - $this->assertEquals( '', get_user_meta( self::$author_id, $key, true ) ); + $this->assertSame( '', get_user_meta( self::$author_id, $key, true ) ); // Set and get. update_user_meta( self::$author_id, $key, $val ); - $this->assertEquals( $val, get_user_meta( self::$author_id, $key, true ) ); + $this->assertSame( $val, get_user_meta( self::$author_id, $key, true ) ); // Change and get again. $val2 = 'value2'; update_user_meta( self::$author_id, $key, $val2 ); - $this->assertEquals( $val2, get_user_meta( self::$author_id, $key, true ) ); + $this->assertSame( $val2, get_user_meta( self::$author_id, $key, true ) ); // Delete and get. delete_user_meta( self::$author_id, $key ); - $this->assertEquals( '', get_user_meta( self::$author_id, $key, true ) ); + $this->assertSame( '', get_user_meta( self::$author_id, $key, true ) ); // Delete by key AND value. update_user_meta( self::$author_id, $key, $val ); // Incorrect key: key still exists. delete_user_meta( self::$author_id, $key, rand_str() ); - $this->assertEquals( $val, get_user_meta( self::$author_id, $key, true ) ); + $this->assertSame( $val, get_user_meta( self::$author_id, $key, true ) ); // Correct key: deleted. delete_user_meta( self::$author_id, $key, $val ); - $this->assertEquals( '', get_user_meta( self::$author_id, $key, true ) ); + $this->assertSame( '', get_user_meta( self::$author_id, $key, true ) ); } @@ -197,11 +197,11 @@ class Tests_User extends WP_UnitTestCase { $this->assertFalse( isset( $user->fooooooooo ) ); $user->$key = 'foo'; - $this->assertEquals( 'foo', $user->$key ); - $this->assertEquals( 'foo', $user->data->$key ); // This will fail with WP < 3.3. + $this->assertSame( 'foo', $user->$key ); + $this->assertSame( 'foo', $user->data->$key ); // This will fail with WP < 3.3. foreach ( get_object_vars( $user ) as $key => $value ) { - $this->assertEquals( $value, $user->$key ); + $this->assertSame( $value, $user->$key ); } } @@ -216,7 +216,7 @@ class Tests_User extends WP_UnitTestCase { // Test custom fields. $user->customField = 123; - $this->assertEquals( $user->customField, 123 ); + $this->assertSame( $user->customField, 123 ); unset( $user->customField ); $this->assertFalse( isset( $user->customField ) ); return $user; @@ -259,7 +259,7 @@ class Tests_User extends WP_UnitTestCase { $this->assertTrue( isset( $user->foo ) ); - $this->assertEquals( 'foo', $user->foo ); + $this->assertSame( 'foo', $user->foo ); } /** @@ -269,9 +269,9 @@ class Tests_User extends WP_UnitTestCase { $user = new WP_User( self::$author_id ); $this->assertTrue( isset( $user->id ) ); - $this->assertEquals( $user->ID, $user->id ); + $this->assertSame( $user->ID, $user->id ); $user->id = 1234; - $this->assertEquals( $user->ID, $user->id ); + $this->assertSame( $user->ID, $user->id ); } /** @@ -297,51 +297,51 @@ class Tests_User extends WP_UnitTestCase { function test_construction() { $user = new WP_User( self::$author_id ); $this->assertInstanceOf( 'WP_User', $user ); - $this->assertEquals( self::$author_id, $user->ID ); + $this->assertSame( self::$author_id, $user->ID ); $user2 = new WP_User( 0, $user->user_login ); $this->assertInstanceOf( 'WP_User', $user2 ); - $this->assertEquals( self::$author_id, $user2->ID ); - $this->assertEquals( $user->user_login, $user2->user_login ); + $this->assertSame( self::$author_id, $user2->ID ); + $this->assertSame( $user->user_login, $user2->user_login ); $user3 = new WP_User(); $this->assertInstanceOf( 'WP_User', $user3 ); - $this->assertEquals( 0, $user3->ID ); + $this->assertSame( 0, $user3->ID ); $this->assertFalse( isset( $user3->user_login ) ); $user3->init( $user->data ); - $this->assertEquals( self::$author_id, $user3->ID ); + $this->assertSame( self::$author_id, $user3->ID ); $user4 = new WP_User( $user->user_login ); $this->assertInstanceOf( 'WP_User', $user4 ); - $this->assertEquals( self::$author_id, $user4->ID ); - $this->assertEquals( $user->user_login, $user4->user_login ); + $this->assertSame( self::$author_id, $user4->ID ); + $this->assertSame( $user->user_login, $user4->user_login ); $user5 = new WP_User( null, $user->user_login ); $this->assertInstanceOf( 'WP_User', $user5 ); - $this->assertEquals( self::$author_id, $user5->ID ); - $this->assertEquals( $user->user_login, $user5->user_login ); + $this->assertSame( self::$author_id, $user5->ID ); + $this->assertSame( $user->user_login, $user5->user_login ); $user6 = new WP_User( $user ); $this->assertInstanceOf( 'WP_User', $user6 ); - $this->assertEquals( self::$author_id, $user6->ID ); - $this->assertEquals( $user->user_login, $user6->user_login ); + $this->assertSame( self::$author_id, $user6->ID ); + $this->assertSame( $user->user_login, $user6->user_login ); $user7 = new WP_User( $user->data ); $this->assertInstanceOf( 'WP_User', $user7 ); - $this->assertEquals( self::$author_id, $user7->ID ); - $this->assertEquals( $user->user_login, $user7->user_login ); + $this->assertSame( self::$author_id, $user7->ID ); + $this->assertSame( $user->user_login, $user7->user_login ); } function test_get() { $user = new WP_User( self::$author_id ); - $this->assertEquals( 'author_login', $user->get( 'user_login' ) ); - $this->assertEquals( 'author@email.com', $user->get( 'user_email' ) ); + $this->assertSame( 'author_login', $user->get( 'user_login' ) ); + $this->assertSame( 'author@email.com', $user->get( 'user_email' ) ); $this->assertEquals( 0, $user->get( 'use_ssl' ) ); - $this->assertEquals( '', $user->get( 'field_that_does_not_exist' ) ); + $this->assertSame( '', $user->get( 'field_that_does_not_exist' ) ); update_user_meta( self::$author_id, 'dashed-key', 'abcdefg' ); - $this->assertEquals( 'abcdefg', $user->get( 'dashed-key' ) ); + $this->assertSame( 'abcdefg', $user->get( 'dashed-key' ) ); } function test_has_prop() { @@ -358,7 +358,7 @@ class Tests_User extends WP_UnitTestCase { $user = new WP_User( self::$author_id ); update_user_meta( self::$author_id, 'description', 'about me' ); - $this->assertEquals( 'about me', $user->get( 'description' ) ); + $this->assertSame( 'about me', $user->get( 'description' ) ); $user_data = array( 'ID' => self::$author_id, @@ -367,10 +367,10 @@ class Tests_User extends WP_UnitTestCase { wp_update_user( $user_data ); $user = new WP_User( self::$author_id ); - $this->assertEquals( 'test user', $user->get( 'display_name' ) ); + $this->assertSame( 'test user', $user->get( 'display_name' ) ); // Make sure there is no collateral damage to fields not in $user_data. - $this->assertEquals( 'about me', $user->get( 'description' ) ); + $this->assertSame( 'about me', $user->get( 'description' ) ); // Pass as stdClass. $user_data = array( @@ -380,12 +380,12 @@ class Tests_User extends WP_UnitTestCase { wp_update_user( (object) $user_data ); $user = new WP_User( self::$author_id ); - $this->assertEquals( 'a test user', $user->get( 'display_name' ) ); + $this->assertSame( 'a test user', $user->get( 'display_name' ) ); $user->display_name = 'some test user'; wp_update_user( $user ); - $this->assertEquals( 'some test user', $user->get( 'display_name' ) ); + $this->assertSame( 'some test user', $user->get( 'display_name' ) ); // Test update of fields in _get_additional_user_keys(). $user_data = array( @@ -419,7 +419,7 @@ class Tests_User extends WP_UnitTestCase { $this->assertNotEmpty( $userdata ); $this->assertInstanceOf( 'WP_User', $userdata ); - $this->assertEquals( $userdata->ID, self::$sub_id ); + $this->assertSame( $userdata->ID, self::$sub_id ); $prefix = $wpdb->get_blog_prefix(); $cap_key = $prefix . 'capabilities'; $this->assertTrue( isset( $userdata->$cap_key ) ); @@ -471,7 +471,7 @@ class Tests_User extends WP_UnitTestCase { $this->assertNotEmpty( $authordata ); $this->assertInstanceOf( 'WP_User', $authordata ); - $this->assertEquals( $authordata->ID, self::$author_id ); + $this->assertSame( $authordata->ID, self::$author_id ); if ( $old_post_id ) { setup_postdata( get_post( $old_post_id ) ); @@ -498,25 +498,25 @@ class Tests_User extends WP_UnitTestCase { // @ticket 23480 $user1 = WP_User::get_data_by( 'id', -1 ); - $this->assertEquals( false, $user1 ); + $this->assertFalse( $user1 ); $user2 = WP_User::get_data_by( 'id', 0 ); - $this->assertEquals( false, $user2 ); + $this->assertFalse( $user2 ); $user3 = WP_User::get_data_by( 'id', null ); - $this->assertEquals( false, $user3 ); + $this->assertFalse( $user3 ); $user4 = WP_User::get_data_by( 'id', '' ); - $this->assertEquals( false, $user4 ); + $this->assertFalse( $user4 ); $user5 = WP_User::get_data_by( 'id', false ); - $this->assertEquals( false, $user5 ); + $this->assertFalse( $user5 ); $user6 = WP_User::get_data_by( 'id', $user->user_nicename ); - $this->assertEquals( false, $user6 ); + $this->assertFalse( $user6 ); $user7 = WP_User::get_data_by( 'id', 99999 ); - $this->assertEquals( false, $user7 ); + $this->assertFalse( $user7 ); } /** @@ -585,7 +585,7 @@ class Tests_User extends WP_UnitTestCase { // Reload the data. $pwd_after = get_userdata( $testuserid )->user_pass; - $this->assertEquals( $pwd_before, $pwd_after ); + $this->assertSame( $pwd_before, $pwd_after ); } /** @@ -624,7 +624,7 @@ class Tests_User extends WP_UnitTestCase { 'user_email' => 'taco@burrito.com', ) ); - $this->assertEquals( $id1, email_exists( 'taco@burrito.com' ) ); + $this->assertSame( $id1, email_exists( 'taco@burrito.com' ) ); $id2 = wp_insert_user( array( @@ -655,7 +655,7 @@ class Tests_User extends WP_UnitTestCase { 'user_email' => 'blackburn@battlefield4.com', ) ); - $this->assertEquals( $id1, email_exists( 'blackburn@battlefield4.com' ) ); + $this->assertSame( $id1, email_exists( 'blackburn@battlefield4.com' ) ); $id2 = wp_insert_user( array( @@ -664,7 +664,7 @@ class Tests_User extends WP_UnitTestCase { 'user_email' => 'miller@battlefield4.com', ) ); - $this->assertEquals( $id2, email_exists( 'miller@battlefield4.com' ) ); + $this->assertSame( $id2, email_exists( 'miller@battlefield4.com' ) ); if ( ! is_wp_error( $id2 ) ) { wp_update_user( @@ -673,7 +673,7 @@ class Tests_User extends WP_UnitTestCase { 'user_email' => 'david@battlefield4.com', ) ); - $this->assertEquals( $id2, email_exists( 'david@battlefield4.com' ) ); + $this->assertSame( $id2, email_exists( 'david@battlefield4.com' ) ); $return = wp_update_user( array( @@ -703,7 +703,7 @@ class Tests_User extends WP_UnitTestCase { $response = wp_insert_user( $user_data ); $this->assertInstanceOf( 'WP_Error', $response ); - $this->assertEquals( 'invalid_username', $response->get_error_code() ); + $this->assertSame( 'invalid_username', $response->get_error_code() ); remove_filter( 'illegal_user_logins', array( $this, '_illegal_user_logins' ) ); @@ -723,7 +723,7 @@ class Tests_User extends WP_UnitTestCase { $response = register_new_user( $user_login, $user_email ); $this->assertInstanceOf( 'WP_Error', $response ); - $this->assertEquals( 'invalid_username', $response->get_error_code() ); + $this->assertSame( 'invalid_username', $response->get_error_code() ); remove_filter( 'illegal_user_logins', array( $this, '_illegal_user_logins' ) ); @@ -746,13 +746,13 @@ class Tests_User extends WP_UnitTestCase { $response = wpmu_validate_user_signup( $user_data['user_login'], $user_data['user_email'] ); $this->assertInstanceOf( 'WP_Error', $response['errors'] ); - $this->assertEquals( 'user_name', $response['errors']->get_error_code() ); + $this->assertSame( 'user_name', $response['errors']->get_error_code() ); remove_filter( 'illegal_user_logins', array( $this, '_illegal_user_logins' ) ); $response = wpmu_validate_user_signup( $user_data['user_login'], $user_data['user_email'] ); $this->assertInstanceOf( 'WP_Error', $response['errors'] ); - $this->assertEquals( 0, count( $response['errors']->get_error_codes() ) ); + $this->assertSame( 0, count( $response['errors']->get_error_codes() ) ); } function _illegal_user_logins_data() { @@ -815,7 +815,7 @@ class Tests_User extends WP_UnitTestCase { ); $user_id = wp_insert_user( $user_details ); - $this->assertEquals( $user_id, email_exists( $user_details['user_email'] ) ); + $this->assertSame( $user_id, email_exists( $user_details['user_email'] ) ); // Check that providing an empty password doesn't remove a user's password. $user_details['ID'] = $user_id; @@ -1044,7 +1044,7 @@ class Tests_User extends WP_UnitTestCase { clean_user_cache( $user ); $user = get_userdata( $user->ID ); - $this->assertEquals( 'key', $user->user_activation_key ); + $this->assertSame( 'key', $user->user_activation_key ); // Check that changing something other than the email doesn't remove the key. $userdata = array( @@ -1054,7 +1054,7 @@ class Tests_User extends WP_UnitTestCase { wp_update_user( $userdata ); $user = get_userdata( $user->ID ); - $this->assertEquals( 'key', $user->user_activation_key ); + $this->assertSame( 'key', $user->user_activation_key ); // Now check that changing the email does remove it. $userdata = array( @@ -1076,7 +1076,7 @@ class Tests_User extends WP_UnitTestCase { clean_user_cache( $user ); $user = get_userdata( $user->ID ); - $this->assertEquals( 'key', $user->user_activation_key ); + $this->assertSame( 'key', $user->user_activation_key ); $userdata = array( 'ID' => $user->ID, @@ -1154,7 +1154,7 @@ class Tests_User extends WP_UnitTestCase { ); $update = wp_update_user( $userdata ); - $this->assertEquals( self::$editor_id, $update ); + $this->assertSame( self::$editor_id, $update ); } /** @@ -1169,11 +1169,11 @@ class Tests_User extends WP_UnitTestCase { $update = wp_update_user( $userdata ); // Was this successful? - $this->assertEquals( self::$editor_id, $update ); + $this->assertSame( self::$editor_id, $update ); // Verify that the email address has been updated. $user = get_userdata( self::$editor_id ); - $this->assertEquals( $user->user_email, 'test2@test.com' ); + $this->assertSame( $user->user_email, 'test2@test.com' ); } /** @@ -1468,7 +1468,7 @@ class Tests_User extends WP_UnitTestCase { $response = edit_user(); $this->assertInstanceOf( 'WP_Error', $response ); - $this->assertEquals( 'pass', $response->get_error_code() ); + $this->assertSame( 'pass', $response->get_error_code() ); // Check new user with password set. $_POST['pass1'] = 'password'; @@ -1479,7 +1479,7 @@ class Tests_User extends WP_UnitTestCase { $this->assertInternalType( 'int', $user_id ); $this->assertInstanceOf( 'WP_User', $user ); - $this->assertEquals( 'nickname1', $user->nickname ); + $this->assertSame( 'nickname1', $user->nickname ); // Check updating user with empty password. $_POST['nickname'] = 'nickname_updated'; @@ -1489,7 +1489,7 @@ class Tests_User extends WP_UnitTestCase { $user_id = edit_user( $user_id ); $this->assertInternalType( 'int', $user_id ); - $this->assertEquals( 'nickname_updated', $user->nickname ); + $this->assertSame( 'nickname_updated', $user->nickname ); // Check updating user with missing second password. $_POST['nickname'] = 'nickname_updated2'; @@ -1499,8 +1499,8 @@ class Tests_User extends WP_UnitTestCase { $response = edit_user( $user_id ); $this->assertInstanceOf( 'WP_Error', $response ); - $this->assertEquals( 'pass', $response->get_error_code() ); - $this->assertEquals( 'nickname_updated', $user->nickname ); + $this->assertSame( 'pass', $response->get_error_code() ); + $this->assertSame( 'nickname_updated', $user->nickname ); // Check updating user with empty password via `check_passwords` action. add_action( 'check_passwords', array( $this, 'action_check_passwords_blank_pw' ), 10, 2 ); @@ -1508,7 +1508,7 @@ class Tests_User extends WP_UnitTestCase { remove_action( 'check_passwords', array( $this, 'action_check_passwords_blank_pw' ) ); $this->assertInternalType( 'int', $user_id ); - $this->assertEquals( 'nickname_updated2', $user->nickname ); + $this->assertSame( 'nickname_updated2', $user->nickname ); } /** @@ -1547,10 +1547,10 @@ class Tests_User extends WP_UnitTestCase { // The new email address gets put into user_meta. $new_email_meta = get_user_meta( $user->ID, '_new_email', true ); - $this->assertEquals( 'after@example.com', $new_email_meta['newemail'] ); + $this->assertSame( 'after@example.com', $new_email_meta['newemail'] ); // The email address of the user doesn't change. $_POST['email'] should be the email address pre-update. - $this->assertEquals( $_POST['email'], $user->user_email ); + $this->assertSame( $_POST['email'], $user->user_email ); } /** @@ -1587,7 +1587,7 @@ class Tests_User extends WP_UnitTestCase { $this->assertEmpty( $new_email_meta ); // $_POST['email'] should be the email address posted from the form. - $this->assertEquals( $_POST['email'], 'after@example.com' ); + $this->assertSame( $_POST['email'], 'after@example.com' ); } /** @@ -1723,11 +1723,11 @@ class Tests_User extends WP_UnitTestCase { $this->assertTrue( $actual['done'] ); // Contains 'Community Events Location'. - $this->assertEquals( 'Community Events Location', $actual['data'][1]['group_label'] ); + $this->assertSame( 'Community Events Location', $actual['data'][1]['group_label'] ); // Contains location IP. - $this->assertEquals( 'IP', $actual['data'][1]['data'][0]['name'] ); - $this->assertEquals( '0.0.0.0', $actual['data'][1]['data'][0]['value'] ); + $this->assertSame( 'IP', $actual['data'][1]['data'][0]['name'] ); + $this->assertSame( '0.0.0.0', $actual['data'][1]['data'][0]['value'] ); } /** @@ -1752,23 +1752,23 @@ class Tests_User extends WP_UnitTestCase { $this->assertTrue( $actual['done'] ); // Contains 'Community Events Location'. - $this->assertEquals( 'Community Events Location', $actual['data'][1]['group_label'] ); + $this->assertSame( 'Community Events Location', $actual['data'][1]['group_label'] ); // Contains location city. - $this->assertEquals( 'City', $actual['data'][1]['data'][0]['name'] ); - $this->assertEquals( 'Cincinnati', $actual['data'][1]['data'][0]['value'] ); + $this->assertSame( 'City', $actual['data'][1]['data'][0]['name'] ); + $this->assertSame( 'Cincinnati', $actual['data'][1]['data'][0]['value'] ); // Contains location country. - $this->assertEquals( 'Country', $actual['data'][1]['data'][1]['name'] ); - $this->assertEquals( 'US', $actual['data'][1]['data'][1]['value'] ); + $this->assertSame( 'Country', $actual['data'][1]['data'][1]['name'] ); + $this->assertSame( 'US', $actual['data'][1]['data'][1]['value'] ); // Contains location latitude. - $this->assertEquals( 'Latitude', $actual['data'][1]['data'][2]['name'] ); - $this->assertEquals( '39.1271100', $actual['data'][1]['data'][2]['value'] ); + $this->assertSame( 'Latitude', $actual['data'][1]['data'][2]['name'] ); + $this->assertSame( '39.1271100', $actual['data'][1]['data'][2]['value'] ); // Contains location longitude. - $this->assertEquals( 'Longitude', $actual['data'][1]['data'][3]['name'] ); - $this->assertEquals( '-84.5143900', $actual['data'][1]['data'][3]['value'] ); + $this->assertSame( 'Longitude', $actual['data'][1]['data'][3]['name'] ); + $this->assertSame( '-84.5143900', $actual['data'][1]['data'][3]['value'] ); } @@ -1796,23 +1796,23 @@ class Tests_User extends WP_UnitTestCase { $this->assertTrue( $actual['done'] ); // Contains Session Tokens. - $this->assertEquals( 'Session Tokens', $actual['data'][1]['group_label'] ); + $this->assertSame( 'Session Tokens', $actual['data'][1]['group_label'] ); // Contains Expiration. - $this->assertEquals( 'Expiration', $actual['data'][1]['data'][0]['name'] ); - $this->assertEquals( 'January 31, 2020 09:13 AM', $actual['data'][1]['data'][0]['value'] ); + $this->assertSame( 'Expiration', $actual['data'][1]['data'][0]['name'] ); + $this->assertSame( 'January 31, 2020 09:13 AM', $actual['data'][1]['data'][0]['value'] ); // Contains IP. - $this->assertEquals( 'IP', $actual['data'][1]['data'][1]['name'] ); - $this->assertEquals( '0.0.0.0', $actual['data'][1]['data'][1]['value'] ); + $this->assertSame( 'IP', $actual['data'][1]['data'][1]['name'] ); + $this->assertSame( '0.0.0.0', $actual['data'][1]['data'][1]['value'] ); // Contains IP. - $this->assertEquals( 'User Agent', $actual['data'][1]['data'][2]['name'] ); - $this->assertEquals( 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36', $actual['data'][1]['data'][2]['value'] ); + $this->assertSame( 'User Agent', $actual['data'][1]['data'][2]['name'] ); + $this->assertSame( 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36', $actual['data'][1]['data'][2]['value'] ); // Contains IP. - $this->assertEquals( 'Last Login', $actual['data'][1]['data'][3]['name'] ); - $this->assertEquals( 'January 29, 2020 09:13 AM', $actual['data'][1]['data'][3]['value'] ); + $this->assertSame( 'Last Login', $actual['data'][1]['data'][3]['name'] ); + $this->assertSame( 'January 29, 2020 09:13 AM', $actual['data'][1]['data'][3]['value'] ); } /** diff --git a/tests/phpunit/tests/user/author.php b/tests/phpunit/tests/user/author.php index 7adb2196c6..472e7a2b73 100644 --- a/tests/phpunit/tests/user/author.php +++ b/tests/phpunit/tests/user/author.php @@ -47,41 +47,41 @@ class Tests_User_Author_Template extends WP_UnitTestCase { $author_name = get_the_author(); $user = new WP_User( self::$author_id ); - $this->assertEquals( $user->display_name, $author_name ); - $this->assertEquals( 'test_author', $author_name ); + $this->assertSame( $user->display_name, $author_name ); + $this->assertSame( 'test_author', $author_name ); } function test_get_the_author_meta() { - $this->assertEquals( 'test_author', get_the_author_meta( 'login' ) ); - $this->assertEquals( 'test_author', get_the_author_meta( 'user_login' ) ); - $this->assertEquals( 'test_author', get_the_author_meta( 'display_name' ) ); + $this->assertSame( 'test_author', get_the_author_meta( 'login' ) ); + $this->assertSame( 'test_author', get_the_author_meta( 'user_login' ) ); + $this->assertSame( 'test_author', get_the_author_meta( 'display_name' ) ); - $this->assertEquals( 'test_author', trim( get_the_author_meta( 'description' ) ) ); - $this->assertEquals( 'test_author', get_the_author_meta( 'user_description' ) ); + $this->assertSame( 'test_author', trim( get_the_author_meta( 'description' ) ) ); + $this->assertSame( 'test_author', get_the_author_meta( 'user_description' ) ); add_user_meta( self::$author_id, 'user_description', 'user description' ); - $this->assertEquals( 'user description', get_user_meta( self::$author_id, 'user_description', true ) ); + $this->assertSame( 'user description', get_user_meta( self::$author_id, 'user_description', true ) ); // user_description in meta is ignored. The content of description is returned instead. // See #20285. - $this->assertEquals( 'test_author', get_the_author_meta( 'user_description' ) ); - $this->assertEquals( 'test_author', trim( get_the_author_meta( 'description' ) ) ); + $this->assertSame( 'test_author', get_the_author_meta( 'user_description' ) ); + $this->assertSame( 'test_author', trim( get_the_author_meta( 'description' ) ) ); update_user_meta( self::$author_id, 'user_description', '' ); - $this->assertEquals( '', get_user_meta( self::$author_id, 'user_description', true ) ); - $this->assertEquals( 'test_author', get_the_author_meta( 'user_description' ) ); - $this->assertEquals( 'test_author', trim( get_the_author_meta( 'description' ) ) ); + $this->assertSame( '', get_user_meta( self::$author_id, 'user_description', true ) ); + $this->assertSame( 'test_author', get_the_author_meta( 'user_description' ) ); + $this->assertSame( 'test_author', trim( get_the_author_meta( 'description' ) ) ); - $this->assertEquals( '', get_the_author_meta( 'does_not_exist' ) ); + $this->assertSame( '', get_the_author_meta( 'does_not_exist' ) ); } function test_get_the_author_meta_no_authordata() { unset( $GLOBALS['authordata'] ); - $this->assertEquals( '', get_the_author_meta( 'id' ) ); - $this->assertEquals( '', get_the_author_meta( 'user_login' ) ); - $this->assertEquals( '', get_the_author_meta( 'does_not_exist' ) ); + $this->assertSame( '', get_the_author_meta( 'id' ) ); + $this->assertSame( '', get_the_author_meta( 'user_login' ) ); + $this->assertSame( '', get_the_author_meta( 'does_not_exist' ) ); } function test_get_the_author_posts() { // Test with no global post, result should be 0 because no author is found. - $this->assertEquals( 0, get_the_author_posts() ); + $this->assertSame( 0, get_the_author_posts() ); $GLOBALS['post'] = self::$post_id; $this->assertEquals( 1, get_the_author_posts() ); } diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php index 7a55db18d1..11d0e2ace8 100644 --- a/tests/phpunit/tests/user/capabilities.php +++ b/tests/phpunit/tests/user/capabilities.php @@ -342,13 +342,13 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $multi_primitive = array_keys( $this->_getMultiSitePrimitiveCaps() ); sort( $single_primitive ); sort( $multi_primitive ); - $this->assertEquals( $single_primitive, $multi_primitive ); + $this->assertSame( $single_primitive, $multi_primitive ); $single_meta = array_keys( $this->_getSingleSiteMetaCaps() ); $multi_meta = array_keys( $this->_getMultiSiteMetaCaps() ); sort( $single_meta ); sort( $multi_meta ); - $this->assertEquals( $single_meta, $multi_meta ); + $this->assertSame( $single_meta, $multi_meta ); } /** @@ -378,7 +378,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $diff = array_diff( array_keys( $user_caps ), array_keys( $caps ) ); - $this->assertEquals( array(), $diff, "User with {$role} role has capabilities that aren't being tested" ); + $this->assertSame( array(), $diff, "User with {$role} role has capabilities that aren't being tested" ); } @@ -521,7 +521,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertTrue( $user->exists(), "User with {$role} role does not exist" ); // Make sure the role name is correct. - $this->assertEquals( array( $role ), $user->roles, "User should only have the {$role} role" ); + $this->assertSame( array( $role ), $user->roles, "User should only have the {$role} role" ); foreach ( $caps as $cap => $roles ) { if ( in_array( $role, $roles, true ) ) { @@ -761,7 +761,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertTrue( $user->exists(), 'User does not exist' ); // Make sure the role name is correct. - $this->assertEquals( array(), $user->roles, 'User should not have any roles' ); + $this->assertSame( array(), $user->roles, 'User should not have any roles' ); $caps = $this->getAllCapsAndRoles(); @@ -783,7 +783,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $user->add_role( 'contributor' ); // User should have two roles now. - $this->assertEquals( array( 'subscriber', 'contributor' ), $user->roles ); + $this->assertSame( array( 'subscriber', 'contributor' ), $user->roles ); $caps = $this->getAllCapsAndRoles(); @@ -799,7 +799,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $user->remove_role( 'contributor' ); // User should have one role now. - $this->assertEquals( array( 'subscriber' ), $user->roles ); + $this->assertSame( array( 'subscriber' ), $user->roles ); } @@ -821,7 +821,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertTrue( $user->exists(), 'User does not exist' ); // Make sure the role name is correct. - $this->assertEquals( array( $role_name ), $user->roles ); + $this->assertSame( array( $role_name ), $user->roles ); $caps = $this->getAllCapsAndRoles(); @@ -860,7 +860,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertTrue( $user->exists(), 'User does not exist' ); // Make sure the role name is correct. - $this->assertEquals( array( $role_name ), $user->roles ); + $this->assertSame( array( $role_name ), $user->roles ); $caps = $this->getPrimitiveCapsAndRoles(); @@ -901,7 +901,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $user = new WP_User( $id ); $this->assertTrue( $user->exists(), "Problem getting user $id" ); - $this->assertEquals( array( $role_name ), $user->roles ); + $this->assertSame( array( $role_name ), $user->roles ); // The user should have all the above caps. $this->assertTrue( $user->has_cap( $role_name ) ); @@ -951,7 +951,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $user = new WP_User( $id ); $this->assertTrue( $user->exists(), "Problem getting user $id" ); - $this->assertEquals( array( $role_name ), $user->roles ); + $this->assertSame( array( $role_name ), $user->roles ); // The user should have all the above caps. $this->assertTrue( $user->has_cap( $role_name ) ); @@ -988,8 +988,8 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertTrue( $user_2->exists(), "Problem getting user $id_2" ); // Make sure they're both still contributors. - $this->assertEquals( array( 'contributor' ), $user_1->roles ); - $this->assertEquals( array( 'contributor' ), $user_2->roles ); + $this->assertSame( array( 'contributor' ), $user_1->roles ); + $this->assertSame( array( 'contributor' ), $user_2->roles ); // Check the extra cap on both users. $this->assertTrue( $user_1->has_cap( 'publish_posts' ) ); @@ -1030,8 +1030,8 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertTrue( $user_2->exists(), "Problem getting user $id_2" ); // Make sure they're both still contributors. - $this->assertEquals( array( 'contributor' ), $user_1->roles ); - $this->assertEquals( array( 'contributor' ), $user_2->roles ); + $this->assertSame( array( 'contributor' ), $user_1->roles ); + $this->assertSame( array( 'contributor' ), $user_2->roles ); // Check the removed cap on both users. $this->assertFalse( $user_1->has_cap( 'publish_posts' ) ); @@ -1053,16 +1053,16 @@ class Tests_User_Capabilities extends WP_UnitTestCase { // They get promoted to editor - level should get bumped to 7. $user->set_role( 'editor' ); - $this->assertEquals( 7, $user->user_level ); + $this->assertSame( 7, $user->user_level ); // Demoted to contributor - level is reduced to 1. $user->set_role( 'contributor' ); - $this->assertEquals( 1, $user->user_level ); + $this->assertSame( 1, $user->user_level ); // If they have two roles, user_level should be the max of the two. $user->add_role( 'editor' ); - $this->assertEquals( array( 'contributor', 'editor' ), $user->roles ); - $this->assertEquals( 7, $user->user_level ); + $this->assertSame( array( 'contributor', 'editor' ), $user->roles ); + $this->assertSame( 7, $user->user_level ); } function test_user_remove_all_caps() { @@ -1153,8 +1153,8 @@ class Tests_User_Capabilities extends WP_UnitTestCase { register_post_type( 'something', array( 'capabilities' => array( 'edit_posts' => 'draw_somethings' ) ) ); $something = get_post_type_object( 'something' ); - $this->assertEquals( 'draw_somethings', $something->cap->edit_posts ); - $this->assertEquals( 'draw_somethings', $something->cap->create_posts ); + $this->assertSame( 'draw_somethings', $something->cap->edit_posts ); + $this->assertSame( 'draw_somethings', $something->cap->create_posts ); register_post_type( 'something', @@ -1167,8 +1167,8 @@ class Tests_User_Capabilities extends WP_UnitTestCase { ) ); $something = get_post_type_object( 'something' ); - $this->assertEquals( 'draw_somethings', $something->cap->edit_posts ); - $this->assertEquals( 'create_somethings', $something->cap->create_posts ); + $this->assertSame( 'draw_somethings', $something->cap->edit_posts ); + $this->assertSame( 'create_somethings', $something->cap->create_posts ); _unregister_post_type( 'something' ); // Test meta authorization callbacks. @@ -1229,7 +1229,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertFalse( $contributor->has_cap( 'publish_post', $post ) ); $this->assertFalse( $contributor->has_cap( 'edit_post', $post ) ); $this->assertFalse( $contributor->has_cap( 'delete_post', $post ) ); - $this->assertEquals( 'publish' === $status, $contributor->has_cap( 'read_post', $post ) ); + $this->assertSame( 'publish' === $status, $contributor->has_cap( 'read_post', $post ) ); } /** @@ -1252,7 +1252,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { register_post_type( 'foobar' ); $cap = get_post_type_object( 'foobar' )->cap; - $this->assertEquals( 'edit_posts', $cap->create_posts ); + $this->assertSame( 'edit_posts', $cap->create_posts ); $this->assertTrue( $admin->has_cap( $cap->create_posts ) ); $this->assertTrue( $author->has_cap( $cap->create_posts ) ); @@ -1266,7 +1266,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { register_post_type( 'foobar', array( 'capability_type' => array( 'foobar', 'foobars' ) ) ); $cap = get_post_type_object( 'foobar' )->cap; - $this->assertEquals( 'edit_foobars', $cap->create_posts ); + $this->assertSame( 'edit_foobars', $cap->create_posts ); $this->assertFalse( $admin->has_cap( $cap->create_posts ) ); $this->assertFalse( $author->has_cap( $cap->create_posts ) ); @@ -1288,8 +1288,8 @@ class Tests_User_Capabilities extends WP_UnitTestCase { _unregister_post_type( 'foobar' ); $cap = get_post_type_object( 'attachment' )->cap; - $this->assertEquals( 'upload_files', $cap->create_posts ); - $this->assertEquals( 'edit_posts', $cap->edit_posts ); + $this->assertSame( 'upload_files', $cap->create_posts ); + $this->assertSame( 'edit_posts', $cap->edit_posts ); $this->assertTrue( $author->has_cap( $cap->create_posts ) ); $this->assertTrue( $author->has_cap( $cap->edit_posts ) ); @@ -1362,7 +1362,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { foreach ( $expected as $meta_cap => $primitive_cap ) { $caps = map_meta_cap( $tax->cap->$meta_cap, $user->ID ); - $this->assertEquals( + $this->assertSame( array( $primitive_cap, ), @@ -1471,7 +1471,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { foreach ( $expected as $meta_cap => $primitive_cap ) { $caps = map_meta_cap( $tax->cap->$meta_cap, $user->ID ); - $this->assertEquals( + $this->assertSame( array( $primitive_cap, ), @@ -1526,7 +1526,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $this->assertNotEmpty( $user->caps ); $user->set_role( 'administrator' ); $this->assertNotEmpty( $user->caps ); - $this->assertEquals( $caps, $user->caps ); + $this->assertSame( $caps, $user->caps ); } function test_current_user_can_for_blog() { @@ -1567,7 +1567,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { current_user_can_for_blog( $blog_id, 'edit_posts' ); - $this->assertEquals( $orig_blog_id, get_current_blog_id() ); + $this->assertSame( $orig_blog_id, get_current_blog_id() ); } function _nullify_current_user() { @@ -1814,7 +1814,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { $author = self::$users['author']; $contributor = self::$users['contributor']; - $this->assertEquals( 'edit_pages', $cpt->cap->edit_posts ); + $this->assertSame( 'edit_pages', $cpt->cap->edit_posts ); $this->assertTrue( user_can( $admin->ID, $cpt->cap->edit_posts ) ); $this->assertTrue( user_can( $editor->ID, $cpt->cap->edit_posts ) ); $this->assertFalse( user_can( $author->ID, $cpt->cap->edit_posts ) ); @@ -1874,7 +1874,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { wp_logout(); - $this->assertEquals( 0, get_current_user_id() ); + $this->assertSame( 0, get_current_user_id() ); } @@ -2192,9 +2192,9 @@ class Tests_User_Capabilities extends WP_UnitTestCase { */ function test_block_caps( $role, $cap, $use_post, $expected ) { if ( $use_post ) { - $this->assertEquals( $expected, self::$users[ $role ]->has_cap( $cap, self::$block_id ) ); + $this->assertSame( $expected, self::$users[ $role ]->has_cap( $cap, self::$block_id ) ); } else { - $this->assertEquals( $expected, self::$users[ $role ]->has_cap( $cap ) ); + $this->assertSame( $expected, self::$users[ $role ]->has_cap( $cap ) ); } } diff --git a/tests/phpunit/tests/user/countUsers.php b/tests/phpunit/tests/user/countUsers.php index 72d18f81bd..bf4b3b8de6 100644 --- a/tests/phpunit/tests/user/countUsers.php +++ b/tests/phpunit/tests/user/countUsers.php @@ -52,7 +52,7 @@ class Tests_User_CountUsers extends WP_UnitTestCase { // Test user counts. $count = count_users( $strategy ); - $this->assertEquals( 8, $count['total_users'] ); + $this->assertSame( 8, $count['total_users'] ); $this->assertEquals( array( 'administrator' => 2, @@ -132,7 +132,7 @@ class Tests_User_CountUsers extends WP_UnitTestCase { // Test users counts on root site. $count = count_users( $strategy ); - $this->assertEquals( 8, $count['total_users'] ); + $this->assertSame( 8, $count['total_users'] ); $this->assertEquals( array( 'administrator' => 2, @@ -150,7 +150,7 @@ class Tests_User_CountUsers extends WP_UnitTestCase { $count = count_users( $strategy ); restore_current_blog(); - $this->assertEquals( 2, $count['total_users'] ); + $this->assertSame( 2, $count['total_users'] ); $this->assertEquals( array( 'administrator' => 1, @@ -165,7 +165,7 @@ class Tests_User_CountUsers extends WP_UnitTestCase { $count = count_users( $strategy ); restore_current_blog(); - $this->assertEquals( 2, $count['total_users'] ); + $this->assertSame( 2, $count['total_users'] ); $this->assertEquals( array( 'administrator' => 1, @@ -227,7 +227,7 @@ class Tests_User_CountUsers extends WP_UnitTestCase { get_userdata( $editor )->add_role( 'author' ); - $this->assertEquals( + $this->assertSame( array( 'editor', 'author', @@ -238,7 +238,7 @@ class Tests_User_CountUsers extends WP_UnitTestCase { // Test user counts. $count = count_users( $strategy ); - $this->assertEquals( 3, $count['total_users'] ); + $this->assertSame( 3, $count['total_users'] ); $this->assertEquals( array( 'administrator' => 2, diff --git a/tests/phpunit/tests/user/getActiveBlogForUser.php b/tests/phpunit/tests/user/getActiveBlogForUser.php index 642b5a3daf..0d13583ae0 100644 --- a/tests/phpunit/tests/user/getActiveBlogForUser.php +++ b/tests/phpunit/tests/user/getActiveBlogForUser.php @@ -54,7 +54,7 @@ if ( is_multisite() ) : wp_delete_site( $site_id_one ); wp_delete_site( $site_id_two ); - $this->assertEquals( $primary_site_id, $result->id ); + $this->assertSame( $primary_site_id, $result->id ); } /** @@ -71,7 +71,7 @@ if ( is_multisite() ) : wp_delete_site( $primary_site_id ); - $this->assertEquals( $primary_site_id, $result->id ); + $this->assertSame( $primary_site_id, $result->id ); } /** @@ -94,7 +94,7 @@ if ( is_multisite() ) : wp_delete_site( $site_id ); - $this->assertEquals( $current_site_id, $result->id ); + $this->assertSame( $current_site_id, $result->id ); } } diff --git a/tests/phpunit/tests/user/mapMetaCap.php b/tests/phpunit/tests/user/mapMetaCap.php index 7e2a7c0d28..9223a57d8d 100644 --- a/tests/phpunit/tests/user/mapMetaCap.php +++ b/tests/phpunit/tests/user/mapMetaCap.php @@ -42,7 +42,7 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { * @ticket 13905 */ function test_capability_type_post_with_invalid_id() { - $this->assertEquals( + $this->assertSame( array( 'do_not_allow' ), map_meta_cap( 'edit_post', self::$user_id, self::$post_id + 1 ) ); @@ -60,29 +60,29 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { $this->assertTrue( $post_type_object->map_meta_cap ); - $this->assertEquals( + $this->assertSame( array( 'edit_others_posts', 'edit_private_posts' ), map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'edit_others_posts', 'edit_private_posts' ), map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_private_posts' ), map_meta_cap( 'read_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_private_posts' ), map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_others_posts', 'delete_private_posts' ), map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_others_posts', 'delete_private_posts' ), map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) ); @@ -99,29 +99,29 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { $post_type_object = get_post_type_object( self::$post_type ); - $this->assertEquals( + $this->assertSame( array( 'edit_others_books', 'edit_private_books' ), map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'edit_others_books', 'edit_private_books' ), map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_private_books' ), map_meta_cap( 'read_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_private_books' ), map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_others_books', 'delete_private_books' ), map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_others_books', 'delete_private_books' ), map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) ); @@ -140,29 +140,29 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { $this->assertFalse( $post_type_object->map_meta_cap ); - $this->assertEquals( + $this->assertSame( array( 'edit_post' ), map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'edit_post' ), map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_post' ), map_meta_cap( 'read_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_post' ), map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_post' ), map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_post' ), map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) ); @@ -185,29 +185,29 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { $this->assertTrue( $post_type_object->map_meta_cap ); - $this->assertEquals( + $this->assertSame( array( 'edit_others_books', 'edit_private_posts' ), map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'edit_others_books', 'edit_private_posts' ), map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_private_posts' ), map_meta_cap( 'read_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_private_posts' ), map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_others_posts', 'delete_private_posts' ), map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_others_posts', 'delete_private_posts' ), map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) ); @@ -230,29 +230,29 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { $this->assertFalse( $post_type_object->map_meta_cap ); - $this->assertEquals( + $this->assertSame( array( 'edit_book' ), map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'edit_book' ), map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_book' ), map_meta_cap( 'read_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_book' ), map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_book' ), map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_book' ), map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) ); @@ -276,29 +276,29 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { $this->assertTrue( $post_type_object->map_meta_cap ); - $this->assertEquals( + $this->assertSame( array( 'edit_others_posts', 'edit_private_posts' ), map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'edit_others_posts', 'edit_private_posts' ), map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_private_posts' ), map_meta_cap( 'read_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'read_private_posts' ), map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_others_posts', 'delete_private_posts' ), map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) ); - $this->assertEquals( + $this->assertSame( array( 'delete_others_posts', 'delete_private_posts' ), map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) ); @@ -319,7 +319,7 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { $post_type_object = get_post_type_object( self::$post_type ); $this->assertFalse( $post_type_object->map_meta_cap ); - $this->assertEquals( 'delete_posts', $post_type_object->cap->delete_posts ); + $this->assertSame( 'delete_posts', $post_type_object->cap->delete_posts ); } function test_unfiltered_html_cap() { @@ -328,10 +328,10 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { } if ( is_multisite() ) { - $this->assertEquals( array( 'do_not_allow' ), map_meta_cap( 'unfiltered_html', 0 ) ); - $this->assertEquals( array( 'unfiltered_html' ), map_meta_cap( 'unfiltered_html', self::$user_id ) ); + $this->assertSame( array( 'do_not_allow' ), map_meta_cap( 'unfiltered_html', 0 ) ); + $this->assertSame( array( 'unfiltered_html' ), map_meta_cap( 'unfiltered_html', self::$user_id ) ); } else { - $this->assertEquals( array( 'unfiltered_html' ), map_meta_cap( 'unfiltered_html', self::$user_id ) ); + $this->assertSame( array( 'unfiltered_html' ), map_meta_cap( 'unfiltered_html', self::$user_id ) ); } } @@ -347,8 +347,8 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { } $this->assertTrue( DISALLOW_UNFILTERED_HTML ); - $this->assertEquals( array( 'update_core' ), map_meta_cap( 'update_core', self::$user_id ) ); - $this->assertEquals( array( 'edit_plugins' ), map_meta_cap( 'edit_plugins', self::$user_id ) ); + $this->assertSame( array( 'update_core' ), map_meta_cap( 'update_core', self::$user_id ) ); + $this->assertSame( array( 'edit_plugins' ), map_meta_cap( 'edit_plugins', self::$user_id ) ); } /** @@ -366,8 +366,8 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { ); $editor = self::factory()->user->create( array( 'role' => 'editor' ) ); - $this->assertEquals( array( 'edit_others_posts', 'edit_published_posts' ), map_meta_cap( 'edit_post', $editor, $post_id ) ); - $this->assertEquals( array( 'delete_others_posts', 'delete_published_posts' ), map_meta_cap( 'delete_post', $editor, $post_id ) ); + $this->assertSame( array( 'edit_others_posts', 'edit_published_posts' ), map_meta_cap( 'edit_post', $editor, $post_id ) ); + $this->assertSame( array( 'delete_others_posts', 'delete_published_posts' ), map_meta_cap( 'delete_post', $editor, $post_id ) ); } @@ -388,7 +388,7 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { $caps = map_meta_cap( 'delete_page', self::$user_id, $post_id ); delete_option( 'page_on_front' ); - $this->assertEquals( array( 'manage_options' ), $caps ); + $this->assertSame( array( 'manage_options' ), $caps ); } /** @@ -408,6 +408,6 @@ class Tests_User_MapMetaCap extends WP_UnitTestCase { $caps = map_meta_cap( 'delete_page', self::$user_id, $post_id ); delete_option( 'page_for_posts' ); - $this->assertEquals( array( 'manage_options' ), $caps ); + $this->assertSame( array( 'manage_options' ), $caps ); } } diff --git a/tests/phpunit/tests/user/multisite.php b/tests/phpunit/tests/user/multisite.php index a5eae8f65a..be74597277 100644 --- a/tests/phpunit/tests/user/multisite.php +++ b/tests/phpunit/tests/user/multisite.php @@ -52,7 +52,7 @@ if ( is_multisite() ) : $blog_ids_of_user = array_keys( get_blogs_of_user( $user1_id ) ); // User should be a member of the created sites and the network's initial site. - $this->assertEquals( $blog_ids, $blog_ids_of_user ); + $this->assertSame( $blog_ids, $blog_ids_of_user ); $this->assertTrue( remove_user_from_blog( $user1_id, $blog_ids[0] ) ); $this->assertTrue( remove_user_from_blog( $user1_id, $blog_ids[2] ) ); @@ -67,11 +67,11 @@ if ( is_multisite() ) : // The user should still be a member of all remaining sites. $blog_ids_of_user = array_keys( $blogs_of_user ); - $this->assertEquals( $blog_ids, $blog_ids_of_user ); + $this->assertSame( $blog_ids, $blog_ids_of_user ); // Each site retrieved should match the expected structure. foreach ( $blogs_of_user as $blog_id => $blog ) { - $this->assertEquals( $blog_id, $blog->userblog_id ); + $this->assertSame( $blog_id, $blog->userblog_id ); $this->assertTrue( isset( $blog->userblog_id ) ); $this->assertTrue( isset( $blog->blogname ) ); $this->assertTrue( isset( $blog->domain ) ); @@ -91,7 +91,7 @@ if ( is_multisite() ) : // Passing true as the second parameter should retrieve ALL sites, even if marked. $blogs_of_user = get_blogs_of_user( $user1_id, true ); $blog_ids_of_user = array_keys( $blogs_of_user ); - $this->assertEquals( $blog_ids, $blog_ids_of_user ); + $this->assertSame( $blog_ids, $blog_ids_of_user ); // Check if sites are flagged as expected. $this->assertEquals( 1, $blogs_of_user[ $blog_ids[0] ]->spam ); @@ -105,7 +105,7 @@ if ( is_multisite() ) : // Passing false (the default) as the second parameter should retrieve only good sites. $blog_ids_of_user = array_keys( get_blogs_of_user( $user1_id, false ) ); - $this->assertEquals( $blog_ids, $blog_ids_of_user ); + $this->assertSame( $blog_ids, $blog_ids_of_user ); } /** @@ -369,7 +369,7 @@ if ( is_multisite() ) : public function test_should_return_false_for_object_user_id() { $u_obj = self::factory()->user->create_and_get(); $this->assertFalse( wpmu_delete_user( $u_obj ) ); - $this->assertEquals( $u_obj->ID, username_exists( $u_obj->user_login ) ); + $this->assertSame( $u_obj->ID, username_exists( $u_obj->user_login ) ); } /** diff --git a/tests/phpunit/tests/user/query.php b/tests/phpunit/tests/user/query.php index bdef6bfa71..15b1e72ac7 100644 --- a/tests/phpunit/tests/user/query.php +++ b/tests/phpunit/tests/user/query.php @@ -54,17 +54,17 @@ class Tests_User_Query extends WP_UnitTestCase { $this->assertEquals( '', $users->get( 'fields' ) ); if ( isset( $users->query_vars['fields'] ) ) { - $this->assertEquals( '', $users->query_vars['fields'] ); + $this->assertSame( '', $users->query_vars['fields'] ); } $users->set( 'fields', 'all' ); - $this->assertEquals( 'all', $users->get( 'fields' ) ); - $this->assertEquals( 'all', $users->query_vars['fields'] ); + $this->assertSame( 'all', $users->get( 'fields' ) ); + $this->assertSame( 'all', $users->query_vars['fields'] ); $users->set( 'fields', '' ); - $this->assertEquals( '', $users->get( 'fields' ) ); - $this->assertEquals( '', $users->query_vars['fields'] ); + $this->assertSame( '', $users->get( 'fields' ) ); + $this->assertSame( '', $users->query_vars['fields'] ); $this->assertNull( $users->get( 'does-not-exist' ) ); } @@ -78,7 +78,7 @@ class Tests_User_Query extends WP_UnitTestCase { ); $ids = $q->get_results(); - $this->assertEquals( array( self::$author_ids[0] ), $ids ); + $this->assertEqualSets( array( self::$author_ids[0] ), $ids ); } public function test_include_comma_separated() { @@ -137,7 +137,7 @@ class Tests_User_Query extends WP_UnitTestCase { $users = $users->get_results(); // +1 for the default user created during installation. - $this->assertEquals( 13, count( $users ) ); + $this->assertSame( 13, count( $users ) ); foreach ( $users as $user ) { $this->assertInstanceOf( 'WP_User', $user ); } @@ -149,7 +149,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); $users = $users->get_results(); - $this->assertEquals( 13, count( $users ) ); + $this->assertSame( 13, count( $users ) ); foreach ( $users as $user ) { $this->assertInstanceOf( 'WP_User', $user ); } @@ -502,7 +502,7 @@ class Tests_User_Query extends WP_UnitTestCase { // +1 for the default user created by the test suite. $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id() ) ); $users = $users->get_results(); - $this->assertEquals( 13, count( $users ) ); + $this->assertSame( 13, count( $users ) ); $users = new WP_User_Query( array( @@ -511,7 +511,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); $users = $users->get_results(); - $this->assertEquals( 10, count( $users ) ); + $this->assertSame( 10, count( $users ) ); $users = new WP_User_Query( array( @@ -520,7 +520,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); $users = $users->get_results(); - $this->assertEquals( 2, count( $users ) ); + $this->assertSame( 2, count( $users ) ); $users = new WP_User_Query( array( @@ -529,7 +529,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); $users = $users->get_results(); - $this->assertEquals( 13, count( $users ) ); + $this->assertSame( 13, count( $users ) ); } /** @@ -557,7 +557,7 @@ class Tests_User_Query extends WP_UnitTestCase { // All values get reset. $query->prepare_query( array( 'number' => 8 ) ); $this->assertNotEmpty( $query->query_limit ); - $this->assertEquals( 'LIMIT 0, 8', $query->query_limit ); + $this->assertSame( 'LIMIT 0, 8', $query->query_limit ); // All values get reset. $query->prepare_query( array( 'fields' => 'all' ) ); @@ -566,7 +566,7 @@ class Tests_User_Query extends WP_UnitTestCase { $_query_vars = $query->query_vars; $query->prepare_query(); - $this->assertEquals( $_query_vars, $query->query_vars ); + $this->assertSame( $_query_vars, $query->query_vars ); $query->prepare_query( array( 'number' => -1 ) ); $this->assertNotEquals( 'LIMIT -1', $query->query_limit ); @@ -1142,7 +1142,7 @@ class Tests_User_Query extends WP_UnitTestCase { $expected_count = 10; // 13 total users minus 3 from query. $this->assertContains( "AND user_nicename NOT IN ( 'peter','paul','mary' )", $q->query_where ); - $this->assertEquals( $expected_count, $found_count ); + $this->assertSame( $expected_count, $found_count ); } /** @@ -1243,7 +1243,7 @@ class Tests_User_Query extends WP_UnitTestCase { $expected_count = 10; // 13 total users minus 3 from query. $this->assertContains( "AND user_login NOT IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where ); - $this->assertEquals( $expected_count, $found_count ); + $this->assertSame( $expected_count, $found_count ); } /** @@ -1314,7 +1314,7 @@ class Tests_User_Query extends WP_UnitTestCase { $wp_user_search = new WP_User_Query( array( 'role' => 'subscriber' ) ); $users = $wp_user_search->get_results(); - $this->assertEquals( 2, count( $users ) ); + $this->assertSame( 2, count( $users ) ); } /** @@ -1323,7 +1323,7 @@ class Tests_User_Query extends WP_UnitTestCase { public function test_get_multiple_roles_by_user_query() { $wp_user_search = new WP_User_Query( array( 'role__in' => array( 'subscriber', 'editor' ) ) ); $users = $wp_user_search->get_results(); - $this->assertEquals( 5, count( $users ) ); + $this->assertSame( 5, count( $users ) ); } /** @@ -1336,7 +1336,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( 2, count( $users ) ); + $this->assertSame( 2, count( $users ) ); } /** @@ -1372,7 +1372,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( 2, count( $users ) ); + $this->assertSame( 2, count( $users ) ); } /** @@ -1392,7 +1392,7 @@ class Tests_User_Query extends WP_UnitTestCase { $users = new WP_User_Query( array( 'role' => array( 'subscriber', 'editor' ) ) ); $users = $users->get_results(); - $this->assertEquals( 2, count( $users ) ); + $this->assertSame( 2, count( $users ) ); foreach ( $users as $user ) { $this->assertInstanceOf( 'WP_User', $user ); @@ -1407,7 +1407,7 @@ class Tests_User_Query extends WP_UnitTestCase { $users = $users->get_results(); // +1 for the default user created during installation. - $this->assertEquals( 8, count( $users ) ); + $this->assertSame( 8, count( $users ) ); foreach ( $users as $user ) { $this->assertInstanceOf( 'WP_User', $user ); } @@ -1436,7 +1436,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( 2, count( $users ) ); + $this->assertSame( 2, count( $users ) ); } /** @@ -1482,7 +1482,7 @@ class Tests_User_Query extends WP_UnitTestCase { ); // Check results. - $this->assertEquals( 1, count( $users ) ); + $this->assertSame( 1, count( $users ) ); $this->assertSame( self::$editor_ids[0], (int) $users[0]->ID ); } @@ -1497,7 +1497,7 @@ class Tests_User_Query extends WP_UnitTestCase { ); // +1 for the default user created during installation. - $this->assertEquals( 11, count( $users ) ); + $this->assertSame( 11, count( $users ) ); $users = get_users( array( @@ -1506,7 +1506,7 @@ class Tests_User_Query extends WP_UnitTestCase { ); // +1 for the default user created during installation. - $this->assertEquals( 10, count( $users ) ); + $this->assertSame( 10, count( $users ) ); } /** @@ -1524,7 +1524,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( 5, count( $users ) ); + $this->assertSame( 5, count( $users ) ); $users = get_users( array( @@ -1533,7 +1533,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( 3, count( $users ) ); + $this->assertSame( 3, count( $users ) ); } /** @@ -1550,7 +1550,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertEquals( 1, count( $users ) ); + $this->assertSame( 1, count( $users ) ); } /** @@ -1568,7 +1568,7 @@ class Tests_User_Query extends WP_UnitTestCase { ); // +1 for the default user created during installation. - $this->assertEquals( 12, count( $users ) ); + $this->assertSame( 12, count( $users ) ); $users = get_users( array( @@ -1577,7 +1577,7 @@ class Tests_User_Query extends WP_UnitTestCase { ); // +1 for the default user created during installation. - $this->assertEquals( 10, count( $users ) ); + $this->assertSame( 10, count( $users ) ); } /** @@ -1690,7 +1690,7 @@ class Tests_User_Query extends WP_UnitTestCase { $ids = $q->get_results(); // Must not include user that has the same string in other fields. - $this->assertEquals( array(), $ids ); + $this->assertSame( array(), $ids ); } /** @@ -1717,7 +1717,7 @@ class Tests_User_Query extends WP_UnitTestCase { $this->assertSame( array( 555 ), $q->results ); // Make sure manually setting total_users doesn't get overwritten. - $this->assertEquals( 1, $q->total_users ); + $this->assertSame( 1, $q->total_users ); } public static function filter_users_pre_query( $posts, $query ) { diff --git a/tests/phpunit/tests/user/slashes.php b/tests/phpunit/tests/user/slashes.php index 0e811e84b1..e5675abb5d 100644 --- a/tests/phpunit/tests/user/slashes.php +++ b/tests/phpunit/tests/user/slashes.php @@ -46,11 +46,11 @@ class Tests_User_Slashes extends WP_UnitTestCase { $id = add_user(); $user = get_user_to_edit( $id ); - $this->assertEquals( $this->slash_1, $user->first_name ); - $this->assertEquals( $this->slash_3, $user->last_name ); - $this->assertEquals( $this->slash_5, $user->nickname ); - $this->assertEquals( $this->slash_7, $user->display_name ); - $this->assertEquals( $this->slash_3, $user->description ); + $this->assertSame( $this->slash_1, $user->first_name ); + $this->assertSame( $this->slash_3, $user->last_name ); + $this->assertSame( $this->slash_5, $user->nickname ); + $this->assertSame( $this->slash_7, $user->display_name ); + $this->assertSame( $this->slash_3, $user->description ); $_POST = array(); $_GET = array(); @@ -71,11 +71,11 @@ class Tests_User_Slashes extends WP_UnitTestCase { $id = add_user(); $user = get_user_to_edit( $id ); - $this->assertEquals( $this->slash_2, $user->first_name ); - $this->assertEquals( $this->slash_4, $user->last_name ); - $this->assertEquals( $this->slash_6, $user->nickname ); - $this->assertEquals( $this->slash_2, $user->display_name ); - $this->assertEquals( $this->slash_4, $user->description ); + $this->assertSame( $this->slash_2, $user->first_name ); + $this->assertSame( $this->slash_4, $user->last_name ); + $this->assertSame( $this->slash_6, $user->nickname ); + $this->assertSame( $this->slash_2, $user->display_name ); + $this->assertSame( $this->slash_4, $user->description ); } /** @@ -100,11 +100,11 @@ class Tests_User_Slashes extends WP_UnitTestCase { $id = edit_user( $id ); $user = get_user_to_edit( $id ); - $this->assertEquals( $this->slash_1, $user->first_name ); - $this->assertEquals( $this->slash_3, $user->last_name ); - $this->assertEquals( $this->slash_5, $user->nickname ); - $this->assertEquals( $this->slash_7, $user->display_name ); - $this->assertEquals( $this->slash_3, $user->description ); + $this->assertSame( $this->slash_1, $user->first_name ); + $this->assertSame( $this->slash_3, $user->last_name ); + $this->assertSame( $this->slash_5, $user->nickname ); + $this->assertSame( $this->slash_7, $user->display_name ); + $this->assertSame( $this->slash_3, $user->description ); $_POST = array(); $_GET = array(); @@ -122,11 +122,11 @@ class Tests_User_Slashes extends WP_UnitTestCase { $id = edit_user( $id ); $user = get_user_to_edit( $id ); - $this->assertEquals( $this->slash_2, $user->first_name ); - $this->assertEquals( $this->slash_4, $user->last_name ); - $this->assertEquals( $this->slash_6, $user->nickname ); - $this->assertEquals( $this->slash_2, $user->display_name ); - $this->assertEquals( $this->slash_4, $user->description ); + $this->assertSame( $this->slash_2, $user->first_name ); + $this->assertSame( $this->slash_4, $user->last_name ); + $this->assertSame( $this->slash_6, $user->nickname ); + $this->assertSame( $this->slash_2, $user->display_name ); + $this->assertSame( $this->slash_4, $user->description ); } /** @@ -148,11 +148,11 @@ class Tests_User_Slashes extends WP_UnitTestCase { ); $user = get_user_to_edit( $id ); - $this->assertEquals( wp_unslash( $this->slash_1 ), $user->first_name ); - $this->assertEquals( wp_unslash( $this->slash_3 ), $user->last_name ); - $this->assertEquals( wp_unslash( $this->slash_5 ), $user->nickname ); - $this->assertEquals( wp_unslash( $this->slash_7 ), $user->display_name ); - $this->assertEquals( wp_unslash( $this->slash_3 ), $user->description ); + $this->assertSame( wp_unslash( $this->slash_1 ), $user->first_name ); + $this->assertSame( wp_unslash( $this->slash_3 ), $user->last_name ); + $this->assertSame( wp_unslash( $this->slash_5 ), $user->nickname ); + $this->assertSame( wp_unslash( $this->slash_7 ), $user->display_name ); + $this->assertSame( wp_unslash( $this->slash_3 ), $user->description ); $id = wp_insert_user( array( @@ -169,11 +169,11 @@ class Tests_User_Slashes extends WP_UnitTestCase { ); $user = get_user_to_edit( $id ); - $this->assertEquals( wp_unslash( $this->slash_2 ), $user->first_name ); - $this->assertEquals( wp_unslash( $this->slash_4 ), $user->last_name ); - $this->assertEquals( wp_unslash( $this->slash_6 ), $user->nickname ); - $this->assertEquals( wp_unslash( $this->slash_2 ), $user->display_name ); - $this->assertEquals( wp_unslash( $this->slash_4 ), $user->description ); + $this->assertSame( wp_unslash( $this->slash_2 ), $user->first_name ); + $this->assertSame( wp_unslash( $this->slash_4 ), $user->last_name ); + $this->assertSame( wp_unslash( $this->slash_6 ), $user->nickname ); + $this->assertSame( wp_unslash( $this->slash_2 ), $user->display_name ); + $this->assertSame( wp_unslash( $this->slash_4 ), $user->description ); } /** @@ -194,11 +194,11 @@ class Tests_User_Slashes extends WP_UnitTestCase { ); $user = get_user_to_edit( $id ); - $this->assertEquals( wp_unslash( $this->slash_1 ), $user->first_name ); - $this->assertEquals( wp_unslash( $this->slash_3 ), $user->last_name ); - $this->assertEquals( wp_unslash( $this->slash_5 ), $user->nickname ); - $this->assertEquals( wp_unslash( $this->slash_7 ), $user->display_name ); - $this->assertEquals( wp_unslash( $this->slash_3 ), $user->description ); + $this->assertSame( wp_unslash( $this->slash_1 ), $user->first_name ); + $this->assertSame( wp_unslash( $this->slash_3 ), $user->last_name ); + $this->assertSame( wp_unslash( $this->slash_5 ), $user->nickname ); + $this->assertSame( wp_unslash( $this->slash_7 ), $user->display_name ); + $this->assertSame( wp_unslash( $this->slash_3 ), $user->description ); $id = wp_update_user( array( @@ -213,11 +213,11 @@ class Tests_User_Slashes extends WP_UnitTestCase { ); $user = get_user_to_edit( $id ); - $this->assertEquals( wp_unslash( $this->slash_2 ), $user->first_name ); - $this->assertEquals( wp_unslash( $this->slash_4 ), $user->last_name ); - $this->assertEquals( wp_unslash( $this->slash_6 ), $user->nickname ); - $this->assertEquals( wp_unslash( $this->slash_2 ), $user->display_name ); - $this->assertEquals( wp_unslash( $this->slash_4 ), $user->description ); + $this->assertSame( wp_unslash( $this->slash_2 ), $user->first_name ); + $this->assertSame( wp_unslash( $this->slash_4 ), $user->last_name ); + $this->assertSame( wp_unslash( $this->slash_6 ), $user->nickname ); + $this->assertSame( wp_unslash( $this->slash_2 ), $user->display_name ); + $this->assertSame( wp_unslash( $this->slash_4 ), $user->description ); } } diff --git a/tests/phpunit/tests/user/updateUserCaches.php b/tests/phpunit/tests/user/updateUserCaches.php index 6a65192ee7..6797ec229b 100644 --- a/tests/phpunit/tests/user/updateUserCaches.php +++ b/tests/phpunit/tests/user/updateUserCaches.php @@ -24,7 +24,7 @@ class Tests_User_UpdateUserCaches extends WP_UnitTestCase { update_user_caches( $data ); - $this->assertEquals( 12345, wp_cache_get( 'foo', 'userlogins' ) ); + $this->assertSame( 12345, wp_cache_get( 'foo', 'userlogins' ) ); } public function test_should_store_user_id_in_useremail_bucket() { @@ -36,7 +36,7 @@ class Tests_User_UpdateUserCaches extends WP_UnitTestCase { update_user_caches( $data ); - $this->assertEquals( 12345, wp_cache_get( 'foo@example.com', 'useremail' ) ); + $this->assertSame( 12345, wp_cache_get( 'foo@example.com', 'useremail' ) ); } public function test_should_store_user_id_in_userslugs_bucket() { @@ -48,7 +48,7 @@ class Tests_User_UpdateUserCaches extends WP_UnitTestCase { update_user_caches( $data ); - $this->assertEquals( 12345, wp_cache_get( 'bar', 'userslugs' ) ); + $this->assertSame( 12345, wp_cache_get( 'bar', 'userslugs' ) ); } /** diff --git a/tests/phpunit/tests/user/wpAuthenticateSpamCheck.php b/tests/phpunit/tests/user/wpAuthenticateSpamCheck.php index 8cf2fd4abd..1d7d93d2f1 100644 --- a/tests/phpunit/tests/user/wpAuthenticateSpamCheck.php +++ b/tests/phpunit/tests/user/wpAuthenticateSpamCheck.php @@ -14,7 +14,7 @@ class Tests_User_WpAuthenticateSpamCheck extends WP_UnitTestCase { $actual_user = wp_authenticate_spam_check( $user ); wp_delete_user( $user_id ); - $this->assertEquals( $user->user_login, $actual_user->user_login ); + $this->assertSame( $user->user_login, $actual_user->user_login ); } /** @@ -26,7 +26,7 @@ class Tests_User_WpAuthenticateSpamCheck extends WP_UnitTestCase { $actual_user = wp_authenticate_spam_check( $user ); wpmu_delete_user( $user_id ); - $this->assertEquals( $user->user_login, $actual_user->user_login ); + $this->assertSame( $user->user_login, $actual_user->user_login ); } /** diff --git a/tests/phpunit/tests/user/wpDeleteUser.php b/tests/phpunit/tests/user/wpDeleteUser.php index 120f1d498b..8bbf351bb2 100644 --- a/tests/phpunit/tests/user/wpDeleteUser.php +++ b/tests/phpunit/tests/user/wpDeleteUser.php @@ -12,18 +12,18 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { */ function test_get_blogs_of_user() { // Logged out users don't have blogs. - $this->assertEquals( array(), get_blogs_of_user( 0 ) ); + $this->assertSame( array(), get_blogs_of_user( 0 ) ); $user_id = self::factory()->user->create( array( 'role' => 'subscriber' ) ); $blogs = get_blogs_of_user( $user_id ); - $this->assertEquals( array( 1 ), array_keys( $blogs ) ); + $this->assertSame( array( 1 ), array_keys( $blogs ) ); // Non-existent users don't have blogs. self::delete_user( $user_id ); $user = new WP_User( $user_id ); $this->assertFalse( $user->exists(), 'WP_User->exists' ); - $this->assertEquals( array(), get_blogs_of_user( $user_id ) ); + $this->assertSame( array(), get_blogs_of_user( $user_id ) ); } /** @@ -71,7 +71,7 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { $this->assertTrue( $post_id > 0 ); $post = get_post( $post_id ); - $this->assertEquals( $post_id, $post->ID ); + $this->assertSame( $post_id, $post->ID ); $post = array( 'post_author' => $user_id, @@ -87,7 +87,7 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { $this->assertTrue( $nav_id > 0 ); $post = get_post( $nav_id ); - $this->assertEquals( $nav_id, $post->ID ); + $this->assertSame( $nav_id, $post->ID ); wp_delete_user( $user_id ); $user = new WP_User( $user_id ); @@ -98,10 +98,10 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { } $this->assertNotNull( get_post( $post_id ) ); - $this->assertEquals( 'trash', get_post( $post_id )->post_status ); + $this->assertSame( 'trash', get_post( $post_id )->post_status ); // 'nav_menu_item' is `delete_with_user = false` so the nav post should remain published. $this->assertNotNull( get_post( $nav_id ) ); - $this->assertEquals( 'publish', get_post( $nav_id )->post_status ); + $this->assertSame( 'publish', get_post( $nav_id )->post_status ); wp_delete_post( $nav_id, true ); $this->assertNull( get_post( $nav_id ) ); wp_delete_post( $post_id, true ); @@ -149,6 +149,6 @@ class Tests_User_WpDeleteUser extends WP_UnitTestCase { public function test_should_return_false_for_object_user_id() { $u_obj = self::factory()->user->create_and_get(); $this->assertFalse( wp_delete_user( $u_obj ) ); - $this->assertEquals( $u_obj->ID, username_exists( $u_obj->user_login ) ); + $this->assertSame( $u_obj->ID, username_exists( $u_obj->user_login ) ); } } diff --git a/tests/phpunit/tests/user/wpSetCurrentUser.php b/tests/phpunit/tests/user/wpSetCurrentUser.php index ec720b814e..b14a1c0d3d 100644 --- a/tests/phpunit/tests/user/wpSetCurrentUser.php +++ b/tests/phpunit/tests/user/wpSetCurrentUser.php @@ -19,7 +19,7 @@ class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { $user = wp_set_current_user( self::$user_id ); $this->assertSame( self::$user_id, $user->ID ); - $this->assertEquals( $user, wp_get_current_user() ); + $this->assertSame( $user, wp_get_current_user() ); $this->assertSame( self::$user_id, get_current_user_id() ); } @@ -27,7 +27,7 @@ class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { $user = wp_set_current_user( self::$user_id, 'foo' ); $this->assertSame( self::$user_id, $user->ID ); - $this->assertEquals( $user, wp_get_current_user() ); + $this->assertSame( $user, wp_get_current_user() ); $this->assertSame( self::$user_id, get_current_user_id() ); } @@ -38,7 +38,7 @@ class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { $user = wp_set_current_user( null, 'foo' ); $this->assertSame( self::$user_id2, $user->ID ); - $this->assertEquals( $user, wp_get_current_user() ); + $this->assertSame( $user, wp_get_current_user() ); $this->assertSame( self::$user_id2, get_current_user_id() ); } @@ -54,7 +54,7 @@ class Tests_User_WpSetCurrentUser extends WP_UnitTestCase { $user = wp_set_current_user( null, 'foo' ); $this->assertSame( self::$user_id2, $user->ID ); - $this->assertEquals( $user, wp_get_current_user() ); + $this->assertSame( $user, wp_get_current_user() ); $this->assertSame( self::$user_id2, get_current_user_id() ); } } diff --git a/tests/phpunit/tests/walker.php b/tests/phpunit/tests/walker.php index c38c1e314e..5ab08b1579 100644 --- a/tests/phpunit/tests/walker.php +++ b/tests/phpunit/tests/walker.php @@ -26,8 +26,8 @@ class Tests_Walker extends WP_UnitTestCase { ); $output = $this->walker->walk( $items, 0 ); - $this->assertEquals( 1, $this->walker->get_number_of_root_elements( $items ) ); - $this->assertEquals( '<li>1</li>', $output ); + $this->assertSame( 1, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( '<li>1</li>', $output ); } @@ -41,8 +41,8 @@ class Tests_Walker extends WP_UnitTestCase { ); $output = $this->walker->walk( $items, -1 ); - $this->assertEquals( 1, $this->walker->get_number_of_root_elements( $items ) ); - $this->assertEquals( '<li>1</li>', $output ); + $this->assertSame( 1, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( '<li>1</li>', $output ); } @@ -56,8 +56,8 @@ class Tests_Walker extends WP_UnitTestCase { ); $output = $this->walker->walk( $items, 1 ); - $this->assertEquals( 1, $this->walker->get_number_of_root_elements( $items ) ); - $this->assertEquals( '<li>1</li>', $output ); + $this->assertSame( 1, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( '<li>1</li>', $output ); } @@ -76,8 +76,8 @@ class Tests_Walker extends WP_UnitTestCase { $output = $this->walker->walk( $items, 0 ); - $this->assertEquals( 2, $this->walker->get_number_of_root_elements( $items ) ); - $this->assertEquals( '<li>1</li><li>2</li>', $output ); + $this->assertSame( 2, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( '<li>1</li><li>2</li>', $output ); } @@ -96,8 +96,8 @@ class Tests_Walker extends WP_UnitTestCase { $output = $this->walker->walk( $items, 0 ); - $this->assertEquals( 1, $this->walker->get_number_of_root_elements( $items ) ); - $this->assertEquals( '<li>1<ul><li>2</li></ul></li>', $output ); + $this->assertSame( 1, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( '<li>1<ul><li>2</li></ul></li>', $output ); } @@ -116,8 +116,8 @@ class Tests_Walker extends WP_UnitTestCase { $output = $this->walker->walk( $items, -1 ); - $this->assertEquals( 1, $this->walker->get_number_of_root_elements( $items ) ); - $this->assertEquals( '<li>1</li><li>2</li>', $output ); + $this->assertSame( 1, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( '<li>1</li><li>2</li>', $output ); } @@ -136,8 +136,8 @@ class Tests_Walker extends WP_UnitTestCase { $output = $this->walker->walk( $items, 1 ); - $this->assertEquals( 1, $this->walker->get_number_of_root_elements( $items ) ); - $this->assertEquals( '<li>1</li>', $output ); + $this->assertSame( 1, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( '<li>1</li>', $output ); } @@ -160,8 +160,8 @@ class Tests_Walker extends WP_UnitTestCase { $output = $this->walker->walk( $items, 2 ); - $this->assertEquals( 1, $this->walker->get_number_of_root_elements( $items ) ); - $this->assertEquals( '<li>1<ul><li>2</li></ul></li>', $output ); + $this->assertSame( 1, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( '<li>1<ul><li>2</li></ul></li>', $output ); } @@ -180,8 +180,8 @@ class Tests_Walker extends WP_UnitTestCase { $output = $this->walker->walk( $items, 0 ); - $this->assertEquals( 0, $this->walker->get_number_of_root_elements( $items ) ); - $this->assertEquals( '<li>1<ul><li>2</li></ul></li>', $output ); + $this->assertSame( 0, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( '<li>1<ul><li>2</li></ul></li>', $output ); } @@ -196,8 +196,8 @@ class Tests_Walker extends WP_UnitTestCase { $output = $this->walker->walk( $items, 0 ); - $this->assertEquals( 0, $this->walker->get_number_of_root_elements( $items ) ); - $this->assertEquals( '<li>1</li>', $output ); + $this->assertSame( 0, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( '<li>1</li>', $output ); } @@ -212,15 +212,15 @@ class Tests_Walker extends WP_UnitTestCase { $output = $this->walker->walk( $items, 1 ); - $this->assertEquals( 0, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( 0, $this->walker->get_number_of_root_elements( $items ) ); // It's not clear what the output of this "should" be. // Currently the item is simply returned. - $this->assertEquals( '<li>1</li>', $output ); + $this->assertSame( '<li>1</li>', $output ); // But as we've only asked for the first depth maybe nothing should be returned? - // $this->assertEquals( '', $output ); + // $this->assertSame( '', $output ); } @@ -243,8 +243,8 @@ class Tests_Walker extends WP_UnitTestCase { $output = $this->walker->walk( $items, 0 ); - $this->assertEquals( 0, $this->walker->get_number_of_root_elements( $items ) ); - $this->assertEquals( '<li>4</li><li>5</li><li>6</li>', $output ); + $this->assertSame( 0, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( '<li>4</li><li>5</li><li>6</li>', $output ); } @@ -267,18 +267,18 @@ class Tests_Walker extends WP_UnitTestCase { $output = $this->walker->walk( $items, 1 ); - $this->assertEquals( 0, $this->walker->get_number_of_root_elements( $items ) ); + $this->assertSame( 0, $this->walker->get_number_of_root_elements( $items ) ); // It's not clear what the output of this "should" be. // Currently the first item is simply returned. - $this->assertEquals( '<li>4</li>', $output ); + $this->assertSame( '<li>4</li>', $output ); // But as we've only asked for the first depth maybe nothing should be returned? - // $this->assertEquals( '', $output ); + // $this->assertSame( '', $output ); // Or maybe all items which are missing parents should simply be treat top level? - // $this->assertEquals( '<li>4</li><li>5</li><li>6</li>', $output ); + // $this->assertSame( '<li>4</li><li>5</li><li>6</li>', $output ); } diff --git a/tests/phpunit/tests/widgets.php b/tests/phpunit/tests/widgets.php index 0ccd86e699..ded364802b 100644 --- a/tests/phpunit/tests/widgets.php +++ b/tests/phpunit/tests/widgets.php @@ -155,7 +155,7 @@ class Tests_Widgets extends WP_UnitTestCase { } } - $this->assertEquals( $num, count( $result ) ); + $this->assertSame( $num, count( $result ) ); } @@ -288,7 +288,7 @@ class Tests_Widgets extends WP_UnitTestCase { * If the sidebar ID is invalid, the second argument passed to * the 'dynamic_sidebar_before' hook will be false. */ - $this->assertSame( false, $this->valid_sidebar ); + $this->assertFalse( $this->valid_sidebar ); } /** @@ -349,7 +349,7 @@ class Tests_Widgets extends WP_UnitTestCase { ob_start(); $retval = $widget->form( array() ); $output = ob_get_clean(); - $this->assertEquals( 'noform', $retval ); + $this->assertSame( 'noform', $retval ); $this->assertContains( 'no-options-widget', $output ); } @@ -361,13 +361,13 @@ class Tests_Widgets extends WP_UnitTestCase { $name = 'Foo'; $foo_widget = new WP_Widget( $id_base, $name ); - $this->assertEquals( $id_base, $foo_widget->id_base ); - $this->assertEquals( $name, $foo_widget->name ); - $this->assertEquals( "widget_{$id_base}", $foo_widget->option_name ); + $this->assertSame( $id_base, $foo_widget->id_base ); + $this->assertSame( $name, $foo_widget->name ); + $this->assertSame( "widget_{$id_base}", $foo_widget->option_name ); $this->assertArrayHasKey( 'classname', $foo_widget->widget_options ); - $this->assertEquals( "widget_{$id_base}", $foo_widget->widget_options['classname'] ); + $this->assertSame( "widget_{$id_base}", $foo_widget->widget_options['classname'] ); $this->assertArrayHasKey( 'id_base', $foo_widget->control_options ); - $this->assertEquals( $id_base, $foo_widget->control_options['id_base'] ); + $this->assertSame( $id_base, $foo_widget->control_options['id_base'] ); $id_base = 'bar'; $name = 'Bar'; @@ -378,8 +378,8 @@ class Tests_Widgets extends WP_UnitTestCase { 'id_base' => 'bar_id_base', ); $bar_widget = new WP_Widget( $id_base, $name, $widget_options, $control_options ); - $this->assertEquals( $widget_options['classname'], $bar_widget->widget_options['classname'] ); - $this->assertEquals( $control_options['id_base'], $bar_widget->control_options['id_base'] ); + $this->assertSame( $widget_options['classname'], $bar_widget->widget_options['classname'] ); + $this->assertSame( $control_options['id_base'], $bar_widget->control_options['id_base'] ); } /** @@ -389,7 +389,7 @@ class Tests_Widgets extends WP_UnitTestCase { function test_wp_widget_get_field_name( $expected, $value_to_test ) { $widget = new WP_Widget( 'foo', 'Foo' ); $widget->_set( 2 ); - $this->assertEquals( $expected, $widget->get_field_name( $value_to_test ) ); + $this->assertSame( $expected, $widget->get_field_name( $value_to_test ) ); } /** @@ -439,7 +439,7 @@ class Tests_Widgets extends WP_UnitTestCase { function test_wp_widget_get_field_id( $expected, $value_to_test ) { $widget = new WP_Widget( 'foo', 'Foo' ); $widget->_set( 2 ); - $this->assertEquals( $expected, $widget->get_field_id( $value_to_test ) ); + $this->assertSame( $expected, $widget->get_field_id( $value_to_test ) ); } @@ -535,7 +535,7 @@ class Tests_Widgets extends WP_UnitTestCase { $option_value = get_option( 'widget_search' ); $this->assertArrayHasKey( '_multiwidget', $option_value ); - $this->assertEquals( 1, $option_value['_multiwidget'] ); + $this->assertSame( 1, $option_value['_multiwidget'] ); $this->assertArrayHasKey( 2, $option_value ); $instance = $option_value[2]; $this->assertInternalType( 'array', $instance ); @@ -545,7 +545,7 @@ class Tests_Widgets extends WP_UnitTestCase { // Pretend this widget is new. delete_option( 'widget_nav_menu' ); $never_used = get_option( 'widget_nav_menu', array() ); - $this->assertEquals( array(), (array) $never_used ); + $this->assertSame( array(), (array) $never_used ); wp_widgets_init(); $wp_widget_search = $wp_registered_widgets['search-2']['callback'][0]; @@ -555,12 +555,12 @@ class Tests_Widgets extends WP_UnitTestCase { $this->assertArrayHasKey( 2, $settings ); foreach ( $option_value as $widget_number => $instance ) { - $this->assertEquals( $settings[ $widget_number ], $option_value[ $widget_number ] ); + $this->assertSame( $settings[ $widget_number ], $option_value[ $widget_number ] ); } // After widgets_init(), get_settings() should create the widget option. $never_used = get_option( 'widget_nav_menu' ); - $this->assertEquals( 1, $never_used['_multiwidget'] ); + $this->assertSame( 1, $never_used['_multiwidget'] ); $this->assertArrayNotHasKey( 0, $never_used ); } @@ -592,7 +592,7 @@ class Tests_Widgets extends WP_UnitTestCase { $option_value = get_option( $wp_widget_search->option_name ); $this->assertArrayHasKey( '_multiwidget', $option_value ); - $this->assertEquals( $overridden_title, $option_value[2]['title'] ); + $this->assertSame( $overridden_title, $option_value[2]['title'] ); } /** @@ -773,7 +773,7 @@ class Tests_Widgets extends WP_UnitTestCase { $result = retrieve_widgets( true ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( $result, $sidebars_widgets ); + $this->assertSame( $result, $sidebars_widgets ); foreach ( $sidebars_widgets as $widgets ) { $this->assertInternalType( 'array', $widgets ); @@ -798,7 +798,7 @@ class Tests_Widgets extends WP_UnitTestCase { $this->assertContains( 'recent-comments-2', $sidebars_widgets['wp_inactive_widgets'] ); // Sidebar_widgets option was updated. - $this->assertEquals( $sidebars_widgets, wp_get_sidebars_widgets() ); + $this->assertSame( $sidebars_widgets, wp_get_sidebars_widgets() ); } /** @@ -823,7 +823,7 @@ class Tests_Widgets extends WP_UnitTestCase { // $sidebars_widgets matches registered sidebars. $this->assertInternalType( 'array', $result ); - $this->assertEquals( $result, $sidebars_widgets ); + $this->assertSame( $result, $sidebars_widgets ); foreach ( $sidebars_widgets as $widgets ) { $this->assertInternalType( 'array', $widgets ); @@ -862,7 +862,7 @@ class Tests_Widgets extends WP_UnitTestCase { $_wp_sidebars_widgets = array(); $this->assertInternalType( 'array', $result ); - $this->assertEquals( $result, $sidebars_widgets ); + $this->assertSame( $result, $sidebars_widgets ); foreach ( $sidebars_widgets as $widgets ) { $this->assertInternalType( 'array', $widgets ); @@ -890,7 +890,7 @@ class Tests_Widgets extends WP_UnitTestCase { $this->assertContains( 'recent-comments-2', $sidebars_widgets['wp_inactive_widgets'] ); // Sidebar_widgets option was updated. - $this->assertEquals( $sidebars_widgets, wp_get_sidebars_widgets() ); + $this->assertSame( $sidebars_widgets, wp_get_sidebars_widgets() ); // Reset. $sidebars_widgets = array( @@ -905,7 +905,7 @@ class Tests_Widgets extends WP_UnitTestCase { $_wp_sidebars_widgets = array(); $this->assertInternalType( 'array', $result ); - $this->assertEquals( $result, $sidebars_widgets ); + $this->assertSame( $result, $sidebars_widgets ); foreach ( $sidebars_widgets as $widgets ) { $this->assertInternalType( 'array', $widgets ); @@ -930,7 +930,7 @@ class Tests_Widgets extends WP_UnitTestCase { $this->assertContains( 'recent-comments-2', $sidebars_widgets['wp_inactive_widgets'] ); // Sidebar_widgets option was updated. - $this->assertEquals( $sidebars_widgets, wp_get_sidebars_widgets() ); + $this->assertSame( $sidebars_widgets, wp_get_sidebars_widgets() ); } /** @@ -957,7 +957,7 @@ class Tests_Widgets extends WP_UnitTestCase { $_wp_sidebars_widgets = array(); $this->assertInternalType( 'array', $result ); - $this->assertEquals( $result, $sidebars_widgets ); + $this->assertSame( $result, $sidebars_widgets ); foreach ( $sidebars_widgets as $widgets ) { $this->assertInternalType( 'array', $widgets ); @@ -1037,7 +1037,7 @@ class Tests_Widgets extends WP_UnitTestCase { $this->assertArrayNotHasKey( 'orphaned_widgets_1', $sidebars_widgets ); // Sidebar_widgets option was updated. - $this->assertEquals( $sidebars_widgets, wp_get_sidebars_widgets() ); + $this->assertSame( $sidebars_widgets, wp_get_sidebars_widgets() ); } /** @@ -1062,7 +1062,7 @@ class Tests_Widgets extends WP_UnitTestCase { $this->assertArrayHasKey( 'fantasy', $filtered_widgets ); $this->assertEmpty( $filtered_widgets['fantasy'] ); $this->assertArrayHasKey( 'array_version', $filtered_widgets ); - $this->assertEquals( 3, $filtered_widgets['array_version'] ); + $this->assertSame( 3, $filtered_widgets['array_version'] ); $this->assertInternalType( 'integer', $filtered_widgets['array_version'] ); } diff --git a/tests/phpunit/tests/widgets/custom-html-widget.php b/tests/phpunit/tests/widgets/custom-html-widget.php index 3a31a7d9a5..ad6a39b464 100644 --- a/tests/phpunit/tests/widgets/custom-html-widget.php +++ b/tests/phpunit/tests/widgets/custom-html-widget.php @@ -47,10 +47,10 @@ class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { */ public function test_construct() { $widget = new WP_Widget_Custom_HTML(); - $this->assertEquals( 'custom_html', $widget->id_base ); - $this->assertEquals( 'widget_custom_html', $widget->widget_options['classname'] ); - $this->assertEquals( 400, $widget->control_options['width'] ); - $this->assertEquals( 350, $widget->control_options['height'] ); + $this->assertSame( 'custom_html', $widget->id_base ); + $this->assertSame( 'widget_custom_html', $widget->widget_options['classname'] ); + $this->assertSame( 400, $widget->control_options['width'] ); + $this->assertSame( 350, $widget->control_options['height'] ); $this->assertTrue( $widget->widget_options['customize_selective_refresh'] ); } @@ -64,9 +64,9 @@ class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { $widget = new WP_Widget_Custom_HTML(); $widget->_register(); - $this->assertEquals( 10, has_action( 'admin_print_scripts-widgets.php', array( $widget, 'enqueue_admin_scripts' ) ) ); - $this->assertEquals( 10, has_action( 'admin_footer-widgets.php', array( 'WP_Widget_Custom_HTML', 'render_control_template_scripts' ) ) ); - $this->assertEquals( 10, has_action( 'admin_head-widgets.php', array( 'WP_Widget_Custom_HTML', 'add_help_text' ) ) ); + $this->assertSame( 10, has_action( 'admin_print_scripts-widgets.php', array( $widget, 'enqueue_admin_scripts' ) ) ); + $this->assertSame( 10, has_action( 'admin_footer-widgets.php', array( 'WP_Widget_Custom_HTML', 'render_control_template_scripts' ) ) ); + $this->assertSame( 10, has_action( 'admin_head-widgets.php', array( 'WP_Widget_Custom_HTML', 'add_help_text' ) ) ); $this->assertContains( 'wp.customHtmlWidgets.idBases.push( "custom_html" );', wp_scripts()->registered['custom-html-widgets']->extra['after'] ); } @@ -117,8 +117,8 @@ class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { $this->assertNotContains( '<p>', $output ); $this->assertNotContains( '<br>', $output ); $this->assertNotContains( '</u>', $output ); - $this->assertEquals( $text_widget_instance, $this->widget_text_args[1] ); - $this->assertEquals( $instance, $this->widget_custom_html_content_args[1] ); + $this->assertSame( $text_widget_instance, $this->widget_text_args[1] ); + $this->assertSame( $instance, $this->widget_custom_html_content_args[1] ); $this->assertSame( $widget, $this->widget_text_args[2] ); $this->assertSame( $widget, $this->widget_custom_html_content_args[2] ); remove_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5 ); @@ -185,7 +185,7 @@ class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { 'content' => $instance['content'], ); $result = $widget->update( $instance, array() ); - $this->assertEquals( $result, $expected ); + $this->assertSame( $result, $expected ); // Make sure KSES is applying as expected. add_filter( 'map_meta_cap', array( $this, 'grant_unfiltered_html_cap' ), 10, 2 ); @@ -193,7 +193,7 @@ class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { $instance['content'] = '<script>alert( "Howdy!" );</script>'; $expected['content'] = $instance['content']; $result = $widget->update( $instance, array() ); - $this->assertEquals( $result, $expected ); + $this->assertSame( $result, $expected ); remove_filter( 'map_meta_cap', array( $this, 'grant_unfiltered_html_cap' ) ); add_filter( 'map_meta_cap', array( $this, 'revoke_unfiltered_html_cap' ), 10, 2 ); @@ -201,7 +201,7 @@ class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { $instance['content'] = '<script>alert( "Howdy!" );</script>'; $expected['content'] = wp_kses_post( $instance['content'] ); $result = $widget->update( $instance, array() ); - $this->assertEquals( $result, $expected ); + $this->assertSame( $result, $expected ); remove_filter( 'map_meta_cap', array( $this, 'revoke_unfiltered_html_cap' ), 10 ); } diff --git a/tests/phpunit/tests/widgets/media-audio-widget.php b/tests/phpunit/tests/widgets/media-audio-widget.php index c3e467094e..fe5df88dcd 100644 --- a/tests/phpunit/tests/widgets/media-audio-widget.php +++ b/tests/phpunit/tests/widgets/media-audio-widget.php @@ -94,7 +94,7 @@ class Test_WP_Widget_Media_Audio extends WP_UnitTestCase { $this->assertArrayHasKey( 'customize_selective_refresh', $widget->widget_options ); $this->assertArrayHasKey( 'description', $widget->widget_options ); $this->assertTrue( $widget->widget_options['customize_selective_refresh'] ); - $this->assertEquals( 'audio', $widget->widget_options['mime_type'] ); + $this->assertSame( 'audio', $widget->widget_options['mime_type'] ); $this->assertEqualSets( array( 'add_to_widget', diff --git a/tests/phpunit/tests/widgets/media-gallery-widget.php b/tests/phpunit/tests/widgets/media-gallery-widget.php index a855e643a2..f27fbccfba 100644 --- a/tests/phpunit/tests/widgets/media-gallery-widget.php +++ b/tests/phpunit/tests/widgets/media-gallery-widget.php @@ -118,7 +118,7 @@ class Test_WP_Widget_Media_Gallery extends WP_UnitTestCase { // Field: title. $instance['title'] = 'Hello <b>World</b> '; $instance = $widget->update( $instance, array() ); - $this->assertEquals( 'Hello World', $instance['title'] ); + $this->assertSame( 'Hello World', $instance['title'] ); // Field: ids. $instance['ids'] = '1,2,3'; diff --git a/tests/phpunit/tests/widgets/media-image-widget.php b/tests/phpunit/tests/widgets/media-image-widget.php index 8367e79898..999eae18df 100644 --- a/tests/phpunit/tests/widgets/media-image-widget.php +++ b/tests/phpunit/tests/widgets/media-image-widget.php @@ -101,7 +101,7 @@ class Test_WP_Widget_Media_Image extends WP_UnitTestCase { $this->assertArrayHasKey( 'customize_selective_refresh', $widget->widget_options ); $this->assertArrayHasKey( 'description', $widget->widget_options ); $this->assertTrue( $widget->widget_options['customize_selective_refresh'] ); - $this->assertEquals( 'image', $widget->widget_options['mime_type'] ); + $this->assertSame( 'image', $widget->widget_options['mime_type'] ); $this->assertEqualSets( array( 'add_to_widget', diff --git a/tests/phpunit/tests/widgets/media-video-widget.php b/tests/phpunit/tests/widgets/media-video-widget.php index 296bb92965..a2776b5831 100644 --- a/tests/phpunit/tests/widgets/media-video-widget.php +++ b/tests/phpunit/tests/widgets/media-video-widget.php @@ -95,7 +95,7 @@ class Test_WP_Widget_Media_Video extends WP_UnitTestCase { $this->assertArrayHasKey( 'customize_selective_refresh', $widget->widget_options ); $this->assertArrayHasKey( 'description', $widget->widget_options ); $this->assertTrue( $widget->widget_options['customize_selective_refresh'] ); - $this->assertEquals( 'video', $widget->widget_options['mime_type'] ); + $this->assertSame( 'video', $widget->widget_options['mime_type'] ); $this->assertEqualSets( array( 'add_to_widget', diff --git a/tests/phpunit/tests/widgets/media-widget.php b/tests/phpunit/tests/widgets/media-widget.php index 95c34ab5ae..db1baa4dab 100644 --- a/tests/phpunit/tests/widgets/media-widget.php +++ b/tests/phpunit/tests/widgets/media-widget.php @@ -76,10 +76,10 @@ class Test_WP_Widget_Media extends WP_UnitTestCase { ), array_keys( $widget->l10n ) ); - $this->assertEquals( count( $widget->l10n ), count( array_filter( $widget->l10n ) ), 'Expected all translation strings to be defined.' ); - $this->assertEquals( 10, has_action( 'admin_print_scripts-widgets.php', array( $widget, 'enqueue_admin_scripts' ) ) ); + $this->assertSame( count( $widget->l10n ), count( array_filter( $widget->l10n ) ), 'Expected all translation strings to be defined.' ); + $this->assertSame( 10, has_action( 'admin_print_scripts-widgets.php', array( $widget, 'enqueue_admin_scripts' ) ) ); $this->assertFalse( has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ), 'Did not expect preview scripts to be enqueued when not in customize preview context.' ); - $this->assertEquals( 10, has_action( 'admin_footer-widgets.php', array( $widget, 'render_control_template_scripts' ) ) ); + $this->assertSame( 10, has_action( 'admin_footer-widgets.php', array( $widget, 'render_control_template_scripts' ) ) ); // With non-default args. $id_base = 'media_pdf'; @@ -92,8 +92,8 @@ class Test_WP_Widget_Media extends WP_UnitTestCase { 'height' => 1100, ); $widget = $this->get_mocked_class_instance( $id_base, $name, $widget_options, $control_options ); - $this->assertEquals( $id_base, $widget->id_base ); - $this->assertEquals( $name, $widget->name ); + $this->assertSame( $id_base, $widget->id_base ); + $this->assertSame( $name, $widget->name ); // Method assertArraySubset doesn't exist in phpunit versions compatible with PHP 5.2. if ( method_exists( $this, 'assertArraySubset' ) ) { @@ -128,7 +128,7 @@ class Test_WP_Widget_Media extends WP_UnitTestCase { $widget = $this->get_mocked_class_instance(); $widget->_register(); - $this->assertEquals( 10, has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) ); + $this->assertSame( 10, has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) ); } /** @@ -169,10 +169,10 @@ class Test_WP_Widget_Media extends WP_UnitTestCase { $widget = $this->get_mocked_class_instance(); $result = $widget->sanitize_token_list( 'What A false class with-token <a href="#">and link</a>' ); - $this->assertEquals( 'What A false class with-token a hrefand linka', $result ); + $this->assertSame( 'What A false class with-token a hrefand linka', $result ); $result = $widget->sanitize_token_list( array( 'foo', '<i>bar', '">NO' ) ); - $this->assertEquals( $result, 'foo ibar NO' ); + $this->assertSame( $result, 'foo ibar NO' ); } /** @@ -339,8 +339,8 @@ class Test_WP_Widget_Media extends WP_UnitTestCase { $widget->widget( $args, $instance ); $this->assertCount( 3, $this->widget_instance_filter_args ); $this->assertEquals( $instance, $this->widget_instance_filter_args[0] ); - $this->assertEquals( $args, $this->widget_instance_filter_args[1] ); - $this->assertEquals( $widget, $this->widget_instance_filter_args[2] ); + $this->assertSame( $args, $this->widget_instance_filter_args[1] ); + $this->assertSame( $widget, $this->widget_instance_filter_args[2] ); $output = ob_get_clean(); $this->assertContains( '<h2>Foo</h2>', $output ); diff --git a/tests/phpunit/tests/widgets/text-widget.php b/tests/phpunit/tests/widgets/text-widget.php index caa25e0eb8..42ca86d709 100644 --- a/tests/phpunit/tests/widgets/text-widget.php +++ b/tests/phpunit/tests/widgets/text-widget.php @@ -48,11 +48,11 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { */ function test_construct() { $widget = new WP_Widget_Text(); - $this->assertEquals( 'text', $widget->id_base ); - $this->assertEquals( 'widget_text', $widget->widget_options['classname'] ); + $this->assertSame( 'text', $widget->id_base ); + $this->assertSame( 'widget_text', $widget->widget_options['classname'] ); $this->assertTrue( $widget->widget_options['customize_selective_refresh'] ); - $this->assertEquals( 400, $widget->control_options['width'] ); - $this->assertEquals( 350, $widget->control_options['height'] ); + $this->assertSame( 400, $widget->control_options['width'] ); + $this->assertSame( 350, $widget->control_options['height'] ); } /** @@ -65,8 +65,8 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { $widget = new WP_Widget_Text(); $widget->_register(); - $this->assertEquals( 10, has_action( 'admin_print_scripts-widgets.php', array( $widget, 'enqueue_admin_scripts' ) ) ); - $this->assertEquals( 10, has_action( 'admin_footer-widgets.php', array( 'WP_Widget_Text', 'render_control_template_scripts' ) ) ); + $this->assertSame( 10, has_action( 'admin_print_scripts-widgets.php', array( $widget, 'enqueue_admin_scripts' ) ) ); + $this->assertSame( 10, has_action( 'admin_footer-widgets.php', array( 'WP_Widget_Text', 'render_control_template_scripts' ) ) ); $this->assertContains( 'wp.textWidgets.idBases.push( "text" );', wp_scripts()->registered['text-widgets']->extra['after'] ); $this->assertFalse( has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) ); } @@ -97,7 +97,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { $widget = new WP_Widget_Text(); $widget->_register(); - $this->assertEquals( 10, has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) ); + $this->assertSame( 10, has_action( 'wp_enqueue_scripts', array( $widget, 'enqueue_preview_scripts' ) ) ); } /** @@ -173,9 +173,9 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { $this->assertContains( '<p>', $output ); $this->assertContains( '<br />', $output ); $this->assertNotEmpty( $this->widget_text_args ); - $this->assertEquals( $instance['text'], $this->widget_text_args[0] ); - $this->assertEquals( $instance, $this->widget_text_args[1] ); - $this->assertEquals( $widget, $this->widget_text_args[2] ); + $this->assertSame( $instance['text'], $this->widget_text_args[0] ); + $this->assertSame( $instance, $this->widget_text_args[1] ); + $this->assertSame( $widget, $this->widget_text_args[2] ); $this->assertEmpty( $this->widget_text_content_args ); $this->assertContains( '[filter:widget_text]', $output ); $this->assertNotContains( '[filter:widget_text_content]', $output ); @@ -200,13 +200,13 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { $this->assertContains( '<p>', $output ); $this->assertContains( '<br />', $output ); $this->assertCount( 3, $this->widget_text_args ); - $this->assertEquals( $expected_instance['text'], $this->widget_text_args[0] ); - $this->assertEquals( $expected_instance, $this->widget_text_args[1] ); - $this->assertEquals( $widget, $this->widget_text_args[2] ); + $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); + $this->assertSame( $expected_instance, $this->widget_text_args[1] ); + $this->assertSame( $widget, $this->widget_text_args[2] ); $this->assertCount( 3, $this->widget_text_content_args ); - $this->assertEquals( $expected_instance['text'] . '[filter:widget_text]', $this->widget_text_content_args[0] ); - $this->assertEquals( $expected_instance, $this->widget_text_content_args[1] ); - $this->assertEquals( $widget, $this->widget_text_content_args[2] ); + $this->assertSame( $expected_instance['text'] . '[filter:widget_text]', $this->widget_text_content_args[0] ); + $this->assertSame( $expected_instance, $this->widget_text_content_args[1] ); + $this->assertSame( $widget, $this->widget_text_content_args[2] ); $this->assertContains( wpautop( $expected_instance['text'] . '[filter:widget_text][filter:widget_text_content]' ), $output ); // Test with filter=true&visual=true, the upgraded widget, in 4.8.1 and above. @@ -224,13 +224,13 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { $this->assertContains( '<p>', $output ); $this->assertContains( '<br />', $output ); $this->assertCount( 3, $this->widget_text_args ); - $this->assertEquals( $expected_instance['text'], $this->widget_text_args[0] ); - $this->assertEquals( $expected_instance, $this->widget_text_args[1] ); - $this->assertEquals( $widget, $this->widget_text_args[2] ); + $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); + $this->assertSame( $expected_instance, $this->widget_text_args[1] ); + $this->assertSame( $widget, $this->widget_text_args[2] ); $this->assertCount( 3, $this->widget_text_content_args ); - $this->assertEquals( $expected_instance['text'] . '[filter:widget_text]', $this->widget_text_content_args[0] ); - $this->assertEquals( $expected_instance, $this->widget_text_content_args[1] ); - $this->assertEquals( $widget, $this->widget_text_content_args[2] ); + $this->assertSame( $expected_instance['text'] . '[filter:widget_text]', $this->widget_text_content_args[0] ); + $this->assertSame( $expected_instance, $this->widget_text_content_args[1] ); + $this->assertSame( $widget, $this->widget_text_content_args[2] ); $this->assertContains( wpautop( $expected_instance['text'] . '[filter:widget_text][filter:widget_text_content]' ), $output ); // Test with filter=true&visual=true, the upgraded widget, in 4.8.1 and above. @@ -248,9 +248,9 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { $this->assertContains( '<p>', $output ); $this->assertContains( '<br />', $output ); $this->assertCount( 3, $this->widget_text_args ); - $this->assertEquals( $expected_instance['text'], $this->widget_text_args[0] ); - $this->assertEquals( $expected_instance, $this->widget_text_args[1] ); - $this->assertEquals( $widget, $this->widget_text_args[2] ); + $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); + $this->assertSame( $expected_instance, $this->widget_text_args[1] ); + $this->assertSame( $widget, $this->widget_text_args[2] ); $this->assertNull( $this->widget_text_content_args ); $this->assertContains( wpautop( $expected_instance['text'] . '[filter:widget_text]' ), $output ); @@ -269,9 +269,9 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { $this->assertNotContains( '<p>', $output ); $this->assertNotContains( '<br />', $output ); $this->assertCount( 3, $this->widget_text_args ); - $this->assertEquals( $expected_instance['text'], $this->widget_text_args[0] ); - $this->assertEquals( $expected_instance, $this->widget_text_args[1] ); - $this->assertEquals( $widget, $this->widget_text_args[2] ); + $this->assertSame( $expected_instance['text'], $this->widget_text_args[0] ); + $this->assertSame( $expected_instance, $this->widget_text_args[1] ); + $this->assertSame( $widget, $this->widget_text_args[2] ); $this->assertNull( $this->widget_text_content_args ); $this->assertContains( $expected_instance['text'] . '[filter:widget_text]', $output ); } @@ -344,7 +344,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { ob_start(); $widget->widget( $args, $instance ); $output = ob_get_clean(); - $this->assertEquals( 1, $this->shortcode_render_count ); + $this->assertSame( 1, $this->shortcode_render_count ); $this->assertNotContains( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' ); $this->assertContains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); $this->assertNotContains( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' ); @@ -362,7 +362,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { ob_start(); $widget->widget( $args, $instance ); $output = ob_get_clean(); - $this->assertEquals( 1, $this->shortcode_render_count ); + $this->assertSame( 1, $this->shortcode_render_count ); $this->assertNotContains( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' ); $this->assertContains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); $this->assertNotContains( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' ); @@ -374,7 +374,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { ob_start(); $widget->widget( $args, $instance ); $output = ob_get_clean(); - $this->assertEquals( 1, $this->shortcode_render_count ); + $this->assertSame( 1, $this->shortcode_render_count ); $this->assertNotContains( '[example]', $output, 'Expected shortcode to be processed in legacy widget with plugin adding filter' ); $this->assertContains( wpautop( $this->example_shortcode_content ), $output, 'Shortcode was applied *with* wpautop() applying to shortcode output since plugin used legacy filter.' ); $this->assertNull( $this->post_during_shortcode ); @@ -390,16 +390,16 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { // Visual Text Widget with only core-added widget_text_content filter for do_shortcode(). $this->assertFalse( has_filter( 'widget_text', 'do_shortcode' ) ); - $this->assertEquals( 11, has_filter( 'widget_text_content', 'do_shortcode' ), 'Expected core to have set do_shortcode as widget_text_content filter.' ); + $this->assertSame( 11, has_filter( 'widget_text_content', 'do_shortcode' ), 'Expected core to have set do_shortcode as widget_text_content filter.' ); $this->shortcode_render_count = 0; ob_start(); $widget->widget( $args, $instance ); $output = ob_get_clean(); - $this->assertEquals( 1, $this->shortcode_render_count ); + $this->assertSame( 1, $this->shortcode_render_count ); $this->assertContains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); $this->assertNotContains( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' ); $this->assertFalse( has_filter( 'widget_text', 'do_shortcode' ), 'The widget_text filter still lacks do_shortcode handler.' ); - $this->assertEquals( 11, has_filter( 'widget_text_content', 'do_shortcode' ), 'The widget_text_content filter still has do_shortcode handler.' ); + $this->assertSame( 11, has_filter( 'widget_text_content', 'do_shortcode' ), 'The widget_text_content filter still has do_shortcode handler.' ); $this->assertNull( $this->post_during_shortcode ); // Visual Text Widget with both filters applied added, one from core and another via plugin. @@ -408,10 +408,10 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { ob_start(); $widget->widget( $args, $instance ); $output = ob_get_clean(); - $this->assertEquals( 1, $this->shortcode_render_count ); + $this->assertSame( 1, $this->shortcode_render_count ); $this->assertContains( $this->example_shortcode_content, $output, 'Shortcode was applied without wpautop corrupting it.' ); $this->assertNotContains( '<p>' . $this->example_shortcode_content . '</p>', $output, 'Expected shortcode_unautop() to have run.' ); - $this->assertEquals( 10, has_filter( 'widget_text', 'do_shortcode' ), 'Expected do_shortcode to be restored to widget_text.' ); + $this->assertSame( 10, has_filter( 'widget_text', 'do_shortcode' ), 'Expected do_shortcode to be restored to widget_text.' ); $this->assertNull( $this->post_during_shortcode ); $this->assertNull( $this->post_during_shortcode ); remove_filter( 'widget_text', 'do_shortcode' ); @@ -423,7 +423,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { ob_start(); $widget->widget( $args, $instance ); $output = ob_get_clean(); - $this->assertEquals( 0, $this->shortcode_render_count ); + $this->assertSame( 0, $this->shortcode_render_count ); $this->assertContains( '[example]', $output ); $this->assertNotContains( $this->example_shortcode_content, $output ); $this->assertFalse( has_filter( 'widget_text', 'do_shortcode' ) ); @@ -730,7 +730,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { 'visual' => true, ); $result = $widget->update( $instance, array() ); - $this->assertEquals( $expected, $result ); + $this->assertSame( $expected, $result ); $this->assertTrue( ! empty( $expected['filter'] ), 'Expected filter prop to be truthy, to handle case where 4.8 is downgraded to 4.7.' ); add_filter( 'map_meta_cap', array( $this, 'grant_unfiltered_html_cap' ), 10, 2 ); @@ -738,7 +738,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { $instance['text'] = '<script>alert( "Howdy!" );</script>'; $expected['text'] = $instance['text']; $result = $widget->update( $instance, array() ); - $this->assertEquals( $expected, $result, 'KSES should apply as expected.' ); + $this->assertSame( $expected, $result, 'KSES should apply as expected.' ); remove_filter( 'map_meta_cap', array( $this, 'grant_unfiltered_html_cap' ) ); add_filter( 'map_meta_cap', array( $this, 'revoke_unfiltered_html_cap' ), 10, 2 ); @@ -746,7 +746,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { $instance['text'] = '<script>alert( "Howdy!" );</script>'; $expected['text'] = wp_kses_post( $instance['text'] ); $result = $widget->update( $instance, array() ); - $this->assertEquals( $expected, $result, 'KSES should not apply since user can unfiltered_html.' ); + $this->assertSame( $expected, $result, 'KSES should not apply since user can unfiltered_html.' ); remove_filter( 'map_meta_cap', array( $this, 'revoke_unfiltered_html_cap' ), 10 ); } @@ -765,7 +765,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { 'filter' => false, ); $result = $widget->update( $instance, array() ); - $this->assertEquals( $instance, $result, 'Updating a widget without visual prop and explicit filter=false leaves visual prop absent' ); + $this->assertSame( $instance, $result, 'Updating a widget without visual prop and explicit filter=false leaves visual prop absent' ); // -- $instance = array( @@ -774,7 +774,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { 'filter' => true, ); $result = $widget->update( $instance, array() ); - $this->assertEquals( $instance, $result, 'Updating a widget without visual prop and explicit filter=true leaves legacy prop absent.' ); + $this->assertSame( $instance, $result, 'Updating a widget without visual prop and explicit filter=true leaves legacy prop absent.' ); // -- $instance = array( @@ -795,7 +795,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { ) ); $result = $widget->update( $instance, $old_instance ); - $this->assertEquals( $expected, $result, 'Updating a pre-existing widget with visual mode forces filter to be true.' ); + $this->assertSame( $expected, $result, 'Updating a pre-existing widget with visual mode forces filter to be true.' ); // -- $instance = array( @@ -816,7 +816,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { 'visual' => true, ) ); - $this->assertEquals( $expected, $result, 'Updating a pre-existing visual widget retains visual mode when updated.' ); + $this->assertSame( $expected, $result, 'Updating a pre-existing visual widget retains visual mode when updated.' ); // -- $instance = array( @@ -837,7 +837,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { 'filter' => true, ) ); - $this->assertEquals( $expected, $result, 'Updating a pre-existing visual widget retains visual=true and supplies missing filter=true.' ); + $this->assertSame( $expected, $result, 'Updating a pre-existing visual widget retains visual=true and supplies missing filter=true.' ); // -- $instance = array( @@ -890,7 +890,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { 'filter' => false, ) ); - $this->assertEquals( $expected, $result, 'Updating a widget that previously had legacy form results in filter allowed to be false.' ); + $this->assertSame( $expected, $result, 'Updating a widget that previously had legacy form results in filter allowed to be false.' ); // -- $instance = array( @@ -906,7 +906,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { 'visual' => true, ) ); - $this->assertEquals( $expected, $result, 'Updating a widget that had \'content\' as its filter value persists non-legacy mode. This only existed in WP 4.8.0.' ); + $this->assertSame( $expected, $result, 'Updating a widget that had \'content\' as its filter value persists non-legacy mode. This only existed in WP 4.8.0.' ); // -- $instance = array( @@ -943,7 +943,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { 'visual' => true, ) ); - $this->assertEquals( $expected, $result, 'Updating a widget with filter=content (from WP 4.8.0) upgrades to filter=true&visual=true.' ); + $this->assertSame( $expected, $result, 'Updating a widget with filter=content (from WP 4.8.0) upgrades to filter=true&visual=true.' ); } /** diff --git a/tests/phpunit/tests/xmlrpc/basic.php b/tests/phpunit/tests/xmlrpc/basic.php index 703a3615c5..25e36f7204 100644 --- a/tests/phpunit/tests/xmlrpc/basic.php +++ b/tests/phpunit/tests/xmlrpc/basic.php @@ -13,7 +13,7 @@ class Tests_XMLRPC_Basic extends WP_XMLRPC_UnitTestCase { $this->assertIXRError( $result ); // If disabled, 405 would result. - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_login_pass_ok() { diff --git a/tests/phpunit/tests/xmlrpc/client.php b/tests/phpunit/tests/xmlrpc/client.php index 8b45017321..7234b2fa67 100644 --- a/tests/phpunit/tests/xmlrpc/client.php +++ b/tests/phpunit/tests/xmlrpc/client.php @@ -12,9 +12,9 @@ class Tests_XMLRPC_Client extends WP_XMLRPC_UnitTestCase { */ function test_ixr_client_allows_query_strings() { $client = new IXR_Client( 'http://example.com/server.php?this-is-needed=true#not-this' ); - $this->assertEquals( 'example.com', $client->server ); - $this->assertEquals( 80, $client->port ); - $this->assertEquals( '/server.php?this-is-needed=true', $client->path ); + $this->assertSame( 'example.com', $client->server ); + $this->assertSame( 80, $client->port ); + $this->assertSame( '/server.php?this-is-needed=true', $client->path ); } /** @@ -22,9 +22,9 @@ class Tests_XMLRPC_Client extends WP_XMLRPC_UnitTestCase { */ function test_wp_ixr_client_allows_query_strings() { $client = new WP_HTTP_IXR_Client( 'http://example.com/server.php?this-is-needed=true#not-this' ); - $this->assertEquals( 'example.com', $client->server ); + $this->assertSame( 'example.com', $client->server ); $this->assertFalse( $client->port ); - $this->assertEquals( '/server.php?this-is-needed=true', $client->path ); + $this->assertSame( '/server.php?this-is-needed=true', $client->path ); } } diff --git a/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php b/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php index 5ae61d3923..c615a26b7d 100644 --- a/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php +++ b/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'username', 'password' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_no_posts() { @@ -16,7 +16,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 500, $result->code ); + $this->assertSame( 500, $result->code ); } function test_no_editable_posts() { @@ -26,7 +26,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); $this->assertNotIXRError( $result ); - $this->assertEquals( 0, count( $result ) ); + $this->assertSame( 0, count( $result ) ); } function test_date() { @@ -44,8 +44,8 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { $this->assertInstanceOf( 'IXR_Date', $result['dateCreated'] ); $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] ); - $this->assertEquals( strtotime( $post->post_date ), $result['dateCreated']->getTimestamp() ); - $this->assertEquals( $date_gmt, $result['date_created_gmt']->getTimestamp() ); + $this->assertSame( strtotime( $post->post_date ), $result['dateCreated']->getTimestamp() ); + $this->assertSame( $date_gmt, $result['date_created_gmt']->getTimestamp() ); } } } diff --git a/tests/phpunit/tests/xmlrpc/mw/editPost.php b/tests/phpunit/tests/xmlrpc/mw/editPost.php index 73d4805558..271ad36f56 100644 --- a/tests/phpunit/tests/xmlrpc/mw/editPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/editPost.php @@ -9,7 +9,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post = array(); $result = $this->myxmlrpcserver->mw_editPost( array( 1, 'username', 'password', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_edit_own_post() { @@ -27,7 +27,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $this->assertTrue( $result ); $out = get_post( $post_id ); - $this->assertEquals( $new_title, $out->post_title ); + $this->assertSame( $new_title, $out->post_title ); } function test_capable_edit_others_post() { @@ -47,7 +47,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $this->assertTrue( $result ); $out = get_post( $post_id ); - $this->assertEquals( $new_title, $out->post_title ); + $this->assertSame( $new_title, $out->post_title ); } function test_incapable_edit_others_post() { @@ -65,10 +65,10 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'title' => $new_title ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); $out = get_post( $post_id ); - $this->assertEquals( $original_title, $out->post_title ); + $this->assertSame( $original_title, $out->post_title ); } function test_capable_reassign_author() { @@ -104,7 +104,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'wp_author_id' => $author_id ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); $out = get_post( $post_id ); $this->assertEquals( $contributor_id, $out->post_author ); @@ -143,7 +143,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { ); $post_id = wp_insert_post( $post ); - $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); + $this->assertSame( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); // Create attachment. $filename = ( DIR_TESTDATA . '/images/a2-small.jpg' ); @@ -174,7 +174,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post5 = array( 'wp_post_thumbnail' => '' ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'author', 'author', $post5 ) ); $this->assertNotIXRError( $result ); - $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); + $this->assertSame( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); remove_theme_support( 'post-thumbnails' ); } @@ -199,7 +199,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $this->assertTrue( $result ); $out = get_post( $post_id ); - $this->assertEquals( $post2['title'], $out->post_title ); + $this->assertSame( $post2['title'], $out->post_title ); $post3 = array( 'description' => 'New Content', @@ -210,8 +210,8 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $this->assertTrue( $result ); $out = get_post( $post_id ); - $this->assertEquals( $post2['title'], $out->post_title ); - $this->assertEquals( $post3['description'], $out->post_content ); + $this->assertSame( $post2['title'], $out->post_title ); + $this->assertSame( $post3['description'], $out->post_content ); $post4 = array( 'mt_excerpt' => 'New Excerpt', @@ -222,9 +222,9 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $this->assertTrue( $result ); $out = get_post( $post_id ); - $this->assertEquals( $post2['title'], $out->post_title ); - $this->assertEquals( $post3['description'], $out->post_content ); - $this->assertEquals( $post4['mt_excerpt'], $out->post_excerpt ); + $this->assertSame( $post2['title'], $out->post_title ); + $this->assertSame( $post3['description'], $out->post_content ); + $this->assertSame( $post4['mt_excerpt'], $out->post_excerpt ); } /** @@ -259,7 +259,7 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'post_type' => 'page' ); $result = $this->myxmlrpcserver->mw_editPost( array( $post_id, 'contributor', 'contributor', $post2 ) ); $this->assertIXRError( $result ); - $this->assertEquals( $result->code, 401 ); + $this->assertSame( $result->code, 401 ); } /** @@ -327,9 +327,9 @@ class Tests_XMLRPC_mw_editPost extends WP_XMLRPC_UnitTestCase { ); $after = get_post( $post_id ); - $this->assertEquals( 'future', $after->post_status ); + $this->assertSame( 'future', $after->post_status ); $future_date_string = strftime( '%Y-%m-%d %H:%M:%S', $future_time ); - $this->assertEquals( $future_date_string, $after->post_date ); + $this->assertSame( $future_date_string, $after->post_date ); } } diff --git a/tests/phpunit/tests/xmlrpc/mw/getPost.php b/tests/phpunit/tests/xmlrpc/mw/getPost.php index 9c914d708e..4522b7d943 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/getPost.php @@ -24,7 +24,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'username', 'password' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_incapable_user() { @@ -32,7 +32,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'subscriber', 'subscriber' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } /** @@ -41,7 +41,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { function test_invalid_postid() { $result = $this->myxmlrpcserver->mw_getPost( array( 9999, 'author', 'author' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 404, $result->code ); + $this->assertSame( 404, $result->code ); } function test_valid_post() { @@ -78,13 +78,13 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { // Check expected values. $this->assertStringMatchesFormat( '%d', $result['userid'] ); - $this->assertEquals( $post_data->post_title, $result['title'] ); - $this->assertEquals( 'publish', $result['post_status'] ); + $this->assertSame( $post_data->post_title, $result['title'] ); + $this->assertSame( 'publish', $result['post_status'] ); $this->assertStringMatchesFormat( '%d', $result['wp_author_id'] ); - $this->assertEquals( $post_data->post_excerpt, $result['mt_excerpt'] ); - $this->assertEquals( url_to_postid( $result['link'] ), self::$post_id ); + $this->assertSame( $post_data->post_excerpt, $result['mt_excerpt'] ); + $this->assertSame( url_to_postid( $result['link'] ), self::$post_id ); - $this->assertEquals( 0, $result['wp_post_thumbnail'] ); + $this->assertSame( 0, $result['wp_post_thumbnail'] ); remove_theme_support( 'post-thumbnails' ); } @@ -103,7 +103,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { $this->assertNotIXRError( $result ); $this->assertInternalType( 'int', $result['wp_post_thumbnail'] ); - $this->assertEquals( $attachment_id, $result['wp_post_thumbnail'] ); + $this->assertSame( $attachment_id, $result['wp_post_thumbnail'] ); remove_theme_support( 'post-thumbnails' ); } @@ -120,13 +120,13 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { $post_data = get_post( self::$post_id ); - $this->assertEquals( strtotime( $post_data->post_date ), $result['dateCreated']->getTimestamp() ); - $this->assertEquals( strtotime( $post_data->post_date ), $result['date_modified']->getTimestamp() ); + $this->assertSame( strtotime( $post_data->post_date ), $result['dateCreated']->getTimestamp() ); + $this->assertSame( strtotime( $post_data->post_date ), $result['date_modified']->getTimestamp() ); $post_date_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $post_data->post_date, false ), 'Ymd\TH:i:s' ) ); $post_modified_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $post_data->post_date, false ), 'Ymd\TH:i:s' ) ); - $this->assertEquals( $post_date_gmt, $result['date_created_gmt']->getTimestamp() ); - $this->assertEquals( $post_modified_gmt, $result['date_modified_gmt']->getTimestamp() ); + $this->assertSame( $post_date_gmt, $result['date_created_gmt']->getTimestamp() ); + $this->assertSame( $post_modified_gmt, $result['date_modified_gmt']->getTimestamp() ); } } diff --git a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php index 06350d00e1..e7338a569c 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php +++ b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php @@ -25,7 +25,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'username', 'password' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } /** @@ -36,7 +36,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'subscriber', 'subscriber' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_no_editable_posts() { @@ -44,7 +44,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) ); $this->assertNotIXRError( $result ); - $this->assertEquals( 0, count( $result ) ); + $this->assertSame( 0, count( $result ) ); } function test_valid_post() { @@ -82,13 +82,13 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { // Check expected values. $this->assertStringMatchesFormat( '%d', $result['userid'] ); $this->assertStringMatchesFormat( '%d', $result['postid'] ); - $this->assertEquals( $post->post_title, $result['title'] ); - $this->assertEquals( 'draft', $result['post_status'] ); + $this->assertSame( $post->post_title, $result['title'] ); + $this->assertSame( 'draft', $result['post_status'] ); $this->assertStringMatchesFormat( '%d', $result['wp_author_id'] ); - $this->assertEquals( $post->post_excerpt, $result['mt_excerpt'] ); - $this->assertEquals( url_to_postid( $result['link'] ), $post->ID ); + $this->assertSame( $post->post_excerpt, $result['mt_excerpt'] ); + $this->assertSame( url_to_postid( $result['link'] ), $post->ID ); - $this->assertEquals( '', $result['wp_post_thumbnail'] ); + $this->assertSame( '', $result['wp_post_thumbnail'] ); } remove_theme_support( 'post-thumbnails' ); @@ -112,7 +112,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { if ( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] === self::$post_id ) { $attachment_id = get_post_meta( $result['postid'], '_thumbnail_id', true ); - $this->assertEquals( $attachment_id, $result['wp_post_thumbnail'] ); + $this->assertSame( $attachment_id, $result['wp_post_thumbnail'] ); } } @@ -135,10 +135,10 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { $this->assertInstanceOf( 'IXR_Date', $result['date_modified'] ); $this->assertInstanceOf( 'IXR_Date', $result['date_modified_gmt'] ); - $this->assertEquals( strtotime( $post->post_date ), $result['dateCreated']->getTimestamp() ); - $this->assertEquals( $date_gmt, $result['date_created_gmt']->getTimestamp() ); - $this->assertEquals( strtotime( $post->post_date ), $result['date_modified']->getTimestamp() ); - $this->assertEquals( $date_modified_gmt, $result['date_modified_gmt']->getTimestamp() ); + $this->assertSame( strtotime( $post->post_date ), $result['dateCreated']->getTimestamp() ); + $this->assertSame( $date_gmt, $result['date_created_gmt']->getTimestamp() ); + $this->assertSame( strtotime( $post->post_date ), $result['date_modified']->getTimestamp() ); + $this->assertSame( $date_modified_gmt, $result['date_modified_gmt']->getTimestamp() ); } } } diff --git a/tests/phpunit/tests/xmlrpc/mw/newPost.php b/tests/phpunit/tests/xmlrpc/mw/newPost.php index 69e4c3c1f6..456acbd31e 100644 --- a/tests/phpunit/tests/xmlrpc/mw/newPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/newPost.php @@ -9,7 +9,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array(); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'username', 'password', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_incapable_user() { @@ -18,7 +18,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array(); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'subscriber', 'subscriber', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_no_content() { @@ -27,8 +27,8 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $post = array(); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 500, $result->code ); - $this->assertEquals( 'Content, title, and excerpt are empty.', $result->message ); + $this->assertSame( 500, $result->code ); + $this->assertSame( 'Content, title, and excerpt are empty.', $result->message ); } function test_basic_content() { @@ -72,7 +72,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'contributor', 'contributor', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_capable_other_author() { @@ -97,7 +97,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'contributor', 'contributor', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } /** @@ -112,7 +112,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'editor', 'editor', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 404, $result->code ); + $this->assertSame( 404, $result->code ); } function test_empty_author() { @@ -125,7 +125,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $out = get_post( $result ); $this->assertEquals( $my_author_id, $out->post_author ); - $this->assertEquals( 'Test', $out->post_title ); + $this->assertSame( 'Test', $out->post_title ); } function test_post_thumbnail() { @@ -157,7 +157,7 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->mw_newPost( array( 1, 'author', 'author', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_capable_set_post_type_as_page() { @@ -172,8 +172,8 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $this->assertStringMatchesFormat( '%d', $result ); $out = get_post( $result ); - $this->assertEquals( 'Test', $out->post_title ); - $this->assertEquals( 'page', $out->post_type ); + $this->assertSame( 'Test', $out->post_title ); + $this->assertSame( 'page', $out->post_type ); } @@ -193,8 +193,8 @@ class Tests_XMLRPC_mw_newPost extends WP_XMLRPC_UnitTestCase { $this->assertStringMatchesFormat( '%d', $result ); $out = get_post( $result ); - $this->assertEquals( 'post', $out->post_type ); - $this->assertEquals( 'draft', $out->post_status ); - $this->assertEquals( '0000-00-00 00:00:00', $out->post_date_gmt ); + $this->assertSame( 'post', $out->post_type ); + $this->assertSame( 'draft', $out->post_status ); + $this->assertSame( '0000-00-00 00:00:00', $out->post_date_gmt ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/deletePost.php b/tests/phpunit/tests/xmlrpc/wp/deletePost.php index 96c0c89cf4..85c6472e52 100644 --- a/tests/phpunit/tests/xmlrpc/wp/deletePost.php +++ b/tests/phpunit/tests/xmlrpc/wp/deletePost.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'username', 'password', 0 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_invalid_post() { @@ -16,7 +16,7 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'editor', 'editor', 340982340 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 404, $result->code ); + $this->assertSame( 404, $result->code ); } function test_incapable_user() { @@ -25,7 +25,7 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_deletePost( array( 1, 'subscriber', 'subscriber', $post_id ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_post_deleted() { @@ -37,6 +37,6 @@ class Tests_XMLRPC_wp_deletePost extends WP_XMLRPC_UnitTestCase { $this->assertTrue( $result ); $post = get_post( $post_id ); - $this->assertEquals( 'trash', $post->post_status ); + $this->assertSame( 'trash', $post->post_status ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php b/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php index 40601246c2..086bc4ad25 100644 --- a/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php @@ -17,7 +17,7 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'username', 'password', 'category', 0 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_empty_taxonomy() { @@ -25,8 +25,8 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', '', 0 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_invalid_taxonomy() { @@ -34,8 +34,8 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'not_existing', 0 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_incapable_user() { @@ -43,8 +43,8 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); - $this->assertEquals( __( 'Sorry, you are not allowed to delete this term.' ), $result->message ); + $this->assertSame( 401, $result->code ); + $this->assertSame( __( 'Sorry, you are not allowed to delete this term.' ), $result->message ); } function test_empty_term() { @@ -52,8 +52,8 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', '' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 500, $result->code ); - $this->assertEquals( __( 'Empty Term.' ), $result->message ); + $this->assertSame( 500, $result->code ); + $this->assertSame( __( 'Empty Term.' ), $result->message ); } function test_invalid_term() { @@ -61,8 +61,8 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', 9999 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 404, $result->code ); - $this->assertEquals( __( 'Invalid term ID.' ), $result->message ); + $this->assertSame( 404, $result->code ); + $this->assertSame( __( 'Invalid term ID.' ), $result->message ); } function test_term_deleted() { diff --git a/tests/phpunit/tests/xmlrpc/wp/editComment.php b/tests/phpunit/tests/xmlrpc/wp/editComment.php index b4fd559543..9a4acf7522 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/editComment.php @@ -59,8 +59,8 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_editComment( array( 1, 'author', 'author', $comment_id, array( 'status' => 'hold' ) ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Sorry, you are not allowed to moderate or edit this comment.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Sorry, you are not allowed to moderate or edit this comment.' ), $result->message ); } function test_trash_comment() { @@ -77,7 +77,7 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { ); $comment_id = wp_insert_comment( $comment_data ); - $this->assertEquals( '1', get_comment( $comment_id )->comment_approved ); + $this->assertSame( '1', get_comment( $comment_id )->comment_approved ); $this->myxmlrpcserver->wp_editComment( array( @@ -91,6 +91,6 @@ class Tests_XMLRPC_wp_editComment extends WP_XMLRPC_UnitTestCase { ) ); - $this->assertEquals( 'trash', get_comment( $comment_id )->comment_approved ); + $this->assertSame( 'trash', get_comment( $comment_id )->comment_approved ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/editPost.php b/tests/phpunit/tests/xmlrpc/wp/editPost.php index 45ce7d6edf..84ca2788c7 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/editPost.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'username', 'password', 0, array() ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_edit_own_post() { @@ -27,7 +27,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->assertTrue( $result ); $out = get_post( $post_id ); - $this->assertEquals( $new_title, $out->post_title ); + $this->assertSame( $new_title, $out->post_title ); } function test_capable_edit_others_post() { @@ -47,7 +47,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->assertTrue( $result ); $out = get_post( $post_id ); - $this->assertEquals( $new_title, $out->post_title ); + $this->assertSame( $new_title, $out->post_title ); } function test_incapable_edit_others_post() { @@ -65,10 +65,10 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'post_title' => $new_title ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); $out = get_post( $post_id ); - $this->assertEquals( $original_title, $out->post_title ); + $this->assertSame( $original_title, $out->post_title ); } function test_capable_reassign_author() { @@ -104,7 +104,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $post2 = array( 'post_author' => $author_id ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'contributor', 'contributor', $post_id, $post2 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); $out = get_post( $post_id ); $this->assertEquals( $contributor_id, $out->post_author ); @@ -143,7 +143,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { ); $post_id = wp_insert_post( $post ); - $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); + $this->assertSame( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); // Create attachment. $filename = ( DIR_TESTDATA . '/images/a2-small.jpg' ); @@ -181,13 +181,13 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $post5 = array( 'post_thumbnail' => '' ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post5 ) ); $this->assertNotIXRError( $result ); - $this->assertEquals( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); + $this->assertSame( '', get_post_meta( $post_id, '_thumbnail_id', true ) ); // Use invalid ID. $post6 = array( 'post_thumbnail' => 398420983409 ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'author', 'author', $post_id, $post6 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 404, $result->code ); + $this->assertSame( 404, $result->code ); remove_theme_support( 'post-thumbnails' ); } @@ -226,14 +226,14 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->assertTrue( $result ); $out = get_post( $post_id ); - $this->assertEquals( $new_title, $out->post_title ); + $this->assertSame( $new_title, $out->post_title ); $edited_object = get_metadata_by_mid( 'post', $mid_edit ); - $this->assertEquals( '87654321', $edited_object->meta_value ); + $this->assertSame( '87654321', $edited_object->meta_value ); $this->assertFalse( get_metadata_by_mid( 'post', $mid_delete ) ); $created_object = get_post_meta( $post_id, 'custom_field_to_create', true ); - $this->assertEquals( $created_object, '12345678' ); + $this->assertSame( $created_object, '12345678' ); } function test_capable_unsticky() { @@ -287,7 +287,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->assertNotIXRError( $result ); // Make sure the edit went through. - $this->assertEquals( 'First edit', get_post( $post_id )->post_content ); + $this->assertSame( 'First edit', get_post( $post_id )->post_content ); // Modify it again. We think it was last modified yesterday, but we actually just modified it above. $struct = array( @@ -296,10 +296,10 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $struct ) ); $this->assertIXRError( $result ); - $this->assertEquals( 409, $result->code ); + $this->assertSame( 409, $result->code ); // Make sure the edit did not go through. - $this->assertEquals( 'First edit', get_post( $post_id )->post_content ); + $this->assertSame( 'First edit', get_post( $post_id )->post_content ); } function test_edit_attachment() { @@ -320,7 +320,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->assertNotIXRError( $result ); // Make sure that the post status is still inherit. - $this->assertEquals( 'inherit', get_post( $post_id )->post_status ); + $this->assertSame( 'inherit', get_post( $post_id )->post_status ); } function test_use_invalid_post_status() { @@ -339,7 +339,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->assertNotIXRError( $result ); // Make sure that the post status is still inherit. - $this->assertEquals( 'draft', get_post( $post_id )->post_status ); + $this->assertSame( 'draft', get_post( $post_id )->post_status ); } /** @@ -367,7 +367,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { ) ); $this->assertNotIXRError( $result ); - $this->assertEquals( 'Updated', get_post( $post_id )->post_title ); + $this->assertSame( 'Updated', get_post( $post_id )->post_title ); $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' ); $this->assertContains( $term_id, $term_ids ); @@ -394,7 +394,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $new_post_content ) ); $this->assertNotIXRError( $result ); - $this->assertEquals( 'Updated', get_post( $post_id )->post_title ); + $this->assertSame( 'Updated', get_post( $post_id )->post_title ); $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' ); $this->assertNotContains( $term_id, $term_ids ); @@ -436,13 +436,13 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { add_post_meta( $post_id, 'enclosure', $enclosure_string ); // Verify that the correct data is there. - $this->assertEquals( $enclosure_string, get_post_meta( $post_id, 'enclosure', true ) ); + $this->assertSame( $enclosure_string, get_post_meta( $post_id, 'enclosure', true ) ); // Attempt to add the enclosure a second time. $this->myxmlrpcserver->add_enclosure_if_new( $post_id, $enclosure ); // Verify that there is only a single value in the array and that a duplicate is not present. - $this->assertEquals( 1, count( get_post_meta( $post_id, 'enclosure' ) ) ); + $this->assertSame( 1, count( get_post_meta( $post_id, 'enclosure' ) ) ); // For good measure, check that the expected value is in the array. $this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) ); @@ -451,7 +451,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->myxmlrpcserver->add_enclosure_if_new( $post_id, $new_enclosure ); // Having added the new enclosure, 2 values are expected in the array. - $this->assertEquals( 2, count( get_post_meta( $post_id, 'enclosure' ) ) ); + $this->assertSame( 2, count( get_post_meta( $post_id, 'enclosure' ) ) ); // Check that the new enclosure is in the enclosure meta. $new_enclosure_string = "{$new_enclosure['url']}\n{$new_enclosure['length']}\n{$new_enclosure['type']}\n"; @@ -491,10 +491,10 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $new_post_content ) ); $after = get_post( $post_id ); - $this->assertEquals( 'future', $after->post_status ); + $this->assertSame( 'future', $after->post_status ); $future_date_string = strftime( '%Y-%m-%d %H:%M:%S', $future_time ); - $this->assertEquals( $future_date_string, $after->post_date ); + $this->assertSame( $future_date_string, $after->post_date ); } /** @@ -511,7 +511,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $post_id = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); $before = get_post( $post_id ); - $this->assertEquals( '0000-00-00 00:00:00', $before->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', $before->post_date_gmt ); // Edit the post without specifying any dates. $new_post_content = array( @@ -523,6 +523,6 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { // The published date should still be zero. $after = get_post( $post_id ); - $this->assertEquals( '0000-00-00 00:00:00', $after->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', $after->post_date_gmt ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/editProfile.php b/tests/phpunit/tests/xmlrpc/wp/editProfile.php index f132c78c5e..570de27220 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editProfile.php +++ b/tests/phpunit/tests/xmlrpc/wp/editProfile.php @@ -9,7 +9,7 @@ class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_editProfile( array( 1, 'username', 'password', array() ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_subscriber_profile() { @@ -30,13 +30,13 @@ class Tests_XMLRPC_wp_editProfile extends WP_XMLRPC_UnitTestCase { // Verify that the new values were stored. $user_data = get_userdata( $subscriber_id ); - $this->assertEquals( $new_data['first_name'], $user_data->first_name ); - $this->assertEquals( $new_data['last_name'], $user_data->last_name ); - $this->assertEquals( $new_data['url'], $user_data->user_url ); - $this->assertEquals( $new_data['display_name'], $user_data->display_name ); - $this->assertEquals( $new_data['nickname'], $user_data->nickname ); - $this->assertEquals( $new_data['nicename'], $user_data->user_nicename ); - $this->assertEquals( $new_data['bio'], $user_data->description ); + $this->assertSame( $new_data['first_name'], $user_data->first_name ); + $this->assertSame( $new_data['last_name'], $user_data->last_name ); + $this->assertSame( $new_data['url'], $user_data->user_url ); + $this->assertSame( $new_data['display_name'], $user_data->display_name ); + $this->assertSame( $new_data['nickname'], $user_data->nickname ); + $this->assertSame( $new_data['nicename'], $user_data->user_nicename ); + $this->assertSame( $new_data['bio'], $user_data->description ); } function test_ignore_password_change() { diff --git a/tests/phpunit/tests/xmlrpc/wp/editTerm.php b/tests/phpunit/tests/xmlrpc/wp/editTerm.php index bea3dde304..27070140af 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/editTerm.php @@ -29,7 +29,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'username', 'password', 'category', 1 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_empty_taxonomy() { @@ -37,8 +37,8 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', '', array( 'taxonomy' => '' ) ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_invalid_taxonomy() { @@ -46,8 +46,8 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'not_existing' ) ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_incapable_user() { @@ -55,8 +55,8 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'category' ) ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); - $this->assertEquals( __( 'Sorry, you are not allowed to edit this term.' ), $result->message ); + $this->assertSame( 401, $result->code ); + $this->assertSame( __( 'Sorry, you are not allowed to edit this term.' ), $result->message ); } function test_term_not_exists() { @@ -64,8 +64,8 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', 9999, array( 'taxonomy' => 'category' ) ) ); $this->assertIXRError( $result ); - $this->assertEquals( 404, $result->code ); - $this->assertEquals( __( 'Invalid term ID.' ), $result->message ); + $this->assertSame( 404, $result->code ); + $this->assertSame( __( 'Invalid term ID.' ), $result->message ); } function test_empty_term() { @@ -73,8 +73,8 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', '', array( 'taxonomy' => 'category' ) ) ); $this->assertIXRError( $result ); - $this->assertEquals( 500, $result->code ); - $this->assertEquals( __( 'Empty Term.' ), $result->message ); + $this->assertSame( 500, $result->code ); + $this->assertSame( __( 'Empty Term.' ), $result->message ); } function test_empty_term_name() { @@ -93,8 +93,8 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'The term name cannot be empty.' ), $result->message ); } function test_parent_for_nonhierarchical() { @@ -113,8 +113,8 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Cannot set parent term, taxonomy is not hierarchical.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Cannot set parent term, taxonomy is not hierarchical.' ), $result->message ); } function test_parent_empty() { @@ -178,7 +178,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { ) ); $this->assertIXRError( $result ); - $this->assertEquals( 500, $result->code ); + $this->assertSame( 500, $result->code ); } function test_parent_not_existing() { @@ -198,8 +198,8 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Parent term does not exist.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Parent term does not exist.' ), $result->message ); } function test_parent_duplicate_slug() { @@ -219,8 +219,8 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { ) ); $this->assertIXRError( $result ); - $this->assertEquals( 500, $result->code ); - $this->assertEquals( htmlspecialchars( sprintf( __( 'The slug “%s” is already in use by another term.' ), $parent_term->slug ) ), $result->message ); + $this->assertSame( 500, $result->code ); + $this->assertSame( htmlspecialchars( sprintf( __( 'The slug “%s” is already in use by another term.' ), $parent_term->slug ) ), $result->message ); } function test_edit_all_fields() { diff --git a/tests/phpunit/tests/xmlrpc/wp/getComment.php b/tests/phpunit/tests/xmlrpc/wp/getComment.php index 0c6b49d1a5..bf5d01b454 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/getComment.php @@ -36,7 +36,7 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'username', 'password', self::$parent_comment_id ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_incapable_user() { @@ -44,7 +44,7 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'contributor', 'contributor', self::$parent_comment_id ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_valid_comment() { @@ -76,11 +76,11 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { $this->assertStringMatchesFormat( '%d', $result['post_id'] ); $this->assertEquals( self::$parent_comment_id, $result['comment_id'] ); $this->assertEquals( 0, $result['parent'] ); - $this->assertEquals( self::$parent_comment_data['comment_content'], $result['content'] ); + $this->assertSame( self::$parent_comment_data['comment_content'], $result['content'] ); $this->assertEquals( self::$post_id, $result['post_id'] ); - $this->assertEquals( self::$parent_comment_data['comment_author'], $result['author'] ); - $this->assertEquals( self::$parent_comment_data['comment_author_url'], $result['author_url'] ); - $this->assertEquals( self::$parent_comment_data['comment_author_email'], $result['author_email'] ); + $this->assertSame( self::$parent_comment_data['comment_author'], $result['author'] ); + $this->assertSame( self::$parent_comment_data['comment_author_url'], $result['author_url'] ); + $this->assertSame( self::$parent_comment_data['comment_author_email'], $result['author_email'] ); } function test_valid_child_comment() { @@ -98,6 +98,6 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', 123456789 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 404, $result->code ); + $this->assertSame( 404, $result->code ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getComments.php b/tests/phpunit/tests/xmlrpc/wp/getComments.php index b3b1d03e3a..07d78e0b0f 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getComments.php +++ b/tests/phpunit/tests/xmlrpc/wp/getComments.php @@ -9,7 +9,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'username', 'password', array() ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_incapable_user() { @@ -17,7 +17,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'contributor', 'contributor', array() ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_capable_user() { @@ -31,7 +31,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { foreach ( $results as $result ) { $comment = get_comment( $result['comment_id'], ARRAY_A ); - $this->assertEquals( $comment['comment_post_ID'], $result['post_id'] ); + $this->assertSame( $comment['comment_post_ID'], $result['post_id'] ); } } @@ -134,7 +134,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getComments( array( 1, 'contributor', 'contributor' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_author_capabilities() { diff --git a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php index 353371b445..6312cdda44 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php +++ b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php @@ -39,7 +39,7 @@ class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getMediaItem( array( 1, 'username', 'password', 0 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_valid_media_item() { @@ -62,8 +62,8 @@ class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase { // Check expected values. $this->assertStringMatchesFormat( '%d', $result['attachment_id'] ); - $this->assertEquals( $this->attachment_data['post_title'], $result['title'] ); - $this->assertEquals( wp_get_attachment_url( $this->attachment_id ), $result['link'] ); - $this->assertEquals( wp_get_attachment_thumb_url( $this->attachment_id ), $result['thumbnail'] ); + $this->assertSame( $this->attachment_data['post_title'], $result['title'] ); + $this->assertSame( wp_get_attachment_url( $this->attachment_id ), $result['link'] ); + $this->assertSame( wp_get_attachment_thumb_url( $this->attachment_id ), $result['thumbnail'] ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getOptions.php b/tests/phpunit/tests/xmlrpc/wp/getOptions.php index 59b3636b3c..6ffdf4503d 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getOptions.php +++ b/tests/phpunit/tests/xmlrpc/wp/getOptions.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'username', 'password' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_valid_username_password() { @@ -16,7 +16,7 @@ class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'subscriber', 'subscriber' ) ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( 'WordPress', $result['software_name']['value'] ); + $this->assertSame( 'WordPress', $result['software_name']['value'] ); } function test_option_value() { @@ -25,7 +25,7 @@ class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'administrator', 'administrator', 'default_comment_status' ) ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( get_option( 'default_comment_status' ), $result['default_comment_status']['value'] ); + $this->assertSame( get_option( 'default_comment_status' ), $result['default_comment_status']['value'] ); $this->assertFalse( $result['default_comment_status']['readonly'] ); } @@ -40,83 +40,83 @@ class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { $this->assertInternalType( 'array', $result ); // Read-only options. - $this->assertEquals( 'WordPress', $result['software_name']['value'] ); + $this->assertSame( 'WordPress', $result['software_name']['value'] ); $this->assertTrue( $result['software_name']['readonly'] ); - $this->assertEquals( $wp_version, $result['software_version']['value'] ); + $this->assertSame( $wp_version, $result['software_version']['value'] ); $this->assertTrue( $result['software_version']['readonly'] ); - $this->assertEquals( get_site_url(), $result['blog_url']['value'] ); + $this->assertSame( get_site_url(), $result['blog_url']['value'] ); $this->assertTrue( $result['blog_url']['readonly'] ); - $this->assertEquals( wp_login_url(), $result['login_url']['value'] ); + $this->assertSame( wp_login_url(), $result['login_url']['value'] ); $this->assertTrue( $result['login_url']['readonly'] ); - $this->assertEquals( get_admin_url(), $result['admin_url']['value'] ); + $this->assertSame( get_admin_url(), $result['admin_url']['value'] ); $this->assertTrue( $result['admin_url']['readonly'] ); - $this->assertEquals( get_option( 'image_default_link_type' ), $result['image_default_link_type']['value'] ); + $this->assertSame( get_option( 'image_default_link_type' ), $result['image_default_link_type']['value'] ); $this->assertTrue( $result['image_default_link_type']['readonly'] ); - $this->assertEquals( get_option( 'image_default_size' ), $result['image_default_size']['value'] ); + $this->assertSame( get_option( 'image_default_size' ), $result['image_default_size']['value'] ); $this->assertTrue( $result['image_default_size']['readonly'] ); - $this->assertEquals( get_option( 'image_default_align' ), $result['image_default_align']['value'] ); + $this->assertSame( get_option( 'image_default_align' ), $result['image_default_align']['value'] ); $this->assertTrue( $result['image_default_align']['readonly'] ); - $this->assertEquals( get_template(), $result['template']['value'] ); + $this->assertSame( get_template(), $result['template']['value'] ); $this->assertTrue( $result['template']['readonly'] ); - $this->assertEquals( get_stylesheet(), $result['stylesheet']['value'] ); + $this->assertSame( get_stylesheet(), $result['stylesheet']['value'] ); $this->assertTrue( $result['stylesheet']['readonly'] ); - $this->assertEquals( current_theme_supports( 'post-thumbnails' ), $result['post_thumbnail']['value'] ); + $this->assertSame( current_theme_supports( 'post-thumbnails' ), $result['post_thumbnail']['value'] ); $this->assertTrue( $result['post_thumbnail']['readonly'] ); // Updatable options. - $this->assertEquals( get_option( 'gmt_offset' ), $result['time_zone']['value'] ); + $this->assertSame( get_option( 'gmt_offset' ), $result['time_zone']['value'] ); $this->assertTrue( $result['time_zone']['readonly'] ); - $this->assertEquals( get_option( 'blogname' ), $result['blog_title']['value'] ); + $this->assertSame( get_option( 'blogname' ), $result['blog_title']['value'] ); $this->assertTrue( $result['blog_title']['readonly'] ); - $this->assertEquals( get_option( 'blogdescription' ), $result['blog_tagline']['value'] ); + $this->assertSame( get_option( 'blogdescription' ), $result['blog_tagline']['value'] ); $this->assertTrue( $result['blog_tagline']['readonly'] ); - $this->assertEquals( get_option( 'date_format' ), $result['date_format']['value'] ); + $this->assertSame( get_option( 'date_format' ), $result['date_format']['value'] ); $this->assertTrue( $result['date_format']['readonly'] ); - $this->assertEquals( get_option( 'time_format' ), $result['time_format']['value'] ); + $this->assertSame( get_option( 'time_format' ), $result['time_format']['value'] ); $this->assertTrue( $result['time_format']['readonly'] ); - $this->assertEquals( get_option( 'users_can_register' ), $result['users_can_register']['value'] ); + $this->assertSame( get_option( 'users_can_register' ), $result['users_can_register']['value'] ); $this->assertTrue( $result['users_can_register']['readonly'] ); - $this->assertEquals( get_option( 'thumbnail_size_w' ), $result['thumbnail_size_w']['value'] ); + $this->assertSame( get_option( 'thumbnail_size_w' ), $result['thumbnail_size_w']['value'] ); $this->assertTrue( $result['thumbnail_size_w']['readonly'] ); - $this->assertEquals( get_option( 'thumbnail_size_h' ), $result['thumbnail_size_h']['value'] ); + $this->assertSame( get_option( 'thumbnail_size_h' ), $result['thumbnail_size_h']['value'] ); $this->assertTrue( $result['thumbnail_size_h']['readonly'] ); - $this->assertEquals( get_option( 'thumbnail_crop' ), $result['thumbnail_crop']['value'] ); + $this->assertSame( get_option( 'thumbnail_crop' ), $result['thumbnail_crop']['value'] ); $this->assertTrue( $result['thumbnail_crop']['readonly'] ); - $this->assertEquals( get_option( 'medium_size_w' ), $result['medium_size_w']['value'] ); + $this->assertSame( get_option( 'medium_size_w' ), $result['medium_size_w']['value'] ); $this->assertTrue( $result['medium_size_w']['readonly'] ); - $this->assertEquals( get_option( 'medium_size_h' ), $result['medium_size_h']['value'] ); + $this->assertSame( get_option( 'medium_size_h' ), $result['medium_size_h']['value'] ); $this->assertTrue( $result['medium_size_h']['readonly'] ); - $this->assertEquals( get_option( 'large_size_w' ), $result['large_size_w']['value'] ); + $this->assertSame( get_option( 'large_size_w' ), $result['large_size_w']['value'] ); $this->assertTrue( $result['large_size_w']['readonly'] ); - $this->assertEquals( get_option( 'large_size_h' ), $result['large_size_h']['value'] ); + $this->assertSame( get_option( 'large_size_h' ), $result['large_size_h']['value'] ); $this->assertTrue( $result['large_size_h']['readonly'] ); - $this->assertEquals( get_option( 'default_comment_status' ), $result['default_comment_status']['value'] ); + $this->assertSame( get_option( 'default_comment_status' ), $result['default_comment_status']['value'] ); $this->assertTrue( $result['default_comment_status']['readonly'] ); - $this->assertEquals( get_option( 'default_ping_status' ), $result['default_ping_status']['value'] ); + $this->assertSame( get_option( 'default_ping_status' ), $result['default_ping_status']['value'] ); $this->assertTrue( $result['default_ping_status']['readonly'] ); } @@ -129,83 +129,83 @@ class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { $this->assertInternalType( 'array', $result ); // Read-only options. - $this->assertEquals( 'WordPress', $result['software_name']['value'] ); + $this->assertSame( 'WordPress', $result['software_name']['value'] ); $this->assertTrue( $result['software_name']['readonly'] ); - $this->assertEquals( $wp_version, $result['software_version']['value'] ); + $this->assertSame( $wp_version, $result['software_version']['value'] ); $this->assertTrue( $result['software_version']['readonly'] ); - $this->assertEquals( get_site_url(), $result['blog_url']['value'] ); + $this->assertSame( get_site_url(), $result['blog_url']['value'] ); $this->assertTrue( $result['blog_url']['readonly'] ); - $this->assertEquals( wp_login_url(), $result['login_url']['value'] ); + $this->assertSame( wp_login_url(), $result['login_url']['value'] ); $this->assertTrue( $result['login_url']['readonly'] ); - $this->assertEquals( get_admin_url(), $result['admin_url']['value'] ); + $this->assertSame( get_admin_url(), $result['admin_url']['value'] ); $this->assertTrue( $result['admin_url']['readonly'] ); - $this->assertEquals( get_option( 'image_default_link_type' ), $result['image_default_link_type']['value'] ); + $this->assertSame( get_option( 'image_default_link_type' ), $result['image_default_link_type']['value'] ); $this->assertTrue( $result['image_default_link_type']['readonly'] ); - $this->assertEquals( get_option( 'image_default_size' ), $result['image_default_size']['value'] ); + $this->assertSame( get_option( 'image_default_size' ), $result['image_default_size']['value'] ); $this->assertTrue( $result['image_default_size']['readonly'] ); - $this->assertEquals( get_option( 'image_default_align' ), $result['image_default_align']['value'] ); + $this->assertSame( get_option( 'image_default_align' ), $result['image_default_align']['value'] ); $this->assertTrue( $result['image_default_align']['readonly'] ); - $this->assertEquals( get_template(), $result['template']['value'] ); + $this->assertSame( get_template(), $result['template']['value'] ); $this->assertTrue( $result['template']['readonly'] ); - $this->assertEquals( get_stylesheet(), $result['stylesheet']['value'] ); + $this->assertSame( get_stylesheet(), $result['stylesheet']['value'] ); $this->assertTrue( $result['stylesheet']['readonly'] ); - $this->assertEquals( current_theme_supports( 'post-thumbnails' ), $result['post_thumbnail']['value'] ); + $this->assertSame( current_theme_supports( 'post-thumbnails' ), $result['post_thumbnail']['value'] ); $this->assertTrue( $result['post_thumbnail']['readonly'] ); // Updatable options. - $this->assertEquals( get_option( 'gmt_offset' ), $result['time_zone']['value'] ); + $this->assertSame( get_option( 'gmt_offset' ), $result['time_zone']['value'] ); $this->assertFalse( $result['time_zone']['readonly'] ); - $this->assertEquals( get_option( 'blogname' ), $result['blog_title']['value'] ); + $this->assertSame( get_option( 'blogname' ), $result['blog_title']['value'] ); $this->assertFalse( $result['blog_title']['readonly'] ); - $this->assertEquals( get_option( 'blogdescription' ), $result['blog_tagline']['value'] ); + $this->assertSame( get_option( 'blogdescription' ), $result['blog_tagline']['value'] ); $this->assertFalse( $result['blog_tagline']['readonly'] ); - $this->assertEquals( get_option( 'date_format' ), $result['date_format']['value'] ); + $this->assertSame( get_option( 'date_format' ), $result['date_format']['value'] ); $this->assertFalse( $result['date_format']['readonly'] ); - $this->assertEquals( get_option( 'time_format' ), $result['time_format']['value'] ); + $this->assertSame( get_option( 'time_format' ), $result['time_format']['value'] ); $this->assertFalse( $result['time_format']['readonly'] ); - $this->assertEquals( get_option( 'users_can_register' ), $result['users_can_register']['value'] ); + $this->assertSame( get_option( 'users_can_register' ), $result['users_can_register']['value'] ); $this->assertFalse( $result['users_can_register']['readonly'] ); - $this->assertEquals( get_option( 'thumbnail_size_w' ), $result['thumbnail_size_w']['value'] ); + $this->assertSame( get_option( 'thumbnail_size_w' ), $result['thumbnail_size_w']['value'] ); $this->assertFalse( $result['thumbnail_size_w']['readonly'] ); - $this->assertEquals( get_option( 'thumbnail_size_h' ), $result['thumbnail_size_h']['value'] ); + $this->assertSame( get_option( 'thumbnail_size_h' ), $result['thumbnail_size_h']['value'] ); $this->assertFalse( $result['thumbnail_size_h']['readonly'] ); - $this->assertEquals( get_option( 'thumbnail_crop' ), $result['thumbnail_crop']['value'] ); + $this->assertSame( get_option( 'thumbnail_crop' ), $result['thumbnail_crop']['value'] ); $this->assertFalse( $result['thumbnail_crop']['readonly'] ); - $this->assertEquals( get_option( 'medium_size_w' ), $result['medium_size_w']['value'] ); + $this->assertSame( get_option( 'medium_size_w' ), $result['medium_size_w']['value'] ); $this->assertFalse( $result['medium_size_w']['readonly'] ); - $this->assertEquals( get_option( 'medium_size_h' ), $result['medium_size_h']['value'] ); + $this->assertSame( get_option( 'medium_size_h' ), $result['medium_size_h']['value'] ); $this->assertFalse( $result['medium_size_h']['readonly'] ); - $this->assertEquals( get_option( 'large_size_w' ), $result['large_size_w']['value'] ); + $this->assertSame( get_option( 'large_size_w' ), $result['large_size_w']['value'] ); $this->assertFalse( $result['large_size_w']['readonly'] ); - $this->assertEquals( get_option( 'large_size_h' ), $result['large_size_h']['value'] ); + $this->assertSame( get_option( 'large_size_h' ), $result['large_size_h']['value'] ); $this->assertFalse( $result['large_size_h']['readonly'] ); - $this->assertEquals( get_option( 'default_comment_status' ), $result['default_comment_status']['value'] ); + $this->assertSame( get_option( 'default_comment_status' ), $result['default_comment_status']['value'] ); $this->assertFalse( $result['default_comment_status']['readonly'] ); - $this->assertEquals( get_option( 'default_ping_status' ), $result['default_ping_status']['value'] ); + $this->assertSame( get_option( 'default_ping_status' ), $result['default_ping_status']['value'] ); $this->assertFalse( $result['default_ping_status']['readonly'] ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getPage.php b/tests/phpunit/tests/xmlrpc/wp/getPage.php index 7991f5568d..03b54a58b6 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPage.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPage.php @@ -25,7 +25,7 @@ class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'username', 'password' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } /** @@ -36,7 +36,7 @@ class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPage( array( 1, 9999, 'editor', 'editor' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 404, $result->code ); + $this->assertSame( 404, $result->code ); } function test_valid_page() { @@ -73,10 +73,10 @@ class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { // Check expected values. $this->assertStringMatchesFormat( '%d', $result['userid'] ); - $this->assertEquals( 'future', $result['page_status'] ); - $this->assertEquals( $post_data->post_title, $result['title'] ); - $this->assertEquals( url_to_postid( $result['link'] ), self::$post_id ); - $this->assertEquals( $post_data->post_excerpt, $result['excerpt'] ); + $this->assertSame( 'future', $result['page_status'] ); + $this->assertSame( $post_data->post_title, $result['title'] ); + $this->assertSame( url_to_postid( $result['link'] ), self::$post_id ); + $this->assertSame( $post_data->post_excerpt, $result['excerpt'] ); $this->assertStringMatchesFormat( '%d', $result['wp_author_id'] ); } @@ -93,7 +93,7 @@ class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { $date_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $post_data->post_date, false ), 'Ymd\TH:i:s' ) ); - $this->assertEquals( strtotime( $post_data->post_date ), $result['dateCreated']->getTimestamp() ); - $this->assertEquals( $date_gmt, $result['date_created_gmt']->getTimestamp() ); + $this->assertSame( strtotime( $post_data->post_date ), $result['dateCreated']->getTimestamp() ); + $this->assertSame( $date_gmt, $result['date_created_gmt']->getTimestamp() ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getPageList.php b/tests/phpunit/tests/xmlrpc/wp/getPageList.php index 8205befb2d..e3ad2e0e84 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPageList.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPageList.php @@ -25,7 +25,7 @@ class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPageList( array( 1, 'username', 'password' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_incapable_user() { @@ -33,7 +33,7 @@ class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPageList( array( 1, 'contributor', 'contributor' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_date() { @@ -49,8 +49,8 @@ class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase { $this->assertInstanceOf( 'IXR_Date', $result->dateCreated ); $this->assertInstanceOf( 'IXR_Date', $result->date_created_gmt ); - $this->assertEquals( strtotime( $page->post_date ), $result->dateCreated->getTimestamp() ); - $this->assertEquals( $date_gmt, $result->date_created_gmt->getTimestamp() ); + $this->assertSame( strtotime( $page->post_date ), $result->dateCreated->getTimestamp() ); + $this->assertSame( $date_gmt, $result->date_created_gmt->getTimestamp() ); } } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getPages.php b/tests/phpunit/tests/xmlrpc/wp/getPages.php index 40da0ea891..ee90a12480 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPages.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPages.php @@ -33,7 +33,7 @@ class Tests_XMLRPC_wp_getPages extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'username', 'password' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_incapable_user() { @@ -41,7 +41,7 @@ class Tests_XMLRPC_wp_getPages extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'contributor', 'contributor' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_capable_user() { @@ -50,7 +50,7 @@ class Tests_XMLRPC_wp_getPages extends WP_XMLRPC_UnitTestCase { foreach ( $results as $result ) { $page = get_post( $result['page_id'] ); - $this->assertEquals( $page->post_type, 'page' ); + $this->assertSame( $page->post_type, 'page' ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getPost.php b/tests/phpunit/tests/xmlrpc/wp/getPost.php index f0bdc0cc3f..30b8addf6c 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPost.php @@ -31,7 +31,7 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'username', 'password', 1 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_valid_post() { @@ -65,15 +65,15 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { // Check expected values. $this->assertStringMatchesFormat( '%d', $result['post_id'] ); - $this->assertEquals( $this->post_data['post_title'], $result['post_title'] ); - $this->assertEquals( 'draft', $result['post_status'] ); - $this->assertEquals( 'post', $result['post_type'] ); + $this->assertSame( $this->post_data['post_title'], $result['post_title'] ); + $this->assertSame( 'draft', $result['post_status'] ); + $this->assertSame( 'post', $result['post_type'] ); $this->assertStringMatchesFormat( '%d', $result['post_author'] ); - $this->assertEquals( $this->post_data['post_excerpt'], $result['post_excerpt'] ); - $this->assertEquals( $this->post_data['post_content'], $result['post_content'] ); - $this->assertEquals( url_to_postid( $result['link'] ), $this->post_id ); + $this->assertSame( $this->post_data['post_excerpt'], $result['post_excerpt'] ); + $this->assertSame( $this->post_data['post_content'], $result['post_content'] ); + $this->assertSame( url_to_postid( $result['link'] ), $this->post_id ); $this->assertEquals( $this->post_custom_field['id'], $result['custom_fields'][0]['id'] ); - $this->assertEquals( $this->post_custom_field['key'], $result['custom_fields'][0]['key'] ); + $this->assertSame( $this->post_custom_field['key'], $result['custom_fields'][0]['key'] ); $this->assertEquals( $this->post_custom_field['value'], $result['custom_fields'][0]['value'] ); remove_theme_support( 'post-thumbnails' ); @@ -85,8 +85,8 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { $this->assertNotIXRError( $result ); // When no fields are requested, only the IDs should be returned. - $this->assertEquals( 1, count( $result ) ); - $this->assertEquals( array( 'post_id' ), array_keys( $result ) ); + $this->assertSame( 1, count( $result ) ); + $this->assertSame( array( 'post_id' ), array_keys( $result ) ); } function test_default_fields() { @@ -109,14 +109,14 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { $this->assertInstanceOf( 'IXR_Date', $result['post_modified'] ); $this->assertInstanceOf( 'IXR_Date', $result['post_modified_gmt'] ); - $this->assertEquals( $this->post_date_ts, $result['post_date']->getTimestamp() ); - $this->assertEquals( $this->post_date_ts, $result['post_modified']->getTimestamp() ); + $this->assertSame( $this->post_date_ts, $result['post_date']->getTimestamp() ); + $this->assertSame( $this->post_date_ts, $result['post_modified']->getTimestamp() ); $post_date_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $this->post_data['post_date'], false ), 'Ymd\TH:i:s' ) ); $post_modified_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $this->post_data['post_date'], false ), 'Ymd\TH:i:s' ) ); - $this->assertEquals( $post_date_gmt, $result['post_date_gmt']->getTimestamp() ); - $this->assertEquals( $post_modified_gmt, $result['post_modified_gmt']->getTimestamp() ); + $this->assertSame( $post_date_gmt, $result['post_date_gmt']->getTimestamp() ); + $this->assertSame( $post_modified_gmt, $result['post_modified_gmt']->getTimestamp() ); } /** @@ -143,8 +143,8 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { $this->assertInternalType( 'string', $result['guid'] ); $this->assertInternalType( 'string', $result['post_mime_type'] ); - $this->assertEquals( 'page', $result['post_type'] ); + $this->assertSame( 'page', $result['post_type'] ); $this->assertEquals( $parent_page_id, $result['post_parent'] ); - $this->assertEquals( 2, $result['menu_order'] ); + $this->assertSame( 2, $result['menu_order'] ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getPostType.php b/tests/phpunit/tests/xmlrpc/wp/getPostType.php index 33a055b580..3781dc0674 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPostType.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPostType.php @@ -32,7 +32,7 @@ class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'username', 'password', 'post' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_invalid_post_type_name() { @@ -40,7 +40,7 @@ class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'editor', 'editor', 'foobar' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_valid_post_type_name() { @@ -55,7 +55,7 @@ class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPostType( array( 1, 'subscriber', 'subscriber', 'post' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_valid_type() { @@ -124,9 +124,9 @@ class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { } // Check expected values. - $this->assertEquals( $this->cpt_name, $result['name'] ); + $this->assertSame( $this->cpt_name, $result['name'] ); foreach ( $this->cpt_args as $key => $value ) { - $this->assertEquals( $value, $result[ $key ] ); + $this->assertSame( $value, $result[ $key ] ); } } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php b/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php index 20f1092574..3afa962d34 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php @@ -7,7 +7,7 @@ class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'username', 'password', 'post' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_incapable_user() { @@ -16,7 +16,7 @@ class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'subscriber', 'subscriber' ) ); $this->assertNotIXRError( $result ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( 0, count( $result ) ); + $this->assertSame( 0, count( $result ) ); } function test_capable_user() { diff --git a/tests/phpunit/tests/xmlrpc/wp/getPosts.php b/tests/phpunit/tests/xmlrpc/wp/getPosts.php index 1cece0550a..8571969f13 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPosts.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPosts.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'username', 'password' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } /** @@ -19,12 +19,12 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'subscriber', 'subscriber' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); $filter = array( 'post_type' => 'page' ); $result = $this->myxmlrpcserver->wp_getPosts( array( 1, 'subscriber', 'subscriber', $filter ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_capable_user() { @@ -71,7 +71,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { ); $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); $this->assertNotIXRError( $results ); - $this->assertEquals( $num_posts, count( $results ) ); + $this->assertSame( $num_posts, count( $results ) ); // Page through results. $posts_found = array(); @@ -83,7 +83,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { $filter['offset'] += $filter['number']; } while ( count( $presults ) > 0 ); // Verify that $post_ids matches $posts_found. - $this->assertEquals( 0, count( array_diff( $post_ids, $posts_found ) ) ); + $this->assertSame( 0, count( array_diff( $post_ids, $posts_found ) ) ); // Add comments to some of the posts. foreach ( $post_ids as $key => $post_id ) { @@ -117,7 +117,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { ); $results3 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter3 ) ); $this->assertNotIXRError( $results3 ); - $this->assertEquals( 1, count( $results3 ) ); + $this->assertSame( 1, count( $results3 ) ); $this->assertEquals( $post->ID, $results3[0]['post_id'] ); _unregister_post_type( $cpt_name ); @@ -159,13 +159,13 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { $filter = array( 's' => 'Third' ); $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); $this->assertNotIXRError( $results ); - $this->assertEquals( 0, count( $results ) ); + $this->assertSame( 0, count( $results ) ); // Search for one of them. $filter = array( 's' => 'First:' ); $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); $this->assertNotIXRError( $results ); - $this->assertEquals( 1, count( $results ) ); + $this->assertSame( 1, count( $results ) ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getProfile.php b/tests/phpunit/tests/xmlrpc/wp/getProfile.php index d84ac9a803..0b7f0b3ed9 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getProfile.php +++ b/tests/phpunit/tests/xmlrpc/wp/getProfile.php @@ -9,7 +9,7 @@ class Tests_XMLRPC_wp_getProfile extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getProfile( array( 1, 'username', 'password' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_subscriber() { diff --git a/tests/phpunit/tests/xmlrpc/wp/getRevisions.php b/tests/phpunit/tests/xmlrpc/wp/getRevisions.php index 15b9287d75..c80e55ac9e 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getRevisions.php +++ b/tests/phpunit/tests/xmlrpc/wp/getRevisions.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'username', 'password', 0 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_incapable_user() { @@ -18,7 +18,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'subscriber', 'subscriber', $post_id ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_capable_user() { diff --git a/tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php b/tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php index 77c1dd9e05..0bf6482d1f 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTaxonomies.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_getTaxonomies extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getTaxonomies( array( 1, 'username', 'password' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_taxonomy_validated() { diff --git a/tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php b/tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php index 5ffff80a81..eb3997527d 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTaxonomy.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'username', 'password', 'category' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_empty_taxonomy() { @@ -16,8 +16,8 @@ class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', '' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_invalid_taxonomy() { @@ -25,8 +25,8 @@ class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', 'not_existing' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_incapable_user() { @@ -34,8 +34,8 @@ class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'subscriber', 'subscriber', 'category' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); - $this->assertEquals( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message ); + $this->assertSame( 401, $result->code ); + $this->assertSame( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message ); } function test_taxonomy_validated() { @@ -51,13 +51,13 @@ class Tests_XMLRPC_wp_getTaxonomy extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTaxonomy( array( 1, 'editor', 'editor', 'category' ) ); $this->assertNotIXRError( $result ); $taxonomy = get_taxonomy( 'category' ); - $this->assertEquals( 'category', $result['name'], 'name' ); - $this->assertEquals( true, $result['_builtin'], '_builtin' ); - $this->assertEquals( $taxonomy->show_ui, $result['show_ui'], 'show_ui' ); - $this->assertEquals( $taxonomy->public, $result['public'], 'public' ); - $this->assertEquals( $taxonomy->hierarchical, $result['hierarchical'], 'hierarchical' ); - $this->assertEquals( (array) $taxonomy->labels, $result['labels'], 'labels' ); - $this->assertEquals( (array) $taxonomy->cap, $result['cap'], 'capabilities' ); - $this->assertEquals( (array) $taxonomy->object_type, $result['object_type'], 'object_types' ); + $this->assertSame( 'category', $result['name'], 'name' ); + $this->assertTrue( $result['_builtin'], '_builtin' ); + $this->assertSame( $taxonomy->show_ui, $result['show_ui'], 'show_ui' ); + $this->assertSame( $taxonomy->public, $result['public'], 'public' ); + $this->assertSame( $taxonomy->hierarchical, $result['hierarchical'], 'hierarchical' ); + $this->assertSame( (array) $taxonomy->labels, $result['labels'], 'labels' ); + $this->assertSame( (array) $taxonomy->cap, $result['cap'], 'capabilities' ); + $this->assertSame( (array) $taxonomy->object_type, $result['object_type'], 'object_types' ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerm.php b/tests/phpunit/tests/xmlrpc/wp/getTerm.php index 35910f6f5d..13b1698a49 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTerm.php @@ -18,7 +18,7 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'username', 'password', 'category', 1 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_empty_taxonomy() { @@ -26,8 +26,8 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', '', 0 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_invalid_taxonomy() { @@ -35,8 +35,8 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'not_existing', 0 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_incapable_user() { @@ -44,8 +44,8 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); - $this->assertEquals( __( 'Sorry, you are not allowed to assign this term.' ), $result->message ); + $this->assertSame( 401, $result->code ); + $this->assertSame( __( 'Sorry, you are not allowed to assign this term.' ), $result->message ); } @@ -54,8 +54,8 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', '' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 500, $result->code ); - $this->assertEquals( __( 'Empty Term.' ), $result->message ); + $this->assertSame( 500, $result->code ); + $this->assertSame( __( 'Empty Term.' ), $result->message ); } function test_invalid_term() { @@ -63,8 +63,8 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', 9999 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 404, $result->code ); - $this->assertEquals( __( 'Invalid term ID.' ), $result->message ); + $this->assertSame( 404, $result->code ); + $this->assertSame( __( 'Invalid term ID.' ), $result->message ); } function test_valid_term() { @@ -92,11 +92,11 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $this->assertStringMatchesFormat( '%d', $result['parent'] ); // Check data. - $this->assertEquals( 0, $result['count'] ); - $this->assertEquals( $term['name'], $result['name'] ); - $this->assertEquals( $term['slug'], $result['slug'] ); - $this->assertEquals( 'category', $result['taxonomy'] ); - $this->assertEquals( $term['description'], $result['description'] ); + $this->assertSame( 0, $result['count'] ); + $this->assertSame( $term['name'], $result['name'] ); + $this->assertSame( $term['slug'], $result['slug'] ); + $this->assertSame( 'category', $result['taxonomy'] ); + $this->assertSame( $term['description'], $result['description'] ); } /** @@ -123,6 +123,6 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $this->assertInternalType( 'array', $result['custom_fields'] ); $term_meta = get_term_meta( self::$term_id, '', true ); - $this->assertEquals( $term_meta['foo'][0], $result['custom_fields'][0]['value'] ); + $this->assertSame( $term_meta['foo'][0], $result['custom_fields'][0]['value'] ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerms.php b/tests/phpunit/tests/xmlrpc/wp/getTerms.php index 0dca65e409..0fb8b0962d 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTerms.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTerms.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'username', 'password', 'category' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_empty_taxonomy() { @@ -16,8 +16,8 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', '' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_invalid_taxonomy() { @@ -25,8 +25,8 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'not_existing' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_incapable_user() { @@ -34,8 +34,8 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getTerms( array( 1, 'subscriber', 'subscriber', 'category' ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); - $this->assertEquals( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message ); + $this->assertSame( 401, $result->code ); + $this->assertSame( __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ), $result->message ); } function test_valid_terms() { @@ -77,29 +77,29 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name ) ); $this->assertNotIXRError( $results ); - $this->assertEquals( $num_terms, count( $results ) ); + $this->assertSame( $num_terms, count( $results ) ); foreach ( $results as $term ) { - $this->assertEquals( $tax_name, $term['taxonomy'] ); + $this->assertSame( $tax_name, $term['taxonomy'] ); } // Test paged results. $filter = array( 'number' => 5 ); $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); $this->assertNotIXRError( $results ); - $this->assertEquals( 5, count( $results2 ) ); - $this->assertEquals( $results[1]['term_id'], $results2[1]['term_id'] ); // Check one of the terms. + $this->assertSame( 5, count( $results2 ) ); + $this->assertSame( $results[1]['term_id'], $results2[1]['term_id'] ); // Check one of the terms. $filter['offset'] = 10; $results3 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); $this->assertNotIXRError( $results3 ); - $this->assertEquals( $num_terms - 10, count( $results3 ) ); - $this->assertEquals( $results[11]['term_id'], $results3[1]['term_id'] ); + $this->assertSame( $num_terms - 10, count( $results3 ) ); + $this->assertSame( $results[11]['term_id'], $results3[1]['term_id'] ); // Test hide_empty (since none have been attached to posts yet, all should be hidden. $filter = array( 'hide_empty' => true ); $results4 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); $this->assertNotIXRError( $results4 ); - $this->assertEquals( 0, count( $results4 ) ); + $this->assertSame( 0, count( $results4 ) ); unset( $GLOBALS['wp_taxonomies'][ $tax_name ] ); } @@ -140,16 +140,16 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $filter = array( 'search' => $name ); $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); $this->assertNotIXRError( $results ); - $this->assertEquals( 1, count( $results ) ); - $this->assertEquals( $name, $results[0]['name'] ); + $this->assertSame( 1, count( $results ) ); + $this->assertSame( $name, $results[0]['name'] ); $this->assertEquals( $name_id, $results[0]['term_id'] ); // Search by partial name. $filter = array( 'search' => substr( $name, 0, 10 ) ); $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); $this->assertNotIXRError( $results2 ); - $this->assertEquals( 1, count( $results2 ) ); - $this->assertEquals( $name, $results2[0]['name'] ); + $this->assertSame( 1, count( $results2 ) ); + $this->assertSame( $name, $results2[0]['name'] ); $this->assertEquals( $name_id, $results2[0]['term_id'] ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getUser.php b/tests/phpunit/tests/xmlrpc/wp/getUser.php index cc19496c9c..3847e0bb10 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUser.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUser.php @@ -27,13 +27,13 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'username', 'password', 1 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_invalid_user() { $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'administrator', 'administrator', 34902348908234 ) ); $this->assertIXRError( $result ); - $this->assertEquals( 404, $result->code ); + $this->assertSame( 404, $result->code ); } function test_incapable_user() { @@ -42,7 +42,7 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getUser( array( 1, 'subscriber', 'subscriber', $editor_id ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_subscriber_self() { @@ -92,17 +92,17 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { // Check expected values. $this->assertEquals( $user_id, $result['user_id'] ); - $this->assertEquals( $user_data['user_login'], $result['username'] ); - $this->assertEquals( $user_data['first_name'], $result['first_name'] ); - $this->assertEquals( $user_data['last_name'], $result['last_name'] ); - $this->assertEquals( $registered_date, $result['registered']->getTimestamp() ); - $this->assertEquals( $user_data['description'], $result['bio'] ); - $this->assertEquals( $user_data['user_email'], $result['email'] ); - $this->assertEquals( $user_data['nickname'], $result['nickname'] ); - $this->assertEquals( $user_data['user_nicename'], $result['nicename'] ); - $this->assertEquals( $user_data['user_url'], $result['url'] ); - $this->assertEquals( $user_data['display_name'], $result['display_name'] ); - $this->assertEquals( $user_data['user_login'], $result['username'] ); + $this->assertSame( $user_data['user_login'], $result['username'] ); + $this->assertSame( $user_data['first_name'], $result['first_name'] ); + $this->assertSame( $user_data['last_name'], $result['last_name'] ); + $this->assertSame( $registered_date, $result['registered']->getTimestamp() ); + $this->assertSame( $user_data['description'], $result['bio'] ); + $this->assertSame( $user_data['user_email'], $result['email'] ); + $this->assertSame( $user_data['nickname'], $result['nickname'] ); + $this->assertSame( $user_data['user_nicename'], $result['nicename'] ); + $this->assertSame( $user_data['user_url'], $result['url'] ); + $this->assertSame( $user_data['display_name'], $result['display_name'] ); + $this->assertSame( $user_data['user_login'], $result['username'] ); $this->assertContains( $user_data['role'], $result['roles'] ); wp_delete_user( $user_id ); @@ -116,7 +116,7 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { $this->assertEquals( $editor_id, $result['user_id'] ); $expected_fields = array( 'user_id' ); - $this->assertEquals( $expected_fields, array_keys( $result ) ); + $this->assertSame( $expected_fields, array_keys( $result ) ); } function test_basic_fields() { diff --git a/tests/phpunit/tests/xmlrpc/wp/getUsers.php b/tests/phpunit/tests/xmlrpc/wp/getUsers.php index 412a13b364..a7dfcf2562 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUsers.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUsers.php @@ -9,7 +9,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'username', 'password' ) ); $this->assertIXRError( $results ); - $this->assertEquals( 403, $results->code ); + $this->assertSame( 403, $results->code ); } function test_incapable_user() { @@ -17,7 +17,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'subscriber', 'subscriber' ) ); $this->assertIXRError( $results ); - $this->assertEquals( 401, $results->code ); + $this->assertSame( 401, $results->code ); } function test_capable_user() { @@ -51,7 +51,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { $filter = array( 'role' => 'invalidrole' ); $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) ); $this->assertIXRError( $results ); - $this->assertEquals( 403, $results->code ); + $this->assertSame( 403, $results->code ); } function test_role_filter() { @@ -102,7 +102,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { } while ( count( $presults ) > 0 ); // Verify that $user_ids matches $users_found. - $this->assertEquals( 0, count( array_diff( $user_ids, $users_found ) ) ); + $this->assertSame( 0, count( array_diff( $user_ids, $users_found ) ) ); } function test_order_filters() { diff --git a/tests/phpunit/tests/xmlrpc/wp/newComment.php b/tests/phpunit/tests/xmlrpc/wp/newComment.php index a44361ae60..82dcc5b9a0 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/newComment.php @@ -41,7 +41,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_new_comment_post_closed() { @@ -52,7 +52,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { ) ); - $this->assertEquals( 'closed', $post->comment_status ); + $this->assertSame( 'closed', $post->comment_status ); $result = $this->myxmlrpcserver->wp_newComment( array( @@ -67,7 +67,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_new_comment_duplicated() { @@ -92,7 +92,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/newPost.php b/tests/phpunit/tests/xmlrpc/wp/newPost.php index 675a47577e..a24a803c6d 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/newPost.php @@ -8,7 +8,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'username', 'password', array() ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_incapable_user() { @@ -16,7 +16,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'subscriber', 'subscriber', array() ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_no_content() { @@ -24,8 +24,8 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', array() ) ); $this->assertIXRError( $result ); - $this->assertEquals( 500, $result->code ); - $this->assertEquals( 'Content, title, and excerpt are empty.', $result->message ); + $this->assertSame( 500, $result->code ); + $this->assertSame( 'Content, title, and excerpt are empty.', $result->message ); } function test_basic_content() { @@ -69,7 +69,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_capable_private() { @@ -92,7 +92,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_capable_other_author() { @@ -117,7 +117,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_invalid_author() { @@ -129,7 +129,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 404, $result->code ); + $this->assertSame( 404, $result->code ); } function test_empty_author() { @@ -142,7 +142,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $out = get_post( $result ); $this->assertEquals( $my_author_id, $out->post_author ); - $this->assertEquals( 'Test', $out->post_title ); + $this->assertSame( 'Test', $out->post_title ); } function test_post_thumbnail() { @@ -174,7 +174,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); $this->assertNotIXRError( $result ); - $this->assertEquals( 'draft', get_post_status( $result ) ); + $this->assertSame( 'draft', get_post_status( $result ) ); } function test_incapable_sticky() { @@ -186,7 +186,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'contributor', 'contributor', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_capable_sticky() { @@ -211,7 +211,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_post_format() { @@ -223,7 +223,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); $this->assertNotIXRError( $result ); - $this->assertEquals( 'quote', get_post_format( $result ) ); + $this->assertSame( 'quote', get_post_format( $result ) ); } function test_invalid_post_format() { @@ -249,7 +249,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); $post2 = array( 'post_title' => 'Test', @@ -259,7 +259,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result2 = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post2 ) ); $this->assertIXRError( $result2 ); - $this->assertEquals( 401, $result2->code ); + $this->assertSame( 401, $result2->code ); } function test_invalid_term_id() { @@ -273,7 +273,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_terms() { @@ -338,7 +338,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { ); $result2 = $this->myxmlrpcserver->wp_newPost( array( 1, 'editor', 'editor', $post2 ) ); $this->assertIXRError( $result2 ); - $this->assertEquals( 401, $result2->code ); + $this->assertSame( 401, $result2->code ); } /** @@ -355,7 +355,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); $fetched_post = get_post( $result ); $this->assertStringMatchesFormat( '%d', $result ); - $this->assertEquals( current_time( 'Y-m-d' ), substr( $fetched_post->post_date, 0, 10 ) ); + $this->assertSame( current_time( 'Y-m-d' ), substr( $fetched_post->post_date, 0, 10 ) ); } /** @@ -372,7 +372,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); $fetched_post = get_post( $result ); $this->assertStringMatchesFormat( '%d', $result ); - $this->assertEquals( '0000-00-00', substr( $fetched_post->post_date_gmt, 0, 10 ) ); + $this->assertSame( '0000-00-00', substr( $fetched_post->post_date_gmt, 0, 10 ) ); } /** @@ -389,7 +389,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); $fetched_post = get_post( $result ); $this->assertStringMatchesFormat( '%d', $result ); - $this->assertEquals( $date_string, $fetched_post->post_date ); + $this->assertSame( $date_string, $fetched_post->post_date ); } /** @@ -406,7 +406,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); $fetched_post = get_post( $result ); $this->assertStringMatchesFormat( '%d', $result ); - $this->assertEquals( $date_string, $fetched_post->post_date_gmt ); + $this->assertSame( $date_string, $fetched_post->post_date_gmt ); } /** @@ -423,7 +423,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); $fetched_post = get_post( $result ); $this->assertStringMatchesFormat( '%d', $result ); - $this->assertEquals( $date_string, $fetched_post->post_date ); + $this->assertSame( $date_string, $fetched_post->post_date ); } /** @@ -440,7 +440,7 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newPost( array( 1, 'author', 'author', $post ) ); $fetched_post = get_post( $result ); $this->assertStringMatchesFormat( '%d', $result ); - $this->assertEquals( $date_string, $fetched_post->post_date_gmt ); + $this->assertSame( $date_string, $fetched_post->post_date_gmt ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/newTerm.php b/tests/phpunit/tests/xmlrpc/wp/newTerm.php index 28bb0e3d6d..b3b5e23bf8 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/newTerm.php @@ -18,7 +18,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'username', 'password', array() ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_empty_taxonomy() { @@ -26,8 +26,8 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => '' ) ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_invalid_taxonomy() { @@ -35,8 +35,8 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'not_existing' ) ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Invalid taxonomy.' ), $result->message ); } function test_incapable_user() { @@ -44,8 +44,8 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'subscriber', 'subscriber', array( 'taxonomy' => 'category' ) ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); - $this->assertEquals( __( 'Sorry, you are not allowed to create terms in this taxonomy.' ), $result->message ); + $this->assertSame( 401, $result->code ); + $this->assertSame( __( 'Sorry, you are not allowed to create terms in this taxonomy.' ), $result->message ); } function test_empty_term() { @@ -63,8 +63,8 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'The term name cannot be empty.' ), $result->message ); } function test_parent_for_nonhierarchical() { @@ -83,8 +83,8 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'This taxonomy is not hierarchical.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'This taxonomy is not hierarchical.' ), $result->message ); } function test_parent_invalid() { @@ -103,7 +103,7 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { ) ); $this->assertIXRError( $result ); - $this->assertEquals( 500, $result->code ); + $this->assertSame( 500, $result->code ); } function test_parent_not_existing() { @@ -122,8 +122,8 @@ class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase { ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); - $this->assertEquals( __( 'Parent term does not exist.' ), $result->message ); + $this->assertSame( 403, $result->code ); + $this->assertSame( __( 'Parent term does not exist.' ), $result->message ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php b/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php index 7b7021ecc4..b3ef2731a2 100644 --- a/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php +++ b/tests/phpunit/tests/xmlrpc/wp/restoreRevision.php @@ -30,7 +30,7 @@ class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { function test_invalid_username_password() { $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'username', 'password', $this->revision_id ) ); $this->assertIXRError( $result ); - $this->assertEquals( 403, $result->code ); + $this->assertSame( 403, $result->code ); } function test_incapable_user() { @@ -38,7 +38,7 @@ class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'subscriber', 'subscriber', $this->revision_id ) ); $this->assertIXRError( $result ); - $this->assertEquals( 401, $result->code ); + $this->assertSame( 401, $result->code ); } function test_capable_user() { @@ -53,6 +53,6 @@ class Tests_XMLRPC_wp_restoreRevision extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_restoreRevision( array( 1, 'editor', 'editor', $this->revision_id ) ); $this->assertTrue( $result ); - $this->assertEquals( 'edit2', get_post( $this->post_id )->post_content ); + $this->assertSame( 'edit2', get_post( $this->post_id )->post_content ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/setOptions.php b/tests/phpunit/tests/xmlrpc/wp/setOptions.php index 27ad135ddc..f99dcc1024 100644 --- a/tests/phpunit/tests/xmlrpc/wp/setOptions.php +++ b/tests/phpunit/tests/xmlrpc/wp/setOptions.php @@ -13,7 +13,7 @@ class Tests_XMLRPC_wp_setOptions extends WP_XMLRPC_UnitTestCase { $escaped_string_with_quote = esc_html( $string_with_quote ); // Title is passed through esc_html(). update_option( 'default_comment_status', 'closed' ); - $this->assertEquals( 'closed', get_option( 'default_comment_status' ) ); + $this->assertSame( 'closed', get_option( 'default_comment_status' ) ); $result = $this->myxmlrpcserver->wp_setOptions( array( 1, @@ -27,7 +27,7 @@ class Tests_XMLRPC_wp_setOptions extends WP_XMLRPC_UnitTestCase { ); $this->assertInternalType( 'array', $result ); - $this->assertEquals( $escaped_string_with_quote, $result['blog_title']['value'] ); - $this->assertEquals( 'open', $result['default_comment_status']['value'] ); + $this->assertSame( $escaped_string_with_quote, $result['blog_title']['value'] ); + $this->assertSame( 'open', $result['default_comment_status']['value'] ); } }