Changeset 45607
- Timestamp:
- 07/08/2019 12:55:20 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 91 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.travis.yml
r45570 r45607 16 16 env: WP_TRAVISCI=e2e 17 17 - php: 7.2 18 env: WP_TRAVISCI=travis: format18 env: WP_TRAVISCI=travis:phpcs 19 19 - php: 7.1 20 20 env: WP_TRAVISCI=travis:js … … 84 84 fi 85 85 - | 86 # We only need to run composer install on the code formattingjob.87 if [[ "$WP_TRAVISCI" == "travis: format" ]]; then86 # We only need to run composer install on the PHP coding standards job. 87 if [[ "$WP_TRAVISCI" == "travis:phpcs" ]]; then 88 88 composer --version 89 89 travis_retry composer install -
trunk/Gruntfile.js
r45448 r45607 1439 1439 } ); 1440 1440 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 1441 1462 // Travis CI tasks. 1442 1463 grunt.registerTask('travis:js', 'Runs Javascript Travis CI tasks.', [ 'jshint:corejs', 'qunit:compiled' ]); 1443 1464 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' ]); 1445 1466 1446 1467 // Patch task. -
trunk/phpcs.xml.dist
r45604 r45607 186 186 <rule ref="WordPress.Files.FileName"> 187 187 <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> 189 221 </properties> 190 222 </rule> -
trunk/phpunit.xml.dist
r44705 r45607 44 44 <arguments> 45 45 <array> 46 <element key="slow Threshold">46 <element key="slow_threshold"> 47 47 <integer>150</integer> 48 48 </element> -
trunk/tests/phpunit/includes/bootstrap.php
r45588 r45607 77 77 78 78 // Should we run in multisite mode? 79 $multisite = '1' == getenv( 'WP_MULTISITE');79 $multisite = ( '1' === getenv( 'WP_MULTISITE' ) ); 80 80 $multisite = $multisite || ( defined( 'WP_TESTS_MULTISITE' ) && WP_TESTS_MULTISITE ); 81 81 $multisite = $multisite || ( defined( 'MULTISITE' ) && MULTISITE ); … … 192 192 193 193 foreach ( $skipped_groups as $group_name => $skipped ) { 194 if ( in_array( $group_name, $groups ) ) {194 if ( in_array( $group_name, $groups, true ) ) { 195 195 $skipped_groups[ $group_name ] = false; 196 196 } -
trunk/tests/phpunit/includes/functions.php
r45580 r45607 101 101 $wpdb->termmeta, 102 102 ) as $table ) { 103 //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 103 104 $wpdb->query( "DELETE FROM {$table}" ); 104 105 } … … 108 109 $wpdb->term_taxonomy, 109 110 ) as $table ) { 111 //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 110 112 $wpdb->query( "DELETE FROM {$table} WHERE term_id != 1" ); 111 113 } -
trunk/tests/phpunit/includes/install.php
r45588 r45607 54 54 $wpdb->query( 'SET foreign_key_checks = 0' ); 55 55 foreach ( $wpdb->tables() as $table => $prefixed_table ) { 56 //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 56 57 $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); 57 58 } 58 59 59 60 foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table ) { 61 //phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 60 62 $wpdb->query( "DROP TABLE IF EXISTS $prefixed_table" ); 61 63 -
trunk/tests/phpunit/includes/mock-fs.php
r42343 r45607 62 62 foreach ( $paths as $path ) { 63 63 // Allow for comments 64 if ( '#' == $path[0] ) {64 if ( '#' === $path[0] ) { 65 65 continue; 66 66 } 67 67 68 68 // Directories 69 if ( '/' == $path[ strlen( $path ) - 1 ] ) {69 if ( '/' === $path[ strlen( $path ) - 1 ] ) { 70 70 $this->mkdir( $path ); 71 71 } else { // Files (with dummy content for now) … … 162 162 function dirlist( $path = '.', $include_hidden = true, $recursive = false ) { 163 163 164 if ( empty( $path ) || '.' == $path ) {164 if ( empty( $path ) || '.' === $path ) { 165 165 $path = $this->cwd(); 166 166 } … … 178 178 $ret = array(); 179 179 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 ) { 189 189 continue; 190 190 } … … 194 194 $struc['type'] = $entry->type; 195 195 196 if ( 'd' == $struc['type'] ) {196 if ( 'd' === $struc['type'] ) { 197 197 if ( $recursive ) { 198 198 $struc['files'] = $this->dirlist( trailingslashit( $path ) . trailingslashit( $struc['name'] ), $include_hidden, $recursive ); … … 220 220 221 221 function is_file() { 222 return $this->type == 'f';222 return 'f' === $this->type; 223 223 } 224 224 225 225 function is_dir() { 226 return $this->type == 'd';226 return 'd' === $this->type; 227 227 } 228 228 } -
trunk/tests/phpunit/includes/object-cache.php
r45580 r45607 873 873 * @param int $expiration The expiration time, defaults to 0. 874 874 * @param string $server_key The key identifying the server to store the value on. 875 * @param bool $by KeyTrue to store in internal cache by key; false to not store by key875 * @param bool $by_key True to store in internal cache by key; false to not store by key 876 876 * @return bool Returns TRUE on success or FALSE on failure. 877 877 */ 878 public function add( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by Key = false ) {878 public function add( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) { 879 879 /* 880 880 * Ensuring that wp_suspend_cache_addition is defined before calling, because sometimes an advanced-cache.php … … 891 891 892 892 // 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 ) ) { 894 894 895 895 // Add does not set the value if the key exists; mimic that here … … 904 904 905 905 // Save to Memcached 906 if ( $by Key ) {906 if ( $by_key ) { 907 907 $result = $this->m->addByKey( $server_key, $derived_key, $value, $expiration ); 908 908 } else { … … 992 992 * @param string $group The group value appended to the $key. 993 993 * @param string $server_key The key identifying the server to store the value on. 994 * @param bool $by KeyTrue to store in internal cache by key; false to not store by key994 * @param bool $by_key True to store in internal cache by key; false to not store by key 995 995 * @return bool Returns TRUE on success or FALSE on failure. 996 996 */ 997 public function append( $key, $value, $group = 'default', $server_key = '', $by Key = false ) {997 public function append( $key, $value, $group = 'default', $server_key = '', $by_key = false ) { 998 998 if ( ! is_string( $value ) && ! is_int( $value ) && ! is_float( $value ) ) { 999 999 return false; … … 1003 1003 1004 1004 // 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 ) ) { 1006 1006 if ( ! isset( $this->cache[ $derived_key ] ) ) { 1007 1007 return false; … … 1014 1014 1015 1015 // Append to Memcached value 1016 if ( $by Key ) {1016 if ( $by_key ) { 1017 1017 $result = $this->m->appendByKey( $server_key, $derived_key, $value ); 1018 1018 } else { … … 1065 1065 * @param int $expiration The expiration time, defaults to 0. 1066 1066 * @param string $server_key The key identifying the server to store the value on. 1067 * @param bool $by KeyTrue to store in internal cache by key; false to not store by key1067 * @param bool $by_key True to store in internal cache by key; false to not store by key 1068 1068 * @return bool Returns TRUE on success or FALSE on failure. 1069 1069 */ 1070 public function cas( $cas_token, $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by Key = false ) {1070 public function cas( $cas_token, $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) { 1071 1071 $derived_key = $this->buildKey( $key, $group ); 1072 1072 $expiration = $this->sanitize_expiration( $expiration ); … … 1077 1077 * operation is treated as a normal "add" for no_mc_groups. 1078 1078 */ 1079 if ( in_array( $group, $this->no_mc_groups ) ) {1079 if ( in_array( $group, $this->no_mc_groups, true ) ) { 1080 1080 $this->add_to_internal_cache( $derived_key, $value ); 1081 1081 return true; … … 1083 1083 1084 1084 // Save to Memcached 1085 if ( $by Key ) {1085 if ( $by_key ) { 1086 1086 $result = $this->m->casByKey( $cas_token, $server_key, $derived_key, $value, $expiration ); 1087 1087 } else { … … 1131 1131 1132 1132 // 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 ) ) { 1134 1134 1135 1135 // Only decrement if the key already exists and value is 0 or greater (mimics memcached behavior) … … 1192 1192 * @param int $time The amount of time the server will wait to delete the item in seconds. 1193 1193 * @param string $server_key The key identifying the server to store the value on. 1194 * @param bool $by KeyTrue to store in internal cache by key; false to not store by key1194 * @param bool $by_key True to store in internal cache by key; false to not store by key 1195 1195 * @return bool Returns TRUE on success or FALSE on failure. 1196 1196 */ 1197 public function delete( $key, $group = 'default', $time = 0, $server_key = '', $by Key = false ) {1197 public function delete( $key, $group = 'default', $time = 0, $server_key = '', $by_key = false ) { 1198 1198 $derived_key = $this->buildKey( $key, $group ); 1199 1199 1200 1200 // 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 ) ) { 1202 1202 if ( isset( $this->cache[ $derived_key ] ) ) { 1203 1203 unset( $this->cache[ $derived_key ] ); … … 1207 1207 } 1208 1208 1209 if ( $by Key ) {1209 if ( $by_key ) { 1210 1210 $result = $this->m->deleteByKey( $server_key, $derived_key, $time ); 1211 1211 } else { … … 1300 1300 * @param null|bool $found Variable passed by reference to determine if the value was found or not. 1301 1301 * @param string $server_key The key identifying the server to store the value on. 1302 * @param bool $by KeyTrue to store in internal cache by key; false to not store by key1302 * @param bool $by_key True to store in internal cache by key; false to not store by key 1303 1303 * @param null|callable $cache_cb Read-through caching callback. 1304 1304 * @param null|float $cas_token The variable to store the CAS token in. 1305 1305 * @return bool|mixed Cached object value. 1306 1306 */ 1307 public function get( $key, $group = 'default', $force = false, &$found = null, $server_key = '', $by Key = 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 ) { 1308 1308 $derived_key = $this->buildKey( $key, $group ); 1309 1309 … … 1312 1312 1313 1313 // 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 ( $by Key ) {1314 if ( func_num_args() > 6 && ! in_array( $group, $this->no_mc_groups, true ) ) { 1315 if ( $by_key ) { 1316 1316 $value = $this->m->getByKey( $server_key, $derived_key, $cache_cb, $cas_token ); 1317 1317 } else { … … 1322 1322 $found = true; 1323 1323 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 ) ) { 1325 1325 return false; 1326 1326 } else { 1327 if ( $by Key ) {1327 if ( $by_key ) { 1328 1328 $value = $this->m->getByKey( $server_key, $derived_key ); 1329 1329 } else { … … 1465 1465 1466 1466 // 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 ) { 1468 1468 $ordered_values = array(); 1469 1469 … … 1604 1604 1605 1605 // 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 ) ) { 1607 1607 1608 1608 // Only increment if the key already exists and the number is currently 0 or greater (mimics memcached behavior) … … 1669 1669 * @param string $group The group value prepended to the $key. 1670 1670 * @param string $server_key The key identifying the server to store the value on. 1671 * @param bool $by KeyTrue to store in internal cache by key; false to not store by key1671 * @param bool $by_key True to store in internal cache by key; false to not store by key 1672 1672 * @return bool Returns TRUE on success or FALSE on failure. 1673 1673 */ 1674 public function prepend( $key, $value, $group = 'default', $server_key = '', $by Key = false ) {1674 public function prepend( $key, $value, $group = 'default', $server_key = '', $by_key = false ) { 1675 1675 if ( ! is_string( $value ) && ! is_int( $value ) && ! is_float( $value ) ) { 1676 1676 return false; … … 1680 1680 1681 1681 // 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 ) ) { 1683 1683 if ( ! isset( $this->cache[ $derived_key ] ) ) { 1684 1684 return false; … … 1691 1691 1692 1692 // Append to Memcached value 1693 if ( $by Key ) {1693 if ( $by_key ) { 1694 1694 $result = $this->m->prependByKey( $server_key, $derived_key, $value ); 1695 1695 } else { … … 1741 1741 * @param mixed $value The value to store. 1742 1742 * @param string $group The group value appended to the $key. 1743 * @param bool $by KeyTrue to store in internal cache by key; false to not store by key1743 * @param bool $by_key True to store in internal cache by key; false to not store by key 1744 1744 * @param int $expiration The expiration time, defaults to 0. 1745 1745 * @return bool Returns TRUE on success or FALSE on failure. 1746 1746 */ 1747 public function replace( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by Key = false ) {1747 public function replace( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) { 1748 1748 $derived_key = $this->buildKey( $key, $group ); 1749 1749 $expiration = $this->sanitize_expiration( $expiration ); 1750 1750 1751 1751 // 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 ) ) { 1753 1753 1754 1754 // Replace won't save unless the key already exists; mimic this behavior here … … 1762 1762 1763 1763 // Save to Memcached 1764 if ( $by Key ) {1764 if ( $by_key ) { 1765 1765 $result = $this->m->replaceByKey( $server_key, $derived_key, $value, $expiration ); 1766 1766 } else { … … 1807 1807 * @param int $expiration The expiration time, defaults to 0. 1808 1808 * @param string $server_key The key identifying the server to store the value on. 1809 * @param bool $by KeyTrue to store in internal cache by key; false to not store by key1809 * @param bool $by_key True to store in internal cache by key; false to not store by key 1810 1810 * @return bool Returns TRUE on success or FALSE on failure. 1811 1811 */ 1812 public function set( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by Key = false ) {1812 public function set( $key, $value, $group = 'default', $expiration = 0, $server_key = '', $by_key = false ) { 1813 1813 $derived_key = $this->buildKey( $key, $group ); 1814 1814 $expiration = $this->sanitize_expiration( $expiration ); 1815 1815 1816 1816 // 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 ) ) { 1818 1818 $this->add_to_internal_cache( $derived_key, $value ); 1819 1819 return true; … … 1821 1821 1822 1822 // Save to Memcached 1823 if ( $by Key ) {1823 if ( $by_key ) { 1824 1824 $result = $this->m->setByKey( $server_key, $derived_key, $value, $expiration ); 1825 1825 } else { … … 1868 1868 * @param int $expiration The expiration time, defaults to 0. 1869 1869 * @param string $server_key The key identifying the server to store the value on. 1870 * @param bool $by KeyTrue to store in internal cache by key; false to not store by key1870 * @param bool $by_key True to store in internal cache by key; false to not store by key 1871 1871 * @return bool Returns TRUE on success or FALSE on failure. 1872 1872 */ 1873 public function setMulti( $items, $groups = 'default', $expiration = 0, $server_key = '', $by Key = false ) {1873 public function setMulti( $items, $groups = 'default', $expiration = 0, $server_key = '', $by_key = false ) { 1874 1874 // Build final keys and replace $items keys with the new keys 1875 1875 $derived_keys = $this->buildKeys( array_keys( $items ), $groups ); … … 1884 1884 1885 1885 // 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 ) ) { 1887 1887 $this->add_to_internal_cache( $derived_key, $value ); 1888 1888 unset( $derived_items[ $derived_key ] ); … … 1891 1891 1892 1892 // Save to memcached 1893 if ( $by Key ) {1893 if ( $by_key ) { 1894 1894 $result = $this->m->setMultiByKey( $server_key, $derived_items, $expiration ); 1895 1895 } else { … … 1954 1954 } 1955 1955 1956 if ( false !== array_search( $group, $this->global_groups ) ) {1956 if ( false !== array_search( $group, $this->global_groups, true ) ) { 1957 1957 $prefix = $this->global_prefix; 1958 1958 } else { … … 1992 1992 1993 1993 // 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 ) ) { 1995 1995 for ( $i = 0; $i < count( $keys ); $i++ ) { 1996 1996 $derived_keys[] = $this->buildKey( $keys[ $i ], $groups[ $i ] ); … … 2002 2002 if ( isset( $groups[ $i ] ) ) { 2003 2003 $derived_keys[] = $this->buildKey( $keys[ $i ], $groups[ $i ] ); 2004 } elseif ( count( $groups ) == 1 ) {2004 } elseif ( count( $groups ) === 1 ) { 2005 2005 $derived_keys[] = $this->buildKey( $keys[ $i ], $groups[0] ); 2006 2006 } else { … … 2047 2047 2048 2048 // Combine the values based on direction of the "pend" 2049 if ( 'pre' == $direction ) {2049 if ( 'pre' === $direction ) { 2050 2050 $combined = $pended . $original; 2051 2051 } else { … … 2081 2081 public function contains_no_mc_group( $groups ) { 2082 2082 if ( is_scalar( $groups ) ) { 2083 return in_array( $groups, $this->no_mc_groups );2083 return in_array( $groups, $this->no_mc_groups, true ); 2084 2084 } 2085 2085 … … 2089 2089 2090 2090 foreach ( $groups as $group ) { 2091 if ( in_array( $group, $this->no_mc_groups ) ) {2091 if ( in_array( $group, $this->no_mc_groups, true ) ) { 2092 2092 return true; 2093 2093 } -
trunk/tests/phpunit/includes/phpunit6/compat.php
r45580 r45607 19 19 20 20 // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid 21 public static function getTickets( $class Name, $methodName ) {22 $annotations = PHPUnit\Util\Test::parseTestMethodAnnotations( $class Name, $methodName );21 public static function getTickets( $class_name, $method_name ) { 22 $annotations = PHPUnit\Util\Test::parseTestMethodAnnotations( $class_name, $method_name ); 23 23 24 24 $tickets = array(); -
trunk/tests/phpunit/includes/phpunit7/speed-trap-listener.php
r45588 r45607 23 23 * @var int 24 24 */ 25 protected $slow Threshold;25 protected $slow_threshold; 26 26 27 27 /** … … 30 30 * @var int 31 31 */ 32 protected $report Length;32 protected $report_length; 33 33 34 34 /** … … 167 167 * 168 168 * @param int $time Test execution time in milliseconds 169 * @param int $slow Threshold 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) 170 170 * @return bool 171 171 */ 172 protected function isSlow( $time, $slow Threshold ) {173 return $time >= $slow Threshold;172 protected function isSlow( $time, $slow_threshold ) { 173 return $time >= $slow_threshold; 174 174 } 175 175 … … 221 221 */ 222 222 protected function getReportLength() { 223 return min( count( $this->slow ), $this->report Length );223 return min( count( $this->slow ), $this->report_length ); 224 224 } 225 225 … … 245 245 */ 246 246 protected function renderHeader() { 247 echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slow Threshold );247 echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slow_threshold ); 248 248 } 249 249 … … 252 252 */ 253 253 protected function renderBody() { 254 $slow Tests = $this->slow;255 256 $length = $this->getReportLength( $slow Tests );254 $slow_tests = $this->slow; 255 256 $length = $this->getReportLength( $slow_tests ); 257 257 for ( $i = 1; $i <= $length; ++$i ) { 258 $label = key( $slow Tests );259 $time = array_shift( $slow Tests );258 $label = key( $slow_tests ); 259 $time = array_shift( $slow_tests ); 260 260 261 261 echo sprintf( " %s. %sms to run %s\n", $i, $time, $label ); … … 269 269 $hidden = $this->getHiddenCount( $this->slow ); 270 270 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 ); 272 272 } 273 273 } … … 279 279 */ 280 280 protected function loadOptions( array $options ) { 281 $this->slow Threshold = isset( $options['slowThreshold'] ) ? $options['slowThreshold'] : 500;282 $this->report Length = 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; 283 283 } 284 284 … … 303 303 $ann = $test->getAnnotations(); 304 304 305 return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slow Threshold;305 return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slow_threshold; 306 306 } 307 307 } -
trunk/tests/phpunit/includes/speed-trap-listener.php
r42343 r45607 23 23 * @var int 24 24 */ 25 protected $slow Threshold;25 protected $slow_threshold; 26 26 27 27 /** … … 30 30 * @var int 31 31 */ 32 protected $report Length;32 protected $report_length; 33 33 34 34 /** … … 167 167 * 168 168 * @param int $time Test execution time in milliseconds 169 * @param int $slow Threshold 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) 170 170 * @return bool 171 171 */ 172 protected function isSlow( $time, $slow Threshold ) {173 return $time >= $slow Threshold;172 protected function isSlow( $time, $slow_threshold ) { 173 return $time >= $slow_threshold; 174 174 } 175 175 … … 221 221 */ 222 222 protected function getReportLength() { 223 return min( count( $this->slow ), $this->report Length );223 return min( count( $this->slow ), $this->report_length ); 224 224 } 225 225 … … 245 245 */ 246 246 protected function renderHeader() { 247 echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slow Threshold );247 echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slow_threshold ); 248 248 } 249 249 … … 252 252 */ 253 253 protected function renderBody() { 254 $slow Tests = $this->slow;255 256 $length = $this->getReportLength( $slow Tests );254 $slow_tests = $this->slow; 255 256 $length = $this->getReportLength( $slow_tests ); 257 257 for ( $i = 1; $i <= $length; ++$i ) { 258 $label = key( $slow Tests );259 $time = array_shift( $slow Tests );258 $label = key( $slow_tests ); 259 $time = array_shift( $slow_tests ); 260 260 261 261 echo sprintf( " %s. %sms to run %s\n", $i, $time, $label ); … … 268 268 protected function renderFooter() { 269 269 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 ); 271 271 } 272 272 } … … 278 278 */ 279 279 protected function loadOptions( array $options ) { 280 $this->slow Threshold = isset( $options['slowThreshold'] ) ? $options['slowThreshold'] : 500;281 $this->report Length = 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; 282 282 } 283 283 … … 302 302 $ann = $test->getAnnotations(); 303 303 304 return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slow Threshold;304 return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slow_threshold; 305 305 } 306 306 } -
trunk/tests/phpunit/includes/trac.php
r45580 r45607 42 42 } 43 43 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 ); 45 45 } 46 46 -
trunk/tests/phpunit/includes/utils.php
r45580 r45607 153 153 $count = 0; 154 154 foreach ( $this->events as $e ) { 155 if ( $e['action'] == $tag ) {155 if ( $e['action'] === $tag ) { 156 156 ++$count; 157 157 } … … 223 223 224 224 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; 227 231 } 228 232 … … 254 258 # echo "checking '{$tree[$i][name]}' == '{$a[0]}'\n"; 255 259 # var_dump($tree[$i]['name'], $a[0]); 256 if ( $tree[ $i ]['name'] == $a[0] ) {260 if ( $tree[ $i ]['name'] === $a[0] ) { 257 261 # echo "n == {$n}\n"; 258 if ( $n == 1) {262 if ( 1 === $n ) { 259 263 $out[] = $tree[ $i ]; 260 264 } else { … … 349 353 $tables = $wpdb->get_col( 'SHOW TABLES;' ); 350 354 foreach ( $tables as $table ) { 355 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 351 356 $wpdb->query( "DROP TABLE IF EXISTS {$table}" ); 352 357 } … … 439 444 * Special class for exposing protected wpdb methods we need to access 440 445 */ 441 class wpdb_exposed_methods_for_testing extends wpdb {446 class WpdbExposedMethodsForTesting extends wpdb { 442 447 public function __construct() { 443 448 global $wpdb; -
trunk/tests/phpunit/includes/wp-profiler.php
r44915 r45607 115 115 if ( $this->stack ) { 116 116 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 ]++; 119 119 } else { 120 @$this->stack[ count( $this->stack ) - 1 ]['filters'][ $tag ]++;120 $this->stack[ count( $this->stack ) - 1 ]['filters'][ $tag ]++; 121 121 } 122 122 } … … 126 126 public function log_action( $tag ) { 127 127 if ( $this->stack ) { 128 @$this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]++;128 $this->stack[ count( $this->stack ) - 1 ]['actions'][ $tag ]++; 129 129 } 130 130 } … … 145 145 $sql = preg_replace( '/(WHERE \w+ =) \'\[-\w]+\'/', '$1 \'xxx\'', $sql ); 146 146 147 @$out[ $sql ] ++;147 $out[ $sql ] ++; 148 148 } 149 149 asort( $out ); … … 156 156 foreach ( $queries as $q ) { 157 157 if ( empty( $q[2] ) ) { 158 @$out['unknown']++;158 $out['unknown']++; 159 159 } else { 160 @$out[ $q[2] ]++;160 $out[ $q[2] ]++; 161 161 } 162 162 } -
trunk/tests/phpunit/tests/admin/includesPlugin.php
r45588 r45607 103 103 104 104 $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.' ); 107 107 108 108 $plugin_files = get_plugin_files( plugin_basename( $plugin[1] ) ); … … 416 416 } 417 417 418 @closedir( $mu_plugins );418 closedir( $mu_plugins ); 419 419 420 420 foreach ( $files_to_move as $file_to_move ) { … … 443 443 } 444 444 445 @closedir( $mu_plugins );445 closedir( $mu_plugins ); 446 446 447 447 foreach ( $files_to_move as $file_to_move ) { -
trunk/tests/phpunit/tests/admin/includesSchema.php
r43641 r45607 29 29 $max_index_length = 191; 30 30 31 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared 31 32 $wpdb->query( 32 33 " … … 67 68 " 68 69 ); 70 // phpcs:enable 69 71 } 70 72 … … 79 81 $sitemeta = self::$sitemeta; 80 82 83 // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared 81 84 $wpdb->query( "DROP TABLE IF EXISTS {$options}" ); 82 85 $wpdb->query( "DROP TABLE IF EXISTS {$blogmeta}" ); 83 86 $wpdb->query( "DROP TABLE IF EXISTS {$sitemeta}" ); 87 // phpcs:enable 84 88 } 85 89 -
trunk/tests/phpunit/tests/adminbar.php
r45588 r45607 745 745 $nodes = $wp_admin_bar->get_nodes(); 746 746 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 ) ) { 748 748 $this->assertTrue( isset( $nodes[ $id ] ), sprintf( 'Menu item %1$s must display for a user with the %2$s cap.', $id, $cap ) ); 749 749 } else { -
trunk/tests/phpunit/tests/ajax/CustomizeMenus.php
r43571 r45607 53 53 function test_ajax_load_available_items_cap_check( $role, $expected_results ) { 54 54 55 if ( 'administrator' != $role ) {55 if ( 'administrator' !== $role ) { 56 56 // If we're not an admin, we should get a wp_die(-1). 57 57 $this->setExpectedException( 'WPAjaxDieStopException' ); … … 442 442 function test_ajax_search_available_items_caps_check( $role, $expected_results ) { 443 443 444 if ( 'administrator' != $role ) {444 if ( 'administrator' !== $role ) { 445 445 // If we're not an admin, we should get a wp_die(-1). 446 446 $this->setExpectedException( 'WPAjaxDieStopException' ); -
trunk/tests/phpunit/tests/ajax/DeleteComment.php
r42343 r45607 95 95 96 96 // 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 ) ) { 98 98 $total = $_POST['_total'] - 1; 99 99 100 100 // 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 ) ) { 102 102 $total = $_POST['_total'] + 1; 103 103 } … … 109 109 // Check for either possible total 110 110 $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 ); 112 112 } 113 113 … … 244 244 245 245 // Force delete the comment 246 if ( 'delete' == $action ) {246 if ( 'delete' === $action ) { 247 247 wp_delete_comment( $comment->comment_ID, true ); 248 248 } -
trunk/tests/phpunit/tests/ajax/DimComment.php
r42343 r45607 90 90 // Check the status 91 91 $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 ) ) { 93 93 $this->assertEquals( 'approved', $current ); 94 94 } else { … … 104 104 105 105 // 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 ) ); 107 107 } 108 108 -
trunk/tests/phpunit/tests/ajax/EditComment.php
r42343 r45607 97 97 98 98 // 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 ) ); 100 100 clean_comment_cache( $comment->comment_ID ); 101 101 -
trunk/tests/phpunit/tests/ajax/Response.php
r42343 r45607 86 86 ob_end_clean(); 87 87 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 ) ); 89 89 } 90 90 -
trunk/tests/phpunit/tests/basic.php
r45424 r45607 23 23 list( $version ) = explode( '-', $GLOBALS['wp_version'] ); 24 24 // 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, '.' ) ) { 26 26 $version .= '.0'; 27 27 } -
trunk/tests/phpunit/tests/comment.php
r43467 r45607 673 673 if ( isset( $GLOBALS['phpmailer']->mock_sent ) 674 674 && ! 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] 676 676 ) { 677 677 $email_sent_when_comment_added = true; … … 701 701 if ( isset( $GLOBALS['phpmailer']->mock_sent ) 702 702 && ! 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] 704 704 ) { 705 705 $email_sent_when_comment_approved = true; … … 723 723 if ( isset( $GLOBALS['phpmailer']->mock_sent ) && 724 724 ! 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] ) { 726 726 $email_sent_when_comment_added = true; 727 727 reset_phpmailer_instance(); -
trunk/tests/phpunit/tests/comment/walker.php
r43571 r45607 55 55 56 56 public function comment( $comment, $args, $depth ) { 57 if ( 1 == $depth ) {57 if ( 1 === $depth ) { 58 58 $this->test_walker->assertTrue( $this->walker->has_children ); 59 59 $this->test_walker->assertTrue( $args['has_children'] ); // Back compat 60 } elseif ( 2 == $depth ) {60 } elseif ( 2 === $depth ) { 61 61 $this->test_walker->assertFalse( $this->walker->has_children ); 62 62 $this->test_walker->assertFalse( $args['has_children'] ); // Back compat -
trunk/tests/phpunit/tests/compat.php
r43571 r45607 126 126 $heredoc, 127 127 // object data 128 new classA(),129 // undefined data128 new ClassA(), 129 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- intentionally undefined data 130 130 @$undefined_var, 131 // unset data131 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- intentionally unset data 132 132 @$unset_var, 133 133 ); … … 316 316 317 317 /* used in test_mb_substr_phpcore */ 318 class classA {318 class ClassA { 319 319 public function __toString() { 320 320 return 'Class A object'; -
trunk/tests/phpunit/tests/customize/manager.php
r45588 r45607 2669 2669 function filter_customize_dynamic_setting_args_for_test_dynamic_settings( $setting_args, $setting_id ) { 2670 2670 $this->assertInternalType( 'string', $setting_id ); 2671 if ( in_array( $setting_id, array( 'foo', 'bar' ) ) ) {2671 if ( in_array( $setting_id, array( 'foo', 'bar' ), true ) ) { 2672 2672 $setting_args = array( 'default' => "dynamic_{$setting_id}_default" ); 2673 2673 } -
trunk/tests/phpunit/tests/customize/nav-menu-item-setting.php
r43571 r45607 387 387 $db_ids = wp_list_pluck( $menu_items, 'db_id' ); 388 388 $this->assertContains( $item_id, $db_ids ); 389 $i = array_search( $item_id, $db_ids );389 $i = array_search( $item_id, $db_ids, true ); 390 390 $updated_item = $menu_items[ $i ]; 391 391 $post_value['post_status'] = $post_value['status']; … … 677 677 $db_ids = wp_list_pluck( $menu_items, 'db_id' ); 678 678 $this->assertContains( $item_id, $db_ids ); 679 $i = array_search( $item_id, $db_ids );679 $i = array_search( $item_id, $db_ids, true ); 680 680 $updated_item = $menu_items[ $i ]; 681 681 $post_value['post_status'] = $post_value['status']; -
trunk/tests/phpunit/tests/customize/nav-menu-setting.php
r43571 r45607 225 225 $menus = wp_get_nav_menus(); 226 226 $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 ); 228 228 $this->assertInternalType( 'int', $i, 'Update-previewed menu does not appear in wp_get_nav_menus()' ); 229 229 $filtered_menu = $menus[ $i ]; … … 270 270 $menus = wp_get_nav_menus(); 271 271 $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 ); 273 273 $this->assertInternalType( 'int', $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()' ); 274 274 $filtered_menu = $menus[ $i ]; -
trunk/tests/phpunit/tests/date/query.php
r43571 r45607 1015 1015 $days_of_year = array( -1, 0, 367 ); 1016 1016 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 ) ) ); 1018 1018 } 1019 1019 } -
trunk/tests/phpunit/tests/db.php
r45603 r45607 24 24 public static function setUpBeforeClass() { 25 25 parent::setUpBeforeClass(); 26 self::$_wpdb = new wpdb_exposed_methods_for_testing();26 self::$_wpdb = new WpdbExposedMethodsForTesting(); 27 27 } 28 28 … … 347 347 348 348 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 ); 350 350 $this->assertGreaterThanOrEqual( 0, $pos ); 351 351 … … 366 366 $id = 0; 367 367 // This, obviously, is an incorrect prepare. 368 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 368 369 $prepared = $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = $id", $id ); 369 370 $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0", $prepared ); … … 383 384 global $wpdb; 384 385 386 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 385 387 $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", 1, array( 'admin' ) ); 386 388 $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = ''", $prepared ); 387 389 390 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 388 391 $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( 1 ), 'admin' ); 389 392 $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared ); … … 403 406 global $wpdb; 404 407 408 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 405 409 $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( 1, array( 'admin' ) ) ); 406 410 $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 1 AND user_login = ''", $prepared ); 407 411 412 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 408 413 $prepared = @$wpdb->prepare( "SELECT * FROM $wpdb->users WHERE id = %d AND user_login = %s", array( array( 1 ), 'admin' ) ); 409 414 $this->assertEquals( "SELECT * FROM $wpdb->users WHERE id = 0 AND user_login = 'admin'", $prepared ); … … 421 426 array_unshift( $args, $query ); 422 427 428 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 423 429 $prepared = @call_user_func_array( array( $wpdb, 'prepare' ), $args ); 424 430 $this->assertEquals( $expected, $prepared ); … … 588 594 $wpdb->last_result = $last_result; 589 595 596 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 590 597 $result = $wpdb->get_col( $query, $column ); 591 598 … … 1044 1051 } 1045 1052 1046 if ( ! in_array( $expected_charset, array( 'utf8', 'utf8mb4', 'latin1' ) ) ) {1053 if ( ! in_array( $expected_charset, array( 'utf8', 'utf8mb4', 'latin1' ), true ) ) { 1047 1054 $this->markTestSkipped( 'This test only works with utf8, utf8mb4 or latin1 character sets' ); 1048 1055 } … … 1117 1124 ); 1118 1125 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 ) ); 1120 1127 1121 1128 $this->assertNull( $row->meta_value ); … … 1140 1147 ); 1141 1148 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 ) ); 1143 1150 1144 1151 $this->assertSame( $value, $row->meta_value ); … … 1155 1162 ); 1156 1163 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 ) ); 1158 1165 1159 1166 $this->assertNull( $row->meta_value ); … … 1178 1185 ); 1179 1186 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 ) ); 1181 1188 1182 1189 $this->assertNull( $row->meta_value ); … … 1193 1200 ); 1194 1201 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 ) ); 1196 1203 1197 1204 $this->assertSame( $value, $row->meta_value ); … … 1216 1223 ); 1217 1224 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 ) ); 1219 1226 1220 1227 $this->assertNull( $row->meta_value ); … … 1229 1236 ); 1230 1237 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 ) ); 1232 1239 1233 1240 $this->assertNull( $row ); … … 1573 1580 $sql = str_replace( '{ESCAPE}', $escape, $sql ); 1574 1581 1582 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 1575 1583 $actual = $wpdb->prepare( $sql, $values ); 1576 1584 … … 1654 1662 $wpdb->query( "CREATE TABLE {$wpdb->prefix}test_placeholder( a VARCHAR(100) );" ); 1655 1663 $sql = $wpdb->prepare( "INSERT INTO {$wpdb->prefix}test_placeholder VALUES(%s)", $value ); 1664 1665 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 1656 1666 $wpdb->query( $sql ); 1657 1667 … … 1668 1678 1669 1679 $sql = $wpdb->prepare( ' %s %1$c ', 'foo' ); 1680 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 1670 1681 $sql = $wpdb->prepare( " $sql %s ", 'foo' ); 1671 1682 -
trunk/tests/phpunit/tests/db/charset.php
r45588 r45607 28 28 require_once( dirname( dirname( __FILE__ ) ) . '/db.php' ); 29 29 30 self::$_wpdb = new wpdb_exposed_methods_for_testing();30 self::$_wpdb = new WpdbExposedMethodsForTesting(); 31 31 32 32 if ( self::$_wpdb->use_mysqli ) { -
trunk/tests/phpunit/tests/dbdelta.php
r43571 r45607 34 34 // Forcing MyISAM, because InnoDB only started supporting FULLTEXT indexes in MySQL 5.7. 35 35 $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 ) 48 52 ); 49 53 … … 300 304 global $wpdb; 301 305 306 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 302 307 $table_row = $wpdb->get_row( "select $column from {$table} where $column = '$value'" ); 303 308 … … 318 323 global $wpdb; 319 324 320 $table_fields = $wpdb->get_results( "DESCRIBE {$table}" ); 325 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 326 $table_fields = $wpdb->get_results( "DESCRIBE $table" ); 321 327 322 328 $this->assertCount( 1, wp_list_filter( $table_fields, array( 'Field' => $column ) ) ); … … 334 340 global $wpdb; 335 341 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" ); 337 344 338 345 $this->assertCount( … … 359 366 global $wpdb; 360 367 361 $table_fields = $wpdb->get_results( "DESCRIBE {$table}" ); 368 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 369 $table_fields = $wpdb->get_results( "DESCRIBE $table" ); 362 370 363 371 $this->assertCount( 0, wp_list_filter( $table_fields, array( 'Field' => $column ) ) ); … … 386 394 ) ENGINE=InnoDB ROW_FORMAT=DYNAMIC"; 387 395 396 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 388 397 $wpdb->query( $create ); 389 398 399 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 390 400 $index = $wpdb->get_row( "SHOW INDEXES FROM $table_name WHERE Key_name='a_key';" ); 391 401 392 402 $actual = dbDelta( $create, false ); 393 403 404 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 394 405 $wpdb->query( "DROP TABLE IF EXISTS $table_name;" ); 395 406 396 if ( 191 != $index->Sub_part ) {407 if ( 191 !== $index->Sub_part ) { 397 408 $this->markTestSkipped( 'This test requires the index to be truncated.' ); 398 409 } … … 528 539 "; 529 540 541 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 530 542 $wpdb->query( $schema ); 531 543 … … 557 569 "; 558 570 571 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 559 572 $wpdb->query( $schema ); 560 573 … … 603 616 "; 604 617 618 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 605 619 $wpdb->query( $schema ); 606 620 … … 999 1013 "; 1000 1014 1015 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared 1001 1016 $wpdb->query( $schema ); 1002 1017 -
trunk/tests/phpunit/tests/external-http/basic.php
r40519 r45607 14 14 15 15 $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 ) ) { 17 17 $this->fail( 'Could not contact PHP.net to check versions.' ); 18 18 } … … 26 26 27 27 $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 ) ) { 29 29 $this->fail( 'Could not contact dev.MySQL.com to check versions.' ); 30 30 } -
trunk/tests/phpunit/tests/feed/atom.php
r43571 r45607 72 72 global $post; 73 73 try { 74 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 74 75 @require( ABSPATH . 'wp-includes/feed-atom.php' ); 75 76 $out = ob_get_clean(); … … 163 164 $link_alts = xml_find( $entries[ $key ]['child'], 'link' ); 164 165 foreach ( $link_alts as $link_alt ) { 165 if ( 'alternate' == $link_alt['attributes']['rel'] ) {166 if ( 'alternate' === $link_alt['attributes']['rel'] ) { 166 167 $this->assertEquals( get_permalink( $post ), $link_alt['attributes']['href'] ); 167 168 } … … 186 187 $categories = xml_find( $entries[ $key ]['child'], 'category' ); 187 188 foreach ( $categories as $category ) { 188 $this->assertTrue( in_array( $category['attributes']['term'], $terms ) );189 $this->assertTrue( in_array( $category['attributes']['term'], $terms, true ) ); 189 190 } 190 191 unset( $terms ); … … 199 200 $link_replies = xml_find( $entries[ $key ]['child'], 'link' ); 200 201 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'] ) { 202 203 $this->assertEquals( get_post_comments_feed_link( $post->ID, 'atom' ), $link_reply['attributes']['href'] ); 203 204 } -
trunk/tests/phpunit/tests/feed/rss2.php
r45247 r45607 84 84 global $post; 85 85 try { 86 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 86 87 @require( ABSPATH . 'wp-includes/feed-rss2.php' ); 87 88 $out = ob_get_clean(); -
trunk/tests/phpunit/tests/file.php
r45345 r45607 209 209 210 210 // 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() ) { 212 212 $this->markTestSkipped( 'This system does not support Signature Verification.' ); 213 213 } … … 229 229 unlink( $file ); 230 230 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() ) { 232 232 $this->markTestSkipped( 'This system does not support Signature Verification.' ); 233 233 } -
trunk/tests/phpunit/tests/formatting/WPSpecialchars.php
r42343 r45607 18 18 // Allowed entities should be unchanged 19 19 foreach ( $allowedentitynames as $ent ) { 20 if ( 'apos' == $ent ) {20 if ( 'apos' === $ent ) { 21 21 // But for some reason, PHP doesn't allow ' 22 22 continue; -
trunk/tests/phpunit/tests/formatting/WPTexturize.php
r42343 r45607 1577 1577 return '!openq1!'; 1578 1578 case '’': 1579 if ( 'apostrophe' == $context ) {1579 if ( 'apostrophe' === $context ) { 1580 1580 return '!apos!'; 1581 1581 } else { … … 2002 2002 return '!q1!'; 2003 2003 case '’': 2004 if ( 'apostrophe' == $context ) {2004 if ( 'apostrophe' === $context ) { 2005 2005 return '!apos!'; 2006 2006 } else { -
trunk/tests/phpunit/tests/functions.php
r45602 r45607 845 845 $charsets = mb_detect_order(); 846 846 $old_charsets = $charsets; 847 if ( ! in_array( 'EUC-JP', $charsets ) ) {847 if ( ! in_array( 'EUC-JP', $charsets, true ) ) { 848 848 $charsets[] = 'EUC-JP'; 849 849 mb_detect_order( $charsets ); … … 870 870 $charsets = mb_detect_order(); 871 871 $old_charsets = $charsets; 872 if ( ! in_array( 'EUC-JP', $charsets ) ) {872 if ( ! in_array( 'EUC-JP', $charsets, true ) ) { 873 873 $charsets[] = 'EUC-JP'; 874 874 mb_detect_order( $charsets ); … … 966 966 $extensions = wp_get_ext_types(); 967 967 968 foreach ( $extensions as $type => $extension List ) {969 foreach ( $extension List as $extension ) {968 foreach ( $extensions as $type => $extension_list ) { 969 foreach ( $extension_list as $extension ) { 970 970 $this->assertEquals( $type, wp_ext2type( $extension ) ); 971 971 $this->assertEquals( $type, wp_ext2type( strtoupper( $extension ) ) ); -
trunk/tests/phpunit/tests/functions/deprecated.php
r42343 r45607 136 136 } 137 137 foreach ( $search as $v ) { 138 if ( $name == $v[ $key ] ) {138 if ( $name === $v[ $key ] ) { 139 139 return $v; 140 140 } -
trunk/tests/phpunit/tests/http/base.php
r45035 r45607 55 55 foreach ( array( 'curl', 'streams', 'fsockopen' ) as $t ) { 56 56 remove_filter( "use_{$t}_transport", '__return_false' ); // Just strip them all 57 if ( $t != $this->transport ) {57 if ( $t !== $this->transport ) { 58 58 add_filter( "use_{$t}_transport", '__return_false' ); // and add it back if need be.. 59 59 } … … 248 248 } 249 249 250 $this->assertTrue( isset( $headers['test1'] ) && 'test' == $headers['test1'] );250 $this->assertTrue( isset( $headers['test1'] ) && 'test' === $headers['test1'] ); 251 251 $this->assertTrue( isset( $headers['test2'] ) && '0' === $headers['test2'] ); 252 252 // 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 76 76 $detected_width = 0; 77 77 $detected_height = 0; 78 $image_size = @getimagesize( $filename );78 $image_size = getimagesize( $filename ); 79 79 80 80 if ( isset( $image_size[0] ) ) { -
trunk/tests/phpunit/tests/image/siteIcon.php
r44785 r45607 56 56 57 57 // 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 ) ] ); 59 59 // Remove the filter we added 60 60 remove_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) ); … … 96 96 97 97 // 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 ) ] ); 99 99 } 100 100 -
trunk/tests/phpunit/tests/import/import.php
r43571 r45607 29 29 // crude but effective: make sure there's no residual data in the main tables 30 30 foreach ( array( 'posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta' ) as $table ) { 31 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 31 32 $wpdb->query( "DELETE FROM {$wpdb->$table}" ); 32 33 } -
trunk/tests/phpunit/tests/kses.php
r45588 r45607 149 149 foreach ( $bad as $k => $x ) { 150 150 $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 ) { 152 152 switch ( $k ) { 153 153 case 6: … … 184 184 foreach ( $safe as $x ) { 185 185 $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 ) { 187 187 $this->fail( "wp_kses_bad_protocol incorrectly blocked $x" ); 188 188 } … … 193 193 $xss = simplexml_load_file( DIR_TESTDATA . '/formatting/xssAttacks.xml' ); 194 194 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 ) ) { 196 196 continue; 197 197 } … … 199 199 $code = (string) $attack->code; 200 200 201 if ( $code == 'See Below') {201 if ( 'See Below' === $code ) { 202 202 continue; 203 203 } 204 204 205 if ( substr( $code, 0, 4 ) == 'perl' ) {205 if ( substr( $code, 0, 4 ) === 'perl' ) { 206 206 $pos = strpos( $code, '"' ) + 1; 207 207 $code = substr( $code, $pos, strrpos( $code, '"' ) - $pos ); … … 211 211 $result = trim( wp_kses_data( $code ) ); 212 212 213 if ( $result == '' || $result == 'XSS' || $result == 'alert("XSS");' || $result == "alert('XSS');") {213 if ( in_array( $result, array( '', 'XSS', 'alert("XSS");', "alert('XSS');" ), true ) ) { 214 214 continue; 215 215 } … … 325 325 326 326 function _wp_kses_allowed_html_filter( $html, $context ) { 327 if ( 'post' == $context ) {327 if ( 'post' === $context ) { 328 328 return array( 'a' => array( 'href' => true ) ); 329 329 } else { -
trunk/tests/phpunit/tests/l10n.php
r45505 r45607 76 76 77 77 $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'] ); 82 82 83 83 $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'] ); 88 88 } 89 89 -
trunk/tests/phpunit/tests/l10n/loadTextdomainJustInTime.php
r42343 r45607 176 176 177 177 switch_to_locale( 'de_DE' ); 178 $expected_de_ DE= i18n_plugin_test();178 $expected_de_de = i18n_plugin_test(); 179 179 180 180 switch_to_locale( 'es_ES' ); 181 $expected_es_ ES= i18n_plugin_test();181 $expected_es_es = i18n_plugin_test(); 182 182 183 183 restore_current_locale(); 184 184 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 ); 187 187 } 188 188 -
trunk/tests/phpunit/tests/l10n/localeSwitcher.php
r42343 r45607 87 87 switch_to_locale( 'de_DE' ); 88 88 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 ); 95 95 } 96 96 97 97 public function test_switch_to_locale_en_US() { 98 98 switch_to_locale( 'en_GB' ); 99 $locale_en_ GB= get_locale();99 $locale_en_gb = get_locale(); 100 100 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 ); 108 108 } 109 109 -
trunk/tests/phpunit/tests/link/themeFile.php
r42819 r45607 9 9 self::markTestSkipped( 'symlink() is not available.' ); 10 10 } 11 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 11 12 if ( ! @symlink( DIR_TESTDATA . '/theme-file-parent', WP_CONTENT_DIR . '/themes/theme-file-parent' ) ) { 12 13 self::markTestSkipped( 'Could not create parent symlink.' ); 13 14 } 15 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged 14 16 if ( ! @symlink( DIR_TESTDATA . '/theme-file-child', WP_CONTENT_DIR . '/themes/theme-file-child' ) ) { 15 17 self::markTestSkipped( 'Could not create child symlink.' ); -
trunk/tests/phpunit/tests/media.php
r45424 r45607 1257 1257 */ 1258 1258 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 ) { 1260 1260 $content = '@embed URL was replaced@'; 1261 1261 } … … 1447 1447 foreach ( $image_meta['sizes'] as $name => $size ) { 1448 1448 // 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 ) ) { 1450 1450 $expected .= $uploads_dir_url . $year_month . '/' . $size['file'] . ' ' . $size['width'] . 'w, '; 1451 1451 } … … 1492 1492 foreach ( $image_meta['sizes'] as $name => $size ) { 1493 1493 // 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 ) ) { 1495 1495 $expected .= $uploads_dir_url . $size['file'] . ' ' . $size['width'] . 'w, '; 1496 1496 } … … 1569 1569 foreach ( $image_meta['sizes'] as $name => $size ) { 1570 1570 // 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 ) ) { 1572 1572 $expected .= $uploads_dir_url . $year_month . '/' . $size['file'] . ' ' . $size['width'] . 'w, '; 1573 1573 } … … 1848 1848 foreach ( $image_meta['sizes'] as $name => $size ) { 1849 1849 // 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 ) ) { 1851 1851 $expected .= $uploads_dir . $year_month . '/' . $size['file'] . ' ' . $size['width'] . 'w, '; 1852 1852 } -
trunk/tests/phpunit/tests/meta.php
r43571 r45607 371 371 $string_mid = "{$meta_id}.0"; 372 372 373 // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- intentional implicit casting check 373 374 $this->assertTrue( floor( $string_mid ) == $string_mid ); 374 375 $this->assertNotEquals( false, get_metadata_by_mid( 'user', $string_mid ) ); -
trunk/tests/phpunit/tests/meta/registerMeta.php
r43571 r45607 506 506 507 507 public function filter_get_object_subtype_for_customtype( $subtype, $object_id ) { 508 if ( $object_id % 2 === 1) {508 if ( 1 === ( $object_id % 2 ) ) { 509 509 return 'odd'; 510 510 } -
trunk/tests/phpunit/tests/multisite.php
r42343 r45607 32 32 33 33 // 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 ) ); 35 35 $this->assertEquals( $user->user_email, $reg_blog[ count( $reg_blog ) - 1 ] ); 36 36 } -
trunk/tests/phpunit/tests/multisite/getSpaceUsed.php
r42343 r45607 29 29 // src directory already contains a content directory with site content, then the initial expectation 30 30 // will be polluted. We create sites until an empty one is available. 31 while ( 0 != get_space_used() ) {31 while ( 0 !== get_space_used() ) { 32 32 restore_current_blog(); 33 33 $blog_id = self::factory()->blog->create(); … … 65 65 // so that we can remove any uploaded files and directories without concern of a conflict with 66 66 // existing content directories in src. 67 while ( 0 != get_space_used() ) {67 while ( 0 !== get_space_used() ) { 68 68 restore_current_blog(); 69 69 $blog_id = self::factory()->blog->create(); -
trunk/tests/phpunit/tests/multisite/site.php
r44806 r45607 167 167 // Check existence of each database table for the created site. 168 168 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 170 172 $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" ); 173 171 174 $wpdb->suppress_errors( $suppress ); 172 175 … … 175 178 176 179 // And the table should not be empty, unless commentmeta, termmeta, or links. 180 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared 177 181 $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 ) { 179 184 $this->assertEmpty( $result ); 180 185 } else { … … 245 250 $prefix = $wpdb->get_blog_prefix( $blog_id ); 246 251 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 248 255 $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" ); 256 249 257 $wpdb->suppress_errors( $suppress ); 250 258 $this->assertNotEmpty( $table_fields, $prefix . $table ); … … 283 291 $prefix = $wpdb->get_blog_prefix( $blog_id ); 284 292 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 286 296 $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" ); 297 287 298 $wpdb->suppress_errors( $suppress ); 288 299 $this->assertEmpty( $table_fields ); … … 321 332 $prefix = $wpdb->get_blog_prefix( $blog_id ); 322 333 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 324 337 $table_fields = $wpdb->get_results( "DESCRIBE $prefix$table;" ); 338 325 339 $wpdb->suppress_errors( $suppress ); 326 340 $this->assertNotEmpty( $table_fields, $prefix . $table ); … … 856 870 */ 857 871 function _domain_exists_cb( $exists, $domain, $path, $site_id ) { 858 if ( 'foo' == $domain && 'bar/'== $path ) {872 if ( 'foo' === $domain && 'bar/' === $path ) { 859 873 return 1234; 860 874 } else { -
trunk/tests/phpunit/tests/oembed/controller.php
r44155 r45607 122 122 } 123 123 124 if ( $url === self::UNTRUSTED_PROVIDER_URL) {124 if ( self::UNTRUSTED_PROVIDER_URL === $url ) { 125 125 return array( 126 126 'response' => array( -
trunk/tests/phpunit/tests/oembed/headers.php
r42343 r45607 31 31 $headers = xdebug_get_headers(); 32 32 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 ) ); 34 34 } 35 35 } -
trunk/tests/phpunit/tests/pomo/mo.php
r43571 r45607 179 179 180 180 function test_overloaded_mb_functions() { 181 if ( ( ini_get( 'mbstring.func_overload' ) & 2 ) == 0 ) {181 if ( ( ini_get( 'mbstring.func_overload' ) & 2 ) === 0 ) { 182 182 $this->markTestSkipped( __METHOD__ . ' only runs when mbstring.func_overload is enabled.' ); 183 183 } -
trunk/tests/phpunit/tests/pomo/pluralForms.php
r42343 r45607 61 61 foreach ( $locales as $slug => $locale ) { 62 62 $plural_expression = $locale->plural_expression; 63 if ( $plural_expression !== 'n != 1') {63 if ( 'n != 1' !== $plural_expression ) { 64 64 $plural_expressions[] = array( $slug, $locale->nplurals, $plural_expression ); 65 65 } … … 83 83 $parenthesized = self::parenthesize_plural_expression( $expression ); 84 84 $old_style = tests_make_plural_form_function( $nplurals, $parenthesized ); 85 $plural Forms= new Plural_Forms( $expression );85 $plural_forms = new Plural_Forms( $expression ); 86 86 87 87 $generated_old = array(); … … 90 90 foreach ( range( 0, 200 ) as $i ) { 91 91 $generated_old[] = $old_style( $i ); 92 $generated_new[] = $plural Forms->get( $i );92 $generated_new[] = $plural_forms->get( $i ); 93 93 } 94 94 … … 152 152 */ 153 153 public function test_simple( $expression, $expected ) { 154 $plural Forms = new Plural_Forms( $expression );155 $actual = array();154 $plural_forms = new Plural_Forms( $expression ); 155 $actual = array(); 156 156 foreach ( array_keys( $expected ) as $num ) { 157 $actual[ $num ] = $plural Forms->get( $num );157 $actual[ $num ] = $plural_forms->get( $num ); 158 158 } 159 159 … … 213 213 public function test_exceptions( $expression, $expected_exception, $call_get ) { 214 214 try { 215 $plural Forms = new Plural_Forms( $expression );215 $plural_forms = new Plural_Forms( $expression ); 216 216 if ( $call_get ) { 217 $plural Forms->get( 1 );217 $plural_forms->get( 1 ); 218 218 } 219 219 } catch ( Exception $e ) { -
trunk/tests/phpunit/tests/post.php
r45588 r45607 96 96 97 97 $tcache = wp_cache_get( $id, 'ctax_relationships' ); 98 if ( 'cpt' == $post_type ) {98 if ( 'cpt' === $post_type ) { 99 99 $this->assertInternalType( 'array', $tcache ); 100 100 $this->assertEquals( 2, count( $tcache ) ); … … 1009 1009 function test_utf8mb3_post_saves_with_emoji() { 1010 1010 global $wpdb; 1011 $_wpdb = new wpdb_exposed_methods_for_testing();1011 $_wpdb = new WpdbExposedMethodsForTesting(); 1012 1012 1013 1013 if ( 'utf8' !== $_wpdb->get_col_charset( $wpdb->posts, 'post_title' ) ) { -
trunk/tests/phpunit/tests/post/meta.php
r43982 r45607 96 96 ); 97 97 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 ) ); 99 99 $actual = get_post_meta( self::$post_id, 'nonunique', false ); 100 100 sort( $actual ); -
trunk/tests/phpunit/tests/post/nav-menu.php
r44966 r45607 652 652 $tag_id = self::factory()->tag->create(); 653 653 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 ) ); 657 657 658 658 update_option( 'page_on_front', $new_id ); -
trunk/tests/phpunit/tests/post/objects.php
r42343 r45607 37 37 $this->assertInternalType( 'array', $post ); 38 38 $this->assertFalse( isset( $post['post_type'] ) ); 39 $this->assertTrue( in_array( 'post', $post ) );39 $this->assertTrue( in_array( 'post', $post, true ) ); 40 40 41 41 $post = get_post( $id ); -
trunk/tests/phpunit/tests/post/thumbnails.php
r43571 r45607 72 72 set_post_thumbnail( self::$post, self::$attachment_id ); 73 73 74 $ WP_Query = new WP_Query(74 $query = new WP_Query( 75 75 array( 76 76 'post_type' => 'any', … … 80 80 ); 81 81 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 ); 87 87 } 88 88 … … 393 393 ); 394 394 395 $post = $which_post === 1? self::$different_post : self::$post;395 $post = 1 === $which_post ? self::$different_post : self::$post; 396 396 397 397 add_filter( 'post_thumbnail_size', array( $this, 'filter_post_thumbnail_size' ), 10, 2 ); -
trunk/tests/phpunit/tests/post/types.php
r43571 r45607 306 306 ); 307 307 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 ) ); 311 311 } 312 312 -
trunk/tests/phpunit/tests/post/wpPostType.php
r43571 r45607 79 79 $post_type_object->add_rewrite_rules(); 80 80 81 $this->assertFalse( in_array( 'foobar', $wp->public_query_vars ) );81 $this->assertFalse( in_array( 'foobar', $wp->public_query_vars, true ) ); 82 82 } 83 83 … … 99 99 100 100 $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 ); 102 102 103 103 $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 ); 105 105 106 106 $this->assertTrue( $in_array ); … … 129 129 $rewrite_tags_after = $wp_rewrite->rewritecode; 130 130 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 ) ); 133 133 } 134 134 -
trunk/tests/phpunit/tests/rest-api.php
r44568 r45607 256 256 function test_rest_route_query_var() { 257 257 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 ) ); 259 259 } 260 260 -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r45588 r45607 2492 2492 2493 2493 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] ) { 2495 2495 $caps = array( 'do_not_allow' ); 2496 2496 } -
trunk/tests/phpunit/tests/rest-api/rest-request.php
r43571 r45607 464 464 $data = $valid->get_error_data( 'rest_missing_callback_param' ); 465 465 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 ) ); 468 468 } 469 469 -
trunk/tests/phpunit/tests/shortcode.php
r44569 r45607 39 39 // [footag foo="bar"] 40 40 function _shortcode_footag( $atts ) { 41 return @"foo = {$atts['foo']}"; 41 $foo = isset( $atts['foo'] ) ? $atts['foo'] : ''; 42 return "foo = $foo"; 42 43 } 43 44 … … 445 446 function _filter_atts2( $out, $pairs, $atts ) { 446 447 // 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'] ) { 448 449 $out['foo'] = $pairs['foo']; 449 450 } -
trunk/tests/phpunit/tests/taxonomy.php
r43571 r45607 812 812 register_taxonomy( 'foo', 'post', array( 'query_var' => 'bar' ) ); 813 813 814 $this->assertInternalType( 'int', array_search( 'bar', $wp->public_query_vars ) );814 $this->assertInternalType( 'int', array_search( 'bar', $wp->public_query_vars, true ) ); 815 815 $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 ) ); 817 817 } 818 818 -
trunk/tests/phpunit/tests/term/cache.php
r43571 r45607 91 91 } 92 92 93 if ( $i % 3 === 0) {93 if ( 0 === ( $i % 3 ) ) { 94 94 $step = 1; 95 95 } else { -
trunk/tests/phpunit/tests/term/getTerms.php
r43571 r45607 2475 2475 2476 2476 foreach ( $found as $f ) { 2477 if ( $t1 == $f->term_id ) {2477 if ( $t1 === $f->term_id ) { 2478 2478 $this->assertSame( 3, $f->count ); 2479 } elseif ( $t2 == $f->term_id ) {2479 } elseif ( $t2 === $f->term_id ) { 2480 2480 $this->assertSame( 2, $f->count ); 2481 2481 } else { … … 2548 2548 2549 2549 foreach ( $found as $f ) { 2550 if ( $t1 == $f->term_id ) {2550 if ( $t1 === $f->term_id ) { 2551 2551 $this->assertEquals( 1, $f->count ); 2552 } elseif ( $t2 == $f->term_id ) {2552 } elseif ( $t2 === $f->term_id ) { 2553 2553 $this->assertEquals( 2, $f->count ); 2554 2554 } else { -
trunk/tests/phpunit/tests/term/wpInsertTerm.php
r43571 r45607 823 823 $cached_children = get_option( 'wptests_tax_children' ); 824 824 $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 ) ); 826 826 } 827 827 -
trunk/tests/phpunit/tests/term/wpTaxonomy.php
r43571 r45607 23 23 24 24 $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 ) ); 26 26 } 27 27 … … 44 44 45 45 $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 ); 47 47 48 48 $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 ); 50 50 51 51 $this->assertTrue( $in_array ); … … 75 75 $rewrite_tags_after = $wp_rewrite->rewritecode; 76 76 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 ) ); 79 79 } 80 80 -
trunk/tests/phpunit/tests/term/wpUpdateTerm.php
r43571 r45607 686 686 $cached_children = get_option( 'wptests_tax_children' ); 687 687 $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 ) ); 689 689 } 690 690 -
trunk/tests/phpunit/tests/theme.php
r44966 r45607 244 244 foreach ( $themes as $name => $theme ) { 245 245 // switch to this theme 246 if ( $i === 2) {246 if ( 2 === $i ) { 247 247 switch_theme( $theme['Template'], $theme['Stylesheet'] ); 248 248 } else { -
trunk/tests/phpunit/tests/theme/support.php
r44138 r45607 143 143 144 144 function supports_foobar( $yesno, $args, $feature ) { 145 if ( $args[0] == $feature[0] ) {145 if ( $args[0] === $feature[0] ) { 146 146 return true; 147 147 } -
trunk/tests/phpunit/tests/theme/themeDir.php
r42816 r45607 146 146 // Ignore themes in the default /themes directory. 147 147 foreach ( $themes as $theme_name => $theme ) { 148 if ( $theme->get_theme_root() != $this->theme_root ) {148 if ( $theme->get_theme_root() !== $this->theme_root ) { 149 149 unset( $themes[ $theme_name ] ); 150 150 } … … 210 210 211 211 $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 ) ); 213 213 } 214 214 -
trunk/tests/phpunit/tests/user.php
r45588 r45607 82 82 foreach ( $user_list as $user ) { 83 83 // 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 ) ) { 85 85 $found[] = $user->ID; 86 86 } … … 162 162 // so we'll just check to make sure our values are included somewhere. 163 163 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 ); 165 165 } 166 166 // delete one key and check again … … 171 171 // make sure that key is excluded from the results 172 172 foreach ( $vals as $k => $v ) { 173 if ( $k == $key_to_delete ) {173 if ( $k === $key_to_delete ) { 174 174 $this->assertFalse( isset( $out[ $k ] ) ); 175 175 } else { 176 $this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] == $v );176 $this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v ); 177 177 } 178 178 } … … 600 600 } 601 601 602 @update_user_meta( $id2, 'key', 'value' );602 update_user_meta( $id2, 'key', 'value' ); 603 603 604 604 $metas = array_keys( get_user_meta( 1 ) ); … … 1023 1023 ); 1024 1024 1025 $this->assertTrue( in_array( self::$contrib_id, $users) );1025 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1026 1026 } 1027 1027 … … 1034 1034 ); 1035 1035 1036 $this->assertTrue( in_array( self::$contrib_id, $users) );1036 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1037 1037 } 1038 1038 … … 1045 1045 ); 1046 1046 1047 $this->assertTrue( in_array( self::$contrib_id, $users) );1047 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1048 1048 } 1049 1049 … … 1056 1056 ); 1057 1057 1058 $this->assertTrue( in_array( self::$contrib_id, $users) );1058 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1059 1059 } 1060 1060 … … 1067 1067 ); 1068 1068 1069 $this->assertTrue( in_array( self::$contrib_id, $users) );1069 $this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) ); 1070 1070 } 1071 1071 … … 1202 1202 */ 1203 1203 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] ); 1206 1206 } 1207 1207 … … 1227 1227 */ 1228 1228 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] ); 1231 1231 } 1232 1232 … … 1466 1466 1467 1467 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] ); 1469 1469 } 1470 1470 … … 1503 1503 1504 1504 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] ); 1506 1506 } 1507 1507 -
trunk/tests/phpunit/tests/user/capabilities.php
r45507 r45607 1547 1547 // Prevents fatal errors in ::tearDown()'s and other uses of restore_current_blog() 1548 1548 $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 ) ) { 1550 1550 return; 1551 1551 } -
trunk/tests/phpunit/tests/user/query.php
r44373 r45607 54 54 55 55 $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 } 57 59 58 60 $users->set( 'fields', 'all' ); … … 1137 1139 ); 1138 1140 1139 $found Count = count( $q->get_results() );1140 $expected Count = 10; // 13 total users minus 3 from query1141 $found_count = count( $q->get_results() ); 1142 $expected_count = 10; // 13 total users minus 3 from query 1141 1143 1142 1144 $this->assertContains( "AND user_nicename NOT IN ( 'peter','paul','mary' )", $q->query_where ); 1143 $this->assertEquals( $expected Count, $foundCount );1145 $this->assertEquals( $expected_count, $found_count ); 1144 1146 } 1145 1147 … … 1238 1240 ); 1239 1241 1240 $found Count = count( $q->get_results() );1241 $expected Count = 10; // 13 total users minus 3 from query1242 $found_count = count( $q->get_results() ); 1243 $expected_count = 10; // 13 total users minus 3 from query 1242 1244 1243 1245 $this->assertContains( "AND user_login NOT IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where ); 1244 $this->assertEquals( $expected Count, $foundCount );1246 $this->assertEquals( $expected_count, $found_count ); 1245 1247 } 1246 1248 -
trunk/tests/phpunit/tests/widgets.php
r43571 r45607 151 151 $names = wp_list_pluck( $wp_registered_sidebars, 'name' ); 152 152 for ( $i = 1; $i <= $num; $i++ ) { 153 if ( in_array( "$id_base $i", $names ) ) {153 if ( in_array( "$id_base $i", $names, true ) ) { 154 154 $result[] = true; 155 155 } -
trunk/tests/phpunit/tests/wp.php
r44577 r45607 23 23 24 24 $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 ) ); 27 27 } 28 28 … … 31 31 32 32 $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 ) ); 34 34 $this->wp->remove_query_var( 'test' ); 35 35 -
trunk/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php
r42343 r45607 110 110 $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] ); 111 111 112 if ( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] == self::$post_id ) {112 if ( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] === self::$post_id ) { 113 113 $attachment_id = get_post_meta( $result['postid'], '_thumbnail_id', true ); 114 114 -
trunk/tests/phpunit/tests/xmlrpc/wp/editPost.php
r45424 r45607 446 446 447 447 // 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 ) ); 449 449 450 450 // Attempt to add a brand new enclosure via XML-RPC … … 456 456 // Check that the new enclosure is in the enclosure meta 457 457 $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 ) ); 459 459 460 460 // 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 ) ); 462 462 } 463 463 -
trunk/tests/phpunit/tests/xmlrpc/wp/getPages.php
r42343 r45607 56 56 57 57 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 ) { 60 60 return array( false ); 61 61 } … … 79 79 $this->assertNotIXRError( $result ); 80 80 81 if ( $result['page_id'] == self::$post_id ) {81 if ( $result['page_id'] === self::$post_id ) { 82 82 $found_incapable = true; 83 83 break; -
trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php
r42343 r45607 122 122 123 123 foreach ( $results as $term ) { 124 if ( $term['term_id'] == $cat1 ) {124 if ( $term['term_id'] === $cat1 ) { 125 125 break; // found cat1 first as expected 126 } elseif ( $term['term_id'] == $cat2 ) {126 } elseif ( $term['term_id'] === $cat2 ) { 127 127 $this->assertFalse( false, 'Incorrect category ordering.' ); 128 128 } -
trunk/tests/phpunit/wp-mail-real-test.php
r44563 r45607 54 54 55 55 // make sure we're installed 56 assert( true == is_blog_installed() );56 assert( true === is_blog_installed() ); 57 57 58 58 // phpcs:ignore Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase
Note: See TracChangeset
for help on using the changeset viewer.