Coding Standards: Fix the remaining issues in /tests.

All PHP files in `/tests` now conform to the PHP coding standards, or have exceptions appropriately marked.

Travis now also runs `phpcs` on the `/tests` directory, any future changes to these files must conform entirely to the WordPress PHP coding standards. 🎉

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45607 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2019-07-08 00:55:20 +00:00
parent 431bc58a48
commit c6c78490e2
91 changed files with 435 additions and 320 deletions

View File

@@ -81,7 +81,7 @@ class Tests_User extends WP_UnitTestCase {
$found = array();
foreach ( $user_list as $user ) {
// only include the users we just created - there might be some others that existed previously
if ( in_array( $user->ID, $nusers ) ) {
if ( in_array( $user->ID, $nusers, true ) ) {
$found[] = $user->ID;
}
}
@@ -161,7 +161,7 @@ class Tests_User extends WP_UnitTestCase {
// for reasons unclear, the resulting array is indexed numerically; meta keys are not included anywhere.
// so we'll just check to make sure our values are included somewhere.
foreach ( $vals as $k => $v ) {
$this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] == $v );
$this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
}
// delete one key and check again
$keys = array_keys( $vals );
@@ -170,10 +170,10 @@ class Tests_User extends WP_UnitTestCase {
$out = get_user_meta( self::$author_id );
// make sure that key is excluded from the results
foreach ( $vals as $k => $v ) {
if ( $k == $key_to_delete ) {
if ( $k === $key_to_delete ) {
$this->assertFalse( isset( $out[ $k ] ) );
} else {
$this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] == $v );
$this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
}
}
}
@@ -599,7 +599,7 @@ class Tests_User extends WP_UnitTestCase {
$this->assertWPError( $id2 );
}
@update_user_meta( $id2, 'key', 'value' );
update_user_meta( $id2, 'key', 'value' );
$metas = array_keys( get_user_meta( 1 ) );
$this->assertNotContains( 'key', $metas );
@@ -1022,7 +1022,7 @@ class Tests_User extends WP_UnitTestCase {
)
);
$this->assertTrue( in_array( self::$contrib_id, $users ) );
$this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
}
public function test_search_users_url() {
@@ -1033,7 +1033,7 @@ class Tests_User extends WP_UnitTestCase {
)
);
$this->assertTrue( in_array( self::$contrib_id, $users ) );
$this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
}
public function test_search_users_email() {
@@ -1044,7 +1044,7 @@ class Tests_User extends WP_UnitTestCase {
)
);
$this->assertTrue( in_array( self::$contrib_id, $users ) );
$this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
}
public function test_search_users_nicename() {
@@ -1055,7 +1055,7 @@ class Tests_User extends WP_UnitTestCase {
)
);
$this->assertTrue( in_array( self::$contrib_id, $users ) );
$this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
}
public function test_search_users_display_name() {
@@ -1066,7 +1066,7 @@ class Tests_User extends WP_UnitTestCase {
)
);
$this->assertTrue( in_array( self::$contrib_id, $users ) );
$this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
}
/**
@@ -1201,8 +1201,8 @@ class Tests_User extends WP_UnitTestCase {
* post author `blackburn@battlefield3.com` and and site admin `admin@example.org`.
*/
if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
$was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
$was_user_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' == $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
$was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
$was_user_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' === $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
}
$this->assertTrue( $was_admin_email_sent );
@@ -1226,8 +1226,8 @@ class Tests_User extends WP_UnitTestCase {
* post author `blackburn@battlefield3.com` and and site admin `admin@example.org`.
*/
if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
$was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
$was_user_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' == $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
$was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
$was_user_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' === $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
}
$this->assertTrue( $was_admin_email_sent );
@@ -1465,7 +1465,7 @@ class Tests_User extends WP_UnitTestCase {
do_action( 'personal_options_update' );
if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
$was_confirmation_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && 'after@example.com' == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
$was_confirmation_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && 'after@example.com' === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
}
// A confirmation email is sent.
@@ -1502,7 +1502,7 @@ class Tests_User extends WP_UnitTestCase {
do_action( 'personal_options_update' );
if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
$was_confirmation_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && 'after@example.com' == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
$was_confirmation_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && 'after@example.com' === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
}
// No confirmation email is sent.