Tests: First pass at using assertSame() instead of assertEquals() in most of the unit tests.

This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Props johnbillion, jrf, SergeyBiryukov.
See #38266.

git-svn-id: https://develop.svn.wordpress.org/trunk@48937 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-09-02 00:35:36 +00:00
parent ba7c6a2d5f
commit 164b22cf6a
426 changed files with 7959 additions and 7949 deletions

View File

@ -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 );
}
/**

View File

@ -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', '' );

View File

@ -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' ) );
}
}

View File

@ -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 );
}
/**

View File

@ -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 ',

View File

@ -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 ) );
}
}
}

View File

@ -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( '<?php\n//Silence is golden.', 'index.php', WPMU_PLUGIN_DIR );
$this->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( '<?php\n//Silence is not golden.', 'index.php', WPMU_PLUGIN_DIR );
$found = get_mu_plugins();
$this->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( '<?php\n//Test', 'foo.php', WPMU_PLUGIN_DIR );
$this->_create_plugin( '<?php\n//Test 2', 'bar.txt', WPMU_PLUGIN_DIR );
$found = get_mu_plugins();
$this->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( "<?php\n//Test", 'not-a-dropin.php', WP_CONTENT_DIR );
$dropins = get_dropins();
$this->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() );
}
/**

View File

@ -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 ) );
}
/**

View File

@ -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',
),
),
);

View File

@ -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() {

View File

@ -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' ) );
}
/**

View File

@ -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'] );
}

View File

@ -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 ) );
}
}

View File

@ -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'] );
}
}

View File

@ -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' ) );
}
/**

View File

@ -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'] );
}
}

View File

@ -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'] );
}
}

View File

@ -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 ) );

View File

@ -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 ) {

View File

@ -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 );

View File

@ -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 );

View File

@ -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'] );

View File

@ -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' );
}
/**

View File

@ -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 );
}
}

View File

@ -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 );

View File

@ -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 alt='[^']*' src='[^']*' srcset='[^']*' class='[^']*' height='[^']*' width='[^']*' loading='lazy'/>$|", $img ), 1 );
$this->assertSame( preg_match( "|^<img alt='[^']*' src='[^']*' srcset='[^']*' class='[^']*' height='[^']*' width='[^']*' loading='lazy'/>$|", $img ), 1 );
}
public function test_get_avatar_size() {
$size = '100';
$img = get_avatar( 1, $size );
$this->assertEquals( preg_match( "|^<img .*height='$size'.*width='$size'|", $img ), 1 );
$this->assertSame( preg_match( "|^<img .*height='$size'.*width='$size'|", $img ), 1 );
}
public function test_get_avatar_alt() {
$alt = 'Mr Hyde';
$img = get_avatar( 1, 96, '', $alt );
$this->assertEquals( preg_match( "|^<img alt='$alt'|", $img ), 1 );
$this->assertSame( preg_match( "|^<img alt='$alt'|", $img ), 1 );
}
public function test_get_avatar_class() {
$class = 'first';
$img = get_avatar( 1, 96, '', '', array( 'class' => $class ) );
$this->assertEquals( preg_match( "|^<img .*class='[^']*{$class}[^']*'|", $img ), 1 );
$this->assertSame( preg_match( "|^<img .*class='[^']*{$class}[^']*'|", $img ), 1 );
}
public function test_get_avatar_default_class() {
$img = get_avatar( 1, 96, '', '', array( 'force_default' => true ) );
$this->assertEquals( preg_match( "|^<img .*class='[^']*avatar-default[^']*'|", $img ), 1 );
$this->assertSame( preg_match( "|^<img .*class='[^']*avatar-default[^']*'|", $img ), 1 );
}
public function test_get_avatar_force_display() {
@ -218,7 +218,7 @@ class Tests_Avatar extends WP_UnitTestCase {
$img = get_avatar( 1 );
remove_filter( 'pre_get_avatar', array( $this, 'pre_get_avatar_filter' ), 10 );
$this->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;

View File

@ -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;
<p>If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)</p>
<ol id="authors"><form action="?import=wordpress&amp;step=2&amp;id=" method="post"><input type="hidden" name="_wpnonce" value="***" /><input type="hidden" name="_wp_http_referer" value="wp-test.php" /><li>Current author: <strong>Alex Shiels</strong><br />Create user <input type="text" value="Alex Shiels" name="user[]" maxlength="30"> <br /> or map to existing<select name="userselect[0]">
EOF;
$this->assertEquals( $expected, mask_input_value( $in ) );
$this->assertSame( $expected, mask_input_value( $in ) );
}
}

View File

@ -131,7 +131,7 @@ class WP_Block_Context_Test extends WP_UnitTestCase {
render_block( $parsed_blocks[0] );
$this->assertEquals(
$this->assertSame(
array(
'gutenberg/contextWithDefault' => 0,
'gutenberg/contextWithAssigned' => 10,
@ -167,7 +167,7 @@ class WP_Block_Context_Test extends WP_UnitTestCase {
render_block( $parsed_blocks[0] );
$this->assertEquals(
$this->assertSame(
array(
'postId' => $post->ID,
'postType' => $post->post_type,
@ -209,7 +209,7 @@ class WP_Block_Context_Test extends WP_UnitTestCase {
remove_filter( 'render_block_context', $filter_block_context );
$this->assertEquals( array( 'example' => 'ok' ), $provided_context[0] );
$this->assertSame( array( 'example' => 'ok' ), $provided_context[0] );
}
}

View File

@ -54,12 +54,12 @@ class WP_Block_List_Test extends WP_UnitTestCase {
$this->assertTrue( isset( $blocks[0] ) );
// Test "offsetGet".
$this->assertEquals( 'core/example', $blocks[0]->name );
$this->assertSame( 'core/example', $blocks[0]->name );
// Test "offsetSet".
$parsed_blocks[0]['blockName'] = 'core/updated';
$blocks[0] = new WP_Block( $parsed_blocks[0], $context, $this->registry );
$this->assertEquals( 'core/updated', $blocks[0]->name );
$this->assertSame( 'core/updated', $blocks[0]->name );
// Test "offsetUnset".
unset( $blocks[0] );
@ -76,10 +76,10 @@ class WP_Block_List_Test extends WP_UnitTestCase {
$assertions = 0;
foreach ( $blocks as $block ) {
$this->assertEquals( 'core/example', $block->name );
$this->assertSame( 'core/example', $block->name );
$assertions++;
foreach ( $block->inner_blocks as $inner_block ) {
$this->assertEquals( 'core/example', $inner_block->name );
$this->assertSame( 'core/example', $inner_block->name );
$assertions++;
}
}
@ -88,14 +88,14 @@ class WP_Block_List_Test extends WP_UnitTestCase {
while ( $blocks->valid() ) {
$key = $blocks->key();
$block = $blocks->current();
$this->assertEquals( 0, $key );
$this->assertSame( 0, $key );
$assertions++;
$this->assertEquals( 'core/example', $block->name );
$this->assertSame( 'core/example', $block->name );
$assertions++;
$blocks->next();
}
$this->assertEquals( 4, $assertions );
$this->assertSame( 4, $assertions );
}
/**
@ -106,7 +106,7 @@ class WP_Block_List_Test extends WP_UnitTestCase {
$context = array();
$blocks = new WP_Block_List( $parsed_blocks, $context, $this->registry );
$this->assertEquals( 1, count( $blocks ) );
$this->assertSame( 1, count( $blocks ) );
}
}

View File

@ -69,7 +69,7 @@ class WP_Test_Block_Parser extends WP_UnitTestCase {
$parser = new WP_Block_Parser();
$result = json_decode( json_encode( $parser->parse( $html ) ), true );
$this->assertEquals(
$this->assertSame(
$expected_parsed,
$result,
"File '$parsed_json_filename' does not match expected value"

View File

@ -106,9 +106,9 @@ class WP_Test_Block_Type_Registry extends WP_UnitTestCase {
);
$block_type = $this->registry->register( $name, $settings );
$this->assertEquals( $name, $block_type->name );
$this->assertEquals( $settings['icon'], $block_type->icon );
$this->assertEquals( $block_type, $this->registry->get_registered( $name ) );
$this->assertSame( $name, $block_type->name );
$this->assertSame( $settings['icon'], $block_type->icon );
$this->assertSame( $block_type, $this->registry->get_registered( $name ) );
}
/**
@ -167,8 +167,8 @@ class WP_Test_Block_Type_Registry extends WP_UnitTestCase {
$this->registry->register( $name, $settings );
$block_type = $this->registry->unregister( $name );
$this->assertEquals( $name, $block_type->name );
$this->assertEquals( $settings['icon'], $block_type->icon );
$this->assertSame( $name, $block_type->name );
$this->assertSame( $settings['icon'], $block_type->icon );
$this->assertFalse( $this->registry->is_registered( $name ) );
}

View File

@ -100,7 +100,7 @@ class WP_Test_Block_Type extends WP_UnitTestCase {
)
);
$output = $block_type->render( $attributes );
$this->assertEquals( $attributes, json_decode( $output, true ) );
$this->assertSame( $attributes, json_decode( $output, true ) );
}
/**
@ -123,7 +123,7 @@ class WP_Test_Block_Type extends WP_UnitTestCase {
)
);
$output = $block_type->render( $attributes, $content );
$this->assertEquals( $expected, json_decode( $output, true ) );
$this->assertSame( $expected, json_decode( $output, true ) );
}
/**
@ -133,7 +133,7 @@ class WP_Test_Block_Type extends WP_UnitTestCase {
$block_type = new WP_Block_Type( 'core/fake', array() );
$output = $block_type->render();
$this->assertEquals( '', $output );
$this->assertSame( '', $output );
}
/**
@ -223,7 +223,7 @@ class WP_Test_Block_Type extends WP_UnitTestCase {
$prepared_attributes = $block_type->prepare_attributes_for_render( $attributes );
$this->assertEquals( $attributes, $prepared_attributes );
$this->assertSame( $attributes, $prepared_attributes );
}
/**

View File

@ -57,10 +57,10 @@ class WP_Block_Test extends WP_UnitTestCase {
$block = new WP_Block( $parsed_block, $context, $this->registry );
$this->assertSame( $parsed_block, $block->parsed_block );
$this->assertEquals( $parsed_block['blockName'], $block->name );
$this->assertEquals( $parsed_block['attrs'], $block->attributes );
$this->assertEquals( $parsed_block['innerContent'], $block->inner_content );
$this->assertEquals( $parsed_block['innerHTML'], $block->inner_html );
$this->assertSame( $parsed_block['blockName'], $block->name );
$this->assertSame( $parsed_block['attrs'], $block->attributes );
$this->assertSame( $parsed_block['innerContent'], $block->inner_content );
$this->assertSame( $parsed_block['innerHTML'], $block->inner_html );
}
/**
@ -82,7 +82,7 @@ class WP_Block_Test extends WP_UnitTestCase {
$block = new WP_Block( $parsed_block, $context, $this->registry );
$this->assertInstanceOf( WP_Block_Type::class, $block->block_type );
$this->assertEquals(
$this->assertSame(
$block_type_settings['attributes'],
$block->block_type->attributes
);
@ -113,10 +113,10 @@ class WP_Block_Test extends WP_UnitTestCase {
$context = array();
$block = new WP_Block( $parsed_block, $context, $this->registry );
$this->assertEquals(
$this->assertSame(
array(
'defaulted' => 10,
'explicit' => 20,
'defaulted' => 10,
),
$block->attributes
);
@ -145,9 +145,9 @@ class WP_Block_Test extends WP_UnitTestCase {
$context = array();
$block = new WP_Block( $parsed_block, $context, $this->registry );
$this->assertEquals( array( 'defaulted' => 10 ), $block->attributes );
$this->assertSame( array( 'defaulted' => 10 ), $block->attributes );
// Intentionally call a second time, to ensure property was assigned.
$this->assertEquals( array( 'defaulted' => 10 ), $block->attributes );
$this->assertSame( array( 'defaulted' => 10 ), $block->attributes );
}
/**
@ -168,7 +168,7 @@ class WP_Block_Test extends WP_UnitTestCase {
);
$block = new WP_Block( $parsed_block, $context, $this->registry );
$this->assertEquals( array( 'requested' => 'included' ), $block->context );
$this->assertSame( array( 'requested' => 'included' ), $block->context );
}
/**
@ -184,7 +184,7 @@ class WP_Block_Test extends WP_UnitTestCase {
$this->assertCount( 1, $block->inner_blocks );
$this->assertInstanceOf( WP_Block::class, $block->inner_blocks[0] );
$this->assertEquals( 'core/example', $block->inner_blocks[0]->name );
$this->assertSame( 'core/example', $block->inner_blocks[0]->name );
}
/**
@ -217,7 +217,7 @@ class WP_Block_Test extends WP_UnitTestCase {
$block = new WP_Block( $parsed_block, $context, $this->registry );
$this->assertCount( 0, $block->context );
$this->assertEquals(
$this->assertSame(
array( 'core/recordId' => 10 ),
$block->inner_blocks[0]->context
);
@ -253,15 +253,15 @@ class WP_Block_Test extends WP_UnitTestCase {
$context = array( 'core/value' => 'original' );
$block = new WP_Block( $parsed_block, $context, $this->registry );
$this->assertEquals(
$this->assertSame(
array( 'core/value' => 'original' ),
$block->context
);
$this->assertEquals(
$this->assertSame(
array( 'core/value' => 'merged' ),
$block->inner_blocks[0]->context
);
$this->assertEquals(
$this->assertSame(
array( 'core/value' => null ),
$block->inner_blocks[0]->inner_blocks[0]->context
);

View File

@ -292,7 +292,7 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
$this->assertSame( 'star', $result->icon );
$this->assertSame( 'Shows warning, error or success notices…', $result->description );
$this->assertEqualSets( array( 'alert', 'message' ), $result->keywords );
$this->assertEquals(
$this->assertSame(
array(
'message' => array(
'type' => 'string',
@ -302,21 +302,21 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
),
$result->attributes
);
$this->assertEquals(
$this->assertSame(
array(
'my-plugin/message' => 'message',
),
$result->provides_context
);
$this->assertEqualSets( array( 'groupId' ), $result->uses_context );
$this->assertEquals(
$this->assertSame(
array(
'align' => true,
'lightBlockWrapper' => true,
),
$result->supports
);
$this->assertEquals(
$this->assertSame(
array(
array(
'name' => 'default',
@ -330,7 +330,7 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
),
$result->styles
);
$this->assertEquals(
$this->assertSame(
array(
'attributes' => array(
'message' => 'This is a notice!',
@ -396,6 +396,6 @@ class WP_Test_Block_Register extends WP_UnitTestCase {
$registry = WP_Block_Type_Registry::get_instance();
$block_type = $registry->get_registered( 'core/test-filtered' );
$this->assertEquals( 'boolean', $block_type->attributes['core/test-filtered']['type'] );
$this->assertSame( 'boolean', $block_type->attributes['core/test-filtered']['type'] );
}
}

View File

@ -60,7 +60,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
$actual_html = do_blocks( $original_html );
$this->assertEqualsIgnoreEOL( $expected_html, $actual_html );
$this->assertSameIgnoreEOL( $expected_html, $actual_html );
}
/**
@ -80,7 +80,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
remove_shortcode( 'someshortcode' );
$this->assertEquals( trim( $classic_filtered_content ), trim( $block_filtered_content ) );
$this->assertSame( trim( $classic_filtered_content ), trim( $block_filtered_content ) );
}
function handle_shortcode( $atts, $content ) {
@ -121,7 +121,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
$content = '<!-- wp:core/test -->' . $content . '<!-- /wp:core/test -->';
}
$this->assertEquals( 'deep inside', do_blocks( $content ) );
$this->assertSame( 'deep inside', do_blocks( $content ) );
}
public function test_can_nest_at_least_so_deep_with_dynamic_blocks() {
@ -142,7 +142,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
)
);
$this->assertEquals( $minimum_depth, (int) do_blocks( $content ) );
$this->assertSame( $minimum_depth, (int) do_blocks( $content ) );
}
public function render_dynamic_incrementer( $attrs, $content ) {
@ -160,7 +160,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
$filtered_content = trim( apply_filters( 'the_content', $test_content ) );
$this->assertEquals( $expected_content, $filtered_content );
$this->assertSame( $expected_content, $filtered_content );
// Check that wpautop() is still defined in the same place.
$this->assertSame( $current_priority, has_action( 'the_content', 'wpautop' ) );
@ -174,7 +174,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
$filtered_content = trim( apply_filters( 'the_content', $test_content ) );
$this->assertEquals( $expected_content, $filtered_content );
$this->assertSame( $expected_content, $filtered_content );
$this->assertSame( $current_priority, has_action( 'the_content', 'wpautop' ) );
$this->assertFalse( has_action( 'the_content', '_restore_wpautop_hook' ) );
@ -222,7 +222,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
$html = do_blocks( self::strip_r( file_get_contents( $html_path ) ) );
$expected_html = self::strip_r( file_get_contents( $server_html_path ) );
$this->assertEquals(
$this->assertSame(
$expected_html,
$html,
"File '$html_path' does not match expected value"
@ -252,7 +252,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
'after';
$updated_post_content = do_blocks( $post_content );
$this->assertEquals(
$this->assertSame(
$updated_post_content,
'before' .
'1:b1' .
@ -286,7 +286,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
$global_post = $post;
do_blocks( '<!-- wp:core/test /-->' );
$this->assertEquals( $global_post, $post );
$this->assertSame( $global_post, $post );
}
public function test_render_latest_comments_on_password_protected_post() {
@ -342,7 +342,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
$data = unserialize( base64_decode( $output ) );
$this->assertEquals( 'inner', $data[1] );
$this->assertSame( 'inner', $data[1] );
}
public function test_dynamic_block_gets_rendered_inner_blocks() {
@ -370,7 +370,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
$data = unserialize( base64_decode( $output ) );
$this->assertEquals( 'before10after', $data[1] );
$this->assertSame( 'before10after', $data[1] );
}
public function test_dynamic_block_gets_rendered_inner_dynamic_blocks() {
@ -390,7 +390,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase {
$inner = $this->render_serialize_dynamic_block( array(), 'deep inner' );
$this->assertEquals( $data[1], 'before' . $inner . 'after' );
$this->assertSame( $data[1], 'before' . $inner . 'after' );
}
/**

View File

@ -25,7 +25,7 @@ class WP_Test_Block_Serialization extends WP_UnitTestCase {
$actual = serialize_blocks( $blocks );
$expected = $original;
$this->assertEquals( $expected, $actual );
$this->assertSame( $expected, $actual );
}
function data_serialize_identity_from_parsed() {
@ -51,10 +51,10 @@ class WP_Test_Block_Serialization extends WP_UnitTestCase {
}
function test_serialized_block_name() {
$this->assertEquals( null, strip_core_block_namespace( null ) );
$this->assertEquals( 'example', strip_core_block_namespace( 'example' ) );
$this->assertEquals( 'example', strip_core_block_namespace( 'core/example' ) );
$this->assertEquals( 'plugin/example', strip_core_block_namespace( 'plugin/example' ) );
$this->assertNull( strip_core_block_namespace( null ) );
$this->assertSame( 'example', strip_core_block_namespace( 'example' ) );
$this->assertSame( 'example', strip_core_block_namespace( 'core/example' ) );
$this->assertSame( 'plugin/example', strip_core_block_namespace( 'plugin/example' ) );
}
}

View File

@ -35,7 +35,7 @@ class Tests_Cache extends WP_UnitTestCase {
$val = 'val';
$this->cache->add( $key, $val );
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->assertSame( $val, $this->cache->get( $key ) );
}
function test_add_get_0() {
@ -44,7 +44,7 @@ class Tests_Cache extends WP_UnitTestCase {
// You can store zero in the cache.
$this->cache->add( $key, $val );
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->assertSame( $val, $this->cache->get( $key ) );
}
function test_add_get_null() {
@ -63,10 +63,10 @@ class Tests_Cache extends WP_UnitTestCase {
// Add $key to the cache.
$this->assertTrue( $this->cache->add( $key, $val1 ) );
$this->assertEquals( $val1, $this->cache->get( $key ) );
$this->assertSame( $val1, $this->cache->get( $key ) );
// $key is in the cache, so reject new calls to add().
$this->assertFalse( $this->cache->add( $key, $val2 ) );
$this->assertEquals( $val1, $this->cache->get( $key ) );
$this->assertSame( $val1, $this->cache->get( $key ) );
}
function test_replace() {
@ -78,9 +78,9 @@ class Tests_Cache extends WP_UnitTestCase {
$this->assertFalse( $this->cache->replace( $key, $val ) );
$this->assertFalse( $this->cache->get( $key ) );
$this->assertTrue( $this->cache->add( $key, $val ) );
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->assertSame( $val, $this->cache->get( $key ) );
$this->assertTrue( $this->cache->replace( $key, $val2 ) );
$this->assertEquals( $val2, $this->cache->get( $key ) );
$this->assertSame( $val2, $this->cache->get( $key ) );
}
function test_set() {
@ -90,10 +90,10 @@ class Tests_Cache extends WP_UnitTestCase {
// memcached accepts set() if the key does not exist.
$this->assertTrue( $this->cache->set( $key, $val1 ) );
$this->assertEquals( $val1, $this->cache->get( $key ) );
$this->assertSame( $val1, $this->cache->get( $key ) );
// Second set() with same key should be allowed.
$this->assertTrue( $this->cache->set( $key, $val2 ) );
$this->assertEquals( $val2, $this->cache->get( $key ) );
$this->assertSame( $val2, $this->cache->get( $key ) );
}
function test_flush() {
@ -108,7 +108,7 @@ class Tests_Cache extends WP_UnitTestCase {
$this->cache->add( $key, $val );
// Item is visible to both cache objects.
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->assertSame( $val, $this->cache->get( $key ) );
$this->cache->flush();
// If there is no value get returns false.
$this->assertFalse( $this->cache->get( $key ) );
@ -122,9 +122,9 @@ class Tests_Cache extends WP_UnitTestCase {
$this->cache->set( $key, $object_a );
$object_a->foo = 'bravo';
$object_b = $this->cache->get( $key );
$this->assertEquals( 'alpha', $object_b->foo );
$this->assertSame( 'alpha', $object_b->foo );
$object_b->foo = 'charlie';
$this->assertEquals( 'bravo', $object_a->foo );
$this->assertSame( 'bravo', $object_a->foo );
$key = __FUNCTION__ . '_2';
$object_a = new stdClass;
@ -132,9 +132,9 @@ class Tests_Cache extends WP_UnitTestCase {
$this->cache->add( $key, $object_a );
$object_a->foo = 'bravo';
$object_b = $this->cache->get( $key );
$this->assertEquals( 'alpha', $object_b->foo );
$this->assertSame( 'alpha', $object_b->foo );
$object_b->foo = 'charlie';
$this->assertEquals( 'bravo', $object_a->foo );
$this->assertSame( 'bravo', $object_a->foo );
}
function test_incr() {
@ -144,10 +144,10 @@ class Tests_Cache extends WP_UnitTestCase {
$this->cache->set( $key, 0 );
$this->cache->incr( $key );
$this->assertEquals( 1, $this->cache->get( $key ) );
$this->assertSame( 1, $this->cache->get( $key ) );
$this->cache->incr( $key, 2 );
$this->assertEquals( 3, $this->cache->get( $key ) );
$this->assertSame( 3, $this->cache->get( $key ) );
}
function test_wp_cache_incr() {
@ -157,10 +157,10 @@ class Tests_Cache extends WP_UnitTestCase {
wp_cache_set( $key, 0 );
wp_cache_incr( $key );
$this->assertEquals( 1, wp_cache_get( $key ) );
$this->assertSame( 1, wp_cache_get( $key ) );
wp_cache_incr( $key, 2 );
$this->assertEquals( 3, wp_cache_get( $key ) );
$this->assertSame( 3, wp_cache_get( $key ) );
}
function test_decr() {
@ -170,14 +170,14 @@ class Tests_Cache extends WP_UnitTestCase {
$this->cache->set( $key, 0 );
$this->cache->decr( $key );
$this->assertEquals( 0, $this->cache->get( $key ) );
$this->assertSame( 0, $this->cache->get( $key ) );
$this->cache->set( $key, 3 );
$this->cache->decr( $key );
$this->assertEquals( 2, $this->cache->get( $key ) );
$this->assertSame( 2, $this->cache->get( $key ) );
$this->cache->decr( $key, 2 );
$this->assertEquals( 0, $this->cache->get( $key ) );
$this->assertSame( 0, $this->cache->get( $key ) );
}
/**
@ -190,14 +190,14 @@ class Tests_Cache extends WP_UnitTestCase {
wp_cache_set( $key, 0 );
wp_cache_decr( $key );
$this->assertEquals( 0, wp_cache_get( $key ) );
$this->assertSame( 0, wp_cache_get( $key ) );
wp_cache_set( $key, 3 );
wp_cache_decr( $key );
$this->assertEquals( 2, wp_cache_get( $key ) );
$this->assertSame( 2, wp_cache_get( $key ) );
wp_cache_decr( $key, 2 );
$this->assertEquals( 0, wp_cache_get( $key ) );
$this->assertSame( 0, wp_cache_get( $key ) );
}
function test_delete() {
@ -206,7 +206,7 @@ class Tests_Cache extends WP_UnitTestCase {
// Verify set.
$this->assertTrue( $this->cache->set( $key, $val ) );
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->assertSame( $val, $this->cache->get( $key ) );
// Verify successful delete.
$this->assertTrue( $this->cache->delete( $key ) );
@ -221,7 +221,7 @@ class Tests_Cache extends WP_UnitTestCase {
// Verify set.
$this->assertTrue( wp_cache_set( $key, $val ) );
$this->assertEquals( $val, wp_cache_get( $key ) );
$this->assertSame( $val, wp_cache_get( $key ) );
// Verify successful delete.
$this->assertTrue( wp_cache_delete( $key ) );
@ -246,38 +246,38 @@ class Tests_Cache extends WP_UnitTestCase {
if ( ! is_multisite() ) {
// Single site ingnores switch_to_blog().
$this->assertTrue( $this->cache->set( $key, $val ) );
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->assertSame( $val, $this->cache->get( $key ) );
$this->cache->switch_to_blog( 999 );
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->assertSame( $val, $this->cache->get( $key ) );
$this->assertTrue( $this->cache->set( $key, $val2 ) );
$this->assertEquals( $val2, $this->cache->get( $key ) );
$this->assertSame( $val2, $this->cache->get( $key ) );
$this->cache->switch_to_blog( get_current_blog_id() );
$this->assertEquals( $val2, $this->cache->get( $key ) );
$this->assertSame( $val2, $this->cache->get( $key ) );
} else {
// Multisite should have separate per-blog caches.
$this->assertTrue( $this->cache->set( $key, $val ) );
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->assertSame( $val, $this->cache->get( $key ) );
$this->cache->switch_to_blog( 999 );
$this->assertFalse( $this->cache->get( $key ) );
$this->assertTrue( $this->cache->set( $key, $val2 ) );
$this->assertEquals( $val2, $this->cache->get( $key ) );
$this->assertSame( $val2, $this->cache->get( $key ) );
$this->cache->switch_to_blog( get_current_blog_id() );
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->assertSame( $val, $this->cache->get( $key ) );
$this->cache->switch_to_blog( 999 );
$this->assertEquals( $val2, $this->cache->get( $key ) );
$this->assertSame( $val2, $this->cache->get( $key ) );
$this->cache->switch_to_blog( get_current_blog_id() );
$this->assertEquals( $val, $this->cache->get( $key ) );
$this->assertSame( $val, $this->cache->get( $key ) );
}
// Global group.
$this->assertTrue( $this->cache->set( $key, $val, 'global-cache-test' ) );
$this->assertEquals( $val, $this->cache->get( $key, 'global-cache-test' ) );
$this->assertSame( $val, $this->cache->get( $key, 'global-cache-test' ) );
$this->cache->switch_to_blog( 999 );
$this->assertEquals( $val, $this->cache->get( $key, 'global-cache-test' ) );
$this->assertSame( $val, $this->cache->get( $key, 'global-cache-test' ) );
$this->assertTrue( $this->cache->set( $key, $val2, 'global-cache-test' ) );
$this->assertEquals( $val2, $this->cache->get( $key, 'global-cache-test' ) );
$this->assertSame( $val2, $this->cache->get( $key, 'global-cache-test' ) );
$this->cache->switch_to_blog( get_current_blog_id() );
$this->assertEquals( $val2, $this->cache->get( $key, 'global-cache-test' ) );
$this->assertSame( $val2, $this->cache->get( $key, 'global-cache-test' ) );
}
function test_wp_cache_init() {
@ -303,11 +303,11 @@ class Tests_Cache extends WP_UnitTestCase {
// Save the first value to cache and verify.
wp_cache_set( $key, $val1 );
$this->assertEquals( $val1, wp_cache_get( $key ) );
$this->assertSame( $val1, wp_cache_get( $key ) );
// Replace the value and verify.
wp_cache_replace( $key, $val2 );
$this->assertEquals( $val2, wp_cache_get( $key ) );
$this->assertSame( $val2, wp_cache_get( $key ) );
// Non-existant key should fail.
$this->assertFalse( wp_cache_replace( $fake_key, $val1 ) );

View File

@ -252,7 +252,7 @@ class Tests_Canonical extends WP_Canonical_UnitTestCase {
}
);
$this->go_to( '/child-page-1' );
$this->assertEquals( 'wp', redirect_guess_404_permalink() );
$this->assertSame( 'wp', redirect_guess_404_permalink() );
}
/**
@ -268,7 +268,7 @@ class Tests_Canonical extends WP_Canonical_UnitTestCase {
$this->go_to( 'strict-redirect' );
// Test default 'non-strict' redirect guess.
$this->assertEquals( get_permalink( $post ), redirect_guess_404_permalink() );
$this->assertSame( get_permalink( $post ), redirect_guess_404_permalink() );
// Test 'strict' redirect guess.
add_filter( 'strict_redirect_guess_404_permalink', '__return_true' );

View File

@ -24,37 +24,31 @@ class Tests_Canonical_HTTPS extends WP_Canonical_UnitTestCase {
* @ticket 27954
*/
public function test_http_request_with_http_home() {
$redirect = redirect_canonical( $this->http, false );
$this->assertEquals( $redirect, false );
$this->assertNull( $redirect );
}
/**
* @ticket 27954
*/
public function test_https_request_with_http_home() {
$redirect = redirect_canonical( $this->https, false );
$this->assertEquals( $redirect, false );
$this->assertNull( $redirect );
}
/**
* @ticket 27954
*/
public function test_https_request_with_https_home() {
add_filter( 'home_url', array( $this, 'set_https' ) );
$redirect = redirect_canonical( $this->https, false );
$this->assertEquals( $redirect, false );
$this->assertNull( $redirect );
remove_filter( 'home_url', array( $this, 'set_https' ) );
}
}

