WordPress.org

Make WordPress Core

Changeset 45607


Ignore:
Timestamp:
07/08/2019 12:55:20 AM (5 months ago)
Author:
pento
Message:

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.

Location:
trunk
Files:
91 edited

Legend:

Unmodified
Added
Removed
  • trunk/.travis.yml

    r45570 r45607  
    1616    env: WP_TRAVISCI=e2e
    1717  - php: 7.2
    18     env: WP_TRAVISCI=travis:format
     18    env: WP_TRAVISCI=travis:phpcs
    1919  - php: 7.1
    2020    env: WP_TRAVISCI=travis:js
     
    8484  fi
    8585- |
    86   # We only need to run composer install on the code formatting job.
    87   if [[ "$WP_TRAVISCI" == "travis:format" ]]; then
     86  # We only need to run composer install on the PHP coding standards job.
     87  if [[ "$WP_TRAVISCI" == "travis:phpcs" ]]; then
    8888    composer --version
    8989    travis_retry composer install
  • trunk/Gruntfile.js

    r45448 r45607  
    14391439    } );
    14401440
     1441    grunt.registerTask( 'lint:php', 'Runs the code linter on changed files.', function() {
     1442        var done = this.async();
     1443        var flags = this.flags;
     1444        var args = changedFiles.php;
     1445        if ( flags.travis ) {
     1446            args = [ 'tests' ];
     1447        }
     1448        args.unshift( 'lint' );
     1449        grunt.util.spawn( {
     1450            cmd: 'composer',
     1451            args: args,
     1452            opts: { stdio: 'inherit' }
     1453        }, function( error ) {
     1454            if ( flags.error && error ) {
     1455                done( false );
     1456            } else {
     1457                done( true );
     1458            }
     1459        } );
     1460    } );
     1461
    14411462    // Travis CI tasks.
    14421463    grunt.registerTask('travis:js', 'Runs Javascript Travis CI tasks.', [ 'jshint:corejs', 'qunit:compiled' ]);
    14431464    grunt.registerTask('travis:phpunit', 'Runs PHPUnit Travis CI tasks.', [ 'build', 'phpunit' ]);
    1444     grunt.registerTask('travis:format', 'Runs Code formatting Travis CI tasks.', [ 'format:php:error' ]);
     1465    grunt.registerTask('travis:phpcs', 'Runs PHP Coding Standards Travis CI tasks.', [ 'format:php:error', 'lint:php:travis:error' ]);
    14451466
    14461467    // Patch task.
  • trunk/phpcs.xml.dist

    r45604 r45607  
    186186    <rule ref="WordPress.Files.FileName">
    187187        <properties>
    188             <property name="custom_test_class_whitelist" type="array" value="WP_UnitTestCase,WP_Ajax_UnitTestCase,WP_Canonical_UnitTestCase,WP_Test_REST_TestCase,WP_Test_REST_Controller_Testcase,WP_Test_REST_Post_Type_Controller_Testcase,WP_XMLRPC_UnitTestCase"/>
     188            <property name="custom_test_class_whitelist" type="array">
     189                <!-- Test case parent classes -->
     190                <element value="WP_UnitTestCase"/>
     191                <element value="WP_Ajax_UnitTestCase"/>
     192                <element value="WP_Canonical_UnitTestCase"/>
     193                <element value="WP_Test_REST_TestCase"/>
     194                <element value="WP_Test_REST_Controller_Testcase"/>
     195                <element value="WP_Test_REST_Post_Type_Controller_Testcase"/>
     196                <element value="WP_XMLRPC_UnitTestCase"/>
     197                <element value="WP_Filesystem_UnitTestCase"/>
     198                <element value="WP_Image_UnitTestCase"/>
     199                <element value="WP_HTTP_UnitTestCase"/>
     200                <element value="WP_Tests_Image_Resize_UnitTestCase"/>
     201                <element value="WP_Import_UnitTestCase"/>
     202                <element value="Tests_Query_Conditionals"/>
     203
     204                <!-- Mock classes -->
     205                <element value="Spy_REST_Server"/>
     206                <element value="WP_REST_Test_Controller"/>
     207                <element value="WP_Image_Editor_Mock"/>
     208                <element value="WP_Filesystem_MockFS"/>
     209                <element value="MockPHPMailer"/>
     210                <element value="MockAction"/>
     211                <element value="WP_Object_Cache"/>
     212
     213                <!-- PHPUnit helpers -->
     214                <element value="TracTickets"/>
     215                <element value="WP_PHPUnit_Util_Getopt"/>
     216                <element value="PHPUnit_Util_Test"/>
     217                <element value="WPProfiler"/>
     218                <element value="SpeedTrapListener"/>
     219                <element value="PHPUnit_Framework_Exception"/>
     220            </property>
    189221        </properties>
    190222    </rule>
  • trunk/phpunit.xml.dist

    r44705 r45607  
    4444            <arguments>
    4545                <array>
    46                     <element key="slowThreshold">
     46                    <element key="slow_threshold">
    4747                        <integer>150</integer>
    4848                    </element>
  • trunk/tests/phpunit/includes/bootstrap.php

    r45588 r45607  
    7777
    7878// Should we run in multisite mode?
    79 $multisite = '1' == getenv( 'WP_MULTISITE' );
     79$multisite = ( '1' === getenv( 'WP_MULTISITE' ) );
    8080$multisite = $multisite || ( defined( 'WP_TESTS_MULTISITE' ) && WP_TESTS_MULTISITE );
    8181$multisite = $multisite || ( defined( 'MULTISITE' ) && MULTISITE );
     
    192192
    193193                    foreach ( $skipped_groups as $group_name => $skipped ) {
    194                         if ( in_array( $group_name, $groups ) ) {
     194                        if ( in_array( $group_name, $groups, true ) ) {
    195195                            $skipped_groups[ $group_name ] = false;
    196196                        }
  • trunk/tests/phpunit/includes/functions.php

    r45580 r45607  
    101101        $wpdb->termmeta,
    102102    ) as $table ) {
     103        //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    103104        $wpdb->query( "DELETE FROM {$table}" );
    104105    }
     
    108109        $wpdb->term_taxonomy,
    109110    ) as $table ) {
     111        //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    110112        $wpdb->query( "DELETE FROM {$table} WHERE term_id != 1" );
    111113    }
  • trunk/tests/phpunit/includes/install.php

    r45588 r45607  
    5454$wpdb->query( 'SET foreign_key_checks = 0' );
    5555foreach ( $wpdb->tables() as $table => $prefixed_table ) {
     56    //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    5657    $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" );
    5758}
    5859
    5960foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) {
     61    //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    6062    $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" );
    6163
  • trunk/tests/phpunit/includes/mock-fs.php

    r42343 r45607  
    6262        foreach ( $paths as $path ) {
    6363            // Allow for comments
    64             if ( '#' == $path[0] ) {
     64            if ( '#' === $path[0] ) {
    6565                continue;
    6666            }
    6767
    6868            // Directories
    69             if ( '/' == $path[ strlen( $path ) - 1 ] ) {
     69            if ( '/' === $path[ strlen( $path ) - 1 ] ) {
    7070                $this->mkdir( $path );
    7171            } else { // Files (with dummy content for now)
     
    162162    function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
    163163
    164         if ( empty( $path ) || '.' == $path ) {
     164        if ( empty( $path ) || '.' === $path ) {
    165165            $path = $this->cwd();
    166166        }
     
    178178        $ret = array();
    179179        foreach ( $this->fs_map[ $path ]->children as $entry ) {
    180             if ( '.' == $entry->name || '..' == $entry->name ) {
    181                 continue;
    182             }
    183 
    184             if ( ! $include_hidden && '.' == $entry->name ) {
    185                 continue;
    186             }
    187 
    188             if ( $limit_file && $entry->name != $limit_file ) {
     180            if ( '.' === $entry->name || '..' === $entry->name ) {
     181                continue;
     182            }
     183
     184            if ( ! $include_hidden && '.' === $entry->name ) {
     185                continue;
     186            }
     187
     188            if ( $limit_file && $entry->name !== $limit_file ) {
    189189                continue;
    190190            }
     
    194194            $struc['type'] = $entry->type;
    195195
    196             if ( 'd' == $struc['type'] ) {
     196            if ( 'd' === $struc['type'] ) {
    197197                if ( $recursive ) {
    198198                    $struc['files'] = $this->dirlist( trailingslashit( $path ) . trailingslashit( $struc['name'] ), $include_hidden, $recursive );
     
    220220
    221221    function is_file() {
    222         return $this->type == 'f';
     222        return 'f' === $this->type;
    223223    }
    224224
    225225    function is_dir() {
    226         return $this->type == 'd';
     226        return 'd' === $this->type;
    227227    }
    228228}
  • trunk/tests/phpunit/includes/object-cache.php

    r45580 r45607  
    873873     * @param   int         $expiration     The expiration time, defaults to 0.
    874874     * @param   string      $server_key     The key identifying the server to store the value on.
    875      * @param   bool        $byKey          True to store in internal cache by key; false to not store by key
     875     * @param   bool        $by_key         True to store in internal cache by key; false to not store by key
    876876     * @return  bool                        Returns TRUE on success or FALSE on failure.
    877877     */
    878     public function add( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $byKey = false ) {
     878    public function add( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
    879879        /*
    880880         * Ensuring that wp_suspend_cache_addition is defined before calling, because sometimes an advanced-cache.php
     
    891891
    892892        // If group is a non-Memcached group, save to runtime cache, not Memcached
    893         if ( in_array( $group, $this->no_mc_groups ) ) {
     893        if ( in_array( $group, $this->no_mc_groups, true ) ) {
    894894
    895895            // Add does not set the value if the key exists; mimic that here
     
    904904
    905905        // Save to Memcached
    906         if ( $byKey ) {
     906        if ( $by_key ) {
    907907            $result = $this->m->addByKey( $server_key, $derived_key, $value, $expiration );
    908908        } else {
     
    992992     * @param   string      $group          The group value appended to the $key.
    993993     * @param   string      $server_key     The key identifying the server to store the value on.
    994      * @param   bool        $byKey          True to store in internal cache by key; false to not store by key
     994     * @param   bool        $by_key         True to store in internal cache by key; false to not store by key
    995995     * @return  bool                        Returns TRUE on success or FALSE on failure.
    996996     */
    997     public function append( $key, $value, $group = 'default', $server_key = '', $byKey = false ) {
     997    public function append( $key, $value, $group = 'default', $server_key = '', $by_key = false ) {
    998998        if ( ! is_string( $value ) && ! is_int( $value ) && ! is_float( $value ) ) {
    999999            return false;
     
    10031003
    10041004        // If group is a non-Memcached group, append to runtime cache value, not Memcached
    1005         if ( in_array( $group, $this->no_mc_groups ) ) {
     1005        if ( in_array( $group, $this->no_mc_groups, true ) ) {
    10061006            if ( ! isset( $this->cache[ $derived_key ] ) ) {
    10071007                return false;
     
    10141014
    10151015        // Append to Memcached value
    1016         if ( $byKey ) {
     1016        if ( $by_key ) {
    10171017            $result = $this->m->appendByKey( $server_key, $derived_key, $value );
    10181018        } else {
     
    10651065     * @param   int         $expiration     The expiration time, defaults to 0.
    10661066     * @param   string      $server_key     The key identifying the server to store the value on.
    1067      * @param   bool        $byKey          True to store in internal cache by key; false to not store by key
     1067     * @param   bool        $by_key         True to store in internal cache by key; false to not store by key
    10681068     * @return  bool                        Returns TRUE on success or FALSE on failure.
    10691069     */
    1070     public function cas( $cas_token, $key, $value, $group = 'default', $expiration = 0, $server_key = '', $byKey = false ) {
     1070    public function cas( $cas_token, $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
    10711071        $derived_key = $this->buildKey( $key, $group );
    10721072        $expiration  = $this->sanitize_expiration( $expiration );
     
    10771077         * operation is treated as a normal "add" for no_mc_groups.
    10781078         */
    1079         if ( in_array( $group, $this->no_mc_groups ) ) {
     1079        if ( in_array( $group, $this->no_mc_groups, true ) ) {
    10801080            $this->add_to_internal_cache( $derived_key, $value );
    10811081            return true;
     
    10831083
    10841084        // Save to Memcached
    1085         if ( $byKey ) {
     1085        if ( $by_key ) {
    10861086            $result = $this->m->casByKey( $cas_token, $server_key, $derived_key, $value, $expiration );
    10871087        } else {
     
    11311131
    11321132        // Decrement values in no_mc_groups
    1133         if ( in_array( $group, $this->no_mc_groups ) ) {
     1133        if ( in_array( $group, $this->no_mc_groups, true ) ) {
    11341134
    11351135            // Only decrement if the key already exists and value is 0 or greater (mimics memcached behavior)
     
    11921192     * @param   int         $time       The amount of time the server will wait to delete the item in seconds.
    11931193     * @param   string      $server_key The key identifying the server to store the value on.
    1194      * @param   bool        $byKey      True to store in internal cache by key; false to not store by key
     1194     * @param   bool        $by_key     True to store in internal cache by key; false to not store by key
    11951195     * @return  bool                    Returns TRUE on success or FALSE on failure.
    11961196     */
    1197     public function delete( $key, $group = 'default', $time = 0, $server_key = '', $byKey = false ) {
     1197    public function delete( $key, $group = 'default', $time = 0, $server_key = '', $by_key = false ) {
    11981198        $derived_key = $this->buildKey( $key, $group );
    11991199
    12001200        // Remove from no_mc_groups array
    1201         if ( in_array( $group, $this->no_mc_groups ) ) {
     1201        if ( in_array( $group, $this->no_mc_groups, true ) ) {
    12021202            if ( isset( $this->cache[ $derived_key ] ) ) {
    12031203                unset( $this->cache[ $derived_key ] );
     
    12071207        }
    12081208
    1209         if ( $byKey ) {
     1209        if ( $by_key ) {
    12101210            $result = $this->m->deleteByKey( $server_key, $derived_key, $time );
    12111211        } else {
     
    13001300     * @param   null|bool       $found      Variable passed by reference to determine if the value was found or not.
    13011301     * @param   string          $server_key The key identifying the server to store the value on.
    1302      * @param   bool            $byKey      True to store in internal cache by key; false to not store by key
     1302     * @param   bool            $by_key     True to store in internal cache by key; false to not store by key
    13031303     * @param   null|callable   $cache_cb   Read-through caching callback.
    13041304     * @param   null|float      $cas_token  The variable to store the CAS token in.
    13051305     * @return  bool|mixed                  Cached object value.
    13061306     */
    1307     public function get( $key, $group = 'default', $force = false, &$found = null, $server_key = '', $byKey = false, $cache_cb = null, &$cas_token = null ) {
     1307    public function get( $key, $group = 'default', $force = false, &$found = null, $server_key = '', $by_key = false, $cache_cb = null, &$cas_token = null ) {
    13081308        $derived_key = $this->buildKey( $key, $group );
    13091309
     
    13121312
    13131313        // If either $cache_db, or $cas_token is set, must hit Memcached and bypass runtime cache
    1314         if ( func_num_args() > 6 && ! in_array( $group, $this->no_mc_groups ) ) {
    1315             if ( $byKey ) {
     1314        if ( func_num_args() > 6 && ! in_array( $group, $this->no_mc_groups, true ) ) {
     1315            if ( $by_key ) {
    13161316                $value = $this->m->getByKey( $server_key, $derived_key, $cache_cb, $cas_token );
    13171317            } else {
     
    13221322                $found = true;
    13231323                return is_object( $this->cache[ $derived_key ] ) ? clone $this->cache[ $derived_key ] : $this->cache[ $derived_key ];
    1324             } elseif ( in_array( $group, $this->no_mc_groups ) ) {
     1324            } elseif ( in_array( $group, $this->no_mc_groups, true ) ) {
    13251325                return false;
    13261326            } else {
    1327                 if ( $byKey ) {
     1327                if ( $by_key ) {
    13281328                    $value = $this->m->getByKey( $server_key, $derived_key );
    13291329                } else {
     
    14651465
    14661466            // If order should be preserved, reorder now
    1467             if ( ! empty( $need_to_get ) && $flags === Memcached::GET_PRESERVE_ORDER ) {
     1467            if ( ! empty( $need_to_get ) && Memcached::GET_PRESERVE_ORDER === $flags ) {
    14681468                $ordered_values = array();
    14691469
     
    16041604
    16051605        // Increment values in no_mc_groups
    1606         if ( in_array( $group, $this->no_mc_groups ) ) {
     1606        if ( in_array( $group, $this->no_mc_groups, true ) ) {
    16071607
    16081608            // Only increment if the key already exists and the number is currently 0 or greater (mimics memcached behavior)
     
    16691669     * @param   string    $group        The group value prepended to the $key.
    16701670     * @param   string    $server_key   The key identifying the server to store the value on.
    1671      * @param   bool      $byKey        True to store in internal cache by key; false to not store by key
     1671     * @param   bool      $by_key       True to store in internal cache by key; false to not store by key
    16721672     * @return  bool                    Returns TRUE on success or FALSE on failure.
    16731673     */
    1674     public function prepend( $key, $value, $group = 'default', $server_key = '', $byKey = false ) {
     1674    public function prepend( $key, $value, $group = 'default', $server_key = '', $by_key = false ) {
    16751675        if ( ! is_string( $value ) && ! is_int( $value ) && ! is_float( $value ) ) {
    16761676            return false;
     
    16801680
    16811681        // If group is a non-Memcached group, prepend to runtime cache value, not Memcached
    1682         if ( in_array( $group, $this->no_mc_groups ) ) {
     1682        if ( in_array( $group, $this->no_mc_groups, true ) ) {
    16831683            if ( ! isset( $this->cache[ $derived_key ] ) ) {
    16841684                return false;
     
    16911691
    16921692        // Append to Memcached value
    1693         if ( $byKey ) {
     1693        if ( $by_key ) {
    16941694            $result = $this->m->prependByKey( $server_key, $derived_key, $value );
    16951695        } else {
     
    17411741     * @param   mixed       $value          The value to store.
    17421742     * @param   string      $group          The group value appended to the $key.
    1743      * @param   bool        $byKey          True to store in internal cache by key; false to not store by key
     1743     * @param   bool        $by_key         True to store in internal cache by key; false to not store by key
    17441744     * @param   int         $expiration     The expiration time, defaults to 0.
    17451745     * @return  bool                        Returns TRUE on success or FALSE on failure.
    17461746     */
    1747     public function replace( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $byKey = false ) {
     1747    public function replace( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
    17481748        $derived_key = $this->buildKey( $key, $group );
    17491749        $expiration  = $this->sanitize_expiration( $expiration );
    17501750
    17511751        // If group is a non-Memcached group, save to runtime cache, not Memcached
    1752         if ( in_array( $group, $this->no_mc_groups ) ) {
     1752        if ( in_array( $group, $this->no_mc_groups, true ) ) {
    17531753
    17541754            // Replace won't save unless the key already exists; mimic this behavior here
     
    17621762
    17631763        // Save to Memcached
    1764         if ( $byKey ) {
     1764        if ( $by_key ) {
    17651765            $result = $this->m->replaceByKey( $server_key, $derived_key, $value, $expiration );
    17661766        } else {
     
    18071807     * @param   int         $expiration The expiration time, defaults to 0.
    18081808     * @param   string      $server_key The key identifying the server to store the value on.
    1809      * @param   bool        $byKey      True to store in internal cache by key; false to not store by key
     1809     * @param   bool        $by_key     True to store in internal cache by key; false to not store by key
    18101810     * @return  bool                    Returns TRUE on success or FALSE on failure.
    18111811     */
    1812     public function set( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $byKey = false ) {
     1812    public function set( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
    18131813        $derived_key = $this->buildKey( $key, $group );
    18141814        $expiration  = $this->sanitize_expiration( $expiration );
    18151815
    18161816        // If group is a non-Memcached group, save to runtime cache, not Memcached
    1817         if ( in_array( $group, $this->no_mc_groups ) ) {
     1817        if ( in_array( $group, $this->no_mc_groups, true ) ) {
    18181818            $this->add_to_internal_cache( $derived_key, $value );
    18191819            return true;
     
    18211821
    18221822        // Save to Memcached
    1823         if ( $byKey ) {
     1823        if ( $by_key ) {
    18241824            $result = $this->m->setByKey( $server_key, $derived_key, $value, $expiration );
    18251825        } else {
     
    18681868     * @param   int             $expiration     The expiration time, defaults to 0.
    18691869     * @param   string          $server_key     The key identifying the server to store the value on.
    1870      * @param   bool            $byKey          True to store in internal cache by key; false to not store by key
     1870     * @param   bool            $by_key         True to store in internal cache by key; false to not store by key
    18711871     * @return  bool                            Returns TRUE on success or FALSE on failure.
    18721872     */
    1873     public function setMulti( $items, $groups = 'default', $expiration = 0, $server_key = '', $byKey = false ) {
     1873    public function setMulti( $items, $groups = 'default', $expiration = 0, $server_key = '', $by_key = false ) {
    18741874        // Build final keys and replace $items keys with the new keys
    18751875        $derived_keys  = $this->buildKeys( array_keys( $items ), $groups );
     
    18841884
    18851885            // If group is a non-Memcached group, save to runtime cache, not Memcached
    1886             if ( in_array( $key_pieces[1], $this->no_mc_groups ) ) {
     1886            if ( in_array( $key_pieces[1], $this->no_mc_groups, true ) ) {
    18871887                $this->add_to_internal_cache( $derived_key, $value );
    18881888                unset( $derived_items[ $derived_key ] );
     
    18911891
    18921892        // Save to memcached
    1893         if ( $byKey ) {
     1893        if ( $by_key ) {
    18941894            $result = $this->m->setMultiByKey( $server_key, $derived_items, $expiration );
    18951895        } else {
     
    19541954        }
    19551955
    1956         if ( false !== array_search( $group, $this->global_groups ) ) {
     1956        if ( false !== array_search( $group, $this->global_groups, true ) ) {
    19571957            $prefix = $this->global_prefix;
    19581958        } else {
     
    19921992
    19931993        // If we have equal numbers of keys and groups, merge $keys[n] and $group[n]
    1994         if ( count( $keys ) == count( $groups ) ) {
     1994        if ( count( $keys ) === count( $groups ) ) {
    19951995            for ( $i = 0; $i < count( $keys ); $i++ ) {
    19961996                $derived_keys[] = $this->buildKey( $keys[ $i ], $groups[ $i ] );
     
    20022002                if ( isset( $groups[ $i ] ) ) {
    20032003                    $derived_keys[] = $this->buildKey( $keys[ $i ], $groups[ $i ] );
    2004                 } elseif ( count( $groups ) == 1 ) {
     2004                } elseif ( count( $groups ) === 1 ) {
    20052005                    $derived_keys[] = $this->buildKey( $keys[ $i ], $groups[0] );
    20062006                } else {
     
    20472047
    20482048        // Combine the values based on direction of the "pend"
    2049         if ( 'pre' == $direction ) {
     2049        if ( 'pre' === $direction ) {
    20502050            $combined = $pended . $original;
    20512051        } else {
     
    20812081    public function contains_no_mc_group( $groups ) {
    20822082        if ( is_scalar( $groups ) ) {
    2083             return in_array( $groups, $this->no_mc_groups );
     2083            return in_array( $groups, $this->no_mc_groups, true );
    20842084        }
    20852085
     
    20892089
    20902090        foreach ( $groups as $group ) {
    2091             if ( in_array( $group, $this->no_mc_groups ) ) {
     2091            if ( in_array( $group, $this->no_mc_groups, true ) ) {
    20922092                return true;
    20932093            }
  • trunk/tests/phpunit/includes/phpunit6/compat.php

    r45580 r45607  
    1919
    2020        // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
    21         public static function getTickets( $className, $methodName ) {
    22             $annotations = PHPUnit\Util\Test::parseTestMethodAnnotations( $className, $methodName );
     21        public static function getTickets( $class_name, $method_name ) {
     22            $annotations = PHPUnit\Util\Test::parseTestMethodAnnotations( $class_name, $method_name );
    2323
    2424            $tickets = array();
  • trunk/tests/phpunit/includes/phpunit7/speed-trap-listener.php

    r45588 r45607  
    2323     * @var int
    2424     */
    25     protected $slowThreshold;
     25    protected $slow_threshold;
    2626
    2727    /**
     
    3030     * @var int
    3131     */
    32     protected $reportLength;
     32    protected $report_length;
    3333
    3434    /**
     
    167167     *
    168168     * @param int $time          Test execution time in milliseconds
    169      * @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds)
     169     * @param int $slow_threshold Test execution time at which a test should be considered slow (milliseconds)
    170170     * @return bool
    171171     */
    172     protected function isSlow( $time, $slowThreshold ) {
    173         return $time >= $slowThreshold;
     172    protected function isSlow( $time, $slow_threshold ) {
     173        return $time >= $slow_threshold;
    174174    }
    175175
     
    221221     */
    222222    protected function getReportLength() {
    223         return min( count( $this->slow ), $this->reportLength );
     223        return min( count( $this->slow ), $this->report_length );
    224224    }
    225225
     
    245245     */
    246246    protected function renderHeader() {
    247         echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold );
     247        echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slow_threshold );
    248248    }
    249249
     
    252252     */
    253253    protected function renderBody() {
    254         $slowTests = $this->slow;
    255 
    256         $length = $this->getReportLength( $slowTests );
     254        $slow_tests = $this->slow;
     255
     256        $length = $this->getReportLength( $slow_tests );
    257257        for ( $i = 1; $i <= $length; ++$i ) {
    258             $label = key( $slowTests );
    259             $time  = array_shift( $slowTests );
     258            $label = key( $slow_tests );
     259            $time  = array_shift( $slow_tests );
    260260
    261261            echo sprintf( " %s. %sms to run %s\n", $i, $time, $label );
     
    269269        $hidden = $this->getHiddenCount( $this->slow );
    270270        if ( $hidden ) {
    271             echo sprintf( '...and there %s %s more above your threshold hidden from view', $hidden == 1 ? 'is' : 'are', $hidden );
     271            echo sprintf( '...and there %s %s more above your threshold hidden from view', 1 === $hidden ? 'is' : 'are', $hidden );
    272272        }
    273273    }
     
    279279     */
    280280    protected function loadOptions( array $options ) {
    281         $this->slowThreshold = isset( $options['slowThreshold'] ) ? $options['slowThreshold'] : 500;
    282         $this->reportLength  = isset( $options['reportLength'] ) ? $options['reportLength'] : 10;
     281        $this->slow_threshold = isset( $options['slowThreshold'] ) ? $options['slowThreshold'] : 500;
     282        $this->report_length  = isset( $options['reportLength'] ) ? $options['reportLength'] : 10;
    283283    }
    284284
     
    303303        $ann = $test->getAnnotations();
    304304
    305         return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold;
     305        return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slow_threshold;
    306306    }
    307307}
  • trunk/tests/phpunit/includes/speed-trap-listener.php

    r42343 r45607  
    2323     * @var int
    2424     */
    25     protected $slowThreshold;
     25    protected $slow_threshold;
    2626
    2727    /**
     
    3030     * @var int
    3131     */
    32     protected $reportLength;
     32    protected $report_length;
    3333
    3434    /**
     
    167167     *
    168168     * @param int $time          Test execution time in milliseconds
    169      * @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds)
     169     * @param int $slow_threshold Test execution time at which a test should be considered slow (milliseconds)
    170170     * @return bool
    171171     */
    172     protected function isSlow( $time, $slowThreshold ) {
    173         return $time >= $slowThreshold;
     172    protected function isSlow( $time, $slow_threshold ) {
     173        return $time >= $slow_threshold;
    174174    }
    175175
     
    221221     */
    222222    protected function getReportLength() {
    223         return min( count( $this->slow ), $this->reportLength );
     223        return min( count( $this->slow ), $this->report_length );
    224224    }
    225225
     
    245245     */
    246246    protected function renderHeader() {
    247         echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold );
     247        echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slow_threshold );
    248248    }
    249249
     
    252252     */
    253253    protected function renderBody() {
    254         $slowTests = $this->slow;
    255 
    256         $length = $this->getReportLength( $slowTests );
     254        $slow_tests = $this->slow;
     255
     256        $length = $this->getReportLength( $slow_tests );
    257257        for ( $i = 1; $i <= $length; ++$i ) {
    258             $label = key( $slowTests );
    259             $time  = array_shift( $slowTests );
     258            $label = key( $slow_tests );
     259            $time  = array_shift( $slow_tests );
    260260
    261261            echo sprintf( " %s. %sms to run %s\n", $i, $time, $label );
     
    268268    protected function renderFooter() {
    269269        if ( $hidden = $this->getHiddenCount( $this->slow ) ) {
    270             echo sprintf( '...and there %s %s more above your threshold hidden from view', $hidden == 1 ? 'is' : 'are', $hidden );
     270            echo sprintf( '...and there %s %s more above your threshold hidden from view', 1 === $hidden ? 'is' : 'are', $hidden );
    271271        }
    272272    }
     
    278278     */
    279279    protected function loadOptions( array $options ) {
    280         $this->slowThreshold = isset( $options['slowThreshold'] ) ? $options['slowThreshold'] : 500;
    281         $this->reportLength  = isset( $options['reportLength'] ) ? $options['reportLength'] : 10;
     280        $this->slow_threshold = isset( $options['slowThreshold'] ) ? $options['slowThreshold'] : 500;
     281        $this->report_length  = isset( $options['reportLength'] ) ? $options['reportLength'] : 10;
    282282    }
    283283
     
    302302        $ann = $test->getAnnotations();
    303303
    304         return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold;
     304        return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slow_threshold;
    305305    }
    306306}
  • trunk/tests/phpunit/includes/trac.php

    r45580 r45607  
    4242        }
    4343
    44         return ! in_array( $ticket_id, self::$trac_ticket_cache[ $trac_url ] );
     44        return ! in_array( $ticket_id, self::$trac_ticket_cache[ $trac_url ], true );
    4545    }
    4646
  • trunk/tests/phpunit/includes/utils.php

    r45580 r45607  
    153153            $count = 0;
    154154            foreach ( $this->events as $e ) {
    155                 if ( $e['action'] == $tag ) {
     155                if ( $e['action'] === $tag ) {
    156156                    ++$count;
    157157                }
     
    223223
    224224    function data_handler( $parser, $data ) {
    225         $index                             = count( $this->data ) - 1;
    226         @$this->data[ $index ]['content'] .= $data;
     225        $index = count( $this->data ) - 1;
     226
     227        if ( ! isset( $this->data[ $index ]['content'] ) ) {
     228            $this->data[ $index ]['content'] = '';
     229        }
     230        $this->data[ $index ]['content'] .= $data;
    227231    }
    228232
     
    254258        #       echo "checking '{$tree[$i][name]}' == '{$a[0]}'\n";
    255259        #       var_dump($tree[$i]['name'], $a[0]);
    256         if ( $tree[ $i ]['name'] == $a[0] ) {
     260        if ( $tree[ $i ]['name'] === $a[0] ) {
    257261            #           echo "n == {$n}\n";
    258             if ( $n == 1 ) {
     262            if ( 1 === $n ) {
    259263                $out[] = $tree[ $i ];
    260264            } else {
     
    349353    $tables = $wpdb->get_col( 'SHOW TABLES;' );
    350354    foreach ( $tables as $table ) {
     355        // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    351356        $wpdb->query( "DROP TABLE IF EXISTS {$table}" );
    352357    }
     
    439444 * Special class for exposing protected wpdb methods we need to access
    440445 */
    441 class wpdb_exposed_methods_for_testing extends wpdb {
     446class WpdbExposedMethodsForTesting extends wpdb {
    442447    public function __construct() {
    443448        global $wpdb;
  • trunk/tests/phpunit/includes/wp-profiler.php

    r44915 r45607  
    115115        if ( $this->stack ) {
    116116            global $wp_actions;
    117             if ( $tag == end( $wp_actions ) ) {
    118                 @$this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ] ++;
     117            if ( end( $wp_actions ) === $tag ) {
     118                $this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]++;
    119119            } else {
    120                 @$this->stack[ count( $this->stack ) - 1 ]['filters'][ $tag ] ++;
     120                $this->stack[ count( $this->stack ) - 1 ]['filters'][ $tag ]++;
    121121            }
    122122        }
     
    126126    public function log_action( $tag ) {
    127127        if ( $this->stack ) {
    128             @$this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ] ++;
     128            $this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]++;
    129129        }
    130130    }
     
    145145            $sql = preg_replace( '/(WHERE \w+ =) \'\[-\w]+\'/', '$1 \'xxx\'', $sql );
    146146
    147             @$out[ $sql ] ++;
     147            $out[ $sql ] ++;
    148148        }
    149149        asort( $out );
     
    156156        foreach ( $queries as $q ) {
    157157            if ( empty( $q[2] ) ) {
    158                 @$out['unknown'] ++;
     158                $out['unknown']++;
    159159            } else {
    160                 @$out[ $q[2] ] ++;
     160                $out[ $q[2] ]++;
    161161            }
    162162        }
  • trunk/tests/phpunit/tests/admin/includesPlugin.php

    r45588 r45607  
    103103
    104104        $sub_dir = trailingslashit( dirname( $plugin[1] ) ) . 'subdir';
    105         @mkdir( $sub_dir );
    106         @file_put_contents( $sub_dir . '/subfile.php', '<?php // Silence.' );
     105        mkdir( $sub_dir );
     106        file_put_contents( $sub_dir . '/subfile.php', '<?php // Silence.' );
    107107
    108108        $plugin_files = get_plugin_files( plugin_basename( $plugin[1] ) );
     
    416416            }
    417417
    418             @closedir( $mu_plugins );
     418            closedir( $mu_plugins );
    419419
    420420            foreach ( $files_to_move as $file_to_move ) {
     
    443443        }
    444444
    445         @closedir( $mu_plugins );
     445        closedir( $mu_plugins );
    446446
    447447        foreach ( $files_to_move as $file_to_move ) {
  • trunk/tests/phpunit/tests/admin/includesSchema.php

    r43641 r45607  
    2929        $max_index_length = 191;
    3030
     31        // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    3132        $wpdb->query(
    3233            "
     
    6768            "
    6869        );
     70        // phpcs:enable
    6971    }
    7072
     
    7981        $sitemeta = self::$sitemeta;
    8082
     83        // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    8184        $wpdb->query( "DROP TABLE IF EXISTS {$options}" );
    8285        $wpdb->query( "DROP TABLE IF EXISTS {$blogmeta}" );
    8386        $wpdb->query( "DROP TABLE IF EXISTS {$sitemeta}" );
     87        // phpcs:enable
    8488    }
    8589
  • trunk/tests/phpunit/tests/adminbar.php

    r45588 r45607  
    745745        $nodes = $wp_admin_bar->get_nodes();
    746746        foreach ( $this->get_my_sites_network_menu_items() as $id => $cap ) {
    747             if ( in_array( $cap, $network_user_caps ) ) {
     747            if ( in_array( $cap, $network_user_caps, true ) ) {
    748748                $this->assertTrue( isset( $nodes[ $id ] ), sprintf( 'Menu item %1$s must display for a user with the %2$s cap.', $id, $cap ) );
    749749            } else {
  • trunk/tests/phpunit/tests/ajax/CustomizeMenus.php

    r43571 r45607  
    5353    function test_ajax_load_available_items_cap_check( $role, $expected_results ) {
    5454
    55         if ( 'administrator' != $role ) {
     55        if ( 'administrator' !== $role ) {
    5656            // If we're not an admin, we should get a wp_die(-1).
    5757            $this->setExpectedException( 'WPAjaxDieStopException' );
     
    442442    function test_ajax_search_available_items_caps_check( $role, $expected_results ) {
    443443
    444         if ( 'administrator' != $role ) {
     444        if ( 'administrator' !== $role ) {
    445445            // If we're not an admin, we should get a wp_die(-1).
    446446            $this->setExpectedException( 'WPAjaxDieStopException' );
  • trunk/tests/phpunit/tests/ajax/DeleteComment.php

    r42343 r45607  
    9595
    9696        // trash, spam, delete should make the total go down
    97         if ( in_array( $action, array( 'trash', 'spam', 'delete' ) ) ) {
     97        if ( in_array( $action, array( 'trash', 'spam', 'delete' ), true ) ) {
    9898            $total = $_POST['_total'] - 1;
    9999
    100100            // unspam, untrash should make the total go up
    101         } elseif ( in_array( $action, array( 'untrash', 'unspam' ) ) ) {
     101        } elseif ( in_array( $action, array( 'untrash', 'unspam' ), true ) ) {
    102102            $total = $_POST['_total'] + 1;
    103103        }
     
    109109        // Check for either possible total
    110110        $message = sprintf( 'returned value: %1$d $total: %2$d  $recalc_total: %3$d', (int) $xml->response[0]->comment[0]->supplemental[0]->total[0], $total, $recalc_total );
    111         $this->assertTrue( in_array( (int) $xml->response[0]->comment[0]->supplemental[0]->total[0], array( $total, $recalc_total ) ), $message );
     111        $this->assertTrue( in_array( (int) $xml->response[0]->comment[0]->supplemental[0]->total[0], array( $total, $recalc_total ), true ), $message );
    112112    }
    113113
     
    244244
    245245        // Force delete the comment
    246         if ( 'delete' == $action ) {
     246        if ( 'delete' === $action ) {
    247247            wp_delete_comment( $comment->comment_ID, true );
    248248        }
  • trunk/tests/phpunit/tests/ajax/DimComment.php

    r42343 r45607  
    9090        // Check the status
    9191        $current = wp_get_comment_status( $comment->comment_ID );
    92         if ( in_array( $prev_status, array( 'unapproved', 'spam' ) ) ) {
     92        if ( in_array( $prev_status, array( 'unapproved', 'spam' ), true ) ) {
    9393            $this->assertEquals( 'approved', $current );
    9494        } else {
     
    104104
    105105        // Check for either possible total
    106         $this->assertTrue( in_array( (int) $xml->response[0]->comment[0]->supplemental[0]->total[0], array( $total, $recalc_total ) ) );
     106        $this->assertTrue( in_array( (int) $xml->response[0]->comment[0]->supplemental[0]->total[0], array( $total, $recalc_total ), true ) );
    107107    }
    108108
  • trunk/tests/phpunit/tests/ajax/EditComment.php

    r42343 r45607  
    9797
    9898        // Manually update the comment_post_ID, because wp_update_comment() will prevent it.
    99         $wpdb->query( "UPDATE {$wpdb->comments} SET comment_post_ID=0 WHERE comment_ID={$comment->comment_ID}" );
     99        $wpdb->update( $wpdb->comments, array( 'comment_post_ID' => 0 ), array( 'comment_ID' => $comment->comment_ID ) );
    100100        clean_comment_cache( $comment->comment_ID );
    101101
  • trunk/tests/phpunit/tests/ajax/Response.php

    r42343 r45607  
    8686        ob_end_clean();
    8787
    88         $this->assertTrue( in_array( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers ) );
     88        $this->assertTrue( in_array( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers, true ) );
    8989    }
    9090
  • trunk/tests/phpunit/tests/basic.php

    r45424 r45607  
    2323        list( $version ) = explode( '-', $GLOBALS['wp_version'] );
    2424        // package.json uses x.y.z, so fill cleaned $wp_version for .0 releases
    25         if ( 1 == substr_count( $version, '.' ) ) {
     25        if ( 1 === substr_count( $version, '.' ) ) {
    2626            $version .= '.0';
    2727        }
  • trunk/tests/phpunit/tests/comment.php

    r43467 r45607  
    673673        if ( isset( $GLOBALS['phpmailer']->mock_sent )
    674674            && ! empty( $GLOBALS['phpmailer']->mock_sent )
    675             && WP_TESTS_EMAIL == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]
     675            && WP_TESTS_EMAIL === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]
    676676        ) {
    677677            $email_sent_when_comment_added = true;
     
    701701        if ( isset( $GLOBALS['phpmailer']->mock_sent )
    702702            && ! empty( $GLOBALS['phpmailer']->mock_sent )
    703             && 'test@test.com' == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]
     703            && 'test@test.com' === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]
    704704        ) {
    705705            $email_sent_when_comment_approved = true;
     
    723723        if ( isset( $GLOBALS['phpmailer']->mock_sent ) &&
    724724            ! empty( $GLOBALS['phpmailer']->mock_sent ) &&
    725             'test@test.com' == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] ) {
     725            'test@test.com' === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] ) {
    726726                $email_sent_when_comment_added = true;
    727727                reset_phpmailer_instance();
  • trunk/tests/phpunit/tests/comment/walker.php

    r43571 r45607  
    5555
    5656    public function comment( $comment, $args, $depth ) {
    57         if ( 1 == $depth ) {
     57        if ( 1 === $depth ) {
    5858            $this->test_walker->assertTrue( $this->walker->has_children );
    5959            $this->test_walker->assertTrue( $args['has_children'] ); // Back compat
    60         } elseif ( 2 == $depth ) {
     60        } elseif ( 2 === $depth ) {
    6161            $this->test_walker->assertFalse( $this->walker->has_children );
    6262            $this->test_walker->assertFalse( $args['has_children'] ); // Back compat
  • trunk/tests/phpunit/tests/compat.php

    r43571 r45607  
    126126            $heredoc,
    127127            // object data
    128             new classA(),
    129             // undefined data
     128            new ClassA(),
     129            // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- intentionally undefined data
    130130            @$undefined_var,
    131             // unset data
     131            // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- intentionally unset data
    132132            @$unset_var,
    133133        );
     
    316316
    317317/* used in test_mb_substr_phpcore */
    318 class classA {
     318class ClassA {
    319319    public function __toString() {
    320320        return 'Class A object';
  • trunk/tests/phpunit/tests/customize/manager.php

    r45588 r45607  
    26692669    function filter_customize_dynamic_setting_args_for_test_dynamic_settings( $setting_args, $setting_id ) {
    26702670        $this->assertInternalType( 'string', $setting_id );
    2671         if ( in_array( $setting_id, array( 'foo', 'bar' ) ) ) {
     2671        if ( in_array( $setting_id, array( 'foo', 'bar' ), true ) ) {
    26722672            $setting_args = array( 'default' => "dynamic_{$setting_id}_default" );
    26732673        }
  • trunk/tests/phpunit/tests/customize/nav-menu-item-setting.php

    r43571 r45607  
    387387        $db_ids     = wp_list_pluck( $menu_items, 'db_id' );
    388388        $this->assertContains( $item_id, $db_ids );
    389         $i                         = array_search( $item_id, $db_ids );
     389        $i                         = array_search( $item_id, $db_ids, true );
    390390        $updated_item              = $menu_items[ $i ];
    391391        $post_value['post_status'] = $post_value['status'];
     
    677677        $db_ids     = wp_list_pluck( $menu_items, 'db_id' );
    678678        $this->assertContains( $item_id, $db_ids );
    679         $i                         = array_search( $item_id, $db_ids );
     679        $i                         = array_search( $item_id, $db_ids, true );
    680680        $updated_item              = $menu_items[ $i ];
    681681        $post_value['post_status'] = $post_value['status'];
  • trunk/tests/phpunit/tests/customize/nav-menu-setting.php

    r43571 r45607  
    225225        $menus     = wp_get_nav_menus();
    226226        $menus_ids = wp_list_pluck( $menus, 'term_id' );
    227         $i         = array_search( $menu_id, $menus_ids );
     227        $i         = array_search( $menu_id, $menus_ids, true );
    228228        $this->assertInternalType( 'int', $i, 'Update-previewed menu does not appear in wp_get_nav_menus()' );
    229229        $filtered_menu = $menus[ $i ];
     
    270270        $menus     = wp_get_nav_menus();
    271271        $menus_ids = wp_list_pluck( $menus, 'term_id' );
    272         $i         = array_search( $menu_id, $menus_ids );
     272        $i         = array_search( $menu_id, $menus_ids, true );
    273273        $this->assertInternalType( 'int', $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()' );
    274274        $filtered_menu = $menus[ $i ];
  • trunk/tests/phpunit/tests/date/query.php

    r43571 r45607  
    10151015        $days_of_year = array( -1, 0, 367 );
    10161016        foreach ( $days_of_year as $day_of_year ) {
    1017             $this->assertFalse( @$this->q->validate_date_values( array( 'dayofyear' => $day_of_year ) ) );
     1017            $this->assertFalse( $this->q->validate_date_values( array( 'dayofyear' => $day_of_year ) ) );
    10181018        }
    10191019    }
  • trunk/tests/phpunit/tests/db.php

    r45603 r45607  
    2424    public static function setUpBeforeClass() {
    2525        parent::setUpBeforeClass();
    26         self::$_wpdb = new wpdb_exposed_methods_for_testing();
     26        self::$_wpdb = new WpdbExposedMethodsForTesting();
    2727    }
    2828
     
    347347
    348348    public function filter_allowed_incompatible_sql_mode( $modes ) {
    349         $pos = array_search( 'ONLY_FULL_GROUP_BY', $modes );
     349        $pos = array_search( 'ONLY_FULL_GROUP_BY', $modes, true );
    350350        $this->assertGreaterThanOrEqual( 0, $pos );
    351351
     
    366366        $id = 0;
    367367        // This, obviously, is an incorrect prepare.
     368        // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    368369        $prepared = $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = $id", $id );
    369370        $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0", $prepared );
     
    383384        global $wpdb;
    384385
     386        // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    385387        $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", 1, array( 'admin' ) );
    386388        $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = ''", $prepared );
    387389
     390        // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    388391        $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( 1 ), 'admin' );
    389392        $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared );
     
    403406        global $wpdb;
    404407
     408        // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    405409        $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( 1, array( 'admin' ) ) );
    406410        $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = ''", $prepared );
    407411
     412        // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    408413        $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( array( 1 ), 'admin' ) );
    409414        $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared );
     
    421426        array_unshift( $args, $query );
    422427
     428        // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    423429        $prepared = @call_user_func_array( array( $wpdb, 'prepare' ), $args );
    424430        $this->assertEquals( $expected, $prepared );
     
    588594        $wpdb->last_result = $last_result;
    589595
     596        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
    590597        $result = $wpdb->get_col( $query, $column );
    591598
     
    10441051        }
    10451052
    1046         if ( ! in_array( $expected_charset, array( 'utf8', 'utf8mb4', 'latin1' ) ) ) {
     1053        if ( ! in_array( $expected_charset, array( 'utf8', 'utf8mb4', 'latin1' ), true ) ) {
    10471054            $this->markTestSkipped( 'This test only works with utf8, utf8mb4 or latin1 character sets' );
    10481055        }
     
    11171124        );
    11181125
    1119         $row = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_key='$key'" );
     1126        $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE meta_key=%s", $key ) );
    11201127
    11211128        $this->assertNull( $row->meta_value );
     
    11401147        );
    11411148
    1142         $row = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_key='$key'" );
     1149        $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE meta_key=%s", $key ) );
    11431150
    11441151        $this->assertSame( $value, $row->meta_value );
     
    11551162        );
    11561163
    1157         $row = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_key='$key'" );
     1164        $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE meta_key=%s", $key ) );
    11581165
    11591166        $this->assertNull( $row->meta_value );
     
    11781185        );
    11791186
    1180         $row = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_key='$key'" );
     1187        $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE meta_key=%s", $key ) );
    11811188
    11821189        $this->assertNull( $row->meta_value );
     
    11931200        );
    11941201
    1195         $row = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_key='$key'" );
     1202        $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE meta_key=%s", $key ) );
    11961203
    11971204        $this->assertSame( $value, $row->meta_value );
     
    12161223        );
    12171224
    1218         $row = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_key='$key'" );
     1225        $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE meta_key=%s", $key ) );
    12191226
    12201227        $this->assertNull( $row->meta_value );
     
    12291236        );
    12301237
    1231         $row = $wpdb->get_row( "SELECT * FROM $wpdb->postmeta WHERE meta_key='$key'" );
     1238        $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE meta_key=%s", $key ) );
    12321239
    12331240        $this->assertNull( $row );
     
    15731580        $sql = str_replace( '{ESCAPE}', $escape, $sql );
    15741581
     1582        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
    15751583        $actual = $wpdb->prepare( $sql, $values );
    15761584
     
    16541662        $wpdb->query( "CREATE TABLE {$wpdb->prefix}test_placeholder( a VARCHAR(100) );" );
    16551663        $sql = $wpdb->prepare( "INSERT INTO {$wpdb->prefix}test_placeholder VALUES(%s)", $value );
     1664
     1665        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
    16561666        $wpdb->query( $sql );
    16571667
     
    16681678
    16691679        $sql = $wpdb->prepare( ' %s %1$c ', 'foo' );
     1680        // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    16701681        $sql = $wpdb->prepare( " $sql %s ", 'foo' );
    16711682
  • trunk/tests/phpunit/tests/db/charset.php

    r45588 r45607  
    2828        require_once( dirname( dirname( __FILE__ ) ) . '/db.php' );
    2929
    30         self::$_wpdb = new wpdb_exposed_methods_for_testing();
     30        self::$_wpdb = new WpdbExposedMethodsForTesting();
    3131
    3232        if ( self::$_wpdb->use_mysqli ) {
  • trunk/tests/phpunit/tests/dbdelta.php

    r43571 r45607  
    3434        // Forcing MyISAM, because InnoDB only started supporting FULLTEXT indexes in MySQL 5.7.
    3535        $wpdb->query(
    36             "
    37             CREATE TABLE {$wpdb->prefix}dbdelta_test (
    38                 id bigint(20) NOT NULL AUTO_INCREMENT,
    39                 column_1 varchar(255) NOT NULL,
    40                 column_2 text,
    41                 column_3 blob,
    42                 PRIMARY KEY  (id),
    43                 KEY key_1 (column_1($this->max_index_length)),
    44                 KEY compound_key (id,column_1($this->max_index_length)),
    45                 FULLTEXT KEY fulltext_key (column_1)
    46             ) ENGINE=MyISAM
    47             "
     36            $wpdb->prepare(
     37                "
     38                CREATE TABLE {$wpdb->prefix}dbdelta_test (
     39                    id bigint(20) NOT NULL AUTO_INCREMENT,
     40                    column_1 varchar(255) NOT NULL,
     41                    column_2 text,
     42                    column_3 blob,
     43                    PRIMARY KEY  (id),
     44                    KEY key_1 (column_1(%d)),
     45                    KEY compound_key (id,column_1(%d)),
     46                    FULLTEXT KEY fulltext_key (column_1)
     47                ) ENGINE=MyISAM
     48                ",
     49                $this->max_index_length,
     50                $this->max_index_length
     51            )
    4852        );
    4953
     
    300304        global $wpdb;
    301305
     306        // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    302307        $table_row = $wpdb->get_row( "select $column from {$table} where $column = '$value'" );
    303308
     
    318323        global $wpdb;
    319324
    320         $table_fields = $wpdb->get_results( "DESCRIBE {$table}" );
     325        // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
     326        $table_fields = $wpdb->get_results( "DESCRIBE $table" );
    321327
    322328        $this->assertCount( 1, wp_list_filter( $table_fields, array( 'Field' => $column ) ) );
     
    334340        global $wpdb;
    335341
    336         $table_indices = $wpdb->get_results( "SHOW INDEX FROM {$table}" );
     342        // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
     343        $table_indices = $wpdb->get_results( "SHOW INDEX FROM $table" );
    337344
    338345        $this->assertCount(
     
    359366        global $wpdb;
    360367
    361         $table_fields = $wpdb->get_results( "DESCRIBE {$table}" );
     368        // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
     369        $table_fields = $wpdb->get_results( "DESCRIBE $table" );
    362370
    363371        $this->assertCount( 0, wp_list_filter( $table_fields, array( 'Field' => $column ) ) );
     
    386394            ) ENGINE=InnoDB ROW_FORMAT=DYNAMIC";
    387395
     396        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
    388397        $wpdb->query( $create );
    389398
     399        // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    390400        $index = $wpdb->get_row( "SHOW INDEXES FROM $table_name WHERE Key_name='a_key';" );
    391401
    392402        $actual = dbDelta( $create, false );
    393403
     404        // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    394405        $wpdb->query( "DROP TABLE IF EXISTS $table_name;" );
    395406
    396         if ( 191 != $index->Sub_part ) {
     407        if ( 191 !== $index->Sub_part ) {
    397408            $this->markTestSkipped( 'This test requires the index to be truncated.' );
    398409        }
     
    528539        ";
    529540
     541        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
    530542        $wpdb->query( $schema );
    531543
     
    557569            ";
    558570
     571        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
    559572        $wpdb->query( $schema );
    560573
     
    603616        ";
    604617
     618        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
    605619        $wpdb->query( $schema );
    606620
     
    9991013        ";
    10001014
     1015        // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
    10011016        $wpdb->query( $schema );
    10021017
  • trunk/tests/phpunit/tests/external-http/basic.php

    r40519 r45607  
    1414
    1515        $response = wp_remote_get( 'https://secure.php.net/supported-versions.php' );
    16         if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
     16        if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
    1717            $this->fail( 'Could not contact PHP.net to check versions.' );
    1818        }
     
    2626
    2727        $response = wp_remote_get( "https://dev.mysql.com/doc/relnotes/mysql/{$matches[1]}/en/" );
    28         if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
     28        if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
    2929            $this->fail( 'Could not contact dev.MySQL.com to check versions.' );
    3030        }
  • trunk/tests/phpunit/tests/feed/atom.php

    r43571 r45607  
    7272        global $post;
    7373        try {
     74            // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    7475            @require( ABSPATH . 'wp-includes/feed-atom.php' );
    7576            $out = ob_get_clean();
     
    163164            $link_alts = xml_find( $entries[ $key ]['child'], 'link' );
    164165            foreach ( $link_alts as $link_alt ) {
    165                 if ( 'alternate' == $link_alt['attributes']['rel'] ) {
     166                if ( 'alternate' === $link_alt['attributes']['rel'] ) {
    166167                    $this->assertEquals( get_permalink( $post ), $link_alt['attributes']['href'] );
    167168                }
     
    186187            $categories = xml_find( $entries[ $key ]['child'], 'category' );
    187188            foreach ( $categories as $category ) {
    188                 $this->assertTrue( in_array( $category['attributes']['term'], $terms ) );
     189                $this->assertTrue( in_array( $category['attributes']['term'], $terms, true ) );
    189190            }
    190191            unset( $terms );
     
    199200            $link_replies = xml_find( $entries[ $key ]['child'], 'link' );
    200201            foreach ( $link_replies as $link_reply ) {
    201                 if ( 'replies' == $link_reply['attributes']['rel'] && 'application/atom+xml' == $link_reply['attributes']['type'] ) {
     202                if ( 'replies' === $link_reply['attributes']['rel'] && 'application/atom+xml' === $link_reply['attributes']['type'] ) {
    202203                    $this->assertEquals( get_post_comments_feed_link( $post->ID, 'atom' ), $link_reply['attributes']['href'] );
    203204                }
  • trunk/tests/phpunit/tests/feed/rss2.php

    r45247 r45607  
    8484        global $post;
    8585        try {
     86            // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    8687            @require( ABSPATH . 'wp-includes/feed-rss2.php' );
    8788            $out = ob_get_clean();
  • trunk/tests/phpunit/tests/file.php

    r45345 r45607  
    209209
    210210        // Check to see if the system parameters prevent signature verifications.
    211         if ( is_wp_error( $verify ) && 'signature_verification_unsupported' == $verify->get_error_code() ) {
     211        if ( is_wp_error( $verify ) && 'signature_verification_unsupported' === $verify->get_error_code() ) {
    212212            $this->markTestSkipped( 'This system does not support Signature Verification.' );
    213213        }
     
    229229        unlink( $file );
    230230
    231         if ( is_wp_error( $verify ) && 'signature_verification_unsupported' == $verify->get_error_code() ) {
     231        if ( is_wp_error( $verify ) && 'signature_verification_unsupported' === $verify->get_error_code() ) {
    232232            $this->markTestSkipped( 'This system does not support Signature Verification.' );
    233233        }
  • trunk/tests/phpunit/tests/formatting/WPSpecialchars.php

    r42343 r45607  
    1818        // Allowed entities should be unchanged
    1919        foreach ( $allowedentitynames as $ent ) {
    20             if ( 'apos' == $ent ) {
     20            if ( 'apos' === $ent ) {
    2121                // But for some reason, PHP doesn't allow &apos;
    2222                continue;
  • trunk/tests/phpunit/tests/formatting/WPTexturize.php

    r42343 r45607  
    15771577                return '!openq1!';
    15781578            case '&#8217;':
    1579                 if ( 'apostrophe' == $context ) {
     1579                if ( 'apostrophe' === $context ) {
    15801580                    return '!apos!';
    15811581                } else {
     
    20022002                return '!q1!';
    20032003            case '&#8217;':
    2004                 if ( 'apostrophe' == $context ) {
     2004                if ( 'apostrophe' === $context ) {
    20052005                    return '!apos!';
    20062006                } else {
  • trunk/tests/phpunit/tests/functions.php

    r45602 r45607  
    845845        $charsets     = mb_detect_order();
    846846        $old_charsets = $charsets;
    847         if ( ! in_array( 'EUC-JP', $charsets ) ) {
     847        if ( ! in_array( 'EUC-JP', $charsets, true ) ) {
    848848            $charsets[] = 'EUC-JP';
    849849            mb_detect_order( $charsets );
     
    870870        $charsets     = mb_detect_order();
    871871        $old_charsets = $charsets;
    872         if ( ! in_array( 'EUC-JP', $charsets ) ) {
     872        if ( ! in_array( 'EUC-JP', $charsets, true ) ) {
    873873            $charsets[] = 'EUC-JP';
    874874            mb_detect_order( $charsets );
     
    966966        $extensions = wp_get_ext_types();
    967967
    968         foreach ( $extensions as $type => $extensionList ) {
    969             foreach ( $extensionList as $extension ) {
     968        foreach ( $extensions as $type => $extension_list ) {
     969            foreach ( $extension_list as $extension ) {
    970970                $this->assertEquals( $type, wp_ext2type( $extension ) );
    971971                $this->assertEquals( $type, wp_ext2type( strtoupper( $extension ) ) );
  • trunk/tests/phpunit/tests/functions/deprecated.php

    r42343 r45607  
    136136        }
    137137        foreach ( $search as $v ) {
    138             if ( $name == $v[ $key ] ) {
     138            if ( $name === $v[ $key ] ) {
    139139                return $v;
    140140            }
  • trunk/tests/phpunit/tests/http/base.php

    r45035 r45607  
    5555        foreach ( array( 'curl', 'streams', 'fsockopen' ) as $t ) {
    5656            remove_filter( "use_{$t}_transport", '__return_false' ); // Just strip them all
    57             if ( $t != $this->transport ) {
     57            if ( $t !== $this->transport ) {
    5858                add_filter( "use_{$t}_transport", '__return_false' ); // and add it back if need be..
    5959            }
     
    248248        }
    249249
    250         $this->assertTrue( isset( $headers['test1'] ) && 'test' == $headers['test1'] );
     250        $this->assertTrue( isset( $headers['test1'] ) && 'test' === $headers['test1'] );
    251251        $this->assertTrue( isset( $headers['test2'] ) && '0' === $headers['test2'] );
    252252        // cURL/HTTP Extension Note: Will never pass, cURL does not pass headers with an empty value.
  • trunk/tests/phpunit/tests/image/base.php

    r42343 r45607  
    7676        $detected_width  = 0;
    7777        $detected_height = 0;
    78         $image_size      = @getimagesize( $filename );
     78        $image_size      = getimagesize( $filename );
    7979
    8080        if ( isset( $image_size[0] ) ) {
  • trunk/tests/phpunit/tests/image/siteIcon.php

    r44785 r45607  
    5656
    5757        // Remove custom size.
    58         unset( $this->wp_site_icon->site_icon_sizes[ array_search( 321, $this->wp_site_icon->site_icon_sizes ) ] );
     58        unset( $this->wp_site_icon->site_icon_sizes[ array_search( 321, $this->wp_site_icon->site_icon_sizes, true ) ] );
    5959        // Remove the filter we added
    6060        remove_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) );
     
    9696
    9797        // Remove custom size.
    98         unset( $this->wp_site_icon->site_icon_sizes[ array_search( 321, $this->wp_site_icon->site_icon_sizes ) ] );
     98        unset( $this->wp_site_icon->site_icon_sizes[ array_search( 321, $this->wp_site_icon->site_icon_sizes, true ) ] );
    9999    }
    100100
  • trunk/tests/phpunit/tests/import/import.php

    r43571 r45607  
    2929        // crude but effective: make sure there's no residual data in the main tables
    3030        foreach ( array( 'posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta' ) as $table ) {
     31            // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    3132            $wpdb->query( "DELETE FROM {$wpdb->$table}" );
    3233        }
  • trunk/tests/phpunit/tests/kses.php

    r45588 r45607  
    149149        foreach ( $bad as $k => $x ) {
    150150            $result = wp_kses_bad_protocol( wp_kses_normalize_entities( $x ), wp_allowed_protocols() );
    151             if ( ! empty( $result ) && $result != 'alert(1);' && $result != 'alert(1)' ) {
     151            if ( ! empty( $result ) && 'alert(1);' !== $result && 'alert(1)' !== $result ) {
    152152                switch ( $k ) {
    153153                    case 6:
     
    184184        foreach ( $safe as $x ) {
    185185            $result = wp_kses_bad_protocol( wp_kses_normalize_entities( $x ), array( 'http', 'https', 'dummy' ) );
    186             if ( $result != $x && $result != 'http://example.org/' ) {
     186            if ( $result !== $x && 'http://example.org/' !== $result ) {
    187187                $this->fail( "wp_kses_bad_protocol incorrectly blocked $x" );
    188188            }
     
    193193        $xss = simplexml_load_file( DIR_TESTDATA . '/formatting/xssAttacks.xml' );
    194194        foreach ( $xss->attack as $attack ) {
    195             if ( in_array( $attack->name, array( 'IMG Embedded commands 2', 'US-ASCII encoding', 'OBJECT w/Flash 2', 'Character Encoding Example' ) ) ) {
     195            if ( in_array( (string) $attack->name, array( 'IMG Embedded commands 2', 'US-ASCII encoding', 'OBJECT w/Flash 2', 'Character Encoding Example' ), true ) ) {
    196196                continue;
    197197            }
     
    199199            $code = (string) $attack->code;
    200200
    201             if ( $code == 'See Below' ) {
     201            if ( 'See Below' === $code ) {
    202202                continue;
    203203            }
    204204
    205             if ( substr( $code, 0, 4 ) == 'perl' ) {
     205            if ( substr( $code, 0, 4 ) === 'perl' ) {
    206206                $pos  = strpos( $code, '"' ) + 1;
    207207                $code = substr( $code, $pos, strrpos( $code, '"' ) - $pos );
     
    211211            $result = trim( wp_kses_data( $code ) );
    212212
    213             if ( $result == '' || $result == 'XSS' || $result == 'alert("XSS");' || $result == "alert('XSS');" ) {
     213            if ( in_array( $result, array( '', 'XSS', 'alert("XSS");', "alert('XSS');" ), true ) ) {
    214214                continue;
    215215            }
     
    325325
    326326    function _wp_kses_allowed_html_filter( $html, $context ) {
    327         if ( 'post' == $context ) {
     327        if ( 'post' === $context ) {
    328328            return array( 'a' => array( 'href' => true ) );
    329329        } else {
  • trunk/tests/phpunit/tests/l10n.php

    r45505 r45607  
    7676
    7777        $this->assertNotEmpty( $installed_translations['default']['en_GB'] );
    78         $data_en_GB = $installed_translations['default']['en_GB'];
    79         $this->assertEquals( '2016-10-26 00:01+0200', $data_en_GB['PO-Revision-Date'] );
    80         $this->assertEquals( 'Development (4.4.x)', $data_en_GB['Project-Id-Version'] );
    81         $this->assertEquals( 'Poedit 1.8.10', $data_en_GB['X-Generator'] );
     78        $data_en_gb = $installed_translations['default']['en_GB'];
     79        $this->assertEquals( '2016-10-26 00:01+0200', $data_en_gb['PO-Revision-Date'] );
     80        $this->assertEquals( 'Development (4.4.x)', $data_en_gb['Project-Id-Version'] );
     81        $this->assertEquals( 'Poedit 1.8.10', $data_en_gb['X-Generator'] );
    8282
    8383        $this->assertNotEmpty( $installed_translations['admin']['es_ES'] );
    84         $data_es_ES = $installed_translations['admin']['es_ES'];
    85         $this->assertEquals( '2016-10-25 18:29+0200', $data_es_ES['PO-Revision-Date'] );
    86         $this->assertEquals( 'Administration', $data_es_ES['Project-Id-Version'] );
    87         $this->assertEquals( 'Poedit 1.8.10', $data_es_ES['X-Generator'] );
     84        $data_es_es = $installed_translations['admin']['es_ES'];
     85        $this->assertEquals( '2016-10-25 18:29+0200', $data_es_es['PO-Revision-Date'] );
     86        $this->assertEquals( 'Administration', $data_es_es['Project-Id-Version'] );
     87        $this->assertEquals( 'Poedit 1.8.10', $data_es_es['X-Generator'] );
    8888    }
    8989
  • trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php

    r42343 r45607  
    176176
    177177        switch_to_locale( 'de_DE' );
    178         $expected_de_DE = i18n_plugin_test();
     178        $expected_de_de = i18n_plugin_test();
    179179
    180180        switch_to_locale( 'es_ES' );
    181         $expected_es_ES = i18n_plugin_test();
     181        $expected_es_es = i18n_plugin_test();
    182182
    183183        restore_current_locale();
    184184
    185         $this->assertSame( 'Das ist ein Dummy Plugin', $expected_de_DE );
    186         $this->assertSame( 'This is a dummy plugin', $expected_es_ES );
     185        $this->assertSame( 'Das ist ein Dummy Plugin', $expected_de_de );
     186        $this->assertSame( 'This is a dummy plugin', $expected_es_es );
    187187    }
    188188
  • trunk/tests/phpunit/tests/l10n/localeSwitcher.php

    r42343 r45607  
    8787        switch_to_locale( 'de_DE' );
    8888
    89         $wp_locale_de_DE = clone $wp_locale;
    90 
    91         // Cleanup.
    92         restore_previous_locale();
    93 
    94         $this->assertEqualSetsWithIndex( $expected, $wp_locale_de_DE->number_format );
     89        $wp_locale_de_de = clone $wp_locale;
     90
     91        // Cleanup.
     92        restore_previous_locale();
     93
     94        $this->assertEqualSetsWithIndex( $expected, $wp_locale_de_de->number_format );
    9595    }
    9696
    9797    public function test_switch_to_locale_en_US() {
    9898        switch_to_locale( 'en_GB' );
    99         $locale_en_GB = get_locale();
     99        $locale_en_gb = get_locale();
    100100        switch_to_locale( 'en_US' );
    101         $locale_en_US = get_locale();
    102 
    103         // Cleanup.
    104         restore_current_locale();
    105 
    106         $this->assertSame( 'en_GB', $locale_en_GB );
    107         $this->assertSame( 'en_US', $locale_en_US );
     101        $locale_en_us = get_locale();
     102
     103        // Cleanup.
     104        restore_current_locale();
     105
     106        $this->assertSame( 'en_GB', $locale_en_gb );
     107        $this->assertSame( 'en_US', $locale_en_us );
    108108    }
    109109
  • trunk/tests/phpunit/tests/link/themeFile.php

    r42819 r45607  
    99            self::markTestSkipped( 'symlink() is not available.' );
    1010        }
     11        // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    1112        if ( ! @symlink( DIR_TESTDATA . '/theme-file-parent', WP_CONTENT_DIR . '/themes/theme-file-parent' ) ) {
    1213            self::markTestSkipped( 'Could not create parent symlink.' );
    1314        }
     15        // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
    1416        if ( ! @symlink( DIR_TESTDATA . '/theme-file-child', WP_CONTENT_DIR . '/themes/theme-file-child' ) ) {
    1517            self::markTestSkipped( 'Could not create child symlink.' );
  • trunk/tests/phpunit/tests/media.php

    r45424 r45607  
    12571257     */
    12581258    function filter_wp_embed_shortcode_custom( $content, $url ) {
    1259         if ( 'https://www.example.com/?video=1' == $url ) {
     1259        if ( 'https://www.example.com/?video=1' === $url ) {
    12601260            $content = '@embed URL was replaced@';
    12611261        }
     
    14471447        foreach ( $image_meta['sizes'] as $name => $size ) {
    14481448            // Whitelist the sizes that should be included so we pick up 'medium_large' in 4.4.
    1449             if ( in_array( $name, $intermediates ) ) {
     1449            if ( in_array( $name, $intermediates, true ) ) {
    14501450                $expected .= $uploads_dir_url . $year_month . '/' . $size['file'] . ' ' . $size['width'] . 'w, ';
    14511451            }
     
    14921492        foreach ( $image_meta['sizes'] as $name => $size ) {
    14931493            // Whitelist the sizes that should be included so we pick up 'medium_large' in 4.4.
    1494             if ( in_array( $name, $intermediates ) ) {
     1494            if ( in_array( $name, $intermediates, true ) ) {
    14951495                $expected .= $uploads_dir_url . $size['file'] . ' ' . $size['width'] . 'w, ';
    14961496            }
     
    15691569        foreach ( $image_meta['sizes'] as $name => $size ) {
    15701570            // Whitelist the sizes that should be included so we pick up 'medium_large' in 4.4.
    1571             if ( in_array( $name, $intermediates ) ) {
     1571            if ( in_array( $name, $intermediates, true ) ) {
    15721572                $expected .= $uploads_dir_url . $year_month . '/' . $size['file'] . ' ' . $size['width'] . 'w, ';
    15731573            }
     
    18481848        foreach ( $image_meta['sizes'] as $name => $size ) {
    18491849            // Whitelist the sizes that should be included so we pick up 'medium_large' in 4.4.
    1850             if ( in_array( $name, $intermediates ) ) {
     1850            if ( in_array( $name, $intermediates, true ) ) {
    18511851                $expected .= $uploads_dir . $year_month . '/' . $size['file'] . ' ' . $size['width'] . 'w, ';
    18521852            }
  • trunk/tests/phpunit/tests/meta.php

    r43571 r45607  
    371371        $string_mid = "{$meta_id}.0";
    372372
     373        // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- intentional implicit casting check
    373374        $this->assertTrue( floor( $string_mid ) == $string_mid );
    374375        $this->assertNotEquals( false, get_metadata_by_mid( 'user', $string_mid ) );
  • trunk/tests/phpunit/tests/meta/registerMeta.php

    r43571 r45607  
    506506
    507507    public function filter_get_object_subtype_for_customtype( $subtype, $object_id ) {
    508         if ( $object_id % 2 === 1 ) {
     508        if ( 1 === ( $object_id % 2 ) ) {
    509509            return 'odd';
    510510        }
  • trunk/tests/phpunit/tests/multisite.php

    r42343 r45607  
    3232
    3333            // currently there is no wrapper function for the registration_log
    34             $reg_blog = $wpdb->get_col( "SELECT email FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.blog_id = 1 AND IP LIKE '" . $ip . "'" );
     34            $reg_blog = $wpdb->get_col( $wpdb->prepare( "SELECT email FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.blog_id = 1 AND IP LIKE %s", $ip ) );
    3535            $this->assertEquals( $user->user_email, $reg_blog[ count( $reg_blog ) - 1 ] );
    3636        }
  • trunk/tests/phpunit/tests/multisite/getSpaceUsed.php

    r42343 r45607  
    2929            // src directory already contains a content directory with site content, then the initial expectation
    3030            // will be polluted. We create sites until an empty one is available.
    31             while ( 0 != get_space_used() ) {
     31            while ( 0 !== get_space_used() ) {
    3232                restore_current_blog();
    3333                $blog_id = self::factory()->blog->create();
     
    6565            // so that we can remove any uploaded files and directories without concern of a conflict with
    6666            // existing content directories in src.
    67             while ( 0 != get_space_used() ) {
     67            while ( 0 !== get_space_used() ) {
    6868                restore_current_blog();
    6969                $blog_id = self::factory()->blog->create();
  • trunk/tests/phpunit/tests/multisite/site.php

    r44806 r45607  
    167167            // Check existence of each database table for the created site.
    168168            foreach ( $wpdb->tables( 'blog', false ) as $table ) {
    169                 $suppress     = $wpdb->suppress_errors();
     169                $suppress = $wpdb->suppress_errors();
     170
     171                // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    170172                $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
     173
    171174                $wpdb->suppress_errors( $suppress );
    172175
     
    175178
    176179                // And the table should not be empty, unless commentmeta, termmeta, or links.
     180                // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    177181                $result = $wpdb->get_results( "SELECT * FROM $prefix$table LIMIT 1" );
    178                 if ( 'commentmeta' == $table || 'termmeta' == $table || 'links' == $table ) {
     182
     183                if ( 'commentmeta' === $table || 'termmeta' === $table || 'links' === $table ) {
    179184                    $this->assertEmpty( $result );
    180185                } else {
     
    245250            $prefix = $wpdb->get_blog_prefix( $blog_id );
    246251            foreach ( $wpdb->tables( 'blog', false ) as $table ) {
    247                 $suppress     = $wpdb->suppress_errors();
     252                $suppress = $wpdb->suppress_errors();
     253
     254                // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    248255                $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
     256
    249257                $wpdb->suppress_errors( $suppress );
    250258                $this->assertNotEmpty( $table_fields, $prefix . $table );
     
    283291            $prefix = $wpdb->get_blog_prefix( $blog_id );
    284292            foreach ( $wpdb->tables( 'blog', false ) as $table ) {
    285                 $suppress     = $wpdb->suppress_errors();
     293                $suppress = $wpdb->suppress_errors();
     294
     295                // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    286296                $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
     297
    287298                $wpdb->suppress_errors( $suppress );
    288299                $this->assertEmpty( $table_fields );
     
    321332            $prefix = $wpdb->get_blog_prefix( $blog_id );
    322333            foreach ( $wpdb->tables( 'blog', false ) as $table ) {
    323                 $suppress     = $wpdb->suppress_errors();
     334                $suppress = $wpdb->suppress_errors();
     335
     336                // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    324337                $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" );
     338
    325339                $wpdb->suppress_errors( $suppress );
    326340                $this->assertNotEmpty( $table_fields, $prefix . $table );
     
    856870         */
    857871        function _domain_exists_cb( $exists, $domain, $path, $site_id ) {
    858             if ( 'foo' == $domain && 'bar/' == $path ) {
     872            if ( 'foo' === $domain && 'bar/' === $path ) {
    859873                return 1234;
    860874            } else {
  • trunk/tests/phpunit/tests/oembed/controller.php

    r44155 r45607  
    122122        }
    123123
    124         if ( $url === self::UNTRUSTED_PROVIDER_URL ) {
     124        if ( self::UNTRUSTED_PROVIDER_URL === $url ) {
    125125            return array(
    126126                'response' => array(
  • trunk/tests/phpunit/tests/oembed/headers.php

    r42343 r45607  
    3131        $headers = xdebug_get_headers();
    3232
    33         $this->assertTrue( in_array( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers ) );
     33        $this->assertTrue( in_array( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers, true ) );
    3434    }
    3535}
  • trunk/tests/phpunit/tests/pomo/mo.php

    r43571 r45607  
    179179
    180180    function test_overloaded_mb_functions() {
    181         if ( ( ini_get( 'mbstring.func_overload' ) & 2 ) == 0 ) {
     181        if ( ( ini_get( 'mbstring.func_overload' ) & 2 ) === 0 ) {
    182182            $this->markTestSkipped( __METHOD__ . ' only runs when mbstring.func_overload is enabled.' );
    183183        }
  • trunk/tests/phpunit/tests/pomo/pluralForms.php

    r42343 r45607  
    6161        foreach ( $locales as $slug => $locale ) {
    6262            $plural_expression = $locale->plural_expression;
    63             if ( $plural_expression !== 'n != 1' ) {
     63            if ( 'n != 1' !== $plural_expression ) {
    6464                $plural_expressions[] = array( $slug, $locale->nplurals, $plural_expression );
    6565            }
     
    8383        $parenthesized = self::parenthesize_plural_expression( $expression );
    8484        $old_style     = tests_make_plural_form_function( $nplurals, $parenthesized );
    85         $pluralForms   = new Plural_Forms( $expression );
     85        $plural_forms  = new Plural_Forms( $expression );
    8686
    8787        $generated_old = array();
     
    9090        foreach ( range( 0, 200 ) as $i ) {
    9191            $generated_old[] = $old_style( $i );
    92             $generated_new[] = $pluralForms->get( $i );
     92            $generated_new[] = $plural_forms->get( $i );
    9393        }
    9494
     
    152152     */
    153153    public function test_simple( $expression, $expected ) {
    154         $pluralForms = new Plural_Forms( $expression );
    155         $actual      = array();
     154        $plural_forms = new Plural_Forms( $expression );
     155        $actual       = array();
    156156        foreach ( array_keys( $expected ) as $num ) {
    157             $actual[ $num ] = $pluralForms->get( $num );
     157            $actual[ $num ] = $plural_forms->get( $num );
    158158        }
    159159
     
    213213    public function test_exceptions( $expression, $expected_exception, $call_get ) {
    214214        try {
    215             $pluralForms = new Plural_Forms( $expression );
     215            $plural_forms = new Plural_Forms( $expression );
    216216            if ( $call_get ) {
    217                 $pluralForms->get( 1 );
     217                $plural_forms->get( 1 );
    218218            }
    219219        } catch ( Exception $e ) {
  • trunk/tests/phpunit/tests/post.php

    r45588 r45607  
    9696
    9797            $tcache = wp_cache_get( $id, 'ctax_relationships' );
    98             if ( 'cpt' == $post_type ) {
     98            if ( 'cpt' === $post_type ) {
    9999                $this->assertInternalType( 'array', $tcache );
    100100                $this->assertEquals( 2, count( $tcache ) );
     
    10091009    function test_utf8mb3_post_saves_with_emoji() {
    10101010        global $wpdb;
    1011         $_wpdb = new wpdb_exposed_methods_for_testing();
     1011        $_wpdb = new WpdbExposedMethodsForTesting();
    10121012
    10131013        if ( 'utf8' !== $_wpdb->get_col_charset( $wpdb->posts, 'post_title' ) ) {
  • trunk/tests/phpunit/tests/post/meta.php

    r43982 r45607  
    9696        );
    9797        sort( $expected );
    98         $this->assertTrue( in_array( get_post_meta( self::$post_id, 'nonunique', true ), $expected ) );
     98        $this->assertTrue( in_array( get_post_meta( self::$post_id, 'nonunique', true ), $expected, true ) );
    9999        $actual = get_post_meta( self::$post_id, 'nonunique', false );
    100100        sort( $actual );
  • trunk/tests/phpunit/tests/post/nav-menu.php

    r44966 r45607  
    652652        $tag_id  = self::factory()->tag->create();
    653653
    654         $wpdb->query( "UPDATE $wpdb->posts SET ID=$new_id WHERE ID=$page_id" );
    655         $wpdb->query( "UPDATE $wpdb->terms SET term_id=$new_id WHERE term_id=$tag_id" );
    656         $wpdb->query( "UPDATE $wpdb->term_taxonomy SET term_id=$new_id WHERE term_id=$tag_id" );
     654        $wpdb->update( $wpdb->posts, array( 'ID' => $new_id ), array( 'ID' => $page_id ) );
     655        $wpdb->update( $wpdb->terms, array( 'term_id' => $new_id ), array( 'term_id' => $tag_id ) );
     656        $wpdb->update( $wpdb->term_taxonomy, array( 'term_id' => $new_id ), array( 'term_id' => $tag_id ) );
    657657
    658658        update_option( 'page_on_front', $new_id );
  • trunk/tests/phpunit/tests/post/objects.php

    r42343 r45607  
    3737        $this->assertInternalType( 'array', $post );
    3838        $this->assertFalse( isset( $post['post_type'] ) );
    39         $this->assertTrue( in_array( 'post', $post ) );
     39        $this->assertTrue( in_array( 'post', $post, true ) );
    4040
    4141        $post = get_post( $id );
  • trunk/tests/phpunit/tests/post/thumbnails.php

    r43571 r45607  
    7272        set_post_thumbnail( self::$post, self::$attachment_id );
    7373
    74         $WP_Query = new WP_Query(
     74        $query = new WP_Query(
    7575            array(
    7676                'post_type' => 'any',
     
    8080        );
    8181
    82         $this->assertFalse( $WP_Query->thumbnails_cached );
    83 
    84         update_post_thumbnail_cache( $WP_Query );
    85 
    86         $this->assertTrue( $WP_Query->thumbnails_cached );
     82        $this->assertFalse( $query->thumbnails_cached );
     83
     84        update_post_thumbnail_cache( $query );
     85
     86        $this->assertTrue( $query->thumbnails_cached );
    8787    }
    8888
     
    393393        );
    394394
    395         $post = $which_post === 1 ? self::$different_post : self::$post;
     395        $post = 1 === $which_post ? self::$different_post : self::$post;
    396396
    397397        add_filter( 'post_thumbnail_size', array( $this, 'filter_post_thumbnail_size' ), 10, 2 );
  • trunk/tests/phpunit/tests/post/types.php

    r43571 r45607  
    306306        );
    307307
    308         $this->assertInternalType( 'int', array_search( 'bar', $wp->public_query_vars ) );
    309         $this->assertTrue( unregister_post_type( 'foo' ) );
    310         $this->assertFalse( array_search( 'bar', $wp->public_query_vars ) );
     308        $this->assertInternalType( 'int', array_search( 'bar', $wp->public_query_vars, true ) );
     309        $this->assertTrue( unregister_post_type( 'foo' ) );
     310        $this->assertFalse( array_search( 'bar', $wp->public_query_vars, true ) );
    311311    }
    312312
  • trunk/tests/phpunit/tests/post/wpPostType.php

    r43571 r45607  
    7979        $post_type_object->add_rewrite_rules();
    8080
    81         $this->assertFalse( in_array( 'foobar', $wp->public_query_vars ) );
     81        $this->assertFalse( in_array( 'foobar', $wp->public_query_vars, true ) );
    8282    }
    8383
     
    9999
    100100        $post_type_object->add_rewrite_rules();
    101         $in_array = in_array( 'foobar', $wp->public_query_vars );
     101        $in_array = in_array( 'foobar', $wp->public_query_vars, true );
    102102
    103103        $post_type_object->remove_rewrite_rules();
    104         $in_array_after = in_array( 'foobar', $wp->public_query_vars );
     104        $in_array_after = in_array( 'foobar', $wp->public_query_vars, true );
    105105
    106106        $this->assertTrue( $in_array );
     
    129129        $rewrite_tags_after = $wp_rewrite->rewritecode;
    130130
    131         $this->assertNotFalse( array_search( "%$post_type%", $rewrite_tags ) );
    132         $this->assertFalse( array_search( "%$post_type%", $rewrite_tags_after ) );
     131        $this->assertNotFalse( array_search( "%$post_type%", $rewrite_tags, true ) );
     132        $this->assertFalse( array_search( "%$post_type%", $rewrite_tags_after, true ) );
    133133    }
    134134
  • trunk/tests/phpunit/tests/rest-api.php

    r44568 r45607  
    256256    function test_rest_route_query_var() {
    257257        rest_api_init();
    258         $this->assertTrue( in_array( 'rest_route', $GLOBALS['wp']->public_query_vars ) );
     258        $this->assertTrue( in_array( 'rest_route', $GLOBALS['wp']->public_query_vars, true ) );
    259259    }
    260260
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r45588 r45607  
    24922492
    24932493    public function revoke_assign_term( $caps, $cap, $user_id, $args ) {
    2494         if ( 'assign_term' === $cap && isset( $args[0] ) && $this->forbidden_cat == $args[0] ) {
     2494        if ( 'assign_term' === $cap && isset( $args[0] ) && $this->forbidden_cat === $args[0] ) {
    24952495            $caps = array( 'do_not_allow' );
    24962496        }
  • trunk/tests/phpunit/tests/rest-api/rest-request.php

    r43571 r45607  
    464464        $data = $valid->get_error_data( 'rest_missing_callback_param' );
    465465
    466         $this->assertTrue( in_array( 'someinteger', $data['params'] ) );
    467         $this->assertTrue( in_array( 'someotherinteger', $data['params'] ) );
     466        $this->assertTrue( in_array( 'someinteger', $data['params'], true ) );
     467        $this->assertTrue( in_array( 'someotherinteger', $data['params'], true ) );
    468468    }
    469469
  • trunk/tests/phpunit/tests/shortcode.php

    r44569 r45607  
    3939    // [footag foo="bar"]
    4040    function _shortcode_footag( $atts ) {
    41         return @"foo = {$atts['foo']}";
     41        $foo = isset( $atts['foo'] ) ? $atts['foo'] : '';
     42        return "foo = $foo";
    4243    }
    4344
     
    445446    function _filter_atts2( $out, $pairs, $atts ) {
    446447        // If foo attribute equals "foo1", change it to be default value
    447         if ( isset( $out['foo'] ) && 'foo1' == $out['foo'] ) {
     448        if ( isset( $out['foo'] ) && 'foo1' === $out['foo'] ) {
    448449            $out['foo'] = $pairs['foo'];
    449450        }
  • trunk/tests/phpunit/tests/taxonomy.php

    r43571 r45607  
    812812        register_taxonomy( 'foo', 'post', array( 'query_var' => 'bar' ) );
    813813
    814         $this->assertInternalType( 'int', array_search( 'bar', $wp->public_query_vars ) );
     814        $this->assertInternalType( 'int', array_search( 'bar', $wp->public_query_vars, true ) );
    815815        $this->assertTrue( unregister_taxonomy( 'foo' ) );
    816         $this->assertFalse( array_search( 'bar', $wp->public_query_vars ) );
     816        $this->assertFalse( array_search( 'bar', $wp->public_query_vars, true ) );
    817817    }
    818818
  • trunk/tests/phpunit/tests/term/cache.php

    r43571 r45607  
    9191            }
    9292
    93             if ( $i % 3 === 0 ) {
     93            if ( 0 === ( $i % 3 ) ) {
    9494                $step = 1;
    9595            } else {
  • trunk/tests/phpunit/tests/term/getTerms.php

    r43571 r45607  
    24752475
    24762476        foreach ( $found as $f ) {
    2477             if ( $t1 == $f->term_id ) {
     2477            if ( $t1 === $f->term_id ) {
    24782478                $this->assertSame( 3, $f->count );
    2479             } elseif ( $t2 == $f->term_id ) {
     2479            } elseif ( $t2 === $f->term_id ) {
    24802480                $this->assertSame( 2, $f->count );
    24812481            } else {
     
    25482548
    25492549        foreach ( $found as $f ) {
    2550             if ( $t1 == $f->term_id ) {
     2550            if ( $t1 === $f->term_id ) {
    25512551                $this->assertEquals( 1, $f->count );
    2552             } elseif ( $t2 == $f->term_id ) {
     2552            } elseif ( $t2 === $f->term_id ) {
    25532553                $this->assertEquals( 2, $f->count );
    25542554            } else {
  • trunk/tests/phpunit/tests/term/wpInsertTerm.php

    r43571 r45607  
    823823        $cached_children = get_option( 'wptests_tax_children' );
    824824        $this->assertNotEmpty( $cached_children[ $t ] );
    825         $this->assertTrue( in_array( $found['term_id'], $cached_children[ $t ] ) );
     825        $this->assertTrue( in_array( $found['term_id'], $cached_children[ $t ], true ) );
    826826    }
    827827
  • trunk/tests/phpunit/tests/term/wpTaxonomy.php

    r43571 r45607  
    2323
    2424        $taxonomy_object->add_rewrite_rules();
    25         $this->assertFalse( in_array( 'foobar', $wp->public_query_vars ) );
     25        $this->assertFalse( in_array( 'foobar', $wp->public_query_vars, true ) );
    2626    }
    2727
     
    4444
    4545        $taxonomy_object->add_rewrite_rules();
    46         $in_array = in_array( 'foobar', $wp->public_query_vars );
     46        $in_array = in_array( 'foobar', $wp->public_query_vars, true );
    4747
    4848        $taxonomy_object->remove_rewrite_rules();
    49         $in_array_after = in_array( 'foobar', $wp->public_query_vars );
     49        $in_array_after = in_array( 'foobar', $wp->public_query_vars, true );
    5050
    5151        $this->assertTrue( $in_array );
     
    7575        $rewrite_tags_after = $wp_rewrite->rewritecode;
    7676
    77         $this->assertNotFalse( array_search( "%$taxonomy%", $rewrite_tags ) );
    78         $this->assertFalse( array_search( "%$taxonomy%", $rewrite_tags_after ) );
     77        $this->assertNotFalse( array_search( "%$taxonomy%", $rewrite_tags, true ) );
     78        $this->assertFalse( array_search( "%$taxonomy%", $rewrite_tags_after, true ) );
    7979    }
    8080
  • trunk/tests/phpunit/tests/term/wpUpdateTerm.php

    r43571 r45607  
    686686        $cached_children = get_option( 'wptests_tax_children' );
    687687        $this->assertNotEmpty( $cached_children[ $t2 ] );
    688         $this->assertTrue( in_array( $found['term_id'], $cached_children[ $t2 ] ) );
     688        $this->assertTrue( in_array( $found['term_id'], $cached_children[ $t2 ], true ) );
    689689    }
    690690
  • trunk/tests/phpunit/tests/theme.php

    r44966 r45607  
    244244            foreach ( $themes as $name => $theme ) {
    245245                // switch to this theme
    246                 if ( $i === 2 ) {
     246                if ( 2 === $i ) {
    247247                    switch_theme( $theme['Template'], $theme['Stylesheet'] );
    248248                } else {
  • trunk/tests/phpunit/tests/theme/support.php

    r44138 r45607  
    143143
    144144    function supports_foobar( $yesno, $args, $feature ) {
    145         if ( $args[0] == $feature[0] ) {
     145        if ( $args[0] === $feature[0] ) {
    146146            return true;
    147147        }
  • trunk/tests/phpunit/tests/theme/themeDir.php

    r42816 r45607  
    146146        // Ignore themes in the default /themes directory.
    147147        foreach ( $themes as $theme_name => $theme ) {
    148             if ( $theme->get_theme_root() != $this->theme_root ) {
     148            if ( $theme->get_theme_root() !== $this->theme_root ) {
    149149                unset( $themes[ $theme_name ] );
    150150            }
     
    210210
    211211        $templates = $theme['Template Files'];
    212         $this->assertTrue( in_array( $this->theme_root . '/page-templates/template-top-level.php', $templates ) );
     212        $this->assertTrue( in_array( $this->theme_root . '/page-templates/template-top-level.php', $templates, true ) );
    213213    }
    214214
  • trunk/tests/phpunit/tests/user.php

    r45588 r45607  
    8282        foreach ( $user_list as $user ) {
    8383            // only include the users we just created - there might be some others that existed previously
    84             if ( in_array( $user->ID, $nusers ) ) {
     84            if ( in_array( $user->ID, $nusers, true ) ) {
    8585                $found[] = $user->ID;
    8686            }
     
    162162        // so we'll just check to make sure our values are included somewhere.
    163163        foreach ( $vals as $k => $v ) {
    164             $this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] == $v );
     164            $this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
    165165        }
    166166        // delete one key and check again
     
    171171        // make sure that key is excluded from the results
    172172        foreach ( $vals as $k => $v ) {
    173             if ( $k == $key_to_delete ) {
     173            if ( $k === $key_to_delete ) {
    174174                $this->assertFalse( isset( $out[ $k ] ) );
    175175            } else {
    176                 $this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] == $v );
     176                $this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
    177177            }
    178178        }
     
    600600        }
    601601
    602         @update_user_meta( $id2, 'key', 'value' );
     602        update_user_meta( $id2, 'key', 'value' );
    603603
    604604        $metas = array_keys( get_user_meta( 1 ) );
     
    10231023        );
    10241024
    1025         $this->assertTrue( in_array( self::$contrib_id, $users ) );
     1025        $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
    10261026    }
    10271027
     
    10341034        );
    10351035
    1036         $this->assertTrue( in_array( self::$contrib_id, $users ) );
     1036        $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
    10371037    }
    10381038
     
    10451045        );
    10461046
    1047         $this->assertTrue( in_array( self::$contrib_id, $users ) );
     1047        $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
    10481048    }
    10491049
     
    10561056        );
    10571057
    1058         $this->assertTrue( in_array( self::$contrib_id, $users ) );
     1058        $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
    10591059    }
    10601060
     
    10671067        );
    10681068
    1069         $this->assertTrue( in_array( self::$contrib_id, $users ) );
     1069        $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
    10701070    }
    10711071
     
    12021202         */
    12031203        if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
    1204             $was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
    1205             $was_user_email_sent  = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' == $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
     1204            $was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
     1205            $was_user_email_sent  = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' === $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
    12061206        }
    12071207
     
    12271227         */
    12281228        if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
    1229             $was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
    1230             $was_user_email_sent  = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' == $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
     1229            $was_admin_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && WP_TESTS_EMAIL === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
     1230            $was_user_email_sent  = ( isset( $GLOBALS['phpmailer']->mock_sent[1] ) && 'blackburn@battlefield3.com' === $GLOBALS['phpmailer']->mock_sent[1]['to'][0][0] );
    12311231        }
    12321232
     
    14661466
    14671467        if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
    1468             $was_confirmation_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && 'after@example.com' == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
     1468            $was_confirmation_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && 'after@example.com' === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
    14691469        }
    14701470
     
    15031503
    15041504        if ( ! empty( $GLOBALS['phpmailer']->mock_sent ) ) {
    1505             $was_confirmation_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && 'after@example.com' == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
     1505            $was_confirmation_email_sent = ( isset( $GLOBALS['phpmailer']->mock_sent[0] ) && 'after@example.com' === $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] );
    15061506        }
    15071507
  • trunk/tests/phpunit/tests/user/capabilities.php

    r45507 r45607  
    15471547        // Prevents fatal errors in ::tearDown()'s and other uses of restore_current_blog()
    15481548        $function_stack = wp_debug_backtrace_summary( null, 0, false );
    1549         if ( in_array( 'restore_current_blog', $function_stack ) ) {
     1549        if ( in_array( 'restore_current_blog', $function_stack, true ) ) {
    15501550            return;
    15511551        }
  • trunk/tests/phpunit/tests/user/query.php

    r44373 r45607  
    5454
    5555        $this->assertEquals( '', $users->get( 'fields' ) );
    56         $this->assertEquals( '', @$users->query_vars['fields'] );
     56        if ( isset( $users->query_vars['fields'] ) ) {
     57            $this->assertEquals( '', $users->query_vars['fields'] );
     58        }
    5759
    5860        $users->set( 'fields', 'all' );
     
    11371139        );
    11381140
    1139         $foundCount    = count( $q->get_results() );
    1140         $expectedCount = 10; // 13 total users minus 3 from query
     1141        $found_count    = count( $q->get_results() );
     1142        $expected_count = 10; // 13 total users minus 3 from query
    11411143
    11421144        $this->assertContains( "AND user_nicename NOT IN ( 'peter','paul','mary' )", $q->query_where );
    1143         $this->assertEquals( $expectedCount, $foundCount );
     1145        $this->assertEquals( $expected_count, $found_count );
    11441146    }
    11451147
     
    12381240        );
    12391241
    1240         $foundCount    = count( $q->get_results() );
    1241         $expectedCount = 10; // 13 total users minus 3 from query
     1242        $found_count    = count( $q->get_results() );
     1243        $expected_count = 10; // 13 total users minus 3 from query
    12421244
    12431245        $this->assertContains( "AND user_login NOT IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where );
    1244         $this->assertEquals( $expectedCount, $foundCount );
     1246        $this->assertEquals( $expected_count, $found_count );
    12451247    }
    12461248
  • trunk/tests/phpunit/tests/widgets.php

    r43571 r45607  
    151151        $names = wp_list_pluck( $wp_registered_sidebars, 'name' );
    152152        for ( $i = 1; $i <= $num; $i++ ) {
    153             if ( in_array( "$id_base $i", $names ) ) {
     153            if ( in_array( "$id_base $i", $names, true ) ) {
    154154                $result[] = true;
    155155            }
  • trunk/tests/phpunit/tests/wp.php

    r44577 r45607  
    2323
    2424        $this->assertSame( $public_qv_count + 2, count( $this->wp->public_query_vars ) );
    25         $this->assertTrue( in_array( 'test', $this->wp->public_query_vars ) );
    26         $this->assertTrue( in_array( 'test2', $this->wp->public_query_vars ) );
     25        $this->assertTrue( in_array( 'test', $this->wp->public_query_vars, true ) );
     26        $this->assertTrue( in_array( 'test2', $this->wp->public_query_vars, true ) );
    2727    }
    2828
     
    3131
    3232        $this->wp->add_query_var( 'test' );
    33         $this->assertTrue( in_array( 'test', $this->wp->public_query_vars ) );
     33        $this->assertTrue( in_array( 'test', $this->wp->public_query_vars, true ) );
    3434        $this->wp->remove_query_var( 'test' );
    3535
  • trunk/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php

    r42343 r45607  
    110110            $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] );
    111111
    112             if ( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] == self::$post_id ) {
     112            if ( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] === self::$post_id ) {
    113113                $attachment_id = get_post_meta( $result['postid'], '_thumbnail_id', true );
    114114
  • trunk/tests/phpunit/tests/xmlrpc/wp/editPost.php

    r45424 r45607  
    446446
    447447        // For good measure, check that the expected value is in the array
    448         $this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ) ) );
     448        $this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) );
    449449
    450450        // Attempt to add a brand new enclosure via XML-RPC
     
    456456        // Check that the new enclosure is in the enclosure meta
    457457        $new_enclosure_string = "{$new_enclosure['url']}\n{$new_enclosure['length']}\n{$new_enclosure['type']}\n";
    458         $this->assertTrue( in_array( $new_enclosure_string, get_post_meta( $post_id, 'enclosure' ) ) );
     458        $this->assertTrue( in_array( $new_enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) );
    459459
    460460        // Check that the old enclosure is in the enclosure meta
    461         $this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ) ) );
     461        $this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) );
    462462    }
    463463
  • trunk/tests/phpunit/tests/xmlrpc/wp/getPages.php

    r42343 r45607  
    5656
    5757    function remove_editor_edit_page_cap( $caps, $cap, $user_id, $args ) {
    58         if ( in_array( $cap, array( 'edit_page', 'edit_others_pages' ) ) ) {
    59             if ( $user_id == self::$editor_id && $args[0] == self::$post_id ) {
     58        if ( in_array( $cap, array( 'edit_page', 'edit_others_pages' ), true ) ) {
     59            if ( $user_id === self::$editor_id && $args[0] === self::$post_id ) {
    6060                return array( false );
    6161            }
     
    7979            $this->assertNotIXRError( $result );
    8080
    81             if ( $result['page_id'] == self::$post_id ) {
     81            if ( $result['page_id'] === self::$post_id ) {
    8282                $found_incapable = true;
    8383                break;
  • trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php

    r42343 r45607  
    122122
    123123        foreach ( $results as $term ) {
    124             if ( $term['term_id'] == $cat1 ) {
     124            if ( $term['term_id'] === $cat1 ) {
    125125                break;  // found cat1 first as expected
    126             } elseif ( $term['term_id'] == $cat2 ) {
     126            } elseif ( $term['term_id'] === $cat2 ) {
    127127                $this->assertFalse( false, 'Incorrect category ordering.' );
    128128            }
  • trunk/tests/phpunit/wp-mail-real-test.php

    r44563 r45607  
    5454
    5555// make sure we're installed
    56 assert( true == is_blog_installed() );
     56assert( true === is_blog_installed() );
    5757
    5858// phpcs:ignore Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase
Note: See TracChangeset for help on using the changeset viewer.