Coding Standards: Fix the remaining issues in /tests.

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

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

See #47632.



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

View File

@@ -152,7 +152,7 @@ class MockAction {
if ( $tag ) {
$count = 0;
foreach ( $this->events as $e ) {
if ( $e['action'] == $tag ) {
if ( $e['action'] === $tag ) {
++$count;
}
}
@@ -222,8 +222,12 @@ class TestXMLParser {
}
function data_handler( $parser, $data ) {
$index = count( $this->data ) - 1;
@$this->data[ $index ]['content'] .= $data;
$index = count( $this->data ) - 1;
if ( ! isset( $this->data[ $index ]['content'] ) ) {
$this->data[ $index ]['content'] = '';
}
$this->data[ $index ]['content'] .= $data;
}
function end_handler( $parser, $name ) {
@@ -253,9 +257,9 @@ function xml_find( $tree /*, $el1, $el2, $el3, .. */ ) {
for ( $i = 0; $i < count( $tree ); $i++ ) {
# echo "checking '{$tree[$i][name]}' == '{$a[0]}'\n";
# var_dump($tree[$i]['name'], $a[0]);
if ( $tree[ $i ]['name'] == $a[0] ) {
if ( $tree[ $i ]['name'] === $a[0] ) {
# echo "n == {$n}\n";
if ( $n == 1 ) {
if ( 1 === $n ) {
$out[] = $tree[ $i ];
} else {
$subtree =& $tree[ $i ]['child'];
@@ -348,6 +352,7 @@ function drop_tables() {
global $wpdb;
$tables = $wpdb->get_col( 'SHOW TABLES;' );
foreach ( $tables as $table ) {
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
$wpdb->query( "DROP TABLE IF EXISTS {$table}" );
}
}
@@ -438,7 +443,7 @@ function _clean_term_filters() {
/**
* Special class for exposing protected wpdb methods we need to access
*/
class wpdb_exposed_methods_for_testing extends wpdb {
class WpdbExposedMethodsForTesting extends wpdb {
public function __construct() {
global $wpdb;
$this->dbh = $wpdb->dbh;