View File

@ -29,7 +29,7 @@ class Tests_Category extends WP_UnitTestCase {
// Validate length is 1 + created due to uncategorized.
$cat_ids = get_all_category_ids();
$this->assertEquals( 3, count( $cat_ids ) );
$this->assertSame( 3, count( $cat_ids ) );
}
/**
@ -53,9 +53,9 @@ class Tests_Category extends WP_UnitTestCase {
// Validate category is returned by slug.
$ret_testcat = get_category_by_slug( 'testcat' );
$this->assertEquals( $testcat->term_id, $ret_testcat->term_id );
$this->assertSame( $testcat->term_id, $ret_testcat->term_id );
$ret_testcat = get_category_by_slug( 'TeStCaT' );
$this->assertEquals( $testcat->term_id, $ret_testcat->term_id );
$this->assertSame( $testcat->term_id, $ret_testcat->term_id );
// Validate unknown category returns false.
$this->assertFalse( get_category_by_slug( 'testcat3' ) );
@ -107,36 +107,36 @@ class Tests_Category extends WP_UnitTestCase {
_make_cat_compat( $testcat2_array );
// Validate compatibility object.
$this->assertEquals( $testcat->cat_ID, $testcat->term_id );
$this->assertEquals( $testcat->category_count, $testcat->count );
$this->assertEquals( $testcat->category_description, $testcat->description );
$this->assertEquals( $testcat->cat_name, $testcat->name );
$this->assertEquals( $testcat->category_nicename, $testcat->slug );
$this->assertEquals( $testcat->category_parent, $testcat->parent );
$this->assertSame( $testcat->cat_ID, $testcat->term_id );
$this->assertSame( $testcat->category_count, $testcat->count );
$this->assertSame( $testcat->category_description, $testcat->description );
$this->assertSame( $testcat->cat_name, $testcat->name );
$this->assertSame( $testcat->category_nicename, $testcat->slug );
$this->assertSame( $testcat->category_parent, $testcat->parent );
// Validate compatibility object with parent.
$this->assertEquals( $testcat->cat_ID, $testcat->term_id );
$this->assertEquals( $testcat->category_count, $testcat->count );
$this->assertEquals( $testcat->category_description, $testcat->description );
$this->assertEquals( $testcat->cat_name, $testcat->name );
$this->assertEquals( $testcat->category_nicename, $testcat->slug );
$this->assertEquals( $testcat->category_parent, $testcat->parent );
$this->assertSame( $testcat->cat_ID, $testcat->term_id );
$this->assertSame( $testcat->category_count, $testcat->count );
$this->assertSame( $testcat->category_description, $testcat->description );
$this->assertSame( $testcat->cat_name, $testcat->name );
$this->assertSame( $testcat->category_nicename, $testcat->slug );
$this->assertSame( $testcat->category_parent, $testcat->parent );
// Validate compatibility array.
$this->assertEquals( $testcat_array['cat_ID'], $testcat_array['term_id'] );
$this->assertEquals( $testcat_array['category_count'], $testcat_array['count'] );
$this->assertEquals( $testcat_array['category_description'], $testcat_array['description'] );
$this->assertEquals( $testcat_array['cat_name'], $testcat_array['name'] );
$this->assertEquals( $testcat_array['category_nicename'], $testcat_array['slug'] );
$this->assertEquals( $testcat_array['category_parent'], $testcat_array['parent'] );
$this->assertSame( $testcat_array['cat_ID'], $testcat_array['term_id'] );
$this->assertSame( $testcat_array['category_count'], $testcat_array['count'] );
$this->assertSame( $testcat_array['category_description'], $testcat_array['description'] );
$this->assertSame( $testcat_array['cat_name'], $testcat_array['name'] );
$this->assertSame( $testcat_array['category_nicename'], $testcat_array['slug'] );
$this->assertSame( $testcat_array['category_parent'], $testcat_array['parent'] );
// Validate compatibility array with parent.
$this->assertEquals( $testcat_array['cat_ID'], $testcat_array['term_id'] );
$this->assertEquals( $testcat_array['category_count'], $testcat_array['count'] );
$this->assertEquals( $testcat_array['category_description'], $testcat_array['description'] );
$this->assertEquals( $testcat_array['cat_name'], $testcat_array['name'] );
$this->assertEquals( $testcat_array['category_nicename'], $testcat_array['slug'] );
$this->assertEquals( $testcat_array['category_parent'], $testcat_array['parent'] );
$this->assertSame( $testcat_array['cat_ID'], $testcat_array['term_id'] );
$this->assertSame( $testcat_array['category_count'], $testcat_array['count'] );
$this->assertSame( $testcat_array['category_description'], $testcat_array['description'] );
$this->assertSame( $testcat_array['cat_name'], $testcat_array['name'] );
$this->assertSame( $testcat_array['category_nicename'], $testcat_array['slug'] );
$this->assertSame( $testcat_array['category_parent'], $testcat_array['parent'] );
}
/**
@ -153,9 +153,9 @@ class Tests_Category extends WP_UnitTestCase {
);
// Validate.
$this->assertEquals( $testcat->name, get_cat_name( $testcat->term_id ) );
$this->assertEquals( '', get_cat_name( -1 ) );
$this->assertEquals( '', get_cat_name( $testcat->term_id + 100 ) );
$this->assertSame( $testcat->name, get_cat_name( $testcat->term_id ) );
$this->assertSame( '', get_cat_name( -1 ) );
$this->assertSame( '', get_cat_name( $testcat->term_id + 100 ) );
}
@ -173,9 +173,9 @@ class Tests_Category extends WP_UnitTestCase {
);
// Validate.
$this->assertEquals( $testcat->term_id, get_cat_ID( $testcat->name ) );
$this->assertEquals( 0, get_cat_ID( 'NO CAT' ) );
$this->assertEquals( 0, get_cat_ID( 12 ) );
$this->assertSame( $testcat->term_id, get_cat_ID( $testcat->name ) );
$this->assertSame( 0, get_cat_ID( 'NO CAT' ) );
$this->assertSame( 0, get_cat_ID( 12 ) );
}
@ -229,17 +229,17 @@ class Tests_Category extends WP_UnitTestCase {
// Validate full match.
$ret_cat = get_category_by_path( '/root/level-1', true );
$this->assertEquals( $root_level_id, $ret_cat->term_id );
$this->assertSame( $root_level_id, $ret_cat->term_id );
$this->assertNull( get_category_by_path( 'level-1', true ) );
$this->assertNull( get_category_by_path( 'nocat/nocat/', true ) );
// Validate partial match.
$ret_cat = get_category_by_path( 'level-1', false );
$this->assertEquals( $root_level_id, $ret_cat->term_id );
$this->assertSame( $root_level_id, $ret_cat->term_id );
$ret_cat = get_category_by_path( 'root/cat/level-1', false );
$this->assertEquals( $root_level_id, $ret_cat->term_id );
$this->assertSame( $root_level_id, $ret_cat->term_id );
$ret_cat = get_category_by_path( 'root$2Fcat%20%2Flevel-1', false );
$this->assertEquals( $root_level_id, $ret_cat->term_id );
$this->assertSame( $root_level_id, $ret_cat->term_id );
$this->assertNull( get_category_by_path( 'nocat/nocat/', false ) );
}
}

View File

@ -774,7 +774,7 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
remove_filter( 'preprocess_comment', array( $this, 'filter_preprocess_comment' ) );
$this->assertNotWPError( $comment );
$this->assertEquals(
$this->assertSame(
array(
'comment_post_ID' => self::$post->ID,
'comment_author' => $user->display_name,

View File

@ -52,7 +52,7 @@ class Tests_Comment extends WP_UnitTestCase {
'comment_parent' => $comments[1],
)
);
$this->assertEquals( 1, $result );
$this->assertSame( 1, $result );
$comment = get_comment( $comments[0] );
$this->assertEquals( $comments[1], $comment->comment_parent );
@ -63,7 +63,7 @@ class Tests_Comment extends WP_UnitTestCase {
'comment_parent' => $comments[1],
)
);
$this->assertEquals( 0, $result );
$this->assertSame( 0, $result );
$result = wp_update_comment(
array(
@ -90,7 +90,7 @@ class Tests_Comment extends WP_UnitTestCase {
);
$comment = get_comment( $comment_id );
$this->assertEquals( 'pingback', $comment->comment_type );
$this->assertSame( 'pingback', $comment->comment_type );
}
/**
@ -109,7 +109,7 @@ class Tests_Comment extends WP_UnitTestCase {
)
);
$this->assertEquals( 'fire', get_comment_meta( $comment_id, 'sauce', true ) );
$this->assertSame( 'fire', get_comment_meta( $comment_id, 'sauce', true ) );
}
/**
@ -147,7 +147,7 @@ class Tests_Comment extends WP_UnitTestCase {
$this->assertSame( 1, $update );
$comment = get_comment( $comment_id );
$this->assertEquals( $updated_comment_text, $comment->comment_content );
$this->assertSame( $updated_comment_text, $comment->comment_content );
}
/**
@ -162,7 +162,7 @@ class Tests_Comment extends WP_UnitTestCase {
'comment_post_ID' => self::$post_id,
)
);
$this->assertSame( false, $update );
$this->assertFalse( $update );
$update = wp_update_comment(
array(
@ -170,7 +170,7 @@ class Tests_Comment extends WP_UnitTestCase {
'comment_post_ID' => -1,
)
);
$this->assertSame( false, $update );
$this->assertFalse( $update );
}
/**
@ -290,8 +290,8 @@ class Tests_Comment extends WP_UnitTestCase {
$comment = get_comment( $id );
$this->assertEquals( $data['comment_date'], $comment->comment_date );
$this->assertEquals( $data['comment_date_gmt'], $comment->comment_date_gmt );
$this->assertSame( $data['comment_date'], $comment->comment_date );
$this->assertSame( $data['comment_date_gmt'], $comment->comment_date_gmt );
}
/**
@ -312,7 +312,7 @@ class Tests_Comment extends WP_UnitTestCase {
$comment = get_comment( $id );
$this->assertEquals( $data['comment_author_IP'], $comment->comment_author_IP );
$this->assertSame( $data['comment_author_IP'], $comment->comment_author_IP );
}
/**
@ -333,7 +333,7 @@ class Tests_Comment extends WP_UnitTestCase {
$comment = get_comment( $id );
$this->assertEquals( $data['comment_author_IP'], $comment->comment_author_IP );
$this->assertSame( $data['comment_author_IP'], $comment->comment_author_IP );
}
/**
@ -355,7 +355,7 @@ class Tests_Comment extends WP_UnitTestCase {
$comment = get_comment( $id );
$this->assertEquals( $data['comment_agent'], $comment->comment_agent );
$this->assertSame( $data['comment_agent'], $comment->comment_agent );
}
/**
@ -377,7 +377,7 @@ class Tests_Comment extends WP_UnitTestCase {
$comment = get_comment( $id );
$this->assertEquals( 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16 Mozilla/5.0 (Macintosh; U; PPC Mac OS ', $comment->comment_agent );
$this->assertSame( 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16 Mozilla/5.0 (Macintosh; U; PPC Mac OS ', $comment->comment_agent );
}
/**
@ -399,7 +399,7 @@ class Tests_Comment extends WP_UnitTestCase {
$comment = get_comment( $id );
$this->assertEquals( $data['comment_agent'], $comment->comment_agent );
$this->assertSame( $data['comment_agent'], $comment->comment_agent );
}
@ -419,7 +419,7 @@ class Tests_Comment extends WP_UnitTestCase {
$comment = get_comment( $id );
$this->assertEquals( strlen( $comment->comment_content ), 65535 );
$this->assertSame( strlen( $comment->comment_content ), 65535 );
}
/**
@ -568,7 +568,7 @@ class Tests_Comment extends WP_UnitTestCase {
)
);
$this->assertEquals( 'fire', get_comment_meta( $c, 'sauce', true ) );
$this->assertSame( 'fire', get_comment_meta( $c, 'sauce', true ) );
}
/**

View File

@ -77,6 +77,6 @@ class Tests_Comment_DateQuery extends WP_UnitTestCase {
'2008-12-10 13:06:27',
);
$this->assertEquals( $expected_dates, wp_list_pluck( $comments, 'comment_date' ) );
$this->assertSame( $expected_dates, wp_list_pluck( $comments, 'comment_date' ) );
}
}

View File

@ -33,7 +33,7 @@ class Tests_Comment_GetCommentAuthorEmailLink extends WP_UnitTestCase {
public function test_global_comment_with_default_parameters() {
$expected = '<a href="mailto:foo@example.org">foo@example.org</a>';
$this->assertEquals( $expected, get_comment_author_email_link() );
$this->assertSame( $expected, get_comment_author_email_link() );
}
/**
@ -53,7 +53,7 @@ class Tests_Comment_GetCommentAuthorEmailLink extends WP_UnitTestCase {
$expected = sprintf( '%1$s<a href="mailto:%2$s">%3$s</a>%4$s', $before, $email, $linktext, $after );
$this->assertEquals( $expected, get_comment_author_email_link( $linktext, $before, $after, $comment ) );
$this->assertSame( $expected, get_comment_author_email_link( $linktext, $before, $after, $comment ) );
}
public function test_all_parameters_with_global_comment() {
@ -63,25 +63,25 @@ class Tests_Comment_GetCommentAuthorEmailLink extends WP_UnitTestCase {
$expected = sprintf( '%1$s<a href="mailto:foo@example.org">%2$s</a>%3$s', $before, $linktext, $after );
$this->assertEquals( $expected, get_comment_author_email_link( $linktext, $before, $after ) );
$this->assertSame( $expected, get_comment_author_email_link( $linktext, $before, $after ) );
}
public function test_linktext() {
$expected = sprintf( '<a href="mailto:foo@example.org">%1$s</a>', $linktext = 'linktext' );
$this->assertEquals( $expected, get_comment_author_email_link( $linktext ) );
$this->assertSame( $expected, get_comment_author_email_link( $linktext ) );
}
public function test_before() {
$expected = sprintf( '%1$s<a href="mailto:foo@example.org">foo@example.org</a>', $before = 'before' );
$this->assertEquals( $expected, get_comment_author_email_link( '', $before ) );
$this->assertSame( $expected, get_comment_author_email_link( '', $before ) );
}
public function test_after() {
$expected = sprintf( '<a href="mailto:foo@example.org">foo@example.org</a>%1$s', $after = 'after' );
$this->assertEquals( $expected, get_comment_author_email_link( '', '', $after ) );
$this->assertSame( $expected, get_comment_author_email_link( '', '', $after ) );
}
/**
@ -96,6 +96,6 @@ class Tests_Comment_GetCommentAuthorEmailLink extends WP_UnitTestCase {
$expected = sprintf( '<a href="mailto:%1$s">%2$s</a>', $email, $email );
$this->assertEquals( $expected, get_comment_author_email_link( '', '', '', $comment ) );
$this->assertSame( $expected, get_comment_author_email_link( '', '', '', $comment ) );
}
}

View File

@ -27,7 +27,7 @@ class Tests_Comment_GetCommentAuthorUrlLink extends WP_UnitTestCase {
public function test_no_comment() {
$url_link = get_comment_author_url_link();
$this->assertEquals( "<a href='' rel='external'></a>", $url_link );
$this->assertSame( "<a href='' rel='external'></a>", $url_link );
}
public function test_global_comment() {
@ -36,7 +36,7 @@ class Tests_Comment_GetCommentAuthorUrlLink extends WP_UnitTestCase {
$url_link = get_comment_author_url_link();
$link = $this->parseCommentAuthorUrl( $comment );
$this->assertEquals( $link, $url_link );
$this->assertSame( $link, $url_link );
}
public function test_comment_arg() {
@ -44,7 +44,7 @@ class Tests_Comment_GetCommentAuthorUrlLink extends WP_UnitTestCase {
$url_link = get_comment_author_url_link( '', '', '', $comment );
$link = $this->parseCommentAuthorUrl( $comment );
$this->assertEquals( $link, $url_link );
$this->assertSame( $link, $url_link );
}
public function test_linktext() {
@ -52,7 +52,7 @@ class Tests_Comment_GetCommentAuthorUrlLink extends WP_UnitTestCase {
$url_link = get_comment_author_url_link( 'Burrito', '', '', $comment );
$link = $this->parseCommentAuthorUrl( $comment, 'Burrito' );
$this->assertEquals( $link, $url_link );
$this->assertSame( $link, $url_link );
}
public function test_before() {
@ -60,7 +60,7 @@ class Tests_Comment_GetCommentAuthorUrlLink extends WP_UnitTestCase {
$url_link = get_comment_author_url_link( 'Burrito', 'I would love a ', '', $comment );
$link = 'I would love a ' . $this->parseCommentAuthorUrl( $comment, 'Burrito' );
$this->assertEquals( $link, $url_link );
$this->assertSame( $link, $url_link );
}
public function test_after() {
@ -68,7 +68,7 @@ class Tests_Comment_GetCommentAuthorUrlLink extends WP_UnitTestCase {
$url_link = get_comment_author_url_link( 'Burrito', '', ' is my favorite word.', $comment );
$link = $this->parseCommentAuthorUrl( $comment, 'Burrito' ) . ' is my favorite word.';
$this->assertEquals( $link, $url_link );
$this->assertSame( $link, $url_link );
}
public function test_before_after() {
@ -76,6 +76,6 @@ class Tests_Comment_GetCommentAuthorUrlLink extends WP_UnitTestCase {
$url_link = get_comment_author_url_link( 'Burrito', 'I would love a ', ' right now.', $comment );
$link = 'I would love a ' . $this->parseCommentAuthorUrl( $comment, 'Burrito' ) . ' right now.';
$this->assertEquals( $link, $url_link );
$this->assertSame( $link, $url_link );
}
}

View File

@ -22,7 +22,7 @@ Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco
$excerpt = get_comment_excerpt( $comment_id );
$this->assertEquals( 20, count( explode( ' ', $excerpt ) ) );
$this->assertSame( 20, count( explode( ' ', $excerpt ) ) );
}
public function test_get_comment_excerpt_filtered() {
@ -36,7 +36,7 @@ Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco
$excerpt = get_comment_excerpt( $comment_id );
$this->assertEquals( 10, count( explode( ' ', $excerpt ) ) );
$this->assertSame( 10, count( explode( ' ', $excerpt ) ) );
}
public function _filter_comment_excerpt_length() {

View File

@ -52,12 +52,12 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
$comments = get_comments( array( 'post_id' => $post_id ) );
$this->assertEquals( 0, get_comment_pages_count( $comments, 10, false ) );
$this->assertEquals( 0, get_comment_pages_count( $comments, 1, false ) );
$this->assertEquals( 0, get_comment_pages_count( $comments, 0, false ) );
$this->assertEquals( 0, get_comment_pages_count( $comments, 10, true ) );
$this->assertEquals( 0, get_comment_pages_count( $comments, 5 ) );
$this->assertEquals( 0, get_comment_pages_count( $comments ) );
$this->assertSame( 0, get_comment_pages_count( $comments, 10, false ) );
$this->assertSame( 0, get_comment_pages_count( $comments, 1, false ) );
$this->assertSame( 0, get_comment_pages_count( $comments, 0, false ) );
$this->assertSame( 0, get_comment_pages_count( $comments, 10, true ) );
$this->assertSame( 0, get_comment_pages_count( $comments, 5 ) );
$this->assertSame( 0, get_comment_pages_count( $comments ) );
$this->assertequals( 0, get_comment_pages_count( null, 1 ) );
}

View File

@ -28,11 +28,11 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-15 00:00:00' ) );
$comment_first = self::factory()->comment->create_post_comments( $p, 1, array( 'comment_date' => '2013-09-14 00:00:00' ) );
$this->assertEquals( 4, get_page_of_comment( $comment_last[0], array( 'per_page' => 3 ) ) );
$this->assertEquals( 2, get_page_of_comment( $comment_last[0], array( 'per_page' => 10 ) ) );
$this->assertSame( 4, get_page_of_comment( $comment_last[0], array( 'per_page' => 3 ) ) );
$this->assertSame( 2, get_page_of_comment( $comment_last[0], array( 'per_page' => 10 ) ) );
$this->assertEquals( 1, get_page_of_comment( $comment_first[0], array( 'per_page' => 3 ) ) );
$this->assertEquals( 1, get_page_of_comment( $comment_first[0], array( 'per_page' => 10 ) ) );
$this->assertSame( 1, get_page_of_comment( $comment_first[0], array( 'per_page' => 3 ) ) );
$this->assertSame( 1, get_page_of_comment( $comment_first[0], array( 'per_page' => 10 ) ) );
}
public function test_type_pings() {
@ -63,7 +63,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
$now -= 10 * $i;
}
$this->assertEquals(
$this->assertSame(
2,
get_page_of_comment(
$trackbacks[0],
@ -73,7 +73,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
)
)
);
$this->assertEquals(
$this->assertSame(
3,
get_page_of_comment(
$pingbacks[0],
@ -83,7 +83,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
)
)
);
$this->assertEquals(
$this->assertSame(
5,
get_page_of_comment(
$trackbacks[0],
@ -148,7 +148,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
'type' => 'trackback',
)
);
$this->assertEquals( 2, $page_trackbacks );
$this->assertSame( 2, $page_trackbacks );
$num_queries = $wpdb->num_queries;
$page_comments = get_page_of_comment(
@ -158,7 +158,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
'type' => 'comment',
)
);
$this->assertEquals( 1, $page_comments );
$this->assertSame( 1, $page_comments );
$this->assertNotEquals( $num_queries, $wpdb->num_queries );
}
@ -243,11 +243,11 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
)
);
$this->assertEquals( 1, get_page_of_comment( $c1, array( 'per_page' => 2 ) ) );
$this->assertSame( 1, get_page_of_comment( $c1, array( 'per_page' => 2 ) ) );
wp_set_comment_status( $c3, '1' );
$this->assertEquals( 2, get_page_of_comment( $c1, array( 'per_page' => 2 ) ) );
$this->assertSame( 2, get_page_of_comment( $c1, array( 'per_page' => 2 ) ) );
}
/**
@ -275,10 +275,10 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
}
$found_0 = get_page_of_comment( $comments_0[0], array( 'per_page' => 2 ) );
$this->assertEquals( 3, $found_0 );
$this->assertSame( 3, $found_0 );
$found_1 = get_page_of_comment( $comments_1[1], array( 'per_page' => 2 ) );
$this->assertEquals( 2, $found_1 );
$this->assertSame( 2, $found_1 );
}
/**
@ -357,7 +357,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
update_option( 'page_comments', 1 );
update_option( 'comments_per_page', 2 );
$this->assertEquals( 2, get_page_of_comment( $c1 ) );
$this->assertSame( 2, get_page_of_comment( $c1 ) );
}
/**
@ -397,7 +397,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
update_option( 'page_comments', 1 );
update_option( 'comments_per_page', 1 );
$this->assertEquals( 2, get_page_of_comment( $c3 ) );
$this->assertSame( 2, get_page_of_comment( $c3 ) );
}
/**
@ -437,7 +437,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
update_option( 'page_comments', 1 );
update_option( 'comments_per_page', 1 );
$this->assertEquals( 2, get_page_of_comment( $c3 ) );
$this->assertSame( 2, get_page_of_comment( $c3 ) );
}
/**

View File

@ -722,7 +722,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $c2 ), $found );
$this->assertSame( array( $c2 ), $found );
}
/**
@ -758,7 +758,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $c2 ), $found );
$this->assertSame( array( $c2 ), $found );
}
/**
@ -874,7 +874,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $c2 ), $found );
$this->assertSame( array( $c2 ), $found );
}
/**
@ -910,7 +910,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $c2 ), $found );
$this->assertSame( array( $c2 ), $found );
}
/**
@ -1016,7 +1016,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $c2 ), $found );
$this->assertSame( array( $c2 ), $found );
}
/**
@ -1044,7 +1044,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $c1 ), $found );
$this->assertSame( array( $c1 ), $found );
}
public function test_status_custom() {
@ -1075,7 +1075,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $c2 ), $found );
$this->assertSame( array( $c2 ), $found );
}
public function test_status_all() {
@ -1293,24 +1293,27 @@ class Tests_Comment_Query extends WP_UnitTestCase {
$post_id = self::factory()->post->create();
self::factory()->comment->create_post_comments( $post_id, $limit );
$comments = get_comments( array( 'post_id' => $post_id ) );
$this->assertEquals( $limit, count( $comments ) );
$this->assertSame( $limit, count( $comments ) );
foreach ( $comments as $comment ) {
$this->assertEquals( $post_id, $comment->comment_post_ID );
}
$post_id2 = self::factory()->post->create();
self::factory()->comment->create_post_comments( $post_id2, $limit );
$comments = get_comments( array( 'post_id' => $post_id2 ) );
$this->assertEquals( $limit, count( $comments ) );
$this->assertSame( $limit, count( $comments ) );
foreach ( $comments as $comment ) {
$this->assertEquals( $post_id2, $comment->comment_post_ID );
}
$post_id3 = self::factory()->post->create();
self::factory()->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '0' ) );
$comments = get_comments( array( 'post_id' => $post_id3 ) );
$this->assertEquals( $limit, count( $comments ) );
$this->assertSame( $limit, count( $comments ) );
foreach ( $comments as $comment ) {
$this->assertEquals( $post_id3, $comment->comment_post_ID );
}
@ -1321,7 +1324,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
'status' => 'hold',
)
);
$this->assertEquals( $limit, count( $comments ) );
$this->assertSame( $limit, count( $comments ) );
foreach ( $comments as $comment ) {
$this->assertEquals( $post_id3, $comment->comment_post_ID );
}
@ -1332,11 +1335,11 @@ class Tests_Comment_Query extends WP_UnitTestCase {
'status' => 'approve',
)
);
$this->assertEquals( 0, count( $comments ) );
$this->assertSame( 0, count( $comments ) );
self::factory()->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '1' ) );
$comments = get_comments( array( 'post_id' => $post_id3 ) );
$this->assertEquals( $limit * 2, count( $comments ) );
$this->assertSame( $limit * 2, count( $comments ) );
foreach ( $comments as $comment ) {
$this->assertEquals( $post_id3, $comment->comment_post_ID );
}
@ -1363,7 +1366,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
'orderby' => array( 'key' ),
)
);
$this->assertEquals( 2, count( $comments ) );
$this->assertSame( 2, count( $comments ) );
$this->assertEquals( $comment_id2, $comments[0]->comment_ID );
$this->assertEquals( $comment_id, $comments[1]->comment_ID );
@ -1373,7 +1376,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
'orderby' => array( 'meta_value' ),
)
);
$this->assertEquals( 2, count( $comments ) );
$this->assertSame( 2, count( $comments ) );
$this->assertEquals( $comment_id2, $comments[0]->comment_ID );
$this->assertEquals( $comment_id, $comments[1]->comment_ID );
@ -1384,7 +1387,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
'order' => 'ASC',
)
);
$this->assertEquals( 2, count( $comments ) );
$this->assertSame( 2, count( $comments ) );
$this->assertEquals( $comment_id, $comments[0]->comment_ID );
$this->assertEquals( $comment_id2, $comments[1]->comment_ID );
@ -1395,7 +1398,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
'order' => 'ASC',
)
);
$this->assertEquals( 2, count( $comments ) );
$this->assertSame( 2, count( $comments ) );
$this->assertEquals( $comment_id, $comments[0]->comment_ID );
$this->assertEquals( $comment_id2, $comments[1]->comment_ID );
@ -1423,7 +1426,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
'orderby' => array( 'key' ),
)
);
$this->assertEquals( 1, count( $comments ) );
$this->assertSame( 1, count( $comments ) );
$comments = get_comments(
array(
@ -1431,7 +1434,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
'orderby' => array( 'meta_value' ),
)
);
$this->assertEquals( 1, count( $comments ) );
$this->assertSame( 1, count( $comments ) );
}
/**
@ -1458,7 +1461,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $comments[1], $comments[2], $comments[0] ), $found );
$this->assertSame( array( $comments[1], $comments[2], $comments[0] ), $found );
}
/**
@ -1502,7 +1505,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $c3, $c1, $c2 ), $found );
$this->assertSame( array( $c3, $c1, $c2 ), $found );
}
/**
@ -1539,7 +1542,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $comments[2], $comments[0], $comments[1] ), $found );
$this->assertSame( array( $comments[2], $comments[0], $comments[1] ), $found );
}
/**
@ -1565,7 +1568,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $comments[2] ), $q->get_comments() );
$this->assertSame( array( $comments[2] ), $q->get_comments() );
}
/**
@ -1591,7 +1594,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $comments[0] ), $q->get_comments() );
$this->assertSame( array( $comments[0] ), $q->get_comments() );
}
/**
@ -2896,7 +2899,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( 2, $found );
$this->assertSame( 2, $found );
}
/**
@ -2937,7 +2940,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( 2, $found );
$this->assertSame( 2, $found );
}
/**
@ -3672,7 +3675,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $c2, $c3 ), $ids->comments );
$this->assertSame( array( $c2, $c3 ), $ids->comments );
}
@ -3689,8 +3692,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( 0, $q->found_comments );
$this->assertEquals( 0, $q->max_num_pages );
$this->assertSame( 0, $q->found_comments );
$this->assertSame( 0, $q->max_num_pages );
}
/**
@ -3707,8 +3710,8 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( 0, $q->found_comments );
$this->assertEquals( 0, $q->max_num_pages );
$this->assertSame( 0, $q->found_comments );
$this->assertSame( 0, $q->max_num_pages );
}
/**
@ -3725,7 +3728,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( 3, $q->found_comments );
$this->assertSame( 3, $q->found_comments );
$this->assertEquals( 2, $q->max_num_pages );
}
@ -3795,7 +3798,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( array( $top_level_comments[0], $top_level_comments[1] ), $q->comments );
$this->assertSame( array( $top_level_comments[0], $top_level_comments[1] ), $q->comments );
}
/**
@ -4676,7 +4679,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
'count' => true,
)
);
$this->assertEquals( $number_of_queries + 1, $wpdb->num_queries );
$this->assertSame( $number_of_queries + 1, $wpdb->num_queries );
}
/**
@ -4705,7 +4708,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
'count' => true,
)
);
$this->assertEquals( $number_of_queries, $wpdb->num_queries );
$this->assertSame( $number_of_queries, $wpdb->num_queries );
}
/**
@ -4733,7 +4736,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
)
);
$this->assertEquals( $number_of_queries, $wpdb->num_queries );
$this->assertSame( $number_of_queries, $wpdb->num_queries );
}
/**
@ -4905,7 +4908,7 @@ class Tests_Comment_Query extends WP_UnitTestCase {
$this->assertSame( array( 555 ), $results );
// Make sure manually setting total_users doesn't get overwritten.
$this->assertEquals( 1, $q->found_comments );
$this->assertSame( 1, $q->found_comments );
}
public static function filter_comments_pre_query( $comments, $query ) {

View File

@ -43,8 +43,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
$comment = get_comment( $id );
$this->assertEquals( wp_unslash( $this->slash_1 ), $comment->comment_author );
$this->assertEquals( wp_unslash( $this->slash_7 ), $comment->comment_content );
$this->assertSame( wp_unslash( $this->slash_1 ), $comment->comment_author );
$this->assertSame( wp_unslash( $this->slash_7 ), $comment->comment_content );
$data = array(
'comment_post_ID' => $post_id,
@ -58,8 +58,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
$comment = get_comment( $id );
$this->assertEquals( wp_unslash( $this->slash_2 ), $comment->comment_author );
$this->assertEquals( wp_unslash( $this->slash_4 ), $comment->comment_content );
$this->assertSame( wp_unslash( $this->slash_2 ), $comment->comment_author );
$this->assertSame( wp_unslash( $this->slash_4 ), $comment->comment_content );
}
/**
@ -88,8 +88,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
edit_comment();
$comment = get_comment( $comment_id );
$this->assertEquals( $this->slash_1, $comment->comment_author );
$this->assertEquals( $this->slash_7, $comment->comment_content );
$this->assertSame( $this->slash_1, $comment->comment_author );
$this->assertSame( $this->slash_7, $comment->comment_content );
$_POST = array();
$_POST['comment_ID'] = $comment_id;
@ -104,8 +104,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
edit_comment();
$comment = get_comment( $comment_id );
$this->assertEquals( $this->slash_2, $comment->comment_author );
$this->assertEquals( $this->slash_4, $comment->comment_content );
$this->assertSame( $this->slash_2, $comment->comment_author );
$this->assertSame( $this->slash_4, $comment->comment_content );
}
/**
@ -123,8 +123,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
);
$comment = get_comment( $comment_id );
$this->assertEquals( wp_unslash( $this->slash_1 ), $comment->comment_author );
$this->assertEquals( wp_unslash( $this->slash_7 ), $comment->comment_content );
$this->assertSame( wp_unslash( $this->slash_1 ), $comment->comment_author );
$this->assertSame( wp_unslash( $this->slash_7 ), $comment->comment_content );
$comment_id = wp_insert_comment(
array(
@ -135,8 +135,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
);
$comment = get_comment( $comment_id );
$this->assertEquals( wp_unslash( $this->slash_2 ), $comment->comment_author );
$this->assertEquals( wp_unslash( $this->slash_4 ), $comment->comment_content );
$this->assertSame( wp_unslash( $this->slash_2 ), $comment->comment_author );
$this->assertSame( wp_unslash( $this->slash_4 ), $comment->comment_content );
}
/**
@ -159,8 +159,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
);
$comment = get_comment( $comment_id );
$this->assertEquals( wp_unslash( $this->slash_1 ), $comment->comment_author );
$this->assertEquals( wp_unslash( $this->slash_7 ), $comment->comment_content );
$this->assertSame( wp_unslash( $this->slash_1 ), $comment->comment_author );
$this->assertSame( wp_unslash( $this->slash_7 ), $comment->comment_content );
wp_update_comment(
array(
@ -171,8 +171,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
);
$comment = get_comment( $comment_id );
$this->assertEquals( wp_unslash( $this->slash_2 ), $comment->comment_author );
$this->assertEquals( wp_unslash( $this->slash_4 ), $comment->comment_content );
$this->assertSame( wp_unslash( $this->slash_2 ), $comment->comment_author );
$this->assertSame( wp_unslash( $this->slash_4 ), $comment->comment_content );
}
}

View File

@ -7,14 +7,14 @@ class Tests_Comment_Template extends WP_UnitTestCase {
function test_get_comments_number() {
$post_id = self::factory()->post->create();
$this->assertEquals( 0, get_comments_number( 0 ) );
$this->assertEquals( 0, get_comments_number( $post_id ) );
$this->assertEquals( 0, get_comments_number( get_post( $post_id ) ) );
$this->assertSame( 0, get_comments_number( 0 ) );
$this->assertSame( '0', get_comments_number( $post_id ) );
$this->assertSame( '0', get_comments_number( get_post( $post_id ) ) );
self::factory()->comment->create_post_comments( $post_id, 12 );
$this->assertEquals( 12, get_comments_number( $post_id ) );
$this->assertEquals( 12, get_comments_number( get_post( $post_id ) ) );
$this->assertSame( '12', get_comments_number( $post_id ) );
$this->assertSame( '12', get_comments_number( get_post( $post_id ) ) );
}
function test_get_comments_number_without_arg() {
@ -22,12 +22,12 @@ class Tests_Comment_Template extends WP_UnitTestCase {
$permalink = get_permalink( $post_id );
$this->go_to( $permalink );
$this->assertEquals( 0, get_comments_number() );
$this->assertSame( '0', get_comments_number() );
self::factory()->comment->create_post_comments( $post_id, 12 );
$this->go_to( $permalink );
$this->assertEquals( 12, get_comments_number() );
$this->assertSame( '12', get_comments_number() );
}
/**
@ -39,13 +39,13 @@ class Tests_Comment_Template extends WP_UnitTestCase {
$comments_number_text = get_comments_number_text( false, false, false, $post_id );
$this->assertEquals( sprintf( _n( '%s Comment', '%s Comments', 6 ), '6' ), $comments_number_text );
$this->assertSame( sprintf( _n( '%s Comment', '%s Comments', 6 ), '6' ), $comments_number_text );
ob_start();
comments_number( false, false, false, $post_id );
$comments_number_text = ob_get_clean();
$this->assertEquals( sprintf( _n( '%s Comment', '%s Comments', 6 ), '6' ), $comments_number_text );
$this->assertSame( sprintf( _n( '%s Comment', '%s Comments', 6 ), '6' ), $comments_number_text );
}
@ -57,17 +57,17 @@ class Tests_Comment_Template extends WP_UnitTestCase {
$permalink = get_permalink( $post_id );
$this->go_to( $permalink );
$this->assertEquals( __( 'No Comments' ), get_comments_number_text() );
$this->assertSame( __( 'No Comments' ), get_comments_number_text() );
$this->factory->comment->create_post_comments( $post_id, 1 );
$this->go_to( $permalink );
$this->assertEquals( __( '1 Comment' ), get_comments_number_text() );
$this->assertSame( __( '1 Comment' ), get_comments_number_text() );
$this->factory->comment->create_post_comments( $post_id, 1 );
$this->go_to( $permalink );
$this->assertEquals( sprintf( _n( '%s Comment', '%s Comments', 2 ), '2' ), get_comments_number_text() );
$this->assertSame( sprintf( _n( '%s Comment', '%s Comments', 2 ), '2' ), get_comments_number_text() );
}
@ -84,7 +84,7 @@ class Tests_Comment_Template extends WP_UnitTestCase {
add_filter( 'gettext_with_context', array( $this, '_enable_comment_number_declension' ), 10, 4 );
$this->assertEquals( $output, get_comments_number_text( false, false, $input ) );
$this->assertSame( $output, get_comments_number_text( false, false, $input ) );
remove_filter( 'gettext_with_context', array( $this, '_enable_comment_number_declension' ), 10, 4 );
}

View File

@ -39,7 +39,7 @@ class Tests_Batch_Update_Comment_Type extends WP_UnitTestCase {
foreach ( $comment_ids as $comment_id ) {
$updated_comment = get_comment( $comment_id );
$this->assertEquals( 'comment', $updated_comment->comment_type );
$this->assertSame( 'comment', $updated_comment->comment_type );
}
}

View File

@ -5,13 +5,13 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
public function test_wp_count_comments() {
$count = wp_count_comments();
$this->assertEquals( 0, $count->approved );
$this->assertEquals( 0, $count->moderated );
$this->assertEquals( 0, $count->spam );
$this->assertEquals( 0, $count->trash );
$this->assertEquals( 0, $count->{'post-trashed'} );
$this->assertEquals( 0, $count->total_comments );
$this->assertEquals( 0, $count->all );
$this->assertSame( 0, $count->approved );
$this->assertSame( 0, $count->moderated );
$this->assertSame( 0, $count->spam );
$this->assertSame( 0, $count->trash );
$this->assertSame( 0, $count->{'post-trashed'} );
$this->assertSame( 0, $count->total_comments );
$this->assertSame( 0, $count->all );
}
public function test_wp_count_comments_approved() {
@ -23,13 +23,13 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
$count = wp_count_comments();
$this->assertEquals( 1, $count->approved );
$this->assertEquals( 0, $count->moderated );
$this->assertEquals( 0, $count->spam );
$this->assertEquals( 0, $count->trash );
$this->assertEquals( 0, $count->{'post-trashed'} );
$this->assertEquals( 1, $count->total_comments );
$this->assertEquals( 1, $count->all );
$this->assertSame( 1, $count->approved );
$this->assertSame( 0, $count->moderated );
$this->assertSame( 0, $count->spam );
$this->assertSame( 0, $count->trash );
$this->assertSame( 0, $count->{'post-trashed'} );
$this->assertSame( 1, $count->total_comments );
$this->assertSame( 1, $count->all );
}
public function test_wp_count_comments_awaiting() {
@ -41,13 +41,13 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
$count = wp_count_comments();
$this->assertEquals( 0, $count->approved );
$this->assertEquals( 1, $count->moderated );
$this->assertEquals( 0, $count->spam );
$this->assertEquals( 0, $count->trash );
$this->assertEquals( 0, $count->{'post-trashed'} );
$this->assertEquals( 1, $count->total_comments );
$this->assertEquals( 1, $count->all );
$this->assertSame( 0, $count->approved );
$this->assertSame( 1, $count->moderated );
$this->assertSame( 0, $count->spam );
$this->assertSame( 0, $count->trash );
$this->assertSame( 0, $count->{'post-trashed'} );
$this->assertSame( 1, $count->total_comments );
$this->assertSame( 1, $count->all );
}
public function test_wp_count_comments_spam() {
@ -59,13 +59,13 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
$count = wp_count_comments();
$this->assertEquals( 0, $count->approved );
$this->assertEquals( 0, $count->moderated );
$this->assertEquals( 1, $count->spam );
$this->assertEquals( 0, $count->trash );
$this->assertEquals( 0, $count->{'post-trashed'} );
$this->assertEquals( 1, $count->total_comments );
$this->assertEquals( 0, $count->all );
$this->assertSame( 0, $count->approved );
$this->assertSame( 0, $count->moderated );
$this->assertSame( 1, $count->spam );
$this->assertSame( 0, $count->trash );
$this->assertSame( 0, $count->{'post-trashed'} );
$this->assertSame( 1, $count->total_comments );
$this->assertSame( 0, $count->all );
}
public function test_wp_count_comments_trash() {
@ -77,13 +77,13 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
$count = wp_count_comments();
$this->assertEquals( 0, $count->approved );
$this->assertEquals( 0, $count->moderated );
$this->assertEquals( 0, $count->spam );
$this->assertEquals( 1, $count->trash );
$this->assertEquals( 0, $count->{'post-trashed'} );
$this->assertEquals( 0, $count->total_comments );
$this->assertEquals( 0, $count->all );
$this->assertSame( 0, $count->approved );
$this->assertSame( 0, $count->moderated );
$this->assertSame( 0, $count->spam );
$this->assertSame( 1, $count->trash );
$this->assertSame( 0, $count->{'post-trashed'} );
$this->assertSame( 0, $count->total_comments );
$this->assertSame( 0, $count->all );
}
public function test_wp_count_comments_post_trashed() {
@ -95,13 +95,13 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
$count = wp_count_comments();
$this->assertEquals( 0, $count->approved );
$this->assertEquals( 0, $count->moderated );
$this->assertEquals( 0, $count->spam );
$this->assertEquals( 0, $count->trash );
$this->assertEquals( 1, $count->{'post-trashed'} );
$this->assertEquals( 0, $count->total_comments );
$this->assertEquals( 0, $count->all );
$this->assertSame( 0, $count->approved );
$this->assertSame( 0, $count->moderated );
$this->assertSame( 0, $count->spam );
$this->assertSame( 0, $count->trash );
$this->assertSame( 1, $count->{'post-trashed'} );
$this->assertSame( 0, $count->total_comments );
$this->assertSame( 0, $count->all );
}
public function test_wp_count_comments_cache() {
@ -119,88 +119,88 @@ class Tests_WP_Count_Comments extends WP_UnitTestCase {
$count1 = wp_count_comments( $post_id );
$this->assertEquals( 1, $count1->approved );
$this->assertEquals( 0, $count1->moderated );
$this->assertEquals( 0, $count1->spam );
$this->assertEquals( 0, $count1->trash );
$this->assertEquals( 0, $count1->{'post-trashed'} );
$this->assertEquals( 1, $count1->total_comments );
$this->assertEquals( 1, $count1->all );
$this->assertSame( 1, $count1->approved );
$this->assertSame( 0, $count1->moderated );
$this->assertSame( 0, $count1->spam );
$this->assertSame( 0, $count1->trash );
$this->assertSame( 0, $count1->{'post-trashed'} );
$this->assertSame( 1, $count1->total_comments );
$this->assertSame( 1, $count1->all );
$all_count1 = wp_count_comments();
$this->assertEquals( 1, $all_count1->approved );
$this->assertEquals( 0, $all_count1->moderated );
$this->assertEquals( 0, $all_count1->spam );
$this->assertEquals( 0, $all_count1->trash );
$this->assertEquals( 0, $all_count1->{'post-trashed'} );
$this->assertEquals( 1, $all_count1->total_comments );
$this->assertEquals( 1, $all_count1->all );
$this->assertSame( 1, $all_count1->approved );
$this->assertSame( 0, $all_count1->moderated );
$this->assertSame( 0, $all_count1->spam );
$this->assertSame( 0, $all_count1->trash );
$this->assertSame( 0, $all_count1->{'post-trashed'} );
$this->assertSame( 1, $all_count1->total_comments );
$this->assertSame( 1, $all_count1->all );
wp_spam_comment( $comment_id );
$count2 = wp_count_comments( $post_id );
$this->assertEquals( 0, $count2->approved );
$this->assertEquals( 0, $count2->moderated );
$this->assertEquals( 1, $count2->spam );
$this->assertEquals( 0, $count2->trash );
$this->assertEquals( 0, $count2->{'post-trashed'} );
$this->assertEquals( 1, $count2->total_comments );
$this->assertEquals( 0, $count2->all );
$this->assertSame( 0, $count2->approved );
$this->assertSame( 0, $count2->moderated );
$this->assertSame( 1, $count2->spam );
$this->assertSame( 0, $count2->trash );
$this->assertSame( 0, $count2->{'post-trashed'} );
$this->assertSame( 1, $count2->total_comments );
$this->assertSame( 0, $count2->all );
$all_count2 = wp_count_comments();
$this->assertEquals( 0, $all_count2->approved );
$this->assertEquals( 0, $all_count2->moderated );
$this->assertEquals( 1, $all_count2->spam );
$this->assertEquals( 0, $all_count2->trash );
$this->assertEquals( 0, $all_count2->{'post-trashed'} );
$this->assertEquals( 1, $all_count2->total_comments );
$this->assertEquals( 0, $all_count2->all );
$this->assertSame( 0, $all_count2->approved );
$this->assertSame( 0, $all_count2->moderated );
$this->assertSame( 1, $all_count2->spam );
$this->assertSame( 0, $all_count2->trash );
$this->assertSame( 0, $all_count2->{'post-trashed'} );
$this->assertSame( 1, $all_count2->total_comments );
$this->assertSame( 0, $all_count2->all );
wp_trash_comment( $comment_id );
$count3 = wp_count_comments( $post_id );
$this->assertEquals( 0, $count3->approved );
$this->assertEquals( 0, $count3->moderated );
$this->assertEquals( 0, $count3->spam );
$this->assertEquals( 1, $count3->trash );
$this->assertEquals( 0, $count3->{'post-trashed'} );
$this->assertEquals( 0, $count3->total_comments );
$this->assertEquals( 0, $count3->all );
$this->assertSame( 0, $count3->approved );
$this->assertSame( 0, $count3->moderated );
$this->assertSame( 0, $count3->spam );
$this->assertSame( 1, $count3->trash );
$this->assertSame( 0, $count3->{'post-trashed'} );
$this->assertSame( 0, $count3->total_comments );
$this->assertSame( 0, $count3->all );
$all_count3 = wp_count_comments();
$this->assertEquals( 0, $all_count3->approved );
$this->assertEquals( 0, $all_count3->moderated );
$this->assertEquals( 0, $all_count3->spam );
$this->assertEquals( 1, $all_count3->trash );
$this->assertEquals( 0, $all_count3->{'post-trashed'} );
$this->assertEquals( 0, $all_count3->total_comments );
$this->assertEquals( 0, $all_count3->all );
$this->assertSame( 0, $all_count3->approved );
$this->assertSame( 0, $all_count3->moderated );
$this->assertSame( 0, $all_count3->spam );
$this->assertSame( 1, $all_count3->trash );
$this->assertSame( 0, $all_count3->{'post-trashed'} );
$this->assertSame( 0, $all_count3->total_comments );
$this->assertSame( 0, $all_count3->all );
wp_untrash_comment( $comment_id );
$count4 = wp_count_comments( $post_id );
$this->assertEquals( 0, $count4->approved );
$this->assertEquals( 0, $count4->moderated );
$this->assertEquals( 1, $count4->spam );
$this->assertEquals( 0, $count4->trash );
$this->assertEquals( 0, $count4->{'post-trashed'} );
$this->assertEquals( 1, $count4->total_comments );
$this->assertEquals( 0, $count4->all );
$this->assertSame( 0, $count4->approved );
$this->assertSame( 0, $count4->moderated );
$this->assertSame( 1, $count4->spam );
$this->assertSame( 0, $count4->trash );
$this->assertSame( 0, $count4->{'post-trashed'} );
$this->assertSame( 1, $count4->total_comments );
$this->assertSame( 0, $count4->all );
$all_count4 = wp_count_comments();
$this->assertEquals( 0, $all_count4->approved );
$this->assertEquals( 0, $all_count4->moderated );
$this->assertEquals( 1, $all_count4->spam );
$this->assertEquals( 0, $all_count4->trash );
$this->assertEquals( 0, $all_count4->{'post-trashed'} );
$this->assertEquals( 1, $all_count4->total_comments );
$this->assertEquals( 0, $all_count4->all );
$this->assertSame( 0, $all_count4->approved );
$this->assertSame( 0, $all_count4->moderated );
$this->assertSame( 1, $all_count4->spam );
$this->assertSame( 0, $all_count4->trash );
$this->assertSame( 0, $all_count4->{'post-trashed'} );
$this->assertSame( 1, $all_count4->total_comments );
$this->assertSame( 0, $all_count4->all );
}
}

View File

@ -36,7 +36,7 @@ class Tests_Compat extends WP_UnitTestCase {
* @dataProvider utf8_string_lengths
*/
function test_mb_strlen( $string, $expected_character_length ) {
$this->assertEquals( $expected_character_length, _mb_strlen( $string, 'UTF-8' ) );
$this->assertSame( $expected_character_length, _mb_strlen( $string, 'UTF-8' ) );
}
/**
@ -44,7 +44,7 @@ class Tests_Compat extends WP_UnitTestCase {
*/
function test_mb_strlen_via_regex( $string, $expected_character_length ) {
_wp_can_use_pcre_u( false );
$this->assertEquals( $expected_character_length, _mb_strlen( $string, 'UTF-8' ) );
$this->assertSame( $expected_character_length, _mb_strlen( $string, 'UTF-8' ) );
_wp_can_use_pcre_u( 'reset' );
}
@ -52,14 +52,14 @@ class Tests_Compat extends WP_UnitTestCase {
* @dataProvider utf8_string_lengths
*/
function test_8bit_mb_strlen( $string, $expected_character_length, $expected_byte_length ) {
$this->assertEquals( $expected_byte_length, _mb_strlen( $string, '8bit' ) );
$this->assertSame( $expected_byte_length, _mb_strlen( $string, '8bit' ) );
}
/**
* @dataProvider utf8_substrings
*/
function test_mb_substr( $string, $start, $length, $expected_character_substring ) {
$this->assertEquals( $expected_character_substring, _mb_substr( $string, $start, $length, 'UTF-8' ) );
$this->assertSame( $expected_character_substring, _mb_substr( $string, $start, $length, 'UTF-8' ) );
}
/**
@ -67,7 +67,7 @@ class Tests_Compat extends WP_UnitTestCase {
*/
function test_mb_substr_via_regex( $string, $start, $length, $expected_character_substring ) {
_wp_can_use_pcre_u( false );
$this->assertEquals( $expected_character_substring, _mb_substr( $string, $start, $length, 'UTF-8' ) );
$this->assertSame( $expected_character_substring, _mb_substr( $string, $start, $length, 'UTF-8' ) );
_wp_can_use_pcre_u( 'reset' );
}
@ -75,7 +75,7 @@ class Tests_Compat extends WP_UnitTestCase {
* @dataProvider utf8_substrings
*/
function test_8bit_mb_substr( $string, $start, $length, $expected_character_substring, $expected_byte_substring ) {
$this->assertEquals( $expected_byte_substring, _mb_substr( $string, $start, $length, '8bit' ) );
$this->assertSame( $expected_byte_substring, _mb_substr( $string, $start, $length, '8bit' ) );
}
function test_mb_substr_phpcore() {
@ -83,12 +83,12 @@ class Tests_Compat extends WP_UnitTestCase {
$string_ascii = 'ABCDEF';
$string_mb = base64_decode( '5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=' );
$this->assertEquals( 'DEF', _mb_substr( $string_ascii, 3 ) );
$this->assertEquals( 'DEF', _mb_substr( $string_ascii, 3, 5, 'ISO-8859-1' ) );
$this->assertSame( 'DEF', _mb_substr( $string_ascii, 3 ) );
$this->assertSame( 'DEF', _mb_substr( $string_ascii, 3, 5, 'ISO-8859-1' ) );
// Specific latin-1 as that is the default the core PHP test operates under.
$this->assertEquals( 'peacrOiqng==', base64_encode( _mb_substr( $string_mb, 2, 7, 'latin-1' ) ) );
$this->assertEquals( '6Kqe44OG44Kt44K544OI44Gn44GZ', base64_encode( _mb_substr( $string_mb, 2, 7, 'utf-8' ) ) );
$this->assertSame( 'peacrOiqng==', base64_encode( _mb_substr( $string_mb, 2, 7, 'latin-1' ) ) );
$this->assertSame( '6Kqe44OG44Kt44K544OI44Gn44GZ', base64_encode( _mb_substr( $string_mb, 2, 7, 'utf-8' ) ) );
/* https://github.com/php/php-src/blob/php-5.6.8/ext/mbstring/tests/mb_substr_variation1.phpt */
$start = 0;
@ -158,25 +158,25 @@ EOT;
);
$iterator = 0;
foreach ( $inputs as $input ) {
$this->assertEquals( $outputs[ $iterator ], _mb_substr( $input, $start, $length ) );
$this->assertSame( $outputs[ $iterator ], _mb_substr( $input, $start, $length ) );
$iterator++;
}
}
function test_hash_hmac_simple() {
$this->assertEquals( '140d1cb79fa12e2a31f32d35ad0a2723', _hash_hmac( 'md5', 'simple', 'key' ) );
$this->assertEquals( '993003b95758e0ac2eba451a4c5877eb1bb7b92a', _hash_hmac( 'sha1', 'simple', 'key' ) );
$this->assertSame( '140d1cb79fa12e2a31f32d35ad0a2723', _hash_hmac( 'md5', 'simple', 'key' ) );
$this->assertSame( '993003b95758e0ac2eba451a4c5877eb1bb7b92a', _hash_hmac( 'sha1', 'simple', 'key' ) );
}
function test_hash_hmac_padding() {
$this->assertEquals( '3c1399103807cf12ec38228614416a8c', _hash_hmac( 'md5', 'simple', '65 character key 65 character key 65 character key 65 character k' ) );
$this->assertEquals( '4428826d20003e309d6c2a6515891370daf184ea', _hash_hmac( 'sha1', 'simple', '65 character key 65 character key 65 character key 65 character k' ) );
$this->assertSame( '3c1399103807cf12ec38228614416a8c', _hash_hmac( 'md5', 'simple', '65 character key 65 character key 65 character key 65 character k' ) );
$this->assertSame( '4428826d20003e309d6c2a6515891370daf184ea', _hash_hmac( 'sha1', 'simple', '65 character key 65 character key 65 character key 65 character k' ) );
}
function test_hash_hmac_output() {
$this->assertEquals( array( 1 => '140d1cb79fa12e2a31f32d35ad0a2723' ), unpack( 'H32', _hash_hmac( 'md5', 'simple', 'key', true ) ) );
$this->assertEquals( array( 1 => '993003b95758e0ac2eba451a4c5877eb1bb7b92a' ), unpack( 'H40', _hash_hmac( 'sha1', 'simple', 'key', true ) ) );
$this->assertSame( array( 1 => '140d1cb79fa12e2a31f32d35ad0a2723' ), unpack( 'H32', _hash_hmac( 'md5', 'simple', 'key', true ) ) );
$this->assertSame( array( 1 => '993003b95758e0ac2eba451a4c5877eb1bb7b92a' ), unpack( 'H40', _hash_hmac( 'sha1', 'simple', 'key', true ) ) );
}
/**
@ -186,8 +186,8 @@ EOT;
require_once ABSPATH . WPINC . '/class-json.php';
$json = new Services_JSON();
// Super basic test to verify Services_JSON is intact and working.
$this->assertEquals( '["foo"]', $json->encodeUnsafe( array( 'foo' ) ) );
$this->assertEquals( array( 'foo' ), $json->decode( '["foo"]' ) );
$this->assertSame( '["foo"]', $json->encodeUnsafe( array( 'foo' ) ) );
$this->assertSame( array( 'foo' ), $json->decode( '["foo"]' ) );
}
/**

View File

@ -43,10 +43,10 @@ class Tests_Cron extends WP_UnitTestCase {
$scheduled = wp_schedule_single_event( $timestamp, $hook );
$this->assertTrue( $scheduled );
$this->assertEquals( $timestamp, wp_next_scheduled( $hook ) );
$this->assertSame( $timestamp, wp_next_scheduled( $hook ) );
// It's a non-recurring event.
$this->assertEquals( '', wp_get_schedule( $hook ) );
$this->assertFalse( wp_get_schedule( $hook ) );
}
@ -59,13 +59,13 @@ class Tests_Cron extends WP_UnitTestCase {
$scheduled = wp_schedule_single_event( $timestamp, $hook, $args );
$this->assertTrue( $scheduled );
// This returns the timestamp only if we provide matching args.
$this->assertEquals( $timestamp, wp_next_scheduled( $hook, $args ) );
$this->assertSame( $timestamp, wp_next_scheduled( $hook, $args ) );
// These don't match so return nothing.
$this->assertEquals( false, wp_next_scheduled( $hook ) );
$this->assertEquals( false, wp_next_scheduled( $hook, array( 'bar' ) ) );
$this->assertFalse( wp_next_scheduled( $hook ) );
$this->assertFalse( wp_next_scheduled( $hook, array( 'bar' ) ) );
// It's a non-recurring event.
$this->assertEquals( '', wp_get_schedule( $hook, $args ) );
$this->assertFalse( wp_get_schedule( $hook, $args ) );
}
function test_schedule_event() {
@ -77,9 +77,9 @@ class Tests_Cron extends WP_UnitTestCase {
$scheduled = wp_schedule_event( $timestamp, $recur, $hook );
$this->assertTrue( $scheduled );
// It's scheduled for the right time.
$this->assertEquals( $timestamp, wp_next_scheduled( $hook ) );
$this->assertSame( $timestamp, wp_next_scheduled( $hook ) );
// It's a recurring event.
$this->assertEquals( $recur, wp_get_schedule( $hook ) );
$this->assertSame( $recur, wp_get_schedule( $hook ) );
}
function test_schedule_event_args() {
@ -92,12 +92,12 @@ class Tests_Cron extends WP_UnitTestCase {
$scheduled = wp_schedule_event( $timestamp, 'hourly', $hook, $args );
$this->assertTrue( $scheduled );
// This returns the timestamp only if we provide matching args.
$this->assertEquals( $timestamp, wp_next_scheduled( $hook, $args ) );
$this->assertSame( $timestamp, wp_next_scheduled( $hook, $args ) );
// These don't match so return nothing.
$this->assertEquals( false, wp_next_scheduled( $hook ) );
$this->assertEquals( false, wp_next_scheduled( $hook, array( 'bar' ) ) );
$this->assertFalse( wp_next_scheduled( $hook ) );
$this->assertFalse( wp_next_scheduled( $hook, array( 'bar' ) ) );
$this->assertEquals( $recur, wp_get_schedule( $hook, $args ) );
$this->assertSame( $recur, wp_get_schedule( $hook, $args ) );
}
@ -107,12 +107,12 @@ class Tests_Cron extends WP_UnitTestCase {
$timestamp = strtotime( '+1 hour' );
wp_schedule_single_event( $timestamp, $hook );
$this->assertEquals( $timestamp, wp_next_scheduled( $hook ) );
$this->assertSame( $timestamp, wp_next_scheduled( $hook ) );
// Now unschedule it and make sure it's gone.
$unscheduled = wp_unschedule_event( $timestamp, $hook );
$this->assertTrue( $unscheduled );
$this->assertEquals( false, wp_next_scheduled( $hook ) );
$this->assertFalse( wp_next_scheduled( $hook ) );
}
function test_clear_schedule() {
@ -275,7 +275,7 @@ class Tests_Cron extends WP_UnitTestCase {
$this->assertFalse( wp_schedule_single_event( $ts2, $hook, $args ) );
// The next event should be at +5 minutes, not +3.
$this->assertEquals( $ts1, wp_next_scheduled( $hook, $args ) );
$this->assertSame( $ts1, wp_next_scheduled( $hook, $args ) );
}
/**
@ -294,10 +294,10 @@ class Tests_Cron extends WP_UnitTestCase {
$this->assertTrue( wp_schedule_single_event( $ts2, $hook, $args ) );
// The next event should be at +3 minutes, even though that one was scheduled second.
$this->assertEquals( $ts2, wp_next_scheduled( $hook, $args ) );
$this->assertSame( $ts2, wp_next_scheduled( $hook, $args ) );
wp_unschedule_event( $ts2, $hook, $args );
// Following event at +30 minutes should be there too.
$this->assertEquals( $ts1, wp_next_scheduled( $hook, $args ) );
$this->assertSame( $ts1, wp_next_scheduled( $hook, $args ) );
}
function test_not_duplicate_event_reversed() {
@ -313,10 +313,10 @@ class Tests_Cron extends WP_UnitTestCase {
$this->assertTrue( wp_schedule_single_event( $ts2, $hook, $args ) );
// The next event should be at +3 minutes.
$this->assertEquals( $ts1, wp_next_scheduled( $hook, $args ) );
$this->assertSame( $ts1, wp_next_scheduled( $hook, $args ) );
wp_unschedule_event( $ts1, $hook, $args );
// Following event should be there too.
$this->assertEquals( $ts2, wp_next_scheduled( $hook, $args ) );
$this->assertSame( $ts2, wp_next_scheduled( $hook, $args ) );
}
/**
@ -470,7 +470,7 @@ class Tests_Cron extends WP_UnitTestCase {
);
$this->assertEquals( $expected, $actual );
$this->assertEquals( $expected->timestamp, $actual2 );
$this->assertSame( $expected->timestamp, $actual2 );
}
function filter_pre_scheduled_event_hooks() {

View File

@ -79,9 +79,9 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
*/
function test_construct() {
$this->assertTrue( post_type_exists( 'custom_css' ) );
$this->assertEquals( 'custom_css', $this->setting->type );
$this->assertEquals( get_stylesheet(), $this->setting->stylesheet );
$this->assertEquals( 'edit_css', $this->setting->capability );
$this->assertSame( 'custom_css', $this->setting->type );
$this->assertSame( get_stylesheet(), $this->setting->stylesheet );
$this->assertSame( 'edit_css', $this->setting->capability );
$exception = null;
try {
@ -113,7 +113,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
function test_crud() {
$this->setting->default = '/* Hello World */';
$this->assertEquals( $this->setting->default, $this->setting->value() );
$this->assertSame( $this->setting->default, $this->setting->value() );
$this->assertNull( wp_get_custom_css_post() );
$this->assertNull( wp_get_custom_css_post( $this->setting->stylesheet ) );
@ -143,29 +143,29 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
remove_theme_mod( 'custom_css_post_id' );
$this->assertEquals( $post_id, wp_get_custom_css_post()->ID );
$this->assertEquals( $post_id, wp_get_custom_css_post( $this->setting->stylesheet )->ID );
$this->assertEquals( $twentyten_post_id, wp_get_custom_css_post( 'twentyten' )->ID );
$this->assertSame( $post_id, wp_get_custom_css_post()->ID );
$this->assertSame( $post_id, wp_get_custom_css_post( $this->setting->stylesheet )->ID );
$this->assertSame( $twentyten_post_id, wp_get_custom_css_post( 'twentyten' )->ID );
$this->assertEquals( $original_css, wp_get_custom_css( $this->setting->stylesheet ) );
$this->assertEquals( $original_css, $this->setting->value() );
$this->assertEquals( $twentyten_css, wp_get_custom_css( 'twentyten' ) );
$this->assertEquals( $twentyten_css, $twentyten_setting->value() );
$this->assertSame( $original_css, wp_get_custom_css( $this->setting->stylesheet ) );
$this->assertSame( $original_css, $this->setting->value() );
$this->assertSame( $twentyten_css, wp_get_custom_css( 'twentyten' ) );
$this->assertSame( $twentyten_css, $twentyten_setting->value() );
$updated_css = 'body { color: blue; }';
$this->wp_customize->set_post_value( $this->setting->id, $updated_css );
$saved = $this->setting->save();
$this->assertNotFalse( $saved );
$this->assertEquals( $updated_css, $this->setting->value() );
$this->assertEquals( $updated_css, wp_get_custom_css( $this->setting->stylesheet ) );
$this->assertEquals( $updated_css, get_post( $post_id )->post_content );
$this->assertSame( $updated_css, $this->setting->value() );
$this->assertSame( $updated_css, wp_get_custom_css( $this->setting->stylesheet ) );
$this->assertSame( $updated_css, get_post( $post_id )->post_content );
$previewed_css = 'body { color: red; }';
$this->wp_customize->set_post_value( $this->setting->id, $previewed_css );
$this->setting->preview();
$this->assertEquals( $previewed_css, $this->setting->value() );
$this->assertEquals( $previewed_css, wp_get_custom_css( $this->setting->stylesheet ) );
$this->assertSame( $previewed_css, $this->setting->value() );
$this->assertSame( $previewed_css, wp_get_custom_css( $this->setting->stylesheet ) );
// Make sure that wp_update_custom_css_post() works as expected for updates.
$r = wp_update_custom_css_post(
@ -176,13 +176,13 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
)
);
$this->assertInstanceOf( 'WP_Post', $r );
$this->assertEquals( $post_id, $r->ID );
$this->assertEquals( 'body { color:red; }', get_post( $r )->post_content );
$this->assertEquals( "body\n\tcolor:red;", get_post( $r )->post_content_filtered );
$this->assertSame( $post_id, $r->ID );
$this->assertSame( 'body { color:red; }', get_post( $r )->post_content );
$this->assertSame( "body\n\tcolor:red;", get_post( $r )->post_content_filtered );
$r = wp_update_custom_css_post( 'body { content: "\o/"; }' );
$this->assertEquals( $this->wp_customize->get_stylesheet(), get_post( $r )->post_name );
$this->assertEquals( 'body { content: "\o/"; }', get_post( $r )->post_content );
$this->assertEquals( '', get_post( $r )->post_content_filtered );
$this->assertSame( $this->wp_customize->get_stylesheet(), get_post( $r )->post_name );
$this->assertSame( 'body { content: "\o/"; }', get_post( $r )->post_content );
$this->assertSame( '', get_post( $r )->post_content_filtered );
// Make sure that wp_update_custom_css_post() works as expected for insertion.
$r = wp_update_custom_css_post(
@ -192,18 +192,18 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
)
);
$this->assertInstanceOf( 'WP_Post', $r );
$this->assertEquals( 'other', get_post( $r )->post_name );
$this->assertEquals( 'body { background:black; }', get_post( $r )->post_content );
$this->assertEquals( 'publish', get_post( $r )->post_status );
$this->assertSame( 'other', get_post( $r )->post_name );
$this->assertSame( 'body { background:black; }', get_post( $r )->post_content );
$this->assertSame( 'publish', get_post( $r )->post_status );
// Test deletion.
wp_delete_post( $post_id );
$this->assertNull( wp_get_custom_css_post() );
$this->assertNull( wp_get_custom_css_post( get_stylesheet() ) );
$this->assertEquals( $previewed_css, wp_get_custom_css( get_stylesheet() ), 'Previewed value remains in spite of deleted post.' );
$this->assertSame( $previewed_css, wp_get_custom_css( get_stylesheet() ), 'Previewed value remains in spite of deleted post.' );
wp_delete_post( $twentyten_post_id );
$this->assertNull( wp_get_custom_css_post( 'twentyten' ) );
$this->assertEquals( '', wp_get_custom_css( 'twentyten' ) );
$this->assertSame( '', wp_get_custom_css( 'twentyten' ) );
}
/**
@ -271,7 +271,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
function test_value_filter() {
add_filter( 'customize_value_custom_css', array( $this, 'filter_value' ), 10, 2 );
$this->setting->default = '/*default*/';
$this->assertEquals( '/*default*//*filtered*/', $this->setting->value() );
$this->assertSame( '/*default*//*filtered*/', $this->setting->value() );
$this->factory()->post->create(
array(
@ -283,11 +283,11 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
)
);
remove_theme_mod( 'custom_css_post_id' );
$this->assertEquals( '/*custom*//*filtered*/', $this->setting->value() );
$this->assertSame( '/*custom*//*filtered*/', $this->setting->value() );
$this->wp_customize->set_post_value( $this->setting->id, '/*overridden*/' );
$this->setting->preview();
$this->assertEquals( '/*overridden*/', $this->setting->value(), 'Expected value to not be filtered since post value is present.' );
$this->assertSame( '/*overridden*/', $this->setting->value(), 'Expected value to not be filtered since post value is present.' );
}
/**
@ -330,7 +330,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
$this->setting->save();
$post = get_post( $post_id );
$this->assertEquals( $original_title, $post->post_title );
$this->assertSame( $original_title, $post->post_title );
$this->assertContains( $overridden_css, $post->post_content );
$this->assertContains( '/* filtered post_content */', $post->post_content );
$this->assertContains( '/* filtered post_content_filtered */', $post->post_content_filtered );
@ -346,11 +346,11 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
function filter_update_custom_css_data( $data, $args ) {
$this->assertInternalType( 'array', $data );
$this->assertEqualSets( array( 'css', 'preprocessed' ), array_keys( $data ) );
$this->assertEquals( '', $data['preprocessed'] );
$this->assertSame( '', $data['preprocessed'] );
$this->assertInternalType( 'array', $args );
$this->assertEqualSets( array( 'css', 'preprocessed', 'stylesheet' ), array_keys( $args ) );
$this->assertEquals( $args['css'], $data['css'] );
$this->assertEquals( $args['preprocessed'], $data['preprocessed'] );
$this->assertSame( $args['css'], $data['css'] );
$this->assertSame( $args['preprocessed'], $data['preprocessed'] );
$data['css'] .= '/* filtered post_content */';
$data['preprocessed'] = '/* filtered post_content_filtered */';

File diff suppressed because it is too large Load Diff

View File

@ -68,8 +68,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
do_action( 'customize_register', $this->wp_customize );
$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'nav_menu_item[123]' );
$this->assertEquals( 'nav_menu_item', $setting->type );
$this->assertEquals( 123, $setting->post_id );
$this->assertSame( 'nav_menu_item', $setting->type );
$this->assertSame( 123, $setting->post_id );
$this->assertNull( $setting->previous_post_id );
$this->assertNull( $setting->update_status );
$this->assertNull( $setting->update_error );
@ -93,7 +93,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
'nav_menu_term_id' => 0,
'_invalid' => false,
);
$this->assertEquals( $default, $setting->default );
$this->assertSame( $default, $setting->default );
$exception = null;
try {
@ -136,9 +136,9 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
'menu_item_parent' => 123,
);
$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, 'nav_menu_item[-5]', compact( 'default' ) );
$this->assertEquals( -5, $setting->post_id );
$this->assertSame( -5, $setting->post_id );
$this->assertNull( $setting->previous_post_id );
$this->assertEquals( $default, $setting->default );
$this->assertSame( $default, $setting->default );
}
/**
@ -167,17 +167,17 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$post = get_post( $item_id );
$menu_item = wp_setup_nav_menu_item( $post );
$this->assertEquals( $item_title, $menu_item->title );
$this->assertSame( $item_title, $menu_item->title );
$setting_id = "nav_menu_item[$item_id]";
$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
$value = $setting->value();
$this->assertEquals( $menu_item->title, $value['title'] );
$this->assertEquals( $menu_item->type, $value['type'] );
$this->assertSame( $menu_item->title, $value['title'] );
$this->assertSame( $menu_item->type, $value['type'] );
$this->assertEquals( $menu_item->object_id, $value['object_id'] );
$this->assertEquals( $menu_id, $value['nav_menu_term_id'] );
$this->assertEquals( 'Hello World', $value['original_title'] );
$this->assertSame( $menu_id, $value['nav_menu_term_id'] );
$this->assertSame( 'Hello World', $value['original_title'] );
$other_menu_id = wp_create_nav_menu( 'Menu2' );
wp_update_nav_menu_item(
@ -188,8 +188,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
)
);
$value = $setting->value();
$this->assertEquals( 'Hola', $value['title'] );
$this->assertEquals( $other_menu_id, $value['nav_menu_term_id'] );
$this->assertSame( 'Hola', $value['title'] );
$this->assertSame( $other_menu_id, $value['nav_menu_term_id'] );
}
/**
@ -220,8 +220,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
$value = $setting->value();
$this->assertEquals( '', $value['title'] );
$this->assertEquals( $original_title, $value['original_title'] );
$this->assertSame( '', $value['title'] );
$this->assertSame( $original_title, $value['original_title'] );
}
/**
@ -250,17 +250,17 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$post = get_post( $item_id );
$menu_item = wp_setup_nav_menu_item( $post );
$this->assertEquals( $item_title, $menu_item->title );
$this->assertSame( $item_title, $menu_item->title );
$setting_id = "nav_menu_item[$item_id]";
$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
$value = $setting->value();
$this->assertEquals( $menu_item->title, $value['title'] );
$this->assertEquals( $menu_item->type, $value['type'] );
$this->assertSame( $menu_item->title, $value['title'] );
$this->assertSame( $menu_item->type, $value['type'] );
$this->assertEquals( $menu_item->object_id, $value['object_id'] );
$this->assertEquals( $menu_id, $value['nav_menu_term_id'] );
$this->assertEquals( 'Salutations', $value['original_title'] );
$this->assertSame( $menu_id, $value['nav_menu_term_id'] );
$this->assertSame( 'Salutations', $value['original_title'] );
}
/**
@ -291,8 +291,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
$value = $setting->value();
$this->assertEquals( $menu_item->type_label, 'Custom Label' );
$this->assertEquals( $menu_item->type_label, $value['type_label'] );
$this->assertSame( $menu_item->type_label, 'Custom Label' );
$this->assertSame( $menu_item->type_label, $value['type_label'] );
}
/**
@ -316,7 +316,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$this->wp_customize->set_post_value( $menu->id, $post_value );
$menu->preview();
$value = $menu->value();
$this->assertEquals( $post_value, $value );
$this->assertSame( $post_value, $value );
$post_id = self::factory()->post->create( array( 'post_title' => 'Hello World' ) );
$item_id = wp_update_nav_menu_item(
@ -337,7 +337,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$setting_id = "nav_menu_item[$item_id]";
$setting = new WP_Customize_Nav_Menu_Item_Setting( $this->wp_customize, $setting_id );
$value = $setting->value();
$this->assertEquals( 0, $value['nav_menu_term_id'] );
$this->assertSame( 0, $value['nav_menu_term_id'] );
}
/**
@ -391,7 +391,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$post_value['post_status'] = $post_value['status'];
unset( $post_value['status'] );
foreach ( $post_value as $key => $value ) {
$this->assertEquals( $value, $updated_item->$key, "Key $key mismatch" );
$this->assertSame( $value, $updated_item->$key, "Key $key mismatch" );
}
}
@ -444,13 +444,13 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$this->assertNotEquals( count( $current_items ), count( $preview_items ) );
$last_item = array_pop( $preview_items );
$this->assertEquals( $new_item_id, $last_item->db_id );
$this->assertSame( $new_item_id, $last_item->db_id );
$post_value['post_status'] = $post_value['status'];
unset( $post_value['status'] );
$post_value['menu_order'] = $post_value['position'];
unset( $post_value['position'] );
foreach ( $post_value as $key => $value ) {
$this->assertEquals( $value, $last_item->$key, "Mismatch for $key property." );
$this->assertSame( $value, $last_item->$key, "Mismatch for $key property." );
}
}
@ -532,7 +532,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
foreach ( $valid_urls as $valid_url ) {
$url_setting = $setting->sanitize( array( 'url' => $valid_url ) );
$this->assertInternalType( 'array', $url_setting );
$this->assertEquals( $valid_url, $url_setting['url'] );
$this->assertSame( $valid_url, $url_setting['url'] );
}
$invalid_urls = array(
@ -543,7 +543,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
foreach ( $invalid_urls as $invalid_url ) {
$url_setting = $setting->sanitize( array( 'url' => $invalid_url ) );
$this->assertInstanceOf( 'WP_Error', $url_setting );
$this->assertEquals( 'invalid_url', $url_setting->get_error_code() );
$this->assertSame( 'invalid_url', $url_setting->get_error_code() );
}
$unsanitized = array(
@ -587,7 +587,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$this->assertEqualSets( array_keys( $unsanitized ), array_keys( $sanitized ) );
foreach ( $expected_sanitized as $key => $value ) {
$this->assertEquals( $value, $sanitized[ $key ], "Expected $key to be sanitized." );
$this->assertSame( $value, $sanitized[ $key ], "Expected $key to be sanitized." );
}
$nav_menu_item_id = wp_update_nav_menu_item(
@ -616,18 +616,18 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$nav_menu_item = wp_setup_nav_menu_item( clone $post );
$this->assertEquals( $expected_sanitized['object_id'], $nav_menu_item->object_id );
$this->assertEquals( $expected_sanitized['object'], $nav_menu_item->object );
$this->assertSame( $expected_sanitized['object'], $nav_menu_item->object );
$this->assertEquals( $expected_sanitized['menu_item_parent'], $nav_menu_item->menu_item_parent );
$this->assertEquals( $expected_sanitized['position'], $post->menu_order );
$this->assertEquals( $expected_sanitized['type'], $nav_menu_item->type );
$this->assertEquals( $expected_sanitized['title'], $post->post_title );
$this->assertEquals( $expected_sanitized['url'], $nav_menu_item->url );
$this->assertEquals( $expected_sanitized['description'], $post->post_content );
$this->assertEquals( $expected_sanitized['attr_title'], $post->post_excerpt );
$this->assertEquals( $expected_sanitized['target'], $nav_menu_item->target );
$this->assertEquals( $expected_sanitized['classes'], implode( ' ', $nav_menu_item->classes ) );
$this->assertEquals( $expected_sanitized['xfn'], $nav_menu_item->xfn );
$this->assertEquals( $expected_sanitized['status'], $post->post_status );
$this->assertSame( $expected_sanitized['position'], $post->menu_order );
$this->assertSame( $expected_sanitized['type'], $nav_menu_item->type );
$this->assertSame( $expected_sanitized['title'], $post->post_title );
$this->assertSame( $expected_sanitized['url'], $nav_menu_item->url );
$this->assertSame( $expected_sanitized['description'], $post->post_content );
$this->assertSame( $expected_sanitized['attr_title'], $post->post_excerpt );
$this->assertSame( $expected_sanitized['target'], $nav_menu_item->target );
$this->assertSame( $expected_sanitized['classes'], implode( ' ', $nav_menu_item->classes ) );
$this->assertSame( $expected_sanitized['xfn'], $nav_menu_item->xfn );
$this->assertSame( $expected_sanitized['status'], $post->post_status );
}
/**
@ -693,10 +693,10 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$this->assertArrayHasKey( 'error', $update_result );
$this->assertArrayHasKey( 'status', $update_result );
$this->assertEquals( $item_id, $update_result['post_id'] );
$this->assertSame( $item_id, $update_result['post_id'] );
$this->assertNull( $update_result['previous_post_id'] );
$this->assertNull( $update_result['error'] );
$this->assertEquals( 'updated', $update_result['status'] );
$this->assertSame( 'updated', $update_result['status'] );
}
/**
@ -748,7 +748,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$this->assertNotEquals( count( $current_items ), count( $preview_items ) );
$last_item = array_pop( $preview_items );
$this->assertEquals( $setting->post_id, $last_item->db_id );
$this->assertSame( $setting->post_id, $last_item->db_id );
$post_value['post_status'] = $post_value['status'];
unset( $post_value['status'] );
$post_value['menu_order'] = $post_value['position'];
@ -766,10 +766,10 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$this->assertArrayHasKey( 'error', $update_result );
$this->assertArrayHasKey( 'status', $update_result );
$this->assertEquals( $setting->post_id, $update_result['post_id'] );
$this->assertEquals( $new_item_id, $update_result['previous_post_id'] );
$this->assertSame( $setting->post_id, $update_result['post_id'] );
$this->assertSame( $new_item_id, $update_result['previous_post_id'] );
$this->assertNull( $update_result['error'] );
$this->assertEquals( 'inserted', $update_result['status'] );
$this->assertSame( 'inserted', $update_result['status'] );
}
/**
@ -820,10 +820,10 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$this->assertArrayHasKey( 'error', $update_result );
$this->assertArrayHasKey( 'status', $update_result );
$this->assertEquals( $delete_item_id, $update_result['post_id'] );
$this->assertSame( $delete_item_id, $update_result['post_id'] );
$this->assertNull( $update_result['previous_post_id'] );
$this->assertNull( $update_result['error'] );
$this->assertEquals( 'deleted', $update_result['status'] );
$this->assertSame( 'deleted', $update_result['status'] );
}
/**
@ -918,26 +918,26 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$item_value = $setting->value();
$this->assertArrayHasKey( 'type_label', $item_value );
$nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
$this->assertEquals( 'Custom Link', $nav_menu_item->type_label );
$this->assertEquals( $item_value['type_label'], $nav_menu_item->type_label );
$this->assertSame( 'Custom Link', $nav_menu_item->type_label );
$this->assertSame( $item_value['type_label'], $nav_menu_item->type_label );
add_filter( 'wp_setup_nav_menu_item', array( $this, 'filter_type_label' ) );
$nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
$this->assertEquals( 'Custom Label', $nav_menu_item->type_label );
$this->assertSame( 'Custom Label', $nav_menu_item->type_label );
$this->assertObjectNotHasAttribute( 'nav_menu_term_id', $nav_menu_item );
$this->assertObjectNotHasAttribute( 'status', $nav_menu_item );
$this->assertEquals( 'publish', $nav_menu_item->post_status );
$this->assertEquals( 'nav_menu_item', $nav_menu_item->post_type );
$this->assertSame( 'publish', $nav_menu_item->post_status );
$this->assertSame( 'nav_menu_item', $nav_menu_item->post_type );
$this->assertObjectNotHasAttribute( 'position', $nav_menu_item );
$this->assertEquals( $post_value['position'], $nav_menu_item->menu_order );
$this->assertEquals( $post_value['title'], $nav_menu_item->post_title );
$this->assertEquals( 123, $nav_menu_item->ID );
$this->assertEquals( 123, $nav_menu_item->db_id );
$this->assertEquals( wp_get_current_user()->ID, $nav_menu_item->post_author );
$this->assertSame( $post_value['position'], $nav_menu_item->menu_order );
$this->assertSame( $post_value['title'], $nav_menu_item->post_title );
$this->assertSame( 123, $nav_menu_item->ID );
$this->assertSame( 123, $nav_menu_item->db_id );
$this->assertSame( wp_get_current_user()->ID, $nav_menu_item->post_author );
$this->assertObjectHasAttribute( 'type_label', $nav_menu_item );
$expected = apply_filters( 'nav_menu_attr_title', wp_unslash( apply_filters( 'excerpt_save_pre', wp_slash( $post_value['attr_title'] ) ) ) );
$this->assertEquals( $expected, $nav_menu_item->attr_title );
$this->assertEquals( 'Attempted \o/ o&#8217;o markup', $nav_menu_item->description );
$this->assertSame( $expected, $nav_menu_item->attr_title );
$this->assertSame( 'Attempted \o/ o&#8217;o markup', $nav_menu_item->description );
}
/**
@ -973,7 +973,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
);
$setting->preview();
$nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
$this->assertEquals( get_term_link( $term_id ), $nav_menu_item->url );
$this->assertSame( get_term_link( $term_id ), $nav_menu_item->url );
// Post.
$setting = new WP_Customize_Nav_Menu_Item_Setting(
@ -992,7 +992,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
);
$setting->preview();
$nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
$this->assertEquals( get_permalink( $post_id ), $nav_menu_item->url );
$this->assertSame( get_permalink( $post_id ), $nav_menu_item->url );
// Post type archive.
$setting = new WP_Customize_Nav_Menu_Item_Setting(
@ -1010,7 +1010,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
);
$setting->preview();
$nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
$this->assertEquals( get_post_type_archive_link( 'press_release' ), $nav_menu_item->url );
$this->assertSame( get_post_type_archive_link( 'press_release' ), $nav_menu_item->url );
}
/**
@ -1064,15 +1064,15 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
'nav_menu_item[' . $nav_menu_item_id . ']'
);
$item_value = $setting->value();
$this->assertEquals( $original_post_title, $item_value['original_title'] );
$this->assertEquals( '', $item_value['title'] );
$this->assertSame( $original_post_title, $item_value['original_title'] );
$this->assertSame( '', $item_value['title'] );
$item = $setting->value_as_wp_post_nav_menu_item();
$this->assertObjectHasAttribute( 'type_label', $item );
$this->assertEquals( $original_post_title, $item->original_title );
$this->assertEquals( $original_post_title, $item->title );
$this->assertSame( $original_post_title, $item->original_title );
$this->assertSame( $original_post_title, $item->title );
$this->assertArrayHasKey( 'type_label', $item_value );
$this->assertEquals( get_post_type_object( 'press_release' )->labels->singular_name, $item_value['type_label'] );
$this->assertEquals( $item->type_label, $item_value['type_label'] );
$this->assertSame( get_post_type_object( 'press_release' )->labels->singular_name, $item_value['type_label'] );
$this->assertSame( $item->type_label, $item_value['type_label'] );
// Post: staged nav menu item.
$setting = new WP_Customize_Nav_Menu_Item_Setting(
@ -1091,15 +1091,15 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
);
$setting->preview();
$item_value = $setting->value();
$this->assertEquals( $original_post_title, $item_value['original_title'] );
$this->assertEquals( '', $item_value['title'] );
$this->assertSame( $original_post_title, $item_value['original_title'] );
$this->assertSame( '', $item_value['title'] );
$item = $setting->value_as_wp_post_nav_menu_item();
$this->assertObjectHasAttribute( 'type_label', $item );
$this->assertEquals( $original_post_title, $item->original_title );
$this->assertEquals( $original_post_title, $item->title );
$this->assertSame( $original_post_title, $item->original_title );
$this->assertSame( $original_post_title, $item->title );
$this->assertArrayHasKey( 'type_label', $item_value );
$this->assertEquals( get_post_type_object( 'press_release' )->labels->singular_name, $item_value['type_label'] );
$this->assertEquals( $item->type_label, $item_value['type_label'] );
$this->assertSame( get_post_type_object( 'press_release' )->labels->singular_name, $item_value['type_label'] );
$this->assertSame( $item->type_label, $item_value['type_label'] );
// Term: existing nav menu item.
$nav_menu_item_id = wp_update_nav_menu_item(
@ -1118,15 +1118,15 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
'nav_menu_item[' . $nav_menu_item_id . ']'
);
$item_value = $setting->value();
$this->assertEquals( $original_term_title, $item_value['original_title'] );
$this->assertEquals( '', $item_value['title'] );
$this->assertSame( $original_term_title, $item_value['original_title'] );
$this->assertSame( '', $item_value['title'] );
$item = $setting->value_as_wp_post_nav_menu_item();
$this->assertObjectHasAttribute( 'type_label', $item );
$this->assertEquals( $original_term_title, $item->original_title );
$this->assertEquals( $original_term_title, $item->title );
$this->assertSame( $original_term_title, $item->original_title );
$this->assertSame( $original_term_title, $item->title );
$this->assertArrayHasKey( 'type_label', $item_value );
$this->assertEquals( get_taxonomy( 'category' )->labels->singular_name, $item_value['type_label'] );
$this->assertEquals( $item->type_label, $item_value['type_label'] );
$this->assertSame( get_taxonomy( 'category' )->labels->singular_name, $item_value['type_label'] );
$this->assertSame( $item->type_label, $item_value['type_label'] );
// Term: staged nav menu item.
$setting = new WP_Customize_Nav_Menu_Item_Setting(
@ -1145,15 +1145,15 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
);
$setting->preview();
$item_value = $setting->value();
$this->assertEquals( $original_term_title, $item_value['original_title'] );
$this->assertEquals( '', $item_value['title'] );
$this->assertSame( $original_term_title, $item_value['original_title'] );
$this->assertSame( '', $item_value['title'] );
$item = $setting->value_as_wp_post_nav_menu_item();
$this->assertObjectHasAttribute( 'type_label', $item );
$this->assertEquals( $original_term_title, $item->original_title );
$this->assertEquals( $original_term_title, $item->title );
$this->assertSame( $original_term_title, $item->original_title );
$this->assertSame( $original_term_title, $item->title );
$this->assertArrayHasKey( 'type_label', $item_value );
$this->assertEquals( get_taxonomy( 'category' )->labels->singular_name, $item_value['type_label'] );
$this->assertEquals( $item->type_label, $item_value['type_label'] );
$this->assertSame( get_taxonomy( 'category' )->labels->singular_name, $item_value['type_label'] );
$this->assertSame( $item->type_label, $item_value['type_label'] );
// Post Type Archive: existing nav menu item.
$nav_menu_item_id = wp_update_nav_menu_item(
@ -1171,15 +1171,15 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
'nav_menu_item[' . $nav_menu_item_id . ']'
);
$item_value = $setting->value();
$this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item_value['original_title'] );
$this->assertEquals( '', $item_value['title'] );
$this->assertSame( get_post_type_object( 'press_release' )->labels->archives, $item_value['original_title'] );
$this->assertSame( '', $item_value['title'] );
$item = $setting->value_as_wp_post_nav_menu_item();
$this->assertObjectHasAttribute( 'type_label', $item );
$this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item->original_title );
$this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item->title );
$this->assertSame( get_post_type_object( 'press_release' )->labels->archives, $item->original_title );
$this->assertSame( get_post_type_object( 'press_release' )->labels->archives, $item->title );
$this->assertArrayHasKey( 'type_label', $item_value );
$this->assertEquals( __( 'Post Type Archive' ), $item_value['type_label'] );
$this->assertEquals( $item->type_label, $item_value['type_label'] );
$this->assertSame( __( 'Post Type Archive' ), $item_value['type_label'] );
$this->assertSame( $item->type_label, $item_value['type_label'] );
// Post Type Archive: staged nav menu item.
$setting = new WP_Customize_Nav_Menu_Item_Setting(
@ -1197,15 +1197,15 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
);
$setting->preview();
$item_value = $setting->value();
$this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item_value['original_title'] );
$this->assertEquals( '', $item_value['title'] );
$this->assertSame( get_post_type_object( 'press_release' )->labels->archives, $item_value['original_title'] );
$this->assertSame( '', $item_value['title'] );
$item = $setting->value_as_wp_post_nav_menu_item();
$this->assertObjectHasAttribute( 'type_label', $item );
$this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item->original_title );
$this->assertEquals( get_post_type_object( 'press_release' )->labels->archives, $item->title );
$this->assertSame( get_post_type_object( 'press_release' )->labels->archives, $item->original_title );
$this->assertSame( get_post_type_object( 'press_release' )->labels->archives, $item->title );
$this->assertArrayHasKey( 'type_label', $item_value );
$this->assertEquals( __( 'Post Type Archive' ), $item_value['type_label'] );
$this->assertEquals( $item->type_label, $item_value['type_label'] );
$this->assertSame( __( 'Post Type Archive' ), $item_value['type_label'] );
$this->assertSame( $item->type_label, $item_value['type_label'] );
}
/**
@ -1238,6 +1238,6 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
$setting->preview();
$nav_menu_item = $setting->value_as_wp_post_nav_menu_item();
$this->assertEquals( $original_title, $nav_menu_item->title );
$this->assertSame( $original_title, $nav_menu_item->title );
}
}

View File

@ -64,9 +64,9 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
do_action( 'customize_register', $this->wp_customize );
$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[123]' );
$this->assertEquals( 'nav_menu', $setting->type );
$this->assertEquals( 'postMessage', $setting->transport );
$this->assertEquals( 123, $setting->term_id );
$this->assertSame( 'nav_menu', $setting->type );
$this->assertSame( 'postMessage', $setting->transport );
$this->assertSame( 123, $setting->term_id );
$this->assertNull( $setting->previous_term_id );
$this->assertNull( $setting->update_status );
$this->assertNull( $setting->update_error );
@ -74,9 +74,9 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
foreach ( array( 'name', 'description', 'parent' ) as $key ) {
$this->assertArrayHasKey( $key, $setting->default );
}
$this->assertEquals( '', $setting->default['name'] );
$this->assertEquals( '', $setting->default['description'] );
$this->assertEquals( 0, $setting->default['parent'] );
$this->assertSame( '', $setting->default['name'] );
$this->assertSame( '', $setting->default['description'] );
$this->assertSame( 0, $setting->default['parent'] );
$exception = null;
try {
@ -119,8 +119,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
'parent' => 123,
);
$setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, 'nav_menu[-5]', compact( 'default' ) );
$this->assertEquals( -5, $setting->term_id );
$this->assertEquals( $default, $setting->default );
$this->assertSame( -5, $setting->term_id );
$this->assertSame( $default, $setting->default );
}
/**
@ -153,14 +153,14 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
foreach ( array( 'name', 'description', 'parent' ) as $key ) {
$this->assertArrayHasKey( $key, $value );
}
$this->assertEquals( $menu_name, $value['name'] );
$this->assertEquals( $description, $value['description'] );
$this->assertEquals( $parent_menu_id, $value['parent'] );
$this->assertSame( $menu_name, $value['name'] );
$this->assertSame( $description, $value['description'] );
$this->assertSame( $parent_menu_id, $value['parent'] );
$new_menu_name = 'Foo';
wp_update_nav_menu_object( $menu_id, wp_slash( array( 'menu-name' => $new_menu_name ) ) );
$updated_value = $setting->value();
$this->assertEquals( $new_menu_name, $updated_value['name'] );
$this->assertSame( $new_menu_name, $updated_value['name'] );
}
/**
@ -196,9 +196,9 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$this->wp_customize->set_post_value( $setting_id, $post_value );
$value = $setting->value();
$this->assertEquals( 'Name 1 \\o/', $value['name'] );
$this->assertEquals( 'Description 1 \\o/', $value['description'] );
$this->assertEquals( 0, $value['parent'] );
$this->assertSame( 'Name 1 \\o/', $value['name'] );
$this->assertSame( 'Description 1 \\o/', $value['description'] );
$this->assertSame( 0, $value['parent'] );
$term = (array) wp_get_nav_menu_object( $menu_id );
@ -209,15 +209,15 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$setting->preview();
$value = $setting->value();
$this->assertEquals( 'Name 2 \\o/', $value['name'] );
$this->assertEquals( 'Description 2 \\o/', $value['description'] );
$this->assertEquals( 1, $value['parent'] );
$this->assertSame( 'Name 2 \\o/', $value['name'] );
$this->assertSame( 'Description 2 \\o/', $value['description'] );
$this->assertSame( 1, $value['parent'] );
$term = (array) wp_get_nav_menu_object( $menu_id );
$this->assertEqualSets( $value, wp_array_slice_assoc( $term, array_keys( $value ) ) );
$menu_object = wp_get_nav_menu_object( $menu_id );
$this->assertEquals( (object) $term, $menu_object );
$this->assertEquals( $post_value['name'], $menu_object->name );
$this->assertSame( $post_value['name'], $menu_object->name );
$nav_menu_options = get_option( 'nav_menu_options', array( 'auto_add' => array() ) );
$this->assertContains( $menu_id, $nav_menu_options['auto_add'] );
@ -227,7 +227,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$i = array_search( $menu_id, $menus_ids, true );
$this->assertInternalType( 'int', $i, 'Update-previewed menu does not appear in wp_get_nav_menus()' );
$filtered_menu = $menus[ $i ];
$this->assertEquals( 'Name 2 \\o/', $filtered_menu->name );
$this->assertSame( 'Name 2 \\o/', $filtered_menu->name );
}
/**
@ -251,18 +251,18 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$this->wp_customize->set_post_value( $setting->id, $post_value );
$setting->preview();
$value = $setting->value();
$this->assertEquals( $post_value, $value );
$this->assertSame( $post_value, $value );
$term = (array) wp_get_nav_menu_object( $menu_id );
$this->assertNotEmpty( $term );
$this->assertNotWPError( $term );
$this->assertEqualSets( $post_value, wp_array_slice_assoc( $term, array_keys( $value ) ) );
$this->assertEquals( $menu_id, $term['term_id'] );
$this->assertEquals( $menu_id, $term['term_taxonomy_id'] );
$this->assertSame( $menu_id, $term['term_id'] );
$this->assertSame( $menu_id, $term['term_taxonomy_id'] );
$menu_object = wp_get_nav_menu_object( $menu_id );
$this->assertEquals( (object) $term, $menu_object );
$this->assertEquals( $post_value['name'], $menu_object->name );
$this->assertSame( $post_value['name'], $menu_object->name );
$nav_menu_options = $this->get_nav_menu_items_option();
$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
@ -272,7 +272,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$i = array_search( $menu_id, $menus_ids, true );
$this->assertInternalType( 'int', $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()' );
$filtered_menu = $menus[ $i ];
$this->assertEquals( 'New Menu Name 1 \\o/', $filtered_menu->name );
$this->assertSame( 'New Menu Name 1 \\o/', $filtered_menu->name );
}
/**
@ -334,15 +334,15 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
'extra' => 'ignored',
);
$sanitized = $setting->sanitize( $value );
$this->assertEquals( 'Hello \\o/ &lt;b&gt;world&lt;/b&gt;', $sanitized['name'] );
$this->assertEquals( 'New line \\o/', $sanitized['description'] );
$this->assertEquals( 0, $sanitized['parent'] );
$this->assertEquals( true, $sanitized['auto_add'] );
$this->assertSame( 'Hello \\o/ &lt;b&gt;world&lt;/b&gt;', $sanitized['name'] );
$this->assertSame( 'New line \\o/', $sanitized['description'] );
$this->assertSame( 0, $sanitized['parent'] );
$this->assertTrue( $sanitized['auto_add'] );
$this->assertEqualSets( array( 'name', 'description', 'parent', 'auto_add' ), array_keys( $sanitized ) );
$value['name'] = ' '; // Blank spaces.
$sanitized = $setting->sanitize( $value );
$this->assertEquals( '(unnamed)', $sanitized['name'] );
$this->assertSame( '(unnamed)', $sanitized['name'] );
}
/**
@ -383,13 +383,13 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$menu_object = wp_get_nav_menu_object( $menu_id );
foreach ( array( 'name', 'description', 'parent' ) as $key ) {
$this->assertEquals( $new_value[ $key ], $menu_object->$key );
$this->assertSame( $new_value[ $key ], $menu_object->$key );
}
$this->assertEqualSets(
wp_array_slice_assoc( $new_value, array( 'name', 'description', 'parent' ) ),
wp_array_slice_assoc( (array) $menu_object, array( 'name', 'description', 'parent' ) )
);
$this->assertEquals( $new_value, $setting->value() );
$this->assertSame( $new_value, $setting->value() );
$save_response = apply_filters( 'customize_save_response', array() );
$this->assertArrayHasKey( 'nav_menu_updates', $save_response );
@ -399,12 +399,12 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$this->assertArrayHasKey( 'error', $update_result );
$this->assertArrayHasKey( 'status', $update_result );
$this->assertArrayHasKey( 'saved_value', $update_result );
$this->assertEquals( $new_value, $update_result['saved_value'] );
$this->assertSame( $new_value, $update_result['saved_value'] );
$this->assertEquals( $menu_id, $update_result['term_id'] );
$this->assertSame( $menu_id, $update_result['term_id'] );
$this->assertNull( $update_result['previous_term_id'] );
$this->assertNull( $update_result['error'] );
$this->assertEquals( 'updated', $update_result['status'] );
$this->assertSame( 'updated', $update_result['status'] );
$nav_menu_options = $this->get_nav_menu_items_option();
$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );
@ -433,7 +433,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$this->assertNull( $setting->previous_term_id );
$this->assertLessThan( 0, $setting->term_id );
$setting->save();
$this->assertEquals( $menu_id, $setting->previous_term_id );
$this->assertSame( $menu_id, $setting->previous_term_id );
$this->assertGreaterThan( 0, $setting->term_id );
$nav_menu_options = $this->get_nav_menu_items_option();
@ -451,12 +451,12 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$this->assertArrayHasKey( 'error', $update_result );
$this->assertArrayHasKey( 'status', $update_result );
$this->assertArrayHasKey( 'saved_value', $update_result );
$this->assertEquals( $setting->value(), $update_result['saved_value'] );
$this->assertSame( $setting->value(), $update_result['saved_value'] );
$this->assertEquals( $menu->term_id, $update_result['term_id'] );
$this->assertEquals( $menu_id, $update_result['previous_term_id'] );
$this->assertSame( $menu->term_id, $update_result['term_id'] );
$this->assertSame( $menu_id, $update_result['previous_term_id'] );
$this->assertNull( $update_result['error'] );
$this->assertEquals( 'inserted', $update_result['status'] );
$this->assertSame( 'inserted', $update_result['status'] );
}
/**
@ -478,10 +478,10 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$expected_resolved_menu_name = "$menu_name (2)";
$new_menu = wp_get_nav_menu_object( $setting->term_id );
$this->assertEquals( $expected_resolved_menu_name, $new_menu->name );
$this->assertSame( $expected_resolved_menu_name, $new_menu->name );
$save_response = apply_filters( 'customize_save_response', array() );
$this->assertEquals( $expected_resolved_menu_name, $save_response['nav_menu_updates'][0]['saved_value']['name'] );
$this->assertSame( $expected_resolved_menu_name, $save_response['nav_menu_updates'][0]['saved_value']['name'] );
}
/**
@ -501,7 +501,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
update_option( 'nav_menu_options', $nav_menu_options );
$menu = wp_get_nav_menu_object( $menu_id );
$this->assertEquals( $menu_name, $menu->name );
$this->assertSame( $menu_name, $menu->name );
$this->wp_customize->set_post_value( $setting_id, false );
$setting->save();
@ -518,10 +518,10 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
$this->assertArrayHasKey( 'saved_value', $update_result );
$this->assertNull( $update_result['saved_value'] );
$this->assertEquals( $menu_id, $update_result['term_id'] );
$this->assertSame( $menu_id, $update_result['term_id'] );
$this->assertNull( $update_result['previous_term_id'] );
$this->assertNull( $update_result['error'] );
$this->assertEquals( 'deleted', $update_result['status'] );
$this->assertSame( 'deleted', $update_result['status'] );
$nav_menu_options = $this->get_nav_menu_items_option();
$this->assertNotContains( $menu_id, $nav_menu_options['auto_add'] );

View File

@ -46,9 +46,9 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
function filter_item_types( $items ) {
$items[] = array(
'title' => 'Custom',
'type_label' => 'Custom Type',
'type' => 'custom_type',
'object' => 'custom_object',
'type_label' => 'Custom Type',
);
return $items;
@ -86,20 +86,20 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
$this->assertInstanceOf( 'WP_Customize_Manager', $menus->manager );
$this->assertEquals( 10, add_filter( 'customize_refresh_nonces', array( $menus, 'filter_nonces' ) ) );
$this->assertEquals( 10, add_action( 'wp_ajax_load-available-menu-items-customizer', array( $menus, 'ajax_load_available_items' ) ) );
$this->assertEquals( 10, add_action( 'wp_ajax_search-available-menu-items-customizer', array( $menus, 'ajax_search_available_items' ) ) );
$this->assertEquals( 10, add_action( 'wp_ajax_customize-nav-menus-insert-auto-draft', array( $menus, 'ajax_insert_auto_draft_post' ) ) );
$this->assertEquals( 10, add_action( 'customize_controls_enqueue_scripts', array( $menus, 'enqueue_scripts' ) ) );
$this->assertEquals( 11, add_action( 'customize_register', array( $menus, 'customize_register' ) ) );
$this->assertEquals( 10, add_filter( 'customize_dynamic_setting_args', array( $menus, 'filter_dynamic_setting_args' ) ) );
$this->assertEquals( 10, add_filter( 'customize_dynamic_setting_class', array( $menus, 'filter_dynamic_setting_class' ) ) );
$this->assertEquals( 10, add_action( 'customize_controls_print_footer_scripts', array( $menus, 'print_templates' ) ) );
$this->assertEquals( 10, add_action( 'customize_controls_print_footer_scripts', array( $menus, 'available_items_template' ) ) );
$this->assertEquals( 10, add_action( 'customize_preview_init', array( $menus, 'customize_preview_init' ) ) );
$this->assertEquals( 10, add_action( 'customize_preview_init', array( $menus, 'make_auto_draft_status_previewable' ) ) );
$this->assertEquals( 10, add_action( 'customize_save_nav_menus_created_posts', array( $menus, 'save_nav_menus_created_posts' ) ) );
$this->assertEquals( 10, add_filter( 'customize_dynamic_partial_args', array( $menus, 'customize_dynamic_partial_args' ) ) );
$this->assertTrue( add_filter( 'customize_refresh_nonces', array( $menus, 'filter_nonces' ) ) );
$this->assertTrue( add_action( 'wp_ajax_load-available-menu-items-customizer', array( $menus, 'ajax_load_available_items' ) ) );
$this->assertTrue( add_action( 'wp_ajax_search-available-menu-items-customizer', array( $menus, 'ajax_search_available_items' ) ) );
$this->assertTrue( add_action( 'wp_ajax_customize-nav-menus-insert-auto-draft', array( $menus, 'ajax_insert_auto_draft_post' ) ) );
$this->assertTrue( add_action( 'customize_controls_enqueue_scripts', array( $menus, 'enqueue_scripts' ) ) );
$this->assertTrue( add_action( 'customize_register', array( $menus, 'customize_register' ) ) );
$this->assertTrue( add_filter( 'customize_dynamic_setting_args', array( $menus, 'filter_dynamic_setting_args' ) ) );
$this->assertTrue( add_filter( 'customize_dynamic_setting_class', array( $menus, 'filter_dynamic_setting_class' ) ) );
$this->assertTrue( add_action( 'customize_controls_print_footer_scripts', array( $menus, 'print_templates' ) ) );
$this->assertTrue( add_action( 'customize_controls_print_footer_scripts', array( $menus, 'available_items_template' ) ) );
$this->assertTrue( add_action( 'customize_preview_init', array( $menus, 'customize_preview_init' ) ) );
$this->assertTrue( add_action( 'customize_preview_init', array( $menus, 'make_auto_draft_status_previewable' ) ) );
$this->assertTrue( add_action( 'customize_save_nav_menus_created_posts', array( $menus, 'save_nav_menus_created_posts' ) ) );
$this->assertTrue( add_filter( 'customize_dynamic_partial_args', array( $menus, 'customize_dynamic_partial_args' ) ) );
}
/**
@ -113,12 +113,12 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
// Invalid post type $obj_name.
$items = $menus->load_available_items_query( 'post_type', 'invalid' );
$this->assertInstanceOf( 'WP_Error', $items );
$this->assertEquals( 'nav_menus_invalid_post_type', $items->get_error_code() );
$this->assertSame( 'nav_menus_invalid_post_type', $items->get_error_code() );
// Invalid taxonomy $obj_name.
$items = $menus->load_available_items_query( 'taxonomy', 'invalid' );
$this->assertInstanceOf( 'WP_Error', $items );
$this->assertEquals( 'invalid_taxonomy', $items->get_error_code() );
$this->assertSame( 'invalid_taxonomy', $items->get_error_code() );
}
/**
@ -317,7 +317,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
's' => 'This Does NOT Exist',
)
);
$this->assertEquals( $expected, $results );
$this->assertSame( $expected, $results );
// Test posts.
foreach ( $post_ids as $post_id ) {
@ -339,7 +339,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
's' => $s,
)
);
$this->assertEquals( $expected, $results[0] );
$this->assertSame( $expected, $results[0] );
}
// Test terms.
@ -361,7 +361,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
's' => $s,
)
);
$this->assertEquals( $expected, $results[0] );
$this->assertSame( $expected, $results[0] );
}
// Test filtered results.
@ -380,7 +380,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
's' => 'cat',
)
);
$this->assertEquals( $count + 1, $this->filter_count_customize_nav_menu_searched_items );
$this->assertSame( $count + 1, $this->filter_count_customize_nav_menu_searched_items );
$this->assertInternalType( 'array', $results );
$this->assertCount( 3, $results );
remove_filter( 'customize_nav_menu_searched_items', array( $this, 'filter_search' ), 10 );
@ -394,8 +394,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
)
);
$this->assertCount( 1, $results );
$this->assertEquals( 'home', $results[0]['id'] );
$this->assertEquals( 'custom', $results[0]['type'] );
$this->assertSame( 'home', $results[0]['id'] );
$this->assertSame( 'custom', $results[0]['type'] );
}
/*
@ -512,11 +512,11 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$expected = array( 'type' => 'nav_menu_item' );
$results = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu_item[123]' );
$this->assertEquals( $expected['type'], $results['type'] );
$this->assertSame( $expected['type'], $results['type'] );
$expected = array( 'type' => 'nav_menu' );
$results = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu[123]' );
$this->assertEquals( $expected['type'], $results['type'] );
$this->assertSame( $expected['type'], $results['type'] );
}
/**
@ -530,11 +530,11 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$expected = 'WP_Customize_Nav_Menu_Item_Setting';
$results = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu_item[123]', array( 'type' => 'nav_menu_item' ) );
$this->assertEquals( $expected, $results );
$this->assertSame( $expected, $results );
$expected = 'WP_Customize_Nav_Menu_Setting';
$results = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu[123]', array( 'type' => 'nav_menu' ) );
$this->assertEquals( $expected, $results );
$this->assertSame( $expected, $results );
}
/**
@ -559,14 +559,14 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
);
do_action( 'customize_register', $this->wp_customize );
$this->assertInstanceOf( 'WP_Customize_Nav_Menu_Item_Setting', $this->wp_customize->get_setting( "nav_menu_item[$item_id]" ) );
$this->assertEquals( 'Primary', $this->wp_customize->get_section( "nav_menu[$menu_id]" )->title );
$this->assertEquals( 'Hello World', $this->wp_customize->get_control( "nav_menu_item[$item_id]" )->label );
$this->assertSame( 'Primary', $this->wp_customize->get_section( "nav_menu[$menu_id]" )->title );
$this->assertSame( 'Hello World', $this->wp_customize->get_control( "nav_menu_item[$item_id]" )->label );
$nav_menus_created_posts_setting = $this->wp_customize->get_setting( 'nav_menus_created_posts' );
$this->assertInstanceOf( 'WP_Customize_Filter_Setting', $nav_menus_created_posts_setting );
$this->assertEquals( 'postMessage', $nav_menus_created_posts_setting->transport );
$this->assertEquals( array(), $nav_menus_created_posts_setting->default );
$this->assertEquals( array( $this->wp_customize->nav_menus, 'sanitize_nav_menus_created_posts' ), $nav_menus_created_posts_setting->sanitize_callback );
$this->assertSame( 'postMessage', $nav_menus_created_posts_setting->transport );
$this->assertSame( array(), $nav_menus_created_posts_setting->default );
$this->assertSame( array( $this->wp_customize->nav_menus, 'sanitize_nav_menus_created_posts' ), $nav_menus_created_posts_setting->sanitize_callback );
}
/**
@ -578,14 +578,14 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
$this->assertEquals( 2, $menus->intval_base10( 2 ) );
$this->assertEquals( 4, $menus->intval_base10( 4.1 ) );
$this->assertEquals( 4, $menus->intval_base10( '4' ) );
$this->assertEquals( 4, $menus->intval_base10( '04' ) );
$this->assertEquals( 42, $menus->intval_base10( +42 ) );
$this->assertEquals( -42, $menus->intval_base10( -42 ) );
$this->assertEquals( 26, $menus->intval_base10( 0x1A ) );
$this->assertEquals( 0, $menus->intval_base10( array() ) );
$this->assertSame( 2, $menus->intval_base10( 2 ) );
$this->assertSame( 4, $menus->intval_base10( 4.1 ) );
$this->assertSame( 4, $menus->intval_base10( '4' ) );
$this->assertSame( 4, $menus->intval_base10( '04' ) );
$this->assertSame( 42, $menus->intval_base10( +42 ) );
$this->assertSame( -42, $menus->intval_base10( -42 ) );
$this->assertSame( 26, $menus->intval_base10( 0x1A ) );
$this->assertSame( 0, $menus->intval_base10( array() ) );
}
/**
@ -600,60 +600,60 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$expected = array(
array(
'title' => 'Posts',
'type_label' => __( 'Post' ),
'type' => 'post_type',
'object' => 'post',
'type_label' => __( 'Post' ),
),
array(
'title' => 'Pages',
'type_label' => __( 'Page' ),
'type' => 'post_type',
'object' => 'page',
'type_label' => __( 'Page' ),
),
array(
'title' => 'Categories',
'type_label' => __( 'Category' ),
'type' => 'taxonomy',
'object' => 'category',
'type_label' => __( 'Category' ),
),
array(
'title' => 'Tags',
'type_label' => __( 'Tag' ),
'type' => 'taxonomy',
'object' => 'post_tag',
'type_label' => __( 'Tag' ),
),
);
if ( current_theme_supports( 'post-formats' ) ) {
$expected[] = array(
'title' => 'Format',
'type_label' => __( 'Format' ),
'type' => 'taxonomy',
'object' => 'post_format',
'type_label' => __( 'Format' ),
);
}
$this->assertEquals( $expected, $menus->available_item_types() );
$this->assertSame( $expected, $menus->available_item_types() );
register_taxonomy( 'wptests_tax', array( 'post' ), array( 'labels' => array( 'name' => 'Foo' ) ) );
$expected[] = array(
'title' => 'Foo',
'type_label' => 'Foo',
'type' => 'taxonomy',
'object' => 'wptests_tax',
'type_label' => 'Foo',
);
$this->assertEquals( $expected, $menus->available_item_types() );
$this->assertSame( $expected, $menus->available_item_types() );
$expected[] = array(
'title' => 'Custom',
'type_label' => 'Custom Type',
'type' => 'custom_type',
'object' => 'custom_object',
'type_label' => 'Custom Type',
);
add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) );
$this->assertEquals( $expected, $menus->available_item_types() );
$this->assertSame( $expected, $menus->available_item_types() );
remove_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) );
}
@ -668,7 +668,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$r = $menus->insert_auto_draft_post( array() );
$this->assertInstanceOf( 'WP_Error', $r );
$this->assertEquals( 'unknown_post_type', $r->get_error_code() );
$this->assertSame( 'unknown_post_type', $r->get_error_code() );
// Non-existent post types allowed as of #39610.
$r = $menus->insert_auto_draft_post(
@ -678,11 +678,11 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
)
);
$this->assertInstanceOf( 'WP_Post', $r );
$this->assertEquals( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) );
$this->assertSame( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) );
$r = $menus->insert_auto_draft_post( array( 'post_type' => 'post' ) );
$this->assertInstanceOf( 'WP_Error', $r );
$this->assertEquals( 'empty_title', $r->get_error_code() );
$this->assertSame( 'empty_title', $r->get_error_code() );
$r = $menus->insert_auto_draft_post(
array(
@ -692,7 +692,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
)
);
$this->assertInstanceOf( 'WP_Error', $r );
$this->assertEquals( 'status_forbidden', $r->get_error_code() );
$this->assertSame( 'status_forbidden', $r->get_error_code() );
$r = $menus->insert_auto_draft_post(
array(
@ -701,11 +701,11 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
)
);
$this->assertInstanceOf( 'WP_Post', $r );
$this->assertEquals( 'Hello World', $r->post_title );
$this->assertEquals( '', $r->post_name );
$this->assertEquals( 'hello-world', get_post_meta( $r->ID, '_customize_draft_post_name', true ) );
$this->assertEquals( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) );
$this->assertEquals( 'post', $r->post_type );
$this->assertSame( 'Hello World', $r->post_title );
$this->assertSame( '', $r->post_name );
$this->assertSame( 'hello-world', get_post_meta( $r->ID, '_customize_draft_post_name', true ) );
$this->assertSame( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) );
$this->assertSame( 'post', $r->post_type );
$r = $menus->insert_auto_draft_post(
array(
@ -716,12 +716,12 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
)
);
$this->assertInstanceOf( 'WP_Post', $r );
$this->assertEquals( 'Hello World', $r->post_title );
$this->assertEquals( 'post', $r->post_type );
$this->assertEquals( '', $r->post_name );
$this->assertEquals( 'greetings-world', get_post_meta( $r->ID, '_customize_draft_post_name', true ) );
$this->assertEquals( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) );
$this->assertEquals( 'Hi World', $r->post_content );
$this->assertSame( 'Hello World', $r->post_title );
$this->assertSame( 'post', $r->post_type );
$this->assertSame( '', $r->post_name );
$this->assertSame( 'greetings-world', get_post_meta( $r->ID, '_customize_draft_post_name', true ) );
$this->assertSame( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) );
$this->assertSame( 'Hi World', $r->post_content );
}
/**
@ -805,14 +805,14 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$args = apply_filters( 'customize_dynamic_partial_args', false, 'nav_menu_instance[68b329da9893e34099c7d8ad5cb9c940]' );
$this->assertInternalType( 'array', $args );
$this->assertEquals( 'nav_menu_instance', $args['type'] );
$this->assertEquals( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] );
$this->assertSame( 'nav_menu_instance', $args['type'] );
$this->assertSame( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] );
$this->assertTrue( $args['container_inclusive'] );
$args = apply_filters( 'customize_dynamic_partial_args', array( 'fallback_refresh' => false ), 'nav_menu_instance[4099c7d8ad5cb9c94068b329da9893e3]' );
$this->assertInternalType( 'array', $args );
$this->assertEquals( 'nav_menu_instance', $args['type'] );
$this->assertEquals( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] );
$this->assertSame( 'nav_menu_instance', $args['type'] );
$this->assertSame( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] );
$this->assertTrue( $args['container_inclusive'] );
$this->assertFalse( $args['fallback_refresh'] );
}
@ -827,9 +827,9 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$menus = new WP_Customize_Nav_Menus( $this->wp_customize );
$menus->customize_preview_init();
$this->assertEquals( 10, has_action( 'wp_enqueue_scripts', array( $menus, 'customize_preview_enqueue_deps' ) ) );
$this->assertEquals( 1000, has_filter( 'wp_nav_menu_args', array( $menus, 'filter_wp_nav_menu_args' ) ) );
$this->assertEquals( 10, has_filter( 'wp_nav_menu', array( $menus, 'filter_wp_nav_menu' ) ) );
$this->assertSame( 10, has_action( 'wp_enqueue_scripts', array( $menus, 'customize_preview_enqueue_deps' ) ) );
$this->assertSame( 1000, has_filter( 'wp_nav_menu_args', array( $menus, 'filter_wp_nav_menu_args' ) ) );
$this->assertSame( 10, has_filter( 'wp_nav_menu', array( $menus, 'filter_wp_nav_menu' ) ) );
}
/**
@ -907,15 +907,15 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
wp_set_current_user( $contributor_user_id );
$sanitized = $menus->sanitize_nav_menus_created_posts( $value );
$this->assertEquals( array(), $sanitized );
$this->assertSame( array(), $sanitized );
wp_set_current_user( $author_user_id );
$sanitized = $menus->sanitize_nav_menus_created_posts( $value );
$this->assertEquals( array( $author_post_id ), $sanitized );
$this->assertSame( array( $author_post_id ), $sanitized );
wp_set_current_user( $administrator_user_id );
$sanitized = $menus->sanitize_nav_menus_created_posts( $value );
$this->assertEquals( array( $contributor_post_id, $author_post_id, $administrator_post_id, $draft_post_id ), $sanitized );
$this->assertSame( array( $contributor_post_id, $author_post_id, $administrator_post_id, $draft_post_id ), $sanitized );
}
/**
@ -996,13 +996,13 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$this->wp_customize->set_post_value( $setting_id, array_merge( $post_ids, array( $pre_published_post_id ) ) );
$setting = $this->wp_customize->get_setting( $setting_id );
$this->assertInstanceOf( 'WP_Customize_Filter_Setting', $setting );
$this->assertEquals( array( $menus, 'sanitize_nav_menus_created_posts' ), $setting->sanitize_callback );
$this->assertEquals( $drafted_post_ids, $setting->post_value() );
$this->assertSame( array( $menus, 'sanitize_nav_menus_created_posts' ), $setting->sanitize_callback );
$this->assertSame( $drafted_post_ids, $setting->post_value() );
$this->assertArrayNotHasKey( $private_post_id, $post_ids );
$this->assertArrayNotHasKey( $trashed_post_id, $post_ids );
$this->assertEquals( 'auto-draft', get_post_status( $drafted_post_ids[0] ) );
$this->assertEquals( 'draft', get_post_status( $drafted_post_ids[1] ) );
$this->assertSame( 'auto-draft', get_post_status( $drafted_post_ids[0] ) );
$this->assertSame( 'draft', get_post_status( $drafted_post_ids[1] ) );
foreach ( $drafted_post_ids as $post_id ) {
$this->assertEmpty( get_post( $post_id )->post_name );
$this->assertNotEmpty( get_post_meta( $post_id, '_customize_draft_post_name', true ) );
@ -1010,15 +1010,15 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$save_action_count = did_action( 'customize_save_nav_menus_created_posts' );
$setting->save();
$this->assertEquals( $save_action_count + 1, did_action( 'customize_save_nav_menus_created_posts' ) );
$this->assertSame( $save_action_count + 1, did_action( 'customize_save_nav_menus_created_posts' ) );
foreach ( $drafted_post_ids as $post_id ) {
$this->assertEquals( 'publish', get_post_status( $post_id ) );
$this->assertSame( 'publish', get_post_status( $post_id ) );
$this->assertRegExp( '/^auto-draft-\d+$/', get_post( $post_id )->post_name );
$this->assertEmpty( get_post_meta( $post_id, '_customize_draft_post_name', true ) );
}
$this->assertEquals( 'private', get_post_status( $private_post_id ) );
$this->assertEquals( 'trash', get_post_status( $trashed_post_id ) );
$this->assertSame( 'private', get_post_status( $private_post_id ) );
$this->assertSame( 'trash', get_post_status( $trashed_post_id ) );
// Ensure that unique slugs were assigned.
$posts = array_map( 'get_post', $drafted_post_ids );
@ -1058,7 +1058,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
);
$this->assertFalse( $results['can_partial_refresh'] );
$this->assertArrayHasKey( 'customize_preview_nav_menus_args', $results );
$this->assertEquals( 'wp_page_menu', $results['fallback_cb'] );
$this->assertSame( 'wp_page_menu', $results['fallback_cb'] );
$nav_menu_term = get_term( wp_create_nav_menu( 'Bar' ) );
$results = $menus->filter_wp_nav_menu_args(
@ -1072,7 +1072,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
);
$this->assertTrue( $results['can_partial_refresh'] );
$this->assertArrayHasKey( 'customize_preview_nav_menus_args', $results );
$this->assertEquals( $nav_menu_term->term_id, $results['customize_preview_nav_menus_args']['menu'] );
$this->assertSame( $nav_menu_term->term_id, $results['customize_preview_nav_menus_args']['menu'] );
$results = $menus->filter_wp_nav_menu_args(
array(
@ -1144,7 +1144,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$this->assertContains( ' data-customize-partial-type="nav_menu_instance"', $result );
$this->assertTrue( (bool) preg_match( '/data-customize-partial-placement-context="(.+?)"/', $result, $matches ) );
$context = json_decode( html_entity_decode( $matches[1] ), true );
$this->assertEquals( $original_args, wp_array_slice_assoc( $context, array_keys( $original_args ) ) ); // Because assertArraySubset is not available in PHP 5.2.
$this->assertSame( $original_args, wp_array_slice_assoc( $context, array_keys( $original_args ) ) ); // Because assertArraySubset is not available in PHP 5.2.
$this->assertTrue( $context['can_partial_refresh'] );
}
@ -1210,7 +1210,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
$partials = $this->wp_customize->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 );
$missing_args_hmac_args = array_merge(
$nav_menu_args['customize_preview_nav_menus_args'],

View File

@ -32,16 +32,16 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
function test_construct_default_args() {
$panel = new WP_Customize_Panel( $this->manager, 'foo' );
$this->assertInternalType( 'int', $panel->instance_number );
$this->assertEquals( $this->manager, $panel->manager );
$this->assertEquals( 'foo', $panel->id );
$this->assertEquals( 160, $panel->priority );
$this->assertEquals( 'edit_theme_options', $panel->capability );
$this->assertEquals( '', $panel->theme_supports );
$this->assertEquals( '', $panel->title );
$this->assertEquals( '', $panel->description );
$this->assertSame( $this->manager, $panel->manager );
$this->assertSame( 'foo', $panel->id );
$this->assertSame( 160, $panel->priority );
$this->assertSame( 'edit_theme_options', $panel->capability );
$this->assertSame( '', $panel->theme_supports );
$this->assertSame( '', $panel->title );
$this->assertSame( '', $panel->description );
$this->assertEmpty( $panel->sections );
$this->assertEquals( 'default', $panel->type );
$this->assertEquals( array( $panel, 'active_callback' ), $panel->active_callback );
$this->assertSame( 'default', $panel->type );
$this->assertSame( array( $panel, 'active_callback' ), $panel->active_callback );
}
/**
@ -60,7 +60,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
$panel = new WP_Customize_Panel( $this->manager, 'foo', $args );
foreach ( $args as $key => $value ) {
$this->assertEquals( $value, $panel->$key );
$this->assertSame( $value, $panel->$key );
}
}
@ -69,7 +69,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
*/
function test_construct_custom_type() {
$panel = new Custom_Panel_Test( $this->manager, 'foo' );
$this->assertEquals( 'titleless', $panel->type );
$this->assertSame( 'titleless', $panel->type );
}
/**
@ -119,9 +119,9 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
);
$panel = new WP_Customize_Panel( $this->manager, 'foo', $args );
$data = $panel->json();
$this->assertEquals( 'foo', $data['id'] );
$this->assertSame( 'foo', $data['id'] );
foreach ( array( 'title', 'description', 'priority', 'type' ) as $key ) {
$this->assertEquals( $args[ $key ], $data[ $key ] );
$this->assertSame( $args[ $key ], $data[ $key ] );
}
$this->assertEmpty( $data['content'] );
$this->assertTrue( $data['active'] );
@ -167,8 +167,8 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
$content = ob_get_clean();
$this->assertTrue( $panel->check_capabilities() );
$this->assertEmpty( $content );
$this->assertEquals( $customize_render_panel_count + 1, did_action( 'customize_render_panel' ), 'Unexpected did_action count for customize_render_panel' );
$this->assertEquals( 1, did_action( "customize_render_panel_{$panel->id}" ), "Unexpected did_action count for customize_render_panel_{$panel->id}" );
$this->assertSame( $customize_render_panel_count + 1, did_action( 'customize_render_panel' ), 'Unexpected did_action count for customize_render_panel' );
$this->assertSame( 1, did_action( "customize_render_panel_{$panel->id}" ), "Unexpected did_action count for customize_render_panel_{$panel->id}" );
}
/**

View File

@ -47,15 +47,15 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
function test_construct_default_args() {
$partial_id = 'blogname';
$partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id );
$this->assertEquals( $partial_id, $partial->id );
$this->assertEquals( $this->selective_refresh, $partial->component );
$this->assertEquals( 'default', $partial->type );
$this->assertSame( $partial_id, $partial->id );
$this->assertSame( $this->selective_refresh, $partial->component );
$this->assertSame( 'default', $partial->type );
$this->assertEmpty( $partial->selector );
$this->assertEquals( array( $partial_id ), $partial->settings );
$this->assertEquals( $partial_id, $partial->primary_setting );
$this->assertEquals( array( $partial, 'render_callback' ), $partial->render_callback );
$this->assertEquals( false, $partial->container_inclusive );
$this->assertEquals( true, $partial->fallback_refresh );
$this->assertSame( array( $partial_id ), $partial->settings );
$this->assertSame( $partial_id, $partial->primary_setting );
$this->assertSame( array( $partial, 'render_callback' ), $partial->render_callback );
$this->assertFalse( $partial->container_inclusive );
$this->assertTrue( $partial->fallback_refresh );
}
/**
@ -102,15 +102,15 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
'fallback_refresh' => false,
);
$partial = new WP_Customize_Partial( $this->selective_refresh, $partial_id, $args );
$this->assertEquals( $partial_id, $partial->id );
$this->assertEquals( $this->selective_refresh, $partial->component );
$this->assertEquals( $args['type'], $partial->type );
$this->assertEquals( $args['selector'], $partial->selector );
$this->assertSame( $partial_id, $partial->id );
$this->assertSame( $this->selective_refresh, $partial->component );
$this->assertSame( $args['type'], $partial->type );
$this->assertSame( $args['selector'], $partial->selector );
$this->assertEqualSets( $args['settings'], $partial->settings );
$this->assertEquals( $args['primary_setting'], $partial->primary_setting );
$this->assertEquals( $args['render_callback'], $partial->render_callback );
$this->assertEquals( false, $partial->container_inclusive );
$this->assertEquals( false, $partial->fallback_refresh );
$this->assertSame( $args['primary_setting'], $partial->primary_setting );
$this->assertSame( $args['render_callback'], $partial->render_callback );
$this->assertFalse( $partial->container_inclusive );
$this->assertFalse( $partial->fallback_refresh );
$this->assertContains( 'Lorem Ipsum', $partial->render() );
$partial = new WP_Customize_Partial(
@ -120,8 +120,8 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
'settings' => 'blogdescription',
)
);
$this->assertEquals( array( 'blogdescription' ), $partial->settings );
$this->assertEquals( 'blogdescription', $partial->primary_setting );
$this->assertSame( array( 'blogdescription' ), $partial->settings );
$this->assertSame( 'blogdescription', $partial->primary_setting );
}
/**
@ -132,13 +132,13 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
function test_id_data() {
$partial = new WP_Customize_Partial( $this->selective_refresh, 'foo' );
$id_data = $partial->id_data();
$this->assertEquals( 'foo', $id_data['base'] );
$this->assertEquals( array(), $id_data['keys'] );
$this->assertSame( 'foo', $id_data['base'] );
$this->assertSame( array(), $id_data['keys'] );
$partial = new WP_Customize_Partial( $this->selective_refresh, 'bar[baz][quux]' );
$id_data = $partial->id_data();
$this->assertEquals( 'bar', $id_data['base'] );
$this->assertEquals( array( 'baz', 'quux' ), $id_data['keys'] );
$this->assertSame( 'bar', $id_data['base'] );
$this->assertSame( array( 'baz', 'quux' ), $id_data['keys'] );
}
/**
@ -180,7 +180,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
* @return string|false Content.
*/
function filter_customize_partial_render_with_id( $rendered, $partial, $container_context ) {
$this->assertEquals( sprintf( 'customize_partial_render_%s', $partial->id ), current_filter() );
$this->assertSame( sprintf( 'customize_partial_render_%s', $partial->id ), current_filter() );
$this->assertTrue( false === $rendered || is_string( $rendered ) );
$this->assertInstanceOf( 'WP_Customize_Partial', $partial );
$this->assertInternalType( 'array', $container_context );
@ -249,9 +249,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
add_filter( 'customize_partial_render', array( $this, 'filter_customize_partial_render' ), 10, 3 );
add_filter( "customize_partial_render_{$partial->id}", array( $this, 'filter_customize_partial_render_with_id' ), 10, 3 );
$rendered = $partial->render();
$this->assertEquals( 'foo', $rendered );
$this->assertEquals( $count_filter_customize_partial_render + 1, $this->count_filter_customize_partial_render );
$this->assertEquals( $count_filter_customize_partial_render_with_id + 1, $this->count_filter_customize_partial_render_with_id );
$this->assertSame( 'foo', $rendered );
$this->assertSame( $count_filter_customize_partial_render + 1, $this->count_filter_customize_partial_render );
$this->assertSame( $count_filter_customize_partial_render_with_id + 1, $this->count_filter_customize_partial_render_with_id );
}
/**
@ -272,9 +272,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
add_filter( 'customize_partial_render', array( $this, 'filter_customize_partial_render' ), 10, 3 );
add_filter( "customize_partial_render_{$partial->id}", array( $this, 'filter_customize_partial_render_with_id' ), 10, 3 );
$rendered = $partial->render();
$this->assertEquals( 'bar', $rendered );
$this->assertEquals( $count_filter_customize_partial_render + 1, $this->count_filter_customize_partial_render );
$this->assertEquals( $count_filter_customize_partial_render_with_id + 1, $this->count_filter_customize_partial_render_with_id );
$this->assertSame( 'bar', $rendered );
$this->assertSame( $count_filter_customize_partial_render + 1, $this->count_filter_customize_partial_render );
$this->assertSame( $count_filter_customize_partial_render_with_id + 1, $this->count_filter_customize_partial_render_with_id );
}
/**

View File

@ -39,16 +39,16 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
function test_construct_default_args() {
$section = new WP_Customize_Section( $this->manager, 'foo' );
$this->assertInternalType( 'int', $section->instance_number );
$this->assertEquals( $this->manager, $section->manager );
$this->assertEquals( 'foo', $section->id );
$this->assertEquals( 160, $section->priority );
$this->assertEquals( 'edit_theme_options', $section->capability );
$this->assertEquals( '', $section->theme_supports );
$this->assertEquals( '', $section->title );
$this->assertEquals( '', $section->description );
$this->assertSame( $this->manager, $section->manager );
$this->assertSame( 'foo', $section->id );
$this->assertSame( 160, $section->priority );
$this->assertSame( 'edit_theme_options', $section->capability );
$this->assertSame( '', $section->theme_supports );
$this->assertSame( '', $section->title );
$this->assertSame( '', $section->description );
$this->assertEmpty( $section->panel );
$this->assertEquals( 'default', $section->type );
$this->assertEquals( array( $section, 'active_callback' ), $section->active_callback );
$this->assertSame( 'default', $section->type );
$this->assertSame( array( $section, 'active_callback' ), $section->active_callback );
}
/**
@ -70,7 +70,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
$section = new WP_Customize_Section( $this->manager, 'foo', $args );
foreach ( $args as $key => $value ) {
$this->assertEquals( $value, $section->$key );
$this->assertSame( $value, $section->$key );
}
}
@ -79,7 +79,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
*/
function test_construct_custom_type() {
$section = new Custom_Section_Test( $this->manager, 'foo' );
$this->assertEquals( 'titleless', $section->type );
$this->assertSame( 'titleless', $section->type );
}
/**
@ -133,9 +133,9 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
$section = new WP_Customize_Section( $this->manager, 'foo', $args );
$data = $section->json();
$this->assertEquals( 'foo', $data['id'] );
$this->assertSame( 'foo', $data['id'] );
foreach ( array( 'title', 'description', 'priority', 'panel', 'type' ) as $key ) {
$this->assertEquals( $args[ $key ], $data[ $key ] );
$this->assertSame( $args[ $key ], $data[ $key ] );
}
$this->assertEmpty( $data['content'] );
$this->assertTrue( $data['active'] );
@ -180,8 +180,8 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
$content = ob_get_clean();
$this->assertTrue( $section->check_capabilities() );
$this->assertEmpty( $content );
$this->assertEquals( $customize_render_section_count + 1, did_action( 'customize_render_section' ), 'Unexpected did_action count for customize_render_section' );
$this->assertEquals( 1, did_action( "customize_render_section_{$section->id}" ), "Unexpected did_action count for customize_render_section_{$section->id}" );
$this->assertSame( $customize_render_section_count + 1, did_action( 'customize_render_section' ), 'Unexpected did_action count for customize_render_section' );
$this->assertSame( 1, did_action( "customize_render_section_{$section->id}" ), "Unexpected did_action count for customize_render_section_{$section->id}" );
}
/**

View File

@ -79,7 +79,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
}
$output = json_decode( ob_get_clean(), true );
$this->assertFalse( $output['success'] );
$this->assertEquals( 'expected_customize_preview', $output['data'] );
$this->assertSame( 'expected_customize_preview', $output['data'] );
// Check expected_customize_preview.
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
@ -92,7 +92,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
}
$output = json_decode( ob_get_clean(), true );
$this->assertFalse( $output['success'] );
$this->assertEquals( 'expected_customize_preview', $output['data'] );
$this->assertSame( 'expected_customize_preview', $output['data'] );
// Check missing_partials.
$this->do_customize_boot_actions();
@ -104,7 +104,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
}
$output = json_decode( ob_get_clean(), true );
$this->assertFalse( $output['success'] );
$this->assertEquals( 'missing_partials', $output['data'] );
$this->assertSame( 'missing_partials', $output['data'] );
// Check missing_partials.
$_POST['partials'] = 'bad';
@ -113,11 +113,11 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
try {
$this->selective_refresh->handle_render_partials_request();
} catch ( WPDieException $e ) {
$this->assertEquals( '', $e->getMessage() );
$this->assertSame( '', $e->getMessage() );
}
$output = json_decode( ob_get_clean(), true );
$this->assertFalse( $output['success'] );
$this->assertEquals( 'malformed_partials', $output['data'] );
$this->assertSame( 'malformed_partials', $output['data'] );
}
/**
@ -156,7 +156,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
add_action( 'customize_render_partials_after', array( $this, 'handle_action_customize_render_partials_after' ), 10, 2 );
$this->selective_refresh->handle_render_partials_request();
} catch ( WPDieException $e ) {
$this->assertEquals( '', $e->getMessage() );
$this->assertSame( '', $e->getMessage() );
}
$output = json_decode( ob_get_clean(), true );
$this->assertTrue( $output['success'] );
@ -164,7 +164,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
$this->assertArrayHasKey( 'contents', $output['data'] );
$this->assertArrayHasKey( 'errors', $output['data'] );
$this->assertArrayHasKey( 'foo', $output['data']['contents'] );
$this->assertEquals( null, $output['data']['contents']['foo'] );
$this->assertNull( $output['data']['contents']['foo'] );
}
/**
@ -198,12 +198,12 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
add_action( 'customize_render_partials_after', array( $this, 'handle_action_customize_render_partials_after' ), 10, 2 );
$this->selective_refresh->handle_render_partials_request();
} catch ( WPDieException $e ) {
$this->assertEquals( '', $e->getMessage() );
$this->assertSame( '', $e->getMessage() );
}
$this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
$this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
$output = json_decode( ob_get_clean(), true );
$this->assertEquals( array( false ), $output['data']['contents']['foo'] );
$this->assertSame( array( false ), $output['data']['contents']['foo'] );
}
/**
@ -236,7 +236,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
try {
$this->selective_refresh->handle_render_partials_request();
} catch ( WPDieException $e ) {
$this->assertEquals( '', $e->getMessage() );
$this->assertSame( '', $e->getMessage() );
}
$output = json_decode( ob_get_clean(), true );
$this->assertNull( $output['data']['contents']['secret_message'] );
@ -266,7 +266,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
try {
$this->selective_refresh->handle_render_partials_request();
} catch ( WPDieException $e ) {
$this->assertEquals( '', $e->getMessage() );
$this->assertSame( '', $e->getMessage() );
}
$output = json_decode( ob_get_clean(), true );
$this->assertNull( $output['data']['contents']['bar'] );
@ -336,12 +336,12 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
add_action( 'customize_render_partials_after', array( $this, 'handle_action_customize_render_partials_after' ), 10, 2 );
$this->selective_refresh->handle_render_partials_request();
} catch ( WPDieException $e ) {
$this->assertEquals( '', $e->getMessage() );
$this->assertSame( '', $e->getMessage() );
}
$this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
$this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
$output = json_decode( ob_get_clean(), true );
$this->assertEquals( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_blogname'] );
$this->assertSame( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_blogname'] );
$this->assertArrayHasKey( 'setting_validities', $output['data'] );
}
@ -445,12 +445,12 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
add_action( 'customize_render_partials_after', array( $this, 'handle_action_customize_render_partials_after' ), 10, 2 );
$this->selective_refresh->handle_render_partials_request();
} catch ( WPDieException $e ) {
$this->assertEquals( '', $e->getMessage() );
$this->assertSame( '', $e->getMessage() );
}
$this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
$this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
$output = json_decode( ob_get_clean(), true );
$this->assertEquals( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_dynamic_blogname'] );
$this->assertSame( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_dynamic_blogname'] );
}
/**
@ -497,13 +497,13 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
add_action( 'customize_render_partials_after', array( $this, 'handle_action_customize_render_partials_after' ), 10, 2 );
$this->selective_refresh->handle_render_partials_request();
} catch ( WPDieException $e ) {
$this->assertEquals( '', $e->getMessage() );
$this->assertSame( '', $e->getMessage() );
}
$this->assertEquals( $count_customize_render_partials_before + 1, has_action( 'customize_render_partials_before' ) );
$this->assertEquals( $count_customize_render_partials_after + 1, has_action( 'customize_render_partials_after' ) );
$output = json_decode( ob_get_clean(), true );
$this->assertEquals( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_blogname'] );
$this->assertEquals( array_fill( 0, 2, get_bloginfo( 'description', 'display' ) ), $output['data']['contents']['test_blogdescription'] );
$this->assertSame( array( get_bloginfo( 'name', 'display' ) ), $output['data']['contents']['test_blogname'] );
$this->assertSame( array_fill( 0, 2, get_bloginfo( 'description', 'display' ) ), $output['data']['contents']['test_blogdescription'] );
}
/**

View File

@ -45,7 +45,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
* @see WP_Customize_Selective_Refresh::__construct()
*/
function test_construct() {
$this->assertEquals( $this->selective_refresh, $this->wp_customize->selective_refresh );
$this->assertSame( $this->selective_refresh, $this->wp_customize->selective_refresh );
}
/**
@ -83,9 +83,9 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
*/
function test_crud_partial() {
$partial = $this->selective_refresh->add_partial( 'foo' );
$this->assertEquals( $this->selective_refresh, $partial->component );
$this->assertSame( $this->selective_refresh, $partial->component );
$this->assertInstanceOf( 'WP_Customize_Partial', $partial );
$this->assertEquals( $partial, $this->selective_refresh->get_partial( $partial->id ) );
$this->assertSame( $partial, $this->selective_refresh->get_partial( $partial->id ) );
$this->assertArrayHasKey( $partial->id, $this->selective_refresh->partials() );
$this->selective_refresh->remove_partial( $partial->id );
@ -93,8 +93,8 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
$this->assertArrayNotHasKey( $partial->id, $this->selective_refresh->partials() );
$partial = new WP_Customize_Partial( $this->selective_refresh, 'bar' );
$this->assertEquals( $partial, $this->selective_refresh->add_partial( $partial ) );
$this->assertEquals( $partial, $this->selective_refresh->get_partial( 'bar' ) );
$this->assertSame( $partial, $this->selective_refresh->add_partial( $partial ) );
$this->assertSame( $partial, $this->selective_refresh->get_partial( 'bar' ) );
$this->assertEqualSets( array( 'bar' ), array_keys( $this->selective_refresh->partials() ) );
add_filter( 'customize_dynamic_partial_args', array( $this, 'filter_customize_dynamic_partial_args' ), 10, 2 );
@ -102,7 +102,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
$partial = $this->selective_refresh->add_partial( 'recognized-class' );
$this->assertInstanceOf( 'Tested_Custom_Partial', $partial );
$this->assertEquals( '.recognized', $partial->selector );
$this->assertSame( '.recognized', $partial->selector );
}
/**
@ -112,8 +112,8 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
*/
function test_init_preview() {
$this->selective_refresh->init_preview();
$this->assertEquals( 10, has_action( 'template_redirect', array( $this->selective_refresh, 'handle_render_partials_request' ) ) );
$this->assertEquals( 10, has_action( 'wp_enqueue_scripts', array( $this->selective_refresh, 'enqueue_preview_scripts' ) ) );
$this->assertSame( 10, has_action( 'template_redirect', array( $this->selective_refresh, 'handle_render_partials_request' ) ) );
$this->assertSame( 10, has_action( 'wp_enqueue_scripts', array( $this->selective_refresh, 'enqueue_preview_scripts' ) ) );
}
/**
@ -126,7 +126,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
$this->assertNotContains( 'customize-selective-refresh', $scripts->queue );
$this->selective_refresh->enqueue_preview_scripts();
$this->assertContains( 'customize-selective-refresh', $scripts->queue );
$this->assertEquals( 1000, has_action( 'wp_footer', array( $this->selective_refresh, 'export_preview_data' ) ) );
$this->assertSame( 1000, has_action( 'wp_footer', array( $this->selective_refresh, 'export_preview_data' ) ) );
}
/**
@ -168,7 +168,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
$this->assertInternalType( 'array', $exported_data['partials'] );
$this->assertArrayHasKey( 'blogname', $exported_data['partials'] );
$this->assertArrayNotHasKey( 'top_secret_message', $exported_data['partials'] );
$this->assertEquals( '#site-title', $exported_data['partials']['blogname']['selector'] );
$this->assertSame( '#site-title', $exported_data['partials']['blogname']['selector'] );
$this->assertArrayHasKey( 'renderQueryVar', $exported_data );
$this->assertArrayHasKey( 'l10n', $exported_data );
}
@ -194,7 +194,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
$this->assertInstanceOf( 'Tested_Custom_Partial', $this->selective_refresh->get_partial( 'recognized-class' ) );
$this->assertNotInstanceOf( 'Tested_Custom_Partial', $this->selective_refresh->get_partial( 'recognized' ) );
$this->assertEquals( '.recognized', $this->selective_refresh->get_partial( 'recognized' )->selector );
$this->assertSame( '.recognized', $this->selective_refresh->get_partial( 'recognized' )->selector );
}
/**

View File

@ -33,19 +33,19 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
function test_constructor_without_args() {
$setting = new WP_Customize_Setting( $this->manager, 'foo' );
$this->assertEquals( $this->manager, $setting->manager );
$this->assertEquals( 'foo', $setting->id );
$this->assertEquals( 'theme_mod', $setting->type );
$this->assertEquals( 'edit_theme_options', $setting->capability );
$this->assertEquals( '', $setting->theme_supports );
$this->assertEquals( '', $setting->default );
$this->assertEquals( 'refresh', $setting->transport );
$this->assertEquals( '', $setting->sanitize_callback );
$this->assertEquals( '', $setting->sanitize_js_callback );
$this->assertSame( $this->manager, $setting->manager );
$this->assertSame( 'foo', $setting->id );
$this->assertSame( 'theme_mod', $setting->type );
$this->assertSame( 'edit_theme_options', $setting->capability );
$this->assertSame( '', $setting->theme_supports );
$this->assertSame( '', $setting->default );
$this->assertSame( 'refresh', $setting->transport );
$this->assertSame( '', $setting->sanitize_callback );
$this->assertSame( '', $setting->sanitize_js_callback );
$this->assertFalse( has_filter( "customize_validate_{$setting->id}" ) );
$this->assertFalse( has_filter( "customize_sanitize_{$setting->id}" ) );
$this->assertFalse( has_filter( "customize_sanitize_js_{$setting->id}" ) );
$this->assertEquals( false, $setting->dirty );
$this->assertFalse( $setting->dirty );
}
/**
@ -100,13 +100,13 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
'sanitize_js_callback' => array( $this, 'sanitize_js_callback_for_tests' ),
);
$setting = new WP_Customize_Setting( $this->manager, 'bar', $args );
$this->assertEquals( 'bar', $setting->id );
$this->assertSame( 'bar', $setting->id );
foreach ( $args as $key => $value ) {
$this->assertEquals( $value, $setting->$key );
$this->assertSame( $value, $setting->$key );
}
$this->assertEquals( 10, has_filter( "customize_validate_{$setting->id}", $args['validate_callback'] ) );
$this->assertEquals( 10, has_filter( "customize_sanitize_{$setting->id}", $args['sanitize_callback'] ) );
$this->assertEquals( 10, has_filter( "customize_sanitize_js_{$setting->id}", $args['sanitize_js_callback'] ) );
$this->assertSame( 10, has_filter( "customize_validate_{$setting->id}", $args['validate_callback'] ) );
$this->assertSame( 10, has_filter( "customize_sanitize_{$setting->id}", $args['sanitize_callback'] ) );
$this->assertSame( 10, has_filter( "customize_sanitize_js_{$setting->id}", $args['sanitize_js_callback'] ) );
}
public $post_data_overrides = array(
@ -146,11 +146,11 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$name = "unset_{$type}_without_post_value";
$default = "default_value_{$name}";
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
$this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );
$this->assertEquals( $default, $setting->value() );
$this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );
$this->assertSame( $default, $setting->value() );
$this->assertTrue( $setting->preview(), 'Preview should not no-op since setting has no existing value.' );
$this->assertEquals( $default, call_user_func( $type_options['getter'], $name, $this->undefined ), sprintf( 'Expected %s(%s) to return setting default: %s.', $type_options['getter'], $name, $default ) );
$this->assertEquals( $default, $setting->value() );
$this->assertSame( $default, call_user_func( $type_options['getter'], $name, $this->undefined ), sprintf( 'Expected %s(%s) to return setting default: %s.', $type_options['getter'], $name, $default ) );
$this->assertSame( $default, $setting->value() );
// Non-multidimensional: See what effect the preview has on an extant setting (default value should not be seen).
$name = "set_{$type}_without_post_value";
@ -158,40 +158,40 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$initial_value = "initial_value_{$name}";
call_user_func( $type_options['setter'], $name, $initial_value );
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
$this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) );
$this->assertEquals( $initial_value, $setting->value() );
$this->assertSame( $initial_value, call_user_func( $type_options['getter'], $name ) );
$this->assertSame( $initial_value, $setting->value() );
$this->assertFalse( $setting->preview(), 'Preview should no-op since setting value was extant and no post value was present.' );
$this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name ) );
$this->assertEquals( $initial_value, $setting->value() );
$this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertSame( $initial_value, call_user_func( $type_options['getter'], $name ) );
$this->assertSame( $initial_value, $setting->value() );
// Non-multidimensional: Try updating a value that had a no-op preview.
$overridden_value = "overridden_value_$name";
call_user_func( $type_options['setter'], $name, $overridden_value );
$message = 'Initial value should be overridden because initial preview() was no-op due to setting having existing value and/or post value was absent.';
$this->assertEquals( $overridden_value, call_user_func( $type_options['getter'], $name ), $message );
$this->assertEquals( $overridden_value, $setting->value(), $message );
$this->assertSame( $overridden_value, call_user_func( $type_options['getter'], $name ), $message );
$this->assertSame( $overridden_value, $setting->value(), $message );
$this->assertNotEquals( $initial_value, $setting->value(), $message );
// Non-multidimensional: Ensure that setting a post value *after* preview() is called results in the post value being seen (deferred preview).
$post_value = "post_value_for_{$setting->id}_set_after_preview_called";
$this->assertEquals( 0, did_action( "customize_post_value_set_{$setting->id}" ) );
$this->assertSame( 0, did_action( "customize_post_value_set_{$setting->id}" ) );
$this->manager->set_post_value( $setting->id, $post_value );
$this->assertEquals( 1, did_action( "customize_post_value_set_{$setting->id}" ) );
$this->assertSame( 1, did_action( "customize_post_value_set_{$setting->id}" ) );
$this->assertNotEquals( $overridden_value, $setting->value() );
$this->assertEquals( $post_value, call_user_func( $type_options['getter'], $name ) );
$this->assertEquals( $post_value, $setting->value() );
$this->assertSame( $post_value, call_user_func( $type_options['getter'], $name ) );
$this->assertSame( $post_value, $setting->value() );
// Non-multidimensional: Test unset setting being overridden by a post value.
$name = "unset_{$type}_overridden";
$default = "default_value_{$name}";
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
$this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );
$this->assertEquals( $default, $setting->value() );
$this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $name, $this->undefined ) );
$this->assertSame( $default, $setting->value() );
$this->assertTrue( $setting->preview(), 'Preview applies because setting has post_data_overrides.' ); // Activate post_data.
$this->assertEquals( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );
$this->assertEquals( $this->post_data_overrides[ $name ], $setting->value() );
$this->assertSame( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );
$this->assertSame( $this->post_data_overrides[ $name ], $setting->value() );
// Non-multidimensional: Test set setting being overridden by a post value.
$name = "set_{$type}_overridden";
@ -199,13 +199,13 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$initial_value = "initial_value_{$name}";
call_user_func( $type_options['setter'], $name, $initial_value );
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
$this->assertEquals( $initial_value, call_user_func( $type_options['getter'], $name, $this->undefined ) );
$this->assertEquals( $initial_value, $setting->value() );
$this->assertSame( $initial_value, call_user_func( $type_options['getter'], $name, $this->undefined ) );
$this->assertSame( $initial_value, $setting->value() );
$this->assertTrue( $setting->preview(), 'Preview applies because setting has post_data_overrides.' ); // Activate post_data.
$this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertEquals( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );
$this->assertEquals( $this->post_data_overrides[ $name ], $setting->value() );
$this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertSame( $this->post_data_overrides[ $name ], call_user_func( $type_options['getter'], $name, $this->undefined ) );
$this->assertSame( $this->post_data_overrides[ $name ], $setting->value() );
}
}
@ -225,12 +225,12 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$name = $base_name . '[foo]';
$default = "default_value_{$name}";
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
$this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
$this->assertEquals( $default, $setting->value() );
$this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
$this->assertSame( $default, $setting->value() );
$this->assertTrue( $setting->preview(), "Preview for $setting->id should apply because setting is not in DB." );
$base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined );
$this->assertArrayHasKey( 'foo', $base_value );
$this->assertEquals( $default, $base_value['foo'] );
$this->assertSame( $default, $base_value['foo'] );
// Multidimensional: See what effect the preview has on an extant setting (default value should not be seen) without post value.
$base_name = "set_{$type}_multi";
@ -244,35 +244,35 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
call_user_func( $type_options['setter'], $base_name, $base_initial_value );
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
$base_value = call_user_func( $type_options['getter'], $base_name, array() );
$this->assertEquals( $initial_value, $base_value['foo'] );
$this->assertEquals( $initial_value, $setting->value() );
$this->assertSame( $initial_value, $base_value['foo'] );
$this->assertSame( $initial_value, $setting->value() );
$this->assertFalse( $setting->preview(), "Preview for $setting->id should no-op because setting is in DB and post value is absent." );
$this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
$base_value = call_user_func( $type_options['getter'], $base_name, array() );
$this->assertEquals( $initial_value, $base_value['foo'] );
$this->assertEquals( $initial_value, $setting->value() );
$this->assertSame( $initial_value, $base_value['foo'] );
$this->assertSame( $initial_value, $setting->value() );
// Multidimensional: Ensure that setting a post value *after* preview() is called results in the post value being seen (deferred preview).
$override_value = "post_value_for_{$setting->id}_set_after_preview_called";
$this->manager->set_post_value( $setting->id, $override_value );
$base_value = call_user_func( $type_options['getter'], $base_name, array() );
$this->assertEquals( $override_value, $base_value['foo'] );
$this->assertEquals( $override_value, $setting->value() );
$this->assertSame( $override_value, $base_value['foo'] );
$this->assertSame( $override_value, $setting->value() );
// Multidimensional: Test unset setting being overridden by a post value.
$base_name = "unset_{$type}_multi_overridden";
$name = $base_name . '[foo]';
$default = "default_value_{$name}";
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
$this->assertEquals( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
$this->assertEquals( $default, $setting->value() );
$this->assertSame( $this->undefined, call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
$this->assertSame( $default, $setting->value() );
$this->assertTrue( $setting->preview(), "Preview for $setting->id should apply because a post value is present." );
$this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
$base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined );
$this->assertArrayHasKey( 'foo', $base_value );
$this->assertEquals( $this->post_data_overrides[ $name ], $base_value['foo'] );
$this->assertSame( $this->post_data_overrides[ $name ], $base_value['foo'] );
// Multidimensional: Test set setting being overridden by a post value.
$base_name = "set_{$type}_multi_overridden";
@ -288,21 +288,21 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined );
$this->assertArrayHasKey( 'foo', $base_value );
$this->assertArrayHasKey( 'bar', $base_value );
$this->assertEquals( $base_initial_value['foo'], $base_value['foo'] );
$this->assertSame( $base_initial_value['foo'], $base_value['foo'] );
$getter = call_user_func( $type_options['getter'], $base_name, $this->undefined );
$this->assertEquals( $base_initial_value['bar'], $getter['bar'] );
$this->assertEquals( $initial_value, $setting->value() );
$this->assertSame( $base_initial_value['bar'], $getter['bar'] );
$this->assertSame( $initial_value, $setting->value() );
$this->assertTrue( $setting->preview(), "Preview for $setting->id should apply because post value is present." );
$this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertEquals( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ) ); // Only applicable for custom types (not options or theme_mods).
$this->assertSame( 0, did_action( "customize_preview_{$setting->type}" ) ); // Only applicable for custom types (not options or theme_mods).
$base_value = call_user_func( $type_options['getter'], $base_name, $this->undefined );
$this->assertArrayHasKey( 'foo', $base_value );
$this->assertEquals( $this->post_data_overrides[ $name ], $base_value['foo'] );
$this->assertSame( $this->post_data_overrides[ $name ], $base_value['foo'] );
$this->assertArrayHasKey( 'bar', call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
$getter = call_user_func( $type_options['getter'], $base_name, $this->undefined );
$this->assertEquals( $base_initial_value['bar'], $getter['bar'] );
$this->assertSame( $base_initial_value['bar'], $getter['bar'] );
}
}
@ -343,7 +343,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$name = preg_replace( '/^customize_value_/', '', current_filter() );
$this->assertInstanceOf( 'WP_Customize_Setting', $setting );
$id_data = $setting->id_data();
$this->assertEquals( $name, $id_data['base'] );
$this->assertSame( $name, $id_data['base'] );
return $this->custom_type_getter( $name, $default );
}
@ -381,13 +381,13 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
// Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need.
add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 );
$this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );
$this->assertEquals( $default, $setting->value() );
$this->assertSame( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );
$this->assertSame( $default, $setting->value() );
$this->assertTrue( $setting->preview() );
$this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) );
$this->assertEquals( 1, did_action( "customize_preview_{$setting->type}" ) );
$this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); // Note: for a non-custom type this is $default.
$this->assertEquals( $default, $setting->value() ); // Should be same as above.
$this->assertSame( 1, did_action( "customize_preview_{$setting->id}" ) );
$this->assertSame( 1, did_action( "customize_preview_{$setting->type}" ) );
$this->assertSame( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); // Note: for a non-custom type this is $default.
$this->assertSame( $default, $setting->value() ); // Should be same as above.
// Custom type existing and no post value override.
$name = "set_{$type}_without_post_value";
@ -397,19 +397,19 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
// Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need.
add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 );
$this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );
$this->assertEquals( $initial_value, $setting->value() );
$this->assertSame( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );
$this->assertSame( $initial_value, $setting->value() );
$this->assertFalse( $setting->preview(), "Preview for $setting->id should not apply because existing type without an override." );
$this->assertEquals( 0, did_action( "customize_preview_{$setting->id}" ), 'Zero preview actions because initial value is set with no incoming post value, so there is no preview to apply.' );
$this->assertEquals( 1, did_action( "customize_preview_{$setting->type}" ) );
$this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above.
$this->assertEquals( $initial_value, $setting->value() ); // Should be same as above.
$this->assertSame( 0, did_action( "customize_preview_{$setting->id}" ), 'Zero preview actions because initial value is set with no incoming post value, so there is no preview to apply.' );
$this->assertSame( 1, did_action( "customize_preview_{$setting->type}" ) );
$this->assertSame( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above.
$this->assertSame( $initial_value, $setting->value() ); // Should be same as above.
// Custom type deferred preview (setting post value after preview ran).
$override_value = "custom_type_value_{$name}_override_deferred_preview";
$this->manager->set_post_value( $setting->id, $override_value );
$this->assertEquals( $override_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above.
$this->assertEquals( $override_value, $setting->value() ); // Should be same as above.
$this->assertSame( $override_value, $this->custom_type_getter( $name, $this->undefined ) ); // Should be same as above.
$this->assertSame( $override_value, $setting->value() ); // Should be same as above.
// Custom type not existing and with a post value override.
$name = "unset_{$type}_with_post_value";
@ -417,13 +417,13 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
// Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need.
add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 );
$this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );
$this->assertEquals( $default, $setting->value() );
$this->assertSame( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) );
$this->assertSame( $default, $setting->value() );
$this->assertTrue( $setting->preview() );
$this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ), 'One preview action now because initial value was not set and/or there is no incoming post value, so there is is a preview to apply.' );
$this->assertEquals( 3, did_action( "customize_preview_{$setting->type}" ) );
$this->assertEquals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );
$this->assertEquals( $post_data_overrides[ $name ], $setting->value() );
$this->assertSame( 1, did_action( "customize_preview_{$setting->id}" ), 'One preview action now because initial value was not set and/or there is no incoming post value, so there is is a preview to apply.' );
$this->assertSame( 3, did_action( "customize_preview_{$setting->type}" ) );
$this->assertSame( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );
$this->assertSame( $post_data_overrides[ $name ], $setting->value() );
// Custom type not existing and with a post value override.
$name = "set_{$type}_with_post_value";
@ -433,13 +433,13 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
// Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need.
add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 );
$this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );
$this->assertEquals( $initial_value, $setting->value() );
$this->assertSame( $initial_value, $this->custom_type_getter( $name, $this->undefined ) );
$this->assertSame( $initial_value, $setting->value() );
$this->assertTrue( $setting->preview() );
$this->assertEquals( 1, did_action( "customize_preview_{$setting->id}" ) );
$this->assertEquals( 4, did_action( "customize_preview_{$setting->type}" ) );
$this->assertEquals( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );
$this->assertEquals( $post_data_overrides[ $name ], $setting->value() );
$this->assertSame( 1, did_action( "customize_preview_{$setting->id}" ) );
$this->assertSame( 4, did_action( "customize_preview_{$setting->type}" ) );
$this->assertSame( $post_data_overrides[ $name ], $this->custom_type_getter( $name, $this->undefined ) );
$this->assertSame( $post_data_overrides[ $name ], $setting->value() );
// Custom type that does not handle supplying the post value from the customize_value_{$id_base} filter.
$setting_id = 'custom_without_previewing_value_filter';
@ -478,11 +478,11 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$name = 'unset_option_without_post_value';
$default = "default_value_{$name}";
$setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) );
$this->assertEquals( $this->undefined, get_option( $name, $this->undefined ) );
$this->assertEquals( $default, $setting->value() );
$this->assertSame( $this->undefined, get_option( $name, $this->undefined ) );
$this->assertSame( $default, $setting->value() );
$this->assertTrue( $setting->preview() );
$this->assertEquals( $default, get_option( $name, $this->undefined ), sprintf( 'Expected get_option(%s) to return setting default: %s.', $name, $default ) );
$this->assertEquals( $default, $setting->value() );
$this->assertSame( $default, get_option( $name, $this->undefined ), sprintf( 'Expected get_option(%s) to return setting default: %s.', $name, $default ) );
$this->assertSame( $default, $setting->value() );
}
/**
@ -527,7 +527,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
* @param WP_Customize_Setting $setting
*/
function handle_customize_update_custom_foo_action( $value, $setting = null ) {
$this->assertEquals( 'hello world \\o/', $value );
$this->assertSame( 'hello world \\o/', $value );
$this->assertInstanceOf( 'WP_Customize_Setting', $setting );
}
@ -539,8 +539,8 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
*/
function handle_customize_save_custom_foo_action( $setting ) {
$this->assertInstanceOf( 'WP_Customize_Setting', $setting );
$this->assertEquals( 'custom', $setting->type );
$this->assertEquals( 'foo', $setting->id );
$this->assertSame( 'custom', $setting->type );
$this->assertSame( 'foo', $setting->id );
}
/**
@ -561,8 +561,8 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$this->assertTrue( $setting->preview() );
$this->assertTrue( $setting->is_current_blog_previewed() );
$this->assertEquals( $post_value, $setting->value() );
$this->assertEquals( $post_value, get_option( $name ) );
$this->assertSame( $post_value, $setting->value() );
$this->assertSame( $post_value, get_option( $name ) );
}
/**
@ -610,8 +610,8 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$this->manager->set_post_value( $setting->id, $value );
$setting->save();
$autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $setting->id ) );
$this->assertEquals( 'yes', $autoload );
$this->assertEquals( $value, get_option( $name ) );
$this->assertSame( 'yes', $autoload );
$this->assertSame( $value, get_option( $name ) );
$name = 'autoloaded2';
$setting = new WP_Customize_Setting(
@ -626,8 +626,8 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$this->manager->set_post_value( $setting->id, $value );
$setting->save();
$autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $setting->id ) );
$this->assertEquals( 'yes', $autoload );
$this->assertEquals( $value, get_option( $name ) );
$this->assertSame( 'yes', $autoload );
$this->assertSame( $value, get_option( $name ) );
$name = 'not-autoloaded1';
$setting = new WP_Customize_Setting(
@ -642,8 +642,8 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$this->manager->set_post_value( $setting->id, $value );
$setting->save();
$autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $setting->id ) );
$this->assertEquals( 'no', $autoload );
$this->assertEquals( $value, get_option( $name ) );
$this->assertSame( 'no', $autoload );
$this->assertSame( $value, get_option( $name ) );
$id_base = 'multi-not-autoloaded';
$setting1 = new WP_Customize_Setting(
@ -665,7 +665,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$this->manager->set_post_value( $setting2->id, 'value2' );
$setting1->save();
$autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $id_base ) );
$this->assertEquals( 'no', $autoload, 'Even though setting1 did not indicate autoload (thus normally true), since another multidimensional option setting of the base did say autoload=false, it should be autoload=no' );
$this->assertSame( 'no', $autoload, 'Even though setting1 did not indicate autoload (thus normally true), since another multidimensional option setting of the base did say autoload=false, it should be autoload=no' );
}
/**
@ -685,18 +685,18 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
);
$setting = new WP_Customize_Setting( $this->manager, 'name', $args );
$this->assertEquals( $default, $setting->value() );
$this->assertEquals( base64_encode( $default ), $setting->js_value() );
$this->assertSame( $default, $setting->value() );
$this->assertSame( base64_encode( $default ), $setting->js_value() );
$exported = $setting->json();
$this->assertArrayHasKey( 'type', $exported );
$this->assertArrayHasKey( 'value', $exported );
$this->assertArrayHasKey( 'transport', $exported );
$this->assertArrayHasKey( 'dirty', $exported );
$this->assertEquals( $setting->js_value(), $exported['value'] );
$this->assertEquals( $args['type'], $setting->type );
$this->assertEquals( $args['transport'], $setting->transport );
$this->assertEquals( $args['dirty'], $setting->dirty );
$this->assertSame( $setting->js_value(), $exported['value'] );
$this->assertSame( $args['type'], $setting->type );
$this->assertSame( $args['transport'], $setting->transport );
$this->assertSame( $args['dirty'], $setting->dirty );
}
/**
@ -715,7 +715,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
);
$validity = $setting->validate( 'BAD!' );
$this->assertInstanceOf( 'WP_Error', $validity );
$this->assertEquals( 'invalid_key', $validity->get_error_code() );
$this->assertSame( 'invalid_key', $validity->get_error_code() );
}
/**
@ -756,13 +756,13 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
$setting_id = 'nav_menu_locations[primary]';
$setting = new WP_Customize_Setting( $this->manager, $setting_id );
$this->assertEquals( $initial_value, $setting->value() );
$this->assertSame( $initial_value, $setting->value() );
$override_value = -123456;
$this->manager->set_post_value( $setting_id, $override_value );
$setting->preview();
$this->assertEquals( $override_value, $setting->value() );
$this->assertSame( $override_value, $setting->value() );
}
}

View File

@ -38,7 +38,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
$this->assertArrayHasKey( 2, get_option( 'widget_search' ) );
$widget_categories = get_option( 'widget_categories' );
$this->assertArrayHasKey( 2, $widget_categories );
$this->assertEquals( '', $widget_categories[2]['title'] );
$this->assertSame( '', $widget_categories[2]['title'] );
$this->backup_registered_sidebars = $GLOBALS['wp_registered_sidebars'];
@ -90,7 +90,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
*/
function test_construct() {
$this->assertInstanceOf( 'WP_Customize_Widgets', $this->manager->widgets );
$this->assertEquals( $this->manager, $this->manager->widgets->manager );
$this->assertSame( $this->manager, $this->manager->widgets->manager );
}
/**
@ -105,7 +105,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
delete_option( 'sidebars_widgets' );
register_sidebar( array( 'id' => $sidebar_id ) );
$this->manager->widgets->customize_register();
$this->assertEquals( array_fill_keys( array( 'wp_inactive_widgets', $sidebar_id ), array() ), wp_get_sidebars_widgets() );
$this->assertSame( array_fill_keys( array( 'wp_inactive_widgets', $sidebar_id ), array() ), wp_get_sidebars_widgets() );
}
/**
@ -121,7 +121,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
$selective_refreshable_widgets = $this->manager->widgets->get_selective_refreshable_widgets();
$this->assertInternalType( 'array', $selective_refreshable_widgets );
$this->assertEquals( count( $wp_widget_factory->widgets ), count( $selective_refreshable_widgets ) );
$this->assertSame( count( $wp_widget_factory->widgets ), count( $selective_refreshable_widgets ) );
$this->assertArrayHasKey( 'text', $selective_refreshable_widgets );
$this->assertTrue( $selective_refreshable_widgets['text'] );
$this->assertArrayHasKey( 'search', $selective_refreshable_widgets );
@ -206,18 +206,18 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
$setting = $this->manager->get_setting( 'widget_categories[2]' );
$this->assertNotEmpty( $setting, 'Expected setting for pre-existing widget category-2, being customized.' );
$this->assertEquals( $expected_transport, $setting->transport );
$this->assertSame( $expected_transport, $setting->transport );
$setting = $this->manager->get_setting( 'widget_search[2]' );
$this->assertNotEmpty( $setting, 'Expected setting for pre-existing widget search-2, not being customized.' );
$this->assertEquals( $expected_transport, $setting->transport );
$this->assertSame( $expected_transport, $setting->transport );
$setting = $this->manager->get_setting( 'widget_search[3]' );
$this->assertNotEmpty( $setting, 'Expected dynamic setting for non-existing widget search-3, being customized.' );
$this->assertEquals( $expected_transport, $setting->transport );
$this->assertSame( $expected_transport, $setting->transport );
$widget_categories = get_option( 'widget_categories' );
$this->assertEquals( $raw_widget_customized['widget_categories[2]'], $widget_categories[2], 'Expected $wp_customize->get_setting(widget_categories[2])->preview() to have been called.' );
$this->assertSame( $raw_widget_customized['widget_categories[2]'], $widget_categories[2], 'Expected $wp_customize->get_setting(widget_categories[2])->preview() to have been called.' );
}
/**
@ -267,9 +267,9 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
);
$args = $this->manager->widgets->get_setting_args( 'widget_foo[2]' );
foreach ( $default_args as $key => $default_value ) {
$this->assertEquals( $default_value, $args[ $key ] );
$this->assertSame( $default_value, $args[ $key ] );
}
$this->assertEquals( 'WIDGET_FOO[2]', $args['uppercase_id_set_by_filter'] );
$this->assertSame( 'WIDGET_FOO[2]', $args['uppercase_id_set_by_filter'] );
$default_args = array(
'type' => 'option',
@ -281,12 +281,12 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
);
$args = $this->manager->widgets->get_setting_args( 'widget_search[2]' );
foreach ( $default_args as $key => $default_value ) {
$this->assertEquals( $default_value, $args[ $key ] );
$this->assertSame( $default_value, $args[ $key ] );
}
remove_theme_support( 'customize-selective-refresh-widgets' );
$args = $this->manager->widgets->get_setting_args( 'widget_search[2]' );
$this->assertEquals( 'refresh', $args['transport'] );
$this->assertSame( 'refresh', $args['transport'] );
add_theme_support( 'customize-selective-refresh-widgets' );
$override_args = array(
@ -299,9 +299,9 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
);
$args = $this->manager->widgets->get_setting_args( 'widget_bar[3]', $override_args );
foreach ( $override_args as $key => $override_value ) {
$this->assertEquals( $override_value, $args[ $key ] );
$this->assertSame( $override_value, $args[ $key ] );
}
$this->assertEquals( 'WIDGET_BAR[3]', $args['uppercase_id_set_by_filter'] );
$this->assertSame( 'WIDGET_BAR[3]', $args['uppercase_id_set_by_filter'] );
$default_args = array(
'type' => 'option',
@ -313,9 +313,9 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
);
$args = $this->manager->widgets->get_setting_args( 'sidebars_widgets[sidebar-1]' );
foreach ( $default_args as $key => $default_value ) {
$this->assertEquals( $default_value, $args[ $key ] );
$this->assertSame( $default_value, $args[ $key ] );
}
$this->assertEquals( 'SIDEBARS_WIDGETS[SIDEBAR-1]', $args['uppercase_id_set_by_filter'] );
$this->assertSame( 'SIDEBARS_WIDGETS[SIDEBAR-1]', $args['uppercase_id_set_by_filter'] );
$override_args = array(
'type' => 'theme_mod',
@ -327,9 +327,9 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
);
$args = $this->manager->widgets->get_setting_args( 'sidebars_widgets[sidebar-2]', $override_args );
foreach ( $override_args as $key => $override_value ) {
$this->assertEquals( $override_value, $args[ $key ] );
$this->assertSame( $override_value, $args[ $key ] );
}
$this->assertEquals( 'SIDEBARS_WIDGETS[SIDEBAR-2]', $args['uppercase_id_set_by_filter'] );
$this->assertSame( 'SIDEBARS_WIDGETS[SIDEBAR-2]', $args['uppercase_id_set_by_filter'] );
}
function filter_widget_customizer_setting_args( $args, $id ) {
@ -353,7 +353,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
$sanitized_for_js = $this->manager->widgets->sanitize_widget_js_instance( $new_categories_instance );
$this->assertArrayHasKey( 'encoded_serialized_instance', $sanitized_for_js );
$this->assertTrue( is_serialized( base64_decode( $sanitized_for_js['encoded_serialized_instance'] ), true ) );
$this->assertEquals( $new_categories_instance['title'], $sanitized_for_js['title'] );
$this->assertSame( $new_categories_instance['title'], $sanitized_for_js['title'] );
$this->assertTrue( $sanitized_for_js['is_widget_customizer_js_value'] );
$this->assertArrayHasKey( 'instance_hash_key', $sanitized_for_js );
@ -362,7 +362,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
$this->assertNull( $this->manager->widgets->sanitize_widget_instance( $corrupted_sanitized_for_js ), 'Expected sanitize_widget_instance to reject corrupted data.' );
$unsanitized_from_js = $this->manager->widgets->sanitize_widget_instance( $sanitized_for_js );
$this->assertEquals( $unsanitized_from_js, $new_categories_instance );
$this->assertSame( $unsanitized_from_js, $new_categories_instance );
}
/**
@ -425,14 +425,14 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
$control = $this->manager->get_control( 'widget_search[2]' );
$params = $control->json();
$this->assertEquals( 'widget_form', $params['type'] );
$this->assertSame( 'widget_form', $params['type'] );
$this->assertRegExp( '#^<li[^>]+>\s*</li>$#', $params['content'] );
$this->assertRegExp( '#^<div[^>]*class=\'widget\'[^>]*#s', $params['widget_control'] );
$this->assertContains( '<div class="widget-content"></div>', $params['widget_control'] );
$this->assertNotContains( '<input class="widefat"', $params['widget_control'] );
$this->assertContains( '<input class="widefat"', $params['widget_content'] );
$this->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( '<!--dynamic_sidebar_before:foo:1-->', trim( $output ) );
$this->assertSame( '<!--dynamic_sidebar_before:foo:1-->', 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'] = ' <oops>';
$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( '<!--dynamic_sidebar_after:foo:1-->', trim( $output ) );
$this->assertSame( '<!--dynamic_sidebar_after:foo:1-->', 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 );
}

View File

@ -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() {

View File

@ -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 ) );
}
}

View File

@ -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 ) );
}
/**

View File

@ -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 ) );
}
}

View File

@ -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 ) );
}
}

View File

@ -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 ) );
}
}

View File

@ -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 ) );
}
}

View File

@ -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 ) {

View File

@ -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 ) );
}
}

View File

@ -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 */

