Coding Standards: Fix the Squiz.PHP.DisallowMultipleAssignments violations in tests.

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45588 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2019-07-02 04:43:01 +00:00
parent 969c17d82d
commit fe28df65e3
36 changed files with 278 additions and 132 deletions
+4 -2
View File
@@ -406,7 +406,8 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
}
$files_to_move = array();
if ( $mu_plugins = opendir( WPMU_PLUGIN_DIR ) ) {
$mu_plugins = opendir( WPMU_PLUGIN_DIR );
if ( $mu_plugins ) {
while ( false !== $plugin = readdir( $mu_plugins ) ) {
if ( 0 !== strpos( $plugin, '.' ) ) {
$files_to_move[] = $plugin;
@@ -432,7 +433,8 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
private function _restore_mu_plugins() {
$mu_bu_dir = WP_CONTENT_DIR . '/mu-plugin-backup';
$files_to_move = array();
if ( is_dir( $mu_bu_dir ) && $mu_plugins = opendir( $mu_bu_dir ) ) {
$mu_plugins = @opendir( $mu_bu_dir );
if ( $mu_plugins ) {
while ( false !== $plugin = readdir( $mu_plugins ) ) {
if ( 0 !== strpos( $plugin, '.' ) ) {
$files_to_move[] = $plugin;
+8 -4
View File
@@ -13,11 +13,15 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
protected static $user_ids = array();
public static function wpSetUpBeforeClass( $factory ) {
self::$user_ids = self::$author_ids = $factory->user->create_many( 2, array( 'role' => 'author' ) );
self::$user_ids = $factory->user->create_many( 2, array( 'role' => 'author' ) );
self::$author_ids = self::$user_ids;
self::$user_ids[] = self::$contributor_id = $factory->user->create( array( 'role' => 'contributor' ) );
self::$user_ids[] = self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
self::$user_ids[] = self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
self::$contributor_id = $factory->user->create( array( 'role' => 'contributor' ) );
self::$user_ids[] = self::$contributor_id;
self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
self::$user_ids[] = self::$editor_id;
self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
self::$user_ids[] = self::$admin_id;
self::$post_id = $factory->post->create();
}
+23 -8
View File
@@ -171,20 +171,32 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
global $current_screen;
foreach ( $this->core_screens as $hook_name => $screen ) {
$_GET = $_POST = $_REQUEST = array();
$GLOBALS['taxnow'] = $GLOBALS['typenow'] = '';
$screen = (object) $screen;
$hook = parse_url( $hook_name );
$_GET = array();
$_POST = array();
$_REQUEST = array();
$GLOBALS['taxnow'] = '';
$GLOBALS['typenow'] = '';
$screen = (object) $screen;
$hook = parse_url( $hook_name );
if ( ! empty( $hook['query'] ) ) {
$args = wp_parse_args( $hook['query'] );
if ( isset( $args['taxonomy'] ) ) {
$GLOBALS['taxnow'] = $_GET['taxonomy'] = $_POST['taxonomy'] = $_REQUEST['taxonomy'] = $args['taxonomy'];
$GLOBALS['taxnow'] = $args['taxonomy'];
$_GET['taxonomy'] = $args['taxonomy'];
$_POST['taxonomy'] = $args['taxonomy'];
$_REQUEST['taxonomy'] = $args['taxonomy'];
}
if ( isset( $args['post_type'] ) ) {
$GLOBALS['typenow'] = $_GET['post_type'] = $_POST['post_type'] = $_REQUEST['post_type'] = $args['post_type'];
$GLOBALS['typenow'] = $args['post_type'];
$_GET['post_type'] = $args['post_type'];
$_POST['post_type'] = $args['post_type'];
$_REQUEST['post_type'] = $args['post_type'];
} elseif ( isset( $screen->post_type ) ) {
$GLOBALS['typenow'] = $_GET['post_type'] = $_POST['post_type'] = $_REQUEST['post_type'] = $screen->post_type;
$GLOBALS['typenow'] = $screen->post_type;
$_GET['post_type'] = $screen->post_type;
$_POST['post_type'] = $screen->post_type;
$_REQUEST['post_type'] = $screen->post_type;
}
}
@@ -484,7 +496,10 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
public function setup_block_editor_test( $hook = 'post.php' ) {
register_post_type( 'type_shows_in_rest', array( 'show_in_rest' => true ) );
$GLOBALS['typenow'] = $_GET['post_type'] = $_POST['post_type'] = $_REQUEST['post_type'] = 'type_shows_in_rest';
$GLOBALS['typenow'] = 'type_shows_in_rest';
$_GET['post_type'] = 'type_shows_in_rest';
$_POST['post_type'] = 'type_shows_in_rest';
$_REQUEST['post_type'] = 'type_shows_in_rest';
$GLOBALS['hook_suffix'] = $hook;
if ( 'post.php' === $hook ) {