View File

@ -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() );
}
}

View File

@ -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 ) );
}
}

View File

@ -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() );
}
/**

View File

@ -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'

View File

@ -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 );
}
/**

View File

@ -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 );
}

View File

@ -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
);

View File

@ -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' ) );

View File

@ -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 );
}
/**

View File

@ -51,10 +51,10 @@ JS;
$expected .= "<script type='text/javascript' src='http://example.com?ver=1.2' id='empty-deps-version-js'></script>\n";
$expected .= "<script type='text/javascript' src='http://example.com' id='empty-deps-null-version-js'></script>\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 = "<script src='http://example.com?ver=$ver' id='empty-deps-no-version-js'></script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -110,10 +110,10 @@ JS;
$expected .= "<script type='text/javascript' src='{$wp_scripts->base_url}ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver' id='jquery-ftp-js'></script>\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 = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=one,two,three&amp;ver={$ver}'></script>\n";
$this->assertEquals( $expected, $print_scripts );
$this->assertSame( $expected, $print_scripts );
}
/**
@ -154,10 +154,10 @@ JS;
$expected .= "<script type='text/javascript' src='http://example.com' id='test-only-data-js'></script>\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 = "<!--[if gt IE 7]>\n<script type='text/javascript' src='http://example.com' id='test-only-conditional-js'></script>\n<![endif]-->\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 .= "<!--[if lt IE 9]>\n<script type='text/javascript' src='http://example.com' id='test-conditional-with-data-js'></script>\n<![endif]-->\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 = "<script type='text/javascript' src='http://example.com' id='test-invalid-js'></script>\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 .= "<script type='text/javascript' src='/child-head.js' id='child-head-js'></script>\n";
$expected_footer = "<script type='text/javascript' src='/parent.js' id='parent-js'></script>\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 = "<script type='text/javascript' src='/child-footer.js' id='child-footer-js'></script>\n";
$expected_footer .= "<script type='text/javascript' src='/parent.js' id='parent-js'></script>\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 .= "<script type='text/javascript' src='/child2-footer.js' id='child2-footer-js'></script>\n";
$expected_footer .= "<script type='text/javascript' src='/parent-footer.js' id='parent-footer-js'></script>\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 = "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
$expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -419,7 +419,7 @@ JS;
$expected = "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
$expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -434,7 +434,7 @@ JS;
$expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
$expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -447,7 +447,7 @@ JS;
$expected = "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -460,7 +460,7 @@ JS;
$expected = "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -475,7 +475,7 @@ JS;
$expected = "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
$expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -492,7 +492,7 @@ JS;
$expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
$expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\nconsole.log(\"after\");\n</script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -509,7 +509,7 @@ JS;
$expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
$expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -535,7 +535,7 @@ JS;
$expected .= "<script type='text/javascript' src='/directory/two.js?ver={$ver}' id='two-js'></script>\n";
$expected .= "<script type='text/javascript' src='/directory/three.js?ver={$ver}' id='three-js'></script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -559,7 +559,7 @@ JS;
$expected .= "<script type='text/javascript' src='/directory/two.js?ver={$ver}' id='two-js'></script>\n";
$expected .= "<script type='text/javascript' src='/directory/three.js?ver={$ver}' id='three-js'></script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -587,7 +587,7 @@ JS;
$expected .= "<script type='text/javascript' id='three-js-after'>\nconsole.log(\"after three\");\n</script>\n";
$expected .= "<script type='text/javascript' src='/directory/four.js?ver={$ver}' id='four-js'></script>\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, "<script type='text/javascript' src='/customize-dependency.js' id='customize-dependency-js'>" ) );
$this->assertEquals( $expected_tail, $tail );
$this->assertSame( $expected_tail, $tail );
}
/**
@ -805,7 +805,7 @@ JS;
$expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$ver}' id='three-js'></script>\n";
$expected .= "<script type='text/javascript' src='/wp-includes/js/script4.js?ver={$ver}' id='four-js'></script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -829,7 +829,7 @@ JS;
$expected .= "<script type='text/javascript' src='/wp-includes/js/script3.js?ver={$ver}' id='three-js'></script>\n";
$expected .= "<script type='text/javascript' src='/wp-includes/js/script4.js?ver={$ver}' id='four-js'></script>\n";
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -856,7 +856,7 @@ JS;
);
$expected .= "<script type='text/javascript' src='/wp-includes/js/script.js' id='test-example-js'></script>\n";
$this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -883,7 +883,7 @@ JS;
);
$expected .= "<script type='text/javascript' src='/wp-content/plugins/my-plugin/js/script.js' id='plugin-example-js'></script>\n";
$this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -910,7 +910,7 @@ JS;
);
$expected .= "<script type='text/javascript' src='/wp-content/themes/my-theme/js/script.js' id='theme-example-js'></script>\n";
$this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -937,7 +937,7 @@ JS;
);
$expected .= "<script type='text/javascript' src='/wp-admin/js/script.js' id='script-handle-js'></script>\n";
$this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -979,7 +979,7 @@ JS;
);
$expected .= "<script type='text/javascript' src='/wp-admin/js/script.js' id='test-example-js'></script>\n";
$this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -1008,7 +1008,7 @@ JS;
);
$expected .= "<script type='text/javascript' src='/wp-includes/js/script.js' id='test-example-js'></script>\n";
$this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
}
/**
@ -1038,7 +1038,7 @@ JS;
$expected .= "<script type='text/javascript' src='/wp-includes/js/script.js' id='test-dependency-js'></script>\n";
$expected .= "<script type='text/javascript' src='/wp-includes/js/script2.js' id='test-example-js'></script>\n";
$this->assertEqualsIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
$this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
}
/**

View File

@ -63,10 +63,10 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase {
$expected .= "<link rel='stylesheet' id='no-deps-null-version-css' href='http://example.com' type='text/css' media='all' />\n";
$expected .= "<link rel='stylesheet' id='no-deps-null-version-print-media-css' href='http://example.com' type='text/css' media='print' />\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 = "<link rel='stylesheet' id='no-deps-no-version-css' href='http://example.com?ver=$ver' media='all' />\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 .= "<link rel='stylesheet' id='reset-css-ftp-css' href='{$wp_styles->base_url}ftp://yui.yahooapis.com/2.8.1/build/reset/reset-min.css?ver=$ver' type='text/css' media='all' />\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' ) );
}
/**

View File

@ -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() );
}
/**

View File

@ -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() );
}
/**

View File

@ -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 <feed> element is present and contains a <title> 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++;
}
}

View File

@ -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 ) );
}

View File

@ -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 ) {

View File

@ -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 );
}
}

View File

@ -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() {

View File

@ -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 ) ) );
}
}

View File

@ -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.

View File

@ -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 &#8216;WordPress', capital_P_dangit( 'Something about &#8216;Wordpress' ) );
$this->assertEquals( 'Something about &#8220;WordPress', capital_P_dangit( 'Something about &#8220;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 &#8216;WordPress', capital_P_dangit( 'Something about &#8216;Wordpress' ) );
$this->assertSame( 'Something about &#8220;WordPress', capital_P_dangit( 'Something about &#8220;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' ) );
}
}

View File

@ -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 ) );
}
}

View File

@ -7,7 +7,7 @@ class Tests_Formatting_ConvertInvalidEntities extends WP_UnitTestCase {
function test_replaces_windows1252_entities_with_unicode_ones() {
$input = '&#130;&#131;&#132;&#133;&#134;&#135;&#136;&#137;&#138;&#139;&#140;&#145;&#146;&#147;&#148;&#149;&#150;&#151;&#152;&#153;&#154;&#155;&#156;&#159;';
$output = '&#8218;&#402;&#8222;&#8230;&#8224;&#8225;&#710;&#8240;&#352;&#8249;&#338;&#8216;&#8217;&#8220;&#8221;&#8226;&#8211;&#8212;&#732;&#8482;&#353;&#8250;&#339;&#376;';
$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 = '&#142;&#158;';
$output = '&#381;&#382;';
$this->assertEquals( $output, convert_invalid_entities( $input ) );
$this->assertSame( $output, convert_invalid_entities( $input ) );
}
function test_escapes_lone_ampersands() {
$this->assertEquals( 'at&#038;t', convert_chars( 'at&t' ) );
$this->assertSame( 'at&#038;t', convert_chars( 'at&t' ) );
}
}

Some files were not shown because too many files have changed in this diff Show More