summaryrefslogtreecommitdiffstatshomepage
path: root/tests/phpunit
diff options
context:
space:
mode:
authorGary Pendergast <pento@git.wordpress.org>2019-07-02 04:43:01 +0000
committerGary Pendergast <pento@git.wordpress.org>2019-07-02 04:43:01 +0000
commitfe28df65e3805a1e154dc9d2df0660cc47a62b6e (patch)
tree4e2e7900df35371b83b058f6bcdde93016b3e1ef /tests/phpunit
parent969c17d82dabc9d50d0ea38775f70ecb87dd3fda (diff)
downloadwordpress-fe28df65e3805a1e154dc9d2df0660cc47a62b6e.tar.gz
wordpress-fe28df65e3805a1e154dc9d2df0660cc47a62b6e.zip
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
Diffstat (limited to 'tests/phpunit')
-rw-r--r--tests/phpunit/includes/abstract-testcase.php3
-rw-r--r--tests/phpunit/includes/bootstrap.php4
-rw-r--r--tests/phpunit/includes/install.php4
-rw-r--r--tests/phpunit/includes/phpunit7/speed-trap-listener.php3
-rw-r--r--tests/phpunit/includes/testcase-canonical.php27
-rw-r--r--tests/phpunit/tests/admin/includesPlugin.php6
-rw-r--r--tests/phpunit/tests/admin/includesPost.php14
-rw-r--r--tests/phpunit/tests/admin/includesScreen.php31
-rw-r--r--tests/phpunit/tests/adminbar.php9
-rw-r--r--tests/phpunit/tests/ajax/Autosave.php6
-rw-r--r--tests/phpunit/tests/ajax/CustomizeManager.php56
-rw-r--r--tests/phpunit/tests/comment/getCommentAuthorUrlLink.php3
-rw-r--r--tests/phpunit/tests/comment/getPageOfComment.php8
-rw-r--r--tests/phpunit/tests/customize/manager.php10
-rw-r--r--tests/phpunit/tests/customize/section.php3
-rw-r--r--tests/phpunit/tests/db/charset.php7
-rw-r--r--tests/phpunit/tests/formatting/Autop.php6
-rw-r--r--tests/phpunit/tests/formatting/SanitizeTextField.php3
-rw-r--r--tests/phpunit/tests/formatting/date.php9
-rw-r--r--tests/phpunit/tests/functions.php6
-rw-r--r--tests/phpunit/tests/general/archives.php3
-rw-r--r--tests/phpunit/tests/import/base.php4
-rw-r--r--tests/phpunit/tests/kses.php3
-rw-r--r--tests/phpunit/tests/menu/nav-menu.php3
-rw-r--r--tests/phpunit/tests/option/wpLoadAllOptions.php3
-rw-r--r--tests/phpunit/tests/post.php33
-rw-r--r--tests/phpunit/tests/post/getPages.php5
-rw-r--r--tests/phpunit/tests/post/wpUniquePostSlug.php3
-rw-r--r--tests/phpunit/tests/query/conditionals.php32
-rw-r--r--tests/phpunit/tests/query/results.php42
-rw-r--r--tests/phpunit/tests/query/setupPostdata.php3
-rw-r--r--tests/phpunit/tests/query/taxQuery.php3
-rw-r--r--tests/phpunit/tests/rest-api/rest-posts-controller.php6
-rw-r--r--tests/phpunit/tests/user.php29
-rw-r--r--tests/phpunit/tests/user/slashes.php16
-rw-r--r--tests/phpunit/tests/user/wpSetCurrentUser.php6
36 files changed, 279 insertions, 133 deletions
diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php
index 9ee08e2260..0dbcc7f45a 100644
--- a/tests/phpunit/includes/abstract-testcase.php
+++ b/tests/phpunit/includes/abstract-testcase.php
@@ -706,7 +706,8 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Framework_TestCase {
// note: the WP and WP_Query classes like to silently fetch parameters
// from all over the place (globals, GET, etc), which makes it tricky
// to run them more than once without very carefully clearing everything
- $_GET = $_POST = array();
+ $_GET = array();
+ $_POST = array();
foreach ( array( 'query_string', 'id', 'postdata', 'authordata', 'day', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages', 'pagenow', 'current_screen' ) as $v ) {
if ( isset( $GLOBALS[ $v ] ) ) {
unset( $GLOBALS[ $v ] );
diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php
index f46f56d7cb..461a0b8631 100644
--- a/tests/phpunit/includes/bootstrap.php
+++ b/tests/phpunit/includes/bootstrap.php
@@ -71,7 +71,9 @@ define( 'WP_MAX_MEMORY_LIMIT', -1 );
define( 'REST_TESTS_IMPOSSIBLY_HIGH_NUMBER', 99999999 );
-$PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php';
+$PHP_SELF = '/index.php';
+$GLOBALS['PHP_SELF'] = '/index.php';
+$_SERVER['PHP_SELF'] = '/index.php';
// Should we run in multisite mode?
$multisite = '1' == getenv( 'WP_MULTISITE' );
diff --git a/tests/phpunit/includes/install.php b/tests/phpunit/includes/install.php
index 45c0d60f83..9400b6966c 100644
--- a/tests/phpunit/includes/install.php
+++ b/tests/phpunit/includes/install.php
@@ -20,7 +20,9 @@ if ( ! defined( 'WP_DEFAULT_THEME' ) ) {
tests_reset__SERVER();
-$PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php';
+$PHP_SELF = '/index.php';
+$GLOBALS['PHP_SELF'] = '/index.php';
+$_SERVER['PHP_SELF'] = '/index.php';
tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter_exit' );
diff --git a/tests/phpunit/includes/phpunit7/speed-trap-listener.php b/tests/phpunit/includes/phpunit7/speed-trap-listener.php
index 60b61891dc..1d8e995e52 100644
--- a/tests/phpunit/includes/phpunit7/speed-trap-listener.php
+++ b/tests/phpunit/includes/phpunit7/speed-trap-listener.php
@@ -266,7 +266,8 @@ class SpeedTrapListener implements PHPUnit_Framework_TestListener {
* Renders slow test report footer.
*/
protected function renderFooter() {
- if ( $hidden = $this->getHiddenCount( $this->slow ) ) {
+ $hidden = $this->getHiddenCount( $this->slow );
+ if ( $hidden ) {
echo sprintf( '...and there %s %s more above your threshold hidden from view', $hidden == 1 ? 'is' : 'are', $hidden );
}
}
diff --git a/tests/phpunit/includes/testcase-canonical.php b/tests/phpunit/includes/testcase-canonical.php
index 32da3eff54..9e0cb54c73 100644
--- a/tests/phpunit/includes/testcase-canonical.php
+++ b/tests/phpunit/includes/testcase-canonical.php
@@ -61,13 +61,14 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
'post_date' => '2008-06-02 00:00:00',
)
);
- self::$post_ids[] = $post_id = $factory->post->create(
+ $post_id = $factory->post->create(
array(
'post_title' => 'post-format-test-gallery',
'post_date' => '2008-06-10 00:00:00',
)
);
- self::$post_ids[] = $factory->post->create(
+ self::$post_ids[] = $post_id;
+ $factory->post->create(
array(
'import_id' => 611,
'post_type' => 'attachment',
@@ -75,6 +76,7 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
'post_parent' => $post_id,
)
);
+ self::$post_ids[] = $post_id;
self::$post_ids[] = $factory->post->create(
array(
@@ -84,13 +86,14 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
)
);
- self::$post_ids[] = $post_id = $factory->post->create(
+ $post_id = $factory->post->create(
array(
'import_id' => 149,
'post_title' => 'comment-test',
'post_date' => '2008-03-03 00:00:00',
)
);
+ self::$post_ids[] = $post_id;
self::$comment_ids = $factory->comment->create_post_comments( $post_id, 15 );
self::$post_ids[] = $factory->post->create( array( 'post_date' => '2008-09-05 00:00:00' ) );
@@ -111,12 +114,13 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
'post_title' => 'about',
)
);
- self::$post_ids[] = $post_id = $factory->post->create(
+ $post_id = $factory->post->create(
array(
'post_type' => 'page',
'post_title' => 'parent-page',
)
);
+ self::$post_ids[] = $post_id;
self::$post_ids[] = $factory->post->create(
array(
'import_id' => 144,
@@ -126,40 +130,45 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
)
);
- self::$post_ids[] = $parent_id = $factory->post->create(
+ $parent_id = $factory->post->create(
array(
'post_name' => 'parent',
'post_type' => 'page',
)
);
- self::$post_ids[] = $child_id_1 = $factory->post->create(
+ self::$post_ids[] = $parent_id;
+ $child_id_1 = $factory->post->create(
array(
'post_name' => 'child1',
'post_type' => 'page',
'post_parent' => $parent_id,
)
);
- self::$post_ids[] = $child_id_2 = $factory->post->create(
+ self::$post_ids[] = $child_id_1;
+ $child_id_2 = $factory->post->create(
array(
'post_name' => 'child2',
'post_type' => 'page',
'post_parent' => $parent_id,
)
);
- self::$post_ids[] = $grandchild_id_1 = $factory->post->create(
+ self::$post_ids[] = $child_id_2;
+ $grandchild_id_1 = $factory->post->create(
array(
'post_name' => 'grandchild',
'post_type' => 'page',
'post_parent' => $child_id_1,
)
);
- self::$post_ids[] = $grandchild_id_2 = $factory->post->create(
+ self::$post_ids[] = $grandchild_id_1;
+ $grandchild_id_2 = $factory->post->create(
array(
'post_name' => 'grandchild',
'post_type' => 'page',
'post_parent' => $child_id_2,
)
);
+ self::$post_ids[] = $grandchild_id_2;
$cat1 = $factory->term->create(
array(
diff --git a/tests/phpunit/tests/admin/includesPlugin.php b/tests/phpunit/tests/admin/includesPlugin.php
index 0526801417..174e6e9a4c 100644
--- a/tests/phpunit/tests/admin/includesPlugin.php
+++ b/tests/phpunit/tests/admin/includesPlugin.php
@@ -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;
diff --git a/tests/phpunit/tests/admin/includesPost.php b/tests/phpunit/tests/admin/includesPost.php
index 06c5ac467c..cad9742f8d 100644
--- a/tests/phpunit/tests/admin/includesPost.php
+++ b/tests/phpunit/tests/admin/includesPost.php
@@ -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[] = 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::$user_ids = $factory->user->create_many( 2, array( 'role' => 'author' ) );
+ self::$author_ids = self::$user_ids;
+
+ 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();
}
diff --git a/tests/phpunit/tests/admin/includesScreen.php b/tests/phpunit/tests/admin/includesScreen.php
index 1b2afcc388..b972944bb6 100644
--- a/tests/phpunit/tests/admin/includesScreen.php
+++ b/tests/phpunit/tests/admin/includesScreen.php
@@ -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 ) {
diff --git a/tests/phpunit/tests/adminbar.php b/tests/phpunit/tests/adminbar.php
index fde88737bd..cc42321bc2 100644
--- a/tests/phpunit/tests/adminbar.php
+++ b/tests/phpunit/tests/adminbar.php
@@ -21,9 +21,12 @@ class Tests_AdminBar extends WP_UnitTestCase {
}
public static function wpSetUpBeforeClass( $factory ) {
- 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::$user_ids[] = self::$no_role_id = $factory->user->create( array( 'role' => '' ) );
+ 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::$no_role_id = $factory->user->create( array( 'role' => '' ) );
+ self::$user_ids[] = self::$no_role_id;
}
/**
diff --git a/tests/phpunit/tests/ajax/Autosave.php b/tests/phpunit/tests/ajax/Autosave.php
index 304e4b741d..14329c036d 100644
--- a/tests/phpunit/tests/ajax/Autosave.php
+++ b/tests/phpunit/tests/ajax/Autosave.php
@@ -29,8 +29,10 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase {
protected static $user_ids = array();
public static function wpSetUpBeforeClass( $factory ) {
- self::$user_ids[] = self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
- self::$user_ids[] = self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
+ self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ self::$user_ids[] = self::$admin_id;
+ self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
+ self::$user_ids[] = self::$editor_id;
self::$post_id = $factory->post->create( array( 'post_status' => 'draft' ) );
self::$post = get_post( self::$post_id );
diff --git a/tests/phpunit/tests/ajax/CustomizeManager.php b/tests/phpunit/tests/ajax/CustomizeManager.php
index 873d017fc1..920ae3c9d5 100644
--- a/tests/phpunit/tests/ajax/CustomizeManager.php
+++ b/tests/phpunit/tests/ajax/CustomizeManager.php
@@ -119,9 +119,11 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
// Unauthorized.
wp_set_current_user( self::$subscriber_user_id );
- $nonce = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
- $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
- $exception = null;
+ $nonce = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
+ $_POST['nonce'] = $nonce;
+ $_GET['nonce'] = $nonce;
+ $_REQUEST['nonce'] = $nonce;
+ $exception = null;
try {
ob_start();
$wp_customize->setup_theme();
@@ -133,14 +135,18 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
// Not called setup_theme.
wp_set_current_user( self::$admin_user_id );
- $nonce = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
- $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
+ $nonce = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
+ $_POST['nonce'] = $nonce;
+ $_GET['nonce'] = $nonce;
+ $_REQUEST['nonce'] = $nonce;
$this->make_ajax_call( 'customize_save' );
$this->assertFalse( $this->_last_response_parsed['success'] );
$this->assertEquals( 'not_preview', $this->_last_response_parsed['data'] );
// Bad nonce.
- $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = 'bad';
+ $_POST['nonce'] = 'bad';
+ $_GET['nonce'] = 'bad';
+ $_REQUEST['nonce'] = 'bad';
$wp_customize->setup_theme();
$this->make_ajax_call( 'customize_save' );
$this->assertFalse( $this->_last_response_parsed['success'] );
@@ -148,7 +154,9 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
// User cannot create.
$nonce = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
- $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
+ $_POST['nonce'] = $nonce;
+ $_GET['nonce'] = $nonce;
+ $_REQUEST['nonce'] = $nonce;
$post_type_obj = get_post_type_object( 'customize_changeset' );
$post_type_obj->cap->create_posts = 'create_customize_changesets';
$this->make_ajax_call( 'customize_save' );
@@ -250,8 +258,10 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
)
);
$wp_customize->register_controls();
- $nonce = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
- $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
+ $nonce = wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() );
+ $_POST['nonce'] = $nonce;
+ $_GET['nonce'] = $nonce;
+ $_REQUEST['nonce'] = $nonce;
$wp_customize->setup_theme();
return $wp_customize;
}
@@ -482,8 +492,10 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
$this->assertFalse( $this->_last_response_parsed['success'] );
$this->assertEquals( 'invalid_nonce', $this->_last_response_parsed['data']['code'] );
- $nonce = wp_create_nonce( 'trash_customize_changeset' );
- $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
+ $nonce = wp_create_nonce( 'trash_customize_changeset' );
+ $_POST['nonce'] = $nonce;
+ $_GET['nonce'] = $nonce;
+ $_REQUEST['nonce'] = $nonce;
$this->make_ajax_call( 'customize_trash' );
$this->assertFalse( $this->_last_response_parsed['success'] );
$this->assertEquals( 'non_existent_changeset', $this->_last_response_parsed['data']['code'] );
@@ -567,15 +579,21 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
$this->assertFalse( $this->_last_response_parsed['success'] );
$this->assertEquals( 'invalid_nonce', $this->_last_response_parsed['data'] );
- $nonce = wp_create_nonce( 'customize_dismiss_autosave_or_lock' );
- $_POST['nonce'] = $_GET['nonce'] = $_REQUEST['nonce'] = $nonce;
+ $nonce = wp_create_nonce( 'customize_dismiss_autosave_or_lock' );
+ $_POST['nonce'] = $nonce;
+ $_GET['nonce'] = $nonce;
+ $_REQUEST['nonce'] = $nonce;
- $_POST['dismiss_lock'] = $_GET['dismiss_lock'] = $_REQUEST['dismiss_lock'] = true;
+ $_POST['dismiss_lock'] = true;
+ $_GET['dismiss_lock'] = true;
+ $_REQUEST['dismiss_lock'] = true;
$this->make_ajax_call( 'customize_dismiss_autosave_or_lock' );
$this->assertFalse( $this->_last_response_parsed['success'] );
$this->assertEquals( 'no_changeset_to_dismiss_lock', $this->_last_response_parsed['data'] );
- $_POST['dismiss_autosave'] = $_GET['dismiss_autosave'] = $_REQUEST['dismiss_autosave'] = true;
+ $_POST['dismiss_autosave'] = true;
+ $_GET['dismiss_autosave'] = true;
+ $_REQUEST['dismiss_autosave'] = true;
$this->make_ajax_call( 'customize_dismiss_autosave_or_lock' );
$this->assertFalse( $this->_last_response_parsed['success'] );
$this->assertEquals( 'no_auto_draft_to_delete', $this->_last_response_parsed['data'] );
@@ -639,12 +657,16 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
)
);
- $_POST['dismiss_autosave'] = $_GET['dismiss_autosave'] = $_REQUEST['dismiss_autosave'] = false;
+ $_POST['dismiss_autosave'] = false;
+ $_GET['dismiss_autosave'] = false;
+ $_REQUEST['dismiss_autosave'] = false;
$this->make_ajax_call( 'customize_dismiss_autosave_or_lock' );
$this->assertTrue( $this->_last_response_parsed['success'] );
$this->assertEquals( 'changeset_lock_dismissed', $this->_last_response_parsed['data'] );
- $_POST['dismiss_autosave'] = $_GET['dismiss_autosave'] = $_REQUEST['dismiss_autosave'] = true;
+ $_POST['dismiss_autosave'] = true;
+ $_GET['dismiss_autosave'] = true;
+ $_REQUEST['dismiss_autosave'] = true;
$this->assertNotWPError( $r );
$this->assertFalse( wp_get_post_autosave( $wp_customize->changeset_post_id() ) );
$this->assertContains( 'Foo', get_post( $wp_customize->changeset_post_id() )->post_content );
diff --git a/tests/phpunit/tests/comment/getCommentAuthorUrlLink.php b/tests/phpunit/tests/comment/getCommentAuthorUrlLink.php
index 468ddeb33a..c123e932c2 100644
--- a/tests/phpunit/tests/comment/getCommentAuthorUrlLink.php
+++ b/tests/phpunit/tests/comment/getCommentAuthorUrlLink.php
@@ -31,7 +31,8 @@ class Tests_Comment_GetCommentAuthorUrlLink extends WP_UnitTestCase {
}
public function test_global_comment() {
- $GLOBALS['comment'] = $comment = reset( self::$comments );
+ $comment = reset( self::$comments );
+ $GLOBALS['comment'] = $comment;
$url_link = get_comment_author_url_link();
$link = $this->parseCommentAuthorUrl( $comment );
diff --git a/tests/phpunit/tests/comment/getPageOfComment.php b/tests/phpunit/tests/comment/getPageOfComment.php
index e492e0e8d4..e6527ffb94 100644
--- a/tests/phpunit/tests/comment/getPageOfComment.php
+++ b/tests/phpunit/tests/comment/getPageOfComment.php
@@ -257,7 +257,8 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
$posts = self::factory()->post->create_many( 2 );
$now = time();
- $comments_0 = $comments_1 = array();
+ $comments_0 = array();
+ $comments_1 = array();
for ( $i = 0; $i < 5; $i++ ) {
$comments_0[] = self::factory()->comment->create(
array(
@@ -286,8 +287,9 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
public function test_only_top_level_comments_should_be_included_in_older_count() {
$post = self::factory()->post->create();
- $now = time();
- $comment_parents = $comment_children = array();
+ $now = time();
+ $comment_parents = array();
+ $comment_children = array();
for ( $i = 0; $i < 5; $i++ ) {
$parent = self::factory()->comment->create(
array(
diff --git a/tests/phpunit/tests/customize/manager.php b/tests/phpunit/tests/customize/manager.php
index 71d7e0e6e4..1a0de4a1e2 100644
--- a/tests/phpunit/tests/customize/manager.php
+++ b/tests/phpunit/tests/customize/manager.php
@@ -936,7 +936,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
);
$uuid = wp_generate_uuid4();
- $wp_customize = $manager = new WP_Customize_Manager(
+ $manager = new WP_Customize_Manager(
array(
'changeset_uuid' => $uuid,
)
@@ -1039,7 +1039,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$this->assertEquals( $previous_saved_data, json_decode( get_post( $post_id )->post_content, true ) );
// Attempt a non-transactional/incremental update.
- $wp_customize = $manager = new WP_Customize_Manager(
+ $manager = new WP_Customize_Manager(
array(
'changeset_uuid' => $uuid,
)
@@ -1100,7 +1100,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
$action_counts[ $action_name ] = did_action( $action_name );
}
- $wp_customize = $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
+ $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
+ $wp_customize = $manager;
do_action( 'customize_register', $wp_customize );
$manager->add_setting(
'scratchpad',
@@ -1142,7 +1143,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
// Test revisions.
add_post_type_support( 'customize_changeset', 'revisions' );
$uuid = wp_generate_uuid4();
- $wp_customize = $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
+ $manager = new WP_Customize_Manager( array( 'changeset_uuid' => $uuid ) );
+ $wp_customize = $manager;
do_action( 'customize_register', $manager );
$manager->set_post_value( 'blogname', 'Hello Surface' );
diff --git a/tests/phpunit/tests/customize/section.php b/tests/phpunit/tests/customize/section.php
index cac5046881..f2b06dfda3 100644
--- a/tests/phpunit/tests/customize/section.php
+++ b/tests/phpunit/tests/customize/section.php
@@ -10,7 +10,8 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
protected static $user_ids = array();
public static function wpSetUpBeforeClass( $factory ) {
- self::$user_ids[] = self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ self::$user_ids[] = self::$admin_id;
}
/**
diff --git a/tests/phpunit/tests/db/charset.php b/tests/phpunit/tests/db/charset.php
index e0f9df2c4b..6f0de5982c 100644
--- a/tests/phpunit/tests/db/charset.php
+++ b/tests/phpunit/tests/db/charset.php
@@ -454,7 +454,9 @@ class Tests_DB_Charset extends WP_UnitTestCase {
}
// The data above is easy to edit. Now, prepare it for the data provider.
- $data_provider = $multiple = $multiple_expected = array();
+ $data_provider = array();
+ $multiple = array();
+ $multiple_expected = array();
foreach ( $fields as $test_case => $field ) {
$expected = $field;
$expected['value'] = $expected['expected'];
@@ -582,7 +584,8 @@ class Tests_DB_Charset extends WP_UnitTestCase {
$vars = get_defined_vars();
unset( $vars['charset'] );
foreach ( $vars as $var_name => $var ) {
- $data = $expected = $var;
+ $data = $var;
+ $expected = $var;
foreach ( $data as &$datum ) {
// 'charset' and 'ascii' are part of the expected return only.
unset( $datum['charset'], $datum['ascii'] );
diff --git a/tests/phpunit/tests/formatting/Autop.php b/tests/phpunit/tests/formatting/Autop.php
index bf1675f548..bf5080ff7a 100644
--- a/tests/phpunit/tests/formatting/Autop.php
+++ b/tests/phpunit/tests/formatting/Autop.php
@@ -415,7 +415,8 @@ Paragraph two.';
'select',
);
- $content = $expected = array();
+ $content = array();
+ $expected = array();
foreach ( $inlines as $inline ) {
$content[] = "<$inline>foo</$inline>";
@@ -543,7 +544,8 @@ line 2<br/>
* @ticket 39307
*/
function test_that_wpautop_doses_not_add_extra_closing_p_in_figure() {
- $content1 = $expected1 = '<figure><img src="example.jpg" /><figcaption>Caption</figcaption></figure>';
+ $content1 = '<figure><img src="example.jpg" /><figcaption>Caption</figcaption></figure>';
+ $expected1 = $content1;
$content2 = '<figure>
<img src="example.jpg" />
diff --git a/tests/phpunit/tests/formatting/SanitizeTextField.php b/tests/phpunit/tests/formatting/SanitizeTextField.php
index c6f978484b..cba4bee9ec 100644
--- a/tests/phpunit/tests/formatting/SanitizeTextField.php
+++ b/tests/phpunit/tests/formatting/SanitizeTextField.php
@@ -133,7 +133,8 @@ class Tests_Formatting_SanitizeTextField extends WP_UnitTestCase {
$expected_oneline = $expected['oneline'];
$expected_multiline = $expected['multiline'];
} else {
- $expected_oneline = $expected_multiline = $expected;
+ $expected_oneline = $expected;
+ $expected_multiline = $expected;
}
$this->assertEquals( $expected_oneline, sanitize_text_field( $string ) );
$this->assertEquals( $expected_multiline, sanitize_textarea_field( $string ) );
diff --git a/tests/phpunit/tests/formatting/date.php b/tests/phpunit/tests/formatting/date.php
index 389852594a..7854748c7d 100644
--- a/tests/phpunit/tests/formatting/date.php
+++ b/tests/phpunit/tests/formatting/date.php
@@ -13,7 +13,8 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
*/
function test_get_date_from_gmt_outside_of_dst() {
update_option( 'timezone_string', 'Europe/London' );
- $gmt = $local = '2012-01-01 12:34:56';
+ $local = '2012-01-01 12:34:56';
+ $gmt = $local;
$this->assertEquals( $local, get_date_from_gmt( $gmt ) );
}
@@ -34,7 +35,8 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
*/
function test_get_gmt_from_date_outside_of_dst() {
update_option( 'timezone_string', 'Europe/London' );
- $local = $gmt = '2012-01-01 12:34:56';
+ $local = '2012-01-01 12:34:56';
+ $gmt = $local;
$this->assertEquals( $gmt, get_gmt_from_date( $local ) );
}
@@ -52,7 +54,8 @@ class Tests_Formatting_Date extends WP_UnitTestCase {
* @ticket 34279
*/
function test_get_date_and_time_from_gmt_no_timezone() {
- $gmt = $local = '2012-01-01 12:34:56';
+ $local = '2012-01-01 12:34:56';
+ $gmt = $local;
$this->assertEquals( $gmt, get_date_from_gmt( $local ) );
}
diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php
index 1013931dd5..aaf6bf653d 100644
--- a/tests/phpunit/tests/functions.php
+++ b/tests/phpunit/tests/functions.php
@@ -842,7 +842,8 @@ class Tests_Functions extends WP_UnitTestCase {
$this->markTestSkipped( 'mbstring extension not available.' );
}
- $old_charsets = $charsets = mb_detect_order();
+ $charsets = mb_detect_order();
+ $old_charsets = $charsets;
if ( ! in_array( 'EUC-JP', $charsets ) ) {
$charsets[] = 'EUC-JP';
mb_detect_order( $charsets );
@@ -866,7 +867,8 @@ class Tests_Functions extends WP_UnitTestCase {
$this->markTestSkipped( 'mbstring extension not available.' );
}
- $old_charsets = $charsets = mb_detect_order();
+ $charsets = mb_detect_order();
+ $old_charsets = $charsets;
if ( ! in_array( 'EUC-JP', $charsets ) ) {
$charsets[] = 'EUC-JP';
mb_detect_order( $charsets );
diff --git a/tests/phpunit/tests/general/archives.php b/tests/phpunit/tests/general/archives.php
index cdf2670f5d..f32bb6bcbc 100644
--- a/tests/phpunit/tests/general/archives.php
+++ b/tests/phpunit/tests/general/archives.php
@@ -30,7 +30,8 @@ class Tests_General_Archives extends WP_UnitTestCase {
)
);
$this->assertInternalType( 'string', $result );
- $this->assertNotEmpty( $time1 = wp_cache_get( 'last_changed', 'posts' ) );
+ $time1 = wp_cache_get( 'last_changed', 'posts' );
+ $this->assertNotEmpty( $time1 );
$this->assertEquals( $num_queries + 1, $wpdb->num_queries );
$num_queries = $wpdb->num_queries;
diff --git a/tests/phpunit/tests/import/base.php b/tests/phpunit/tests/import/base.php
index 45ec430743..5897ce55fb 100644
--- a/tests/phpunit/tests/import/base.php
+++ b/tests/phpunit/tests/import/base.php
@@ -27,7 +27,9 @@ abstract class WP_Import_UnitTestCase extends WP_UnitTestCase {
$this->assertTrue( ! empty( $file ), 'Path to import file is empty.' );
$this->assertTrue( is_file( $file ), 'Import file is not a file.' );
- $authors = $mapping = $new = array();
+ $authors = array();
+ $mapping = array();
+ $new = array();
$i = 0;
// each user is either mapped to a given ID, mapped to a new user
diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php
index 98c2987c2e..6cfa8df881 100644
--- a/tests/phpunit/tests/kses.php
+++ b/tests/phpunit/tests/kses.php
@@ -54,7 +54,8 @@ class Tests_Kses extends WP_UnitTestCase {
$attr = "$name='$value'";
$expected_attr = "$name='" . trim( $value, ';' ) . "'";
} else {
- $attr = $expected_attr = $name;
+ $attr = $name;
+ $expected_attr = $name;
}
$string = "<a $attr>I link this</a>";
$expect_string = "<a $expected_attr>I link this</a>";
diff --git a/tests/phpunit/tests/menu/nav-menu.php b/tests/phpunit/tests/menu/nav-menu.php
index b0b5c446fb..2627f9f21a 100644
--- a/tests/phpunit/tests/menu/nav-menu.php
+++ b/tests/phpunit/tests/menu/nav-menu.php
@@ -54,11 +54,12 @@ class Tests_Nav_Menu_Theme_Change extends WP_UnitTestCase {
*/
function test_filter_registered_locations() {
$this->register_nav_menu_locations( array( 'primary', 'secondary' ) );
- $old_next_theme_nav_menu_locations = $prev_theme_nav_menu_locations = array(
+ $prev_theme_nav_menu_locations = array(
'primary' => 1,
'secondary' => 2,
'social' => 3,
);
+ $old_next_theme_nav_menu_locations = $prev_theme_nav_menu_locations;
$new_next_theme_nav_menu_locations = wp_map_nav_menu_locations( $old_next_theme_nav_menu_locations, $prev_theme_nav_menu_locations );
$expected_nav_menu_locations = array(
diff --git a/tests/phpunit/tests/option/wpLoadAllOptions.php b/tests/phpunit/tests/option/wpLoadAllOptions.php
index f2fb8a685d..5088f10b9a 100644
--- a/tests/phpunit/tests/option/wpLoadAllOptions.php
+++ b/tests/phpunit/tests/option/wpLoadAllOptions.php
@@ -104,6 +104,7 @@ class Tests_Option_WP_Load_Alloptions extends WP_UnitTestCase {
}
function return_pre_cache_filter( $alloptions ) {
- return $this->alloptions = $alloptions;
+ $this->alloptions = $alloptions;
+ return $this->alloptions;
}
}
diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php
index d0d902978c..70d93ea355 100644
--- a/tests/phpunit/tests/post.php
+++ b/tests/phpunit/tests/post.php
@@ -48,7 +48,8 @@ class Tests_Post extends WP_UnitTestCase {
function _unset_current_user() {
global $current_user, $user_ID;
- $current_user = $user_ID = null;
+ $current_user = null;
+ $user_ID = null;
}
// test simple valid behavior: insert and get a post
@@ -124,7 +125,8 @@ class Tests_Post extends WP_UnitTestCase {
);
// insert a post and make sure the ID is ok
- $id = $this->post_ids[] = wp_insert_post( $post );
+ $id = wp_insert_post( $post );
+ $this->post_ids[] = $id;
#dmp(_get_cron_array());
$this->assertTrue( is_numeric( $id ) );
$this->assertTrue( $id > 0 );
@@ -158,7 +160,8 @@ class Tests_Post extends WP_UnitTestCase {
);
// insert a post and make sure the ID is ok
- $id = $this->post_ids[] = wp_insert_post( $post );
+ $id = wp_insert_post( $post );
+ $this->post_ids[] = $id;
// fetch the post and make sure has the correct date and status
$out = get_post( $id );
@@ -200,7 +203,8 @@ class Tests_Post extends WP_UnitTestCase {
);
// insert a post and make sure the ID is ok
- $id = $this->post_ids[] = wp_insert_post( $post );
+ $id = wp_insert_post( $post );
+ $this->post_ids[] = $id;
// fetch the post and make sure has the correct date and status
$out = get_post( $id );
@@ -240,7 +244,8 @@ class Tests_Post extends WP_UnitTestCase {
);
// insert a post and make sure the ID is ok
- $id = $this->post_ids[] = wp_insert_post( $post );
+ $id = wp_insert_post( $post );
+ $this->post_ids[] = $id;
#dmp(_get_cron_array());
$this->assertTrue( is_numeric( $id ) );
$this->assertTrue( $id > 0 );
@@ -272,7 +277,8 @@ class Tests_Post extends WP_UnitTestCase {
);
// insert a post and make sure the ID is ok
- $id = $this->post_ids[] = wp_insert_post( $post );
+ $id = wp_insert_post( $post );
+ $this->post_ids[] = $id;
// fetch the post and make sure has the correct date and status
$out = get_post( $id );
@@ -313,7 +319,8 @@ class Tests_Post extends WP_UnitTestCase {
);
// insert a post and make sure the ID is ok
- $id = $this->post_ids[] = wp_insert_post( $post );
+ $id = wp_insert_post( $post );
+ $this->post_ids[] = $id;
// fetch the post and make sure has the correct date and status
$out = get_post( $id );
@@ -353,7 +360,8 @@ class Tests_Post extends WP_UnitTestCase {
);
// insert a post and make sure the ID is ok
- $id = $this->post_ids[] = wp_insert_post( $post );
+ $id = wp_insert_post( $post );
+ $this->post_ids[] = $id;
#dmp(_get_cron_array());
$this->assertTrue( is_numeric( $id ) );
$this->assertTrue( $id > 0 );
@@ -407,7 +415,8 @@ class Tests_Post extends WP_UnitTestCase {
);
// insert a post and make sure the ID is ok
- $id = $this->post_ids[] = wp_insert_post( $post );
+ $id = wp_insert_post( $post );
+ $this->post_ids[] = $id;
// fetch the post and make sure has the correct date and status
$out = get_post( $id );
@@ -511,7 +520,8 @@ class Tests_Post extends WP_UnitTestCase {
);
// insert a post and make sure the ID is ok
- $id = $this->post_ids[] = wp_insert_post( $post );
+ $id = wp_insert_post( $post );
+ $this->post_ids[] = $id;
// check that there's a publish_future_post job scheduled at the right time
$this->assertEquals( $future_date, $this->_next_schedule_for_post( 'publish_future_post', $id ) );
@@ -540,7 +550,8 @@ class Tests_Post extends WP_UnitTestCase {
);
// insert a post and make sure the ID is ok
- $id = $this->post_ids[] = wp_insert_post( $post );
+ $id = wp_insert_post( $post );
+ $this->post_ids[] = $id;
$plink = get_permalink( $id );
diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php
index 2271cae672..b92ff088b9 100644
--- a/tests/phpunit/tests/post/getPages.php
+++ b/tests/phpunit/tests/post/getPages.php
@@ -21,8 +21,9 @@ class Tests_Post_getPages extends WP_UnitTestCase {
$pages = get_pages();
$this->assertEquals( 3, count( $pages ) );
- $this->assertNotEmpty( $time1 = wp_cache_get( 'last_changed', 'posts' ) );
- $num_queries = $wpdb->num_queries;
+ $time1 = wp_cache_get( 'last_changed', 'posts' );
+ $this->assertNotEmpty( $time1 );
+ $num_queries = $wpdb->num_queries;
foreach ( $pages as $page ) {
$this->assertInstanceOf( 'WP_Post', $page );
}
diff --git a/tests/phpunit/tests/post/wpUniquePostSlug.php b/tests/phpunit/tests/post/wpUniquePostSlug.php
index 575bec4fa4..eb6d637389 100644
--- a/tests/phpunit/tests/post/wpUniquePostSlug.php
+++ b/tests/phpunit/tests/post/wpUniquePostSlug.php
@@ -31,7 +31,8 @@ class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase {
'post_title' => $post_title,
);
- $id = $this->post_ids[] = self::factory()->post->create( $post );
+ $id = self::factory()->post->create( $post );
+ $this->post_ids[] = $id;
}
$post = get_post( $id );
diff --git a/tests/phpunit/tests/query/conditionals.php b/tests/phpunit/tests/query/conditionals.php
index fc34496070..a67c6f29fc 100644
--- a/tests/phpunit/tests/query/conditionals.php
+++ b/tests/phpunit/tests/query/conditionals.php
@@ -161,20 +161,22 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '(about)/trackback/?$' => 'index.php?pagename=$matches[1]&tb=1'
function test_page_trackback() {
$page_ids = array();
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'parent-page',
)
);
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_ids[] = $page_id;
+ $page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'child-page-1',
'post_parent' => $page_id,
)
);
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_ids[] = $page_id;
+ $page_ids[] = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'child-page-2',
@@ -197,20 +199,22 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
//'(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]'
function test_page_feed() {
$page_ids = array();
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'parent-page',
)
);
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_ids[] = $page_id;
+ $page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'child-page-1',
'post_parent' => $page_id,
)
);
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_ids[] = $page_id;
+ $page_ids[] = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'child-page-2',
@@ -233,20 +237,22 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
function test_page_feed_with_no_comments() {
$page_ids = array();
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'parent-page',
)
);
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_ids[] = $page_id;
+ $page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'child-page-1',
'post_parent' => $page_id,
)
);
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_ids[] = $page_id;
+ $page_ids[] = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'child-page-2',
@@ -269,20 +275,22 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// '(about)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?pagename=$matches[1]&feed=$matches[2]'
function test_page_feed_atom() {
$page_ids = array();
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'parent-page',
)
);
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_ids[] = $page_id;
+ $page_id = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'child-page-1',
'post_parent' => $page_id,
)
);
- $page_ids[] = $page_id = self::factory()->post->create(
+ $page_ids[] = $page_id;
+ $page_ids[] = self::factory()->post->create(
array(
'post_type' => 'page',
'post_title' => 'child-page-2',
diff --git a/tests/phpunit/tests/query/results.php b/tests/phpunit/tests/query/results.php
index a0e8df11dc..daa171efb9 100644
--- a/tests/phpunit/tests/query/results.php
+++ b/tests/phpunit/tests/query/results.php
@@ -22,49 +22,56 @@ class Tests_Query_Results extends WP_UnitTestCase {
static $child_four;
public static function wpSetUpBeforeClass( $factory ) {
- self::$cat_ids[] = $cat_a = $factory->term->create(
+ $cat_a = $factory->term->create(
array(
'taxonomy' => 'category',
'name' => 'cat-a',
)
);
- self::$cat_ids[] = $cat_b = $factory->term->create(
+ self::$cat_ids[] = $cat_a;
+ $cat_b = $factory->term->create(
array(
'taxonomy' => 'category',
'name' => 'cat-b',
)
);
- self::$cat_ids[] = $cat_c = $factory->term->create(
+ self::$cat_ids[] = $cat_b;
+ $cat_c = $factory->term->create(
array(
'taxonomy' => 'category',
'name' => 'cat-c',
)
);
+ self::$cat_ids[] = $cat_c;
- self::$tag_ids[] = $tag_a = $factory->term->create(
+ $tag_a = $factory->term->create(
array(
'taxonomy' => 'post_tag',
'name' => 'tag-a',
)
);
- self::$tag_ids[] = $tag_b = $factory->term->create(
+ self::$tag_ids[] = $tag_a;
+ $tag_b = $factory->term->create(
array(
'taxonomy' => 'post_tag',
'name' => 'tag-b',
)
);
- self::$tag_ids[] = $tag_c = $factory->term->create(
+ self::$tag_ids[] = $tag_b;
+ $tag_c = $factory->term->create(
array(
'taxonomy' => 'post_tag',
'name' => 'tag-c',
)
);
- self::$tag_ids[] = $tag_nun = $factory->term->create(
+ self::$tag_ids[] = $tag_c;
+ $tag_nun = $factory->term->create(
array(
'taxonomy' => 'post_tag',
'name' => 'tag-נ',
)
);
+ self::$tag_ids[] = $tag_nun;
self::$post_ids[] = $factory->post->create(
array(
@@ -232,52 +239,59 @@ class Tests_Query_Results extends WP_UnitTestCase {
)
);
- self::$post_ids[] = self::$parent_one = $factory->post->create(
+ self::$parent_one = $factory->post->create(
array(
'post_title' => 'parent-one',
'post_date' => '2007-01-01 00:00:00',
)
);
- self::$post_ids[] = self::$parent_two = $factory->post->create(
+ self::$post_ids[] = self::$parent_one;
+ self::$parent_two = $factory->post->create(
array(
'post_title' => 'parent-two',
'post_date' => '2007-01-01 00:00:00',
)
);
- self::$post_ids[] = self::$parent_three = $factory->post->create(
+ self::$post_ids[] = self::$parent_two;
+ self::$parent_three = $factory->post->create(
array(
'post_title' => 'parent-three',
'post_date' => '2007-01-01 00:00:00',
)
);
- self::$post_ids[] = self::$child_one = $factory->post->create(
+ self::$post_ids[] = self::$parent_three;
+ self::$child_one = $factory->post->create(
array(
'post_title' => 'child-one',
'post_parent' => self::$parent_one,
'post_date' => '2007-01-01 00:00:01',
)
);
- self::$post_ids[] = self::$child_two = $factory->post->create(
+ self::$post_ids[] = self::$child_one;
+ self::$child_two = $factory->post->create(
array(
'post_title' => 'child-two',
'post_parent' => self::$parent_one,
'post_date' => '2007-01-01 00:00:02',
)
);
- self::$post_ids[] = self::$child_three = $factory->post->create(
+ self::$post_ids[] = self::$child_two;
+ self::$child_three = $factory->post->create(
array(
'post_title' => 'child-three',
'post_parent' => self::$parent_two,
'post_date' => '2007-01-01 00:00:03',
)
);
- self::$post_ids[] = self::$child_four = $factory->post->create(
+ self::$post_ids[] = self::$child_three;
+ self::$child_four = $factory->post->create(
array(
'post_title' => 'child-four',
'post_parent' => self::$parent_two,
'post_date' => '2007-01-01 00:00:04',
)
);
+ self::$post_ids[] = self::$child_four;
}
function setUp() {
diff --git a/tests/phpunit/tests/query/setupPostdata.php b/tests/phpunit/tests/query/setupPostdata.php
index 34a99d68a9..38d473065f 100644
--- a/tests/phpunit/tests/query/setupPostdata.php
+++ b/tests/phpunit/tests/query/setupPostdata.php
@@ -403,7 +403,8 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
*/
function test_setup_postdata_loop() {
$post_id = self::factory()->post->create( array( 'post_content' => 'global post' ) );
- $GLOBALS['wp_query']->post = $GLOBALS['post'] = get_post( $post_id );
+ $GLOBALS['post'] = get_post( $post_id );
+ $GLOBALS['wp_query']->post = $GLOBALS['post'];
$ids = self::factory()->post->create_many( 5 );
foreach ( $ids as $id ) {
diff --git a/tests/phpunit/tests/query/taxQuery.php b/tests/phpunit/tests/query/taxQuery.php
index 8112c81367..42e73d779e 100644
--- a/tests/phpunit/tests/query/taxQuery.php
+++ b/tests/phpunit/tests/query/taxQuery.php
@@ -1298,7 +1298,8 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase {
$posts = self::factory()->post->create_many( 5 );
- $cats = $tags = array();
+ $cats = array();
+ $tags = array();
// need term_taxonomy_ids in addition to term_ids, so no factory
for ( $i = 0; $i < 5; $i++ ) {
diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php
index dea31fd677..13f90846ea 100644
--- a/tests/phpunit/tests/rest-api/rest-posts-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php
@@ -1378,8 +1378,10 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
$attachments_url = add_query_arg( 'parent', self::$post_id, $attachments_url );
$this->assertEquals( $attachments_url, $links['https://api.w.org/attachment'][0]['href'] );
- $term_links = $links['https://api.w.org/term'];
- $tag_link = $cat_link = $format_link = null;
+ $term_links = $links['https://api.w.org/term'];
+ $tag_link = null;
+ $cat_link = null;
+ $format_link = null;
foreach ( $term_links as $link ) {
if ( 'post_tag' === $link['attributes']['taxonomy'] ) {
$tag_link = $link;
diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php
index 01be5de452..644adf58d0 100644
--- a/tests/phpunit/tests/user.php
+++ b/tests/phpunit/tests/user.php
@@ -18,7 +18,7 @@ class Tests_User extends WP_UnitTestCase {
protected $user_data;
public static function wpSetUpBeforeClass( $factory ) {
- self::$user_ids[] = self::$contrib_id = $factory->user->create(
+ self::$contrib_id = $factory->user->create(
array(
'user_login' => 'user1',
'user_nicename' => 'userone',
@@ -33,23 +33,28 @@ class Tests_User extends WP_UnitTestCase {
'description' => 'I am a WordPress user that cares about privacy.',
)
);
+ self::$user_ids[] = self::$contrib_id;
- self::$user_ids[] = self::$author_id = $factory->user->create(
+ self::$author_id = $factory->user->create(
array(
'user_login' => 'author_login',
'user_email' => 'author@email.com',
'role' => 'author',
)
);
+ self::$user_ids[] = self::$author_id;
- self::$user_ids[] = self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
- self::$user_ids[] = self::$editor_id = $factory->user->create(
+ self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
+ self::$user_ids[] = self::$admin_id;
+ self::$editor_id = $factory->user->create(
array(
'role' => 'editor',
'user_email' => 'test@test.com',
)
);
- self::$user_ids[] = self::$sub_id = $factory->user->create( array( 'role' => 'subscriber' ) );
+ self::$user_ids[] = self::$editor_id;
+ self::$sub_id = $factory->user->create( array( 'role' => 'subscriber' ) );
+ self::$user_ids[] = self::$sub_id;
self::$_author = get_user_by( 'ID', self::$author_id );
}
@@ -1374,7 +1379,9 @@ class Tests_User extends WP_UnitTestCase {
* @ticket 35715
*/
function test_edit_user_blank_pw() {
- $_POST = $_GET = $_REQUEST = array();
+ $_POST = array();
+ $_GET = array();
+ $_REQUEST = array();
$_POST['role'] = 'subscriber';
$_POST['email'] = 'user1@example.com';
$_POST['user_login'] = 'user_login1';
@@ -1390,7 +1397,8 @@ class Tests_User extends WP_UnitTestCase {
$this->assertEquals( 'pass', $response->get_error_code() );
// Check new user with password set.
- $_POST['pass1'] = $_POST['pass2'] = 'password';
+ $_POST['pass1'] = 'password';
+ $_POST['pass2'] = 'password';
$user_id = edit_user();
$user = get_user_by( 'ID', $user_id );
@@ -1401,7 +1409,8 @@ class Tests_User extends WP_UnitTestCase {
// Check updating user with empty password.
$_POST['nickname'] = 'nickname_updated';
- $_POST['pass1'] = $_POST['pass2'] = '';
+ $_POST['pass1'] = '';
+ $_POST['pass2'] = '';
$user_id = edit_user( $user_id );
@@ -1550,7 +1559,9 @@ class Tests_User extends WP_UnitTestCase {
* @ticket 42564
*/
function test_edit_user_role_update() {
- $_POST = $_GET = $_REQUEST = array();
+ $_POST = array();
+ $_GET = array();
+ $_REQUEST = array();
$administrator = self::factory()->user->create(
array(
diff --git a/tests/phpunit/tests/user/slashes.php b/tests/phpunit/tests/user/slashes.php
index b15d9436b1..202d6a1622 100644
--- a/tests/phpunit/tests/user/slashes.php
+++ b/tests/phpunit/tests/user/slashes.php
@@ -27,7 +27,9 @@ class Tests_User_Slashes extends WP_UnitTestCase {
* Tests the controller function that expects slashed data
*/
function test_add_user() {
- $_POST = $_GET = $_REQUEST = array();
+ $_POST = array();
+ $_GET = array();
+ $_REQUEST = array();
$_POST['user_login'] = 'slash_example_user_1';
$_POST['pass1'] = 'password';
$_POST['pass2'] = 'password';
@@ -49,7 +51,9 @@ class Tests_User_Slashes extends WP_UnitTestCase {
$this->assertEquals( $this->slash_7, $user->display_name );
$this->assertEquals( $this->slash_3, $user->description );
- $_POST = $_GET = $_REQUEST = array();
+ $_POST = array();
+ $_GET = array();
+ $_REQUEST = array();
$_POST['user_login'] = 'slash_example_user_2';
$_POST['pass1'] = 'password';
$_POST['pass2'] = 'password';
@@ -78,7 +82,9 @@ class Tests_User_Slashes extends WP_UnitTestCase {
function test_edit_user() {
$id = self::factory()->user->create();
- $_POST = $_GET = $_REQUEST = array();
+ $_POST = array();
+ $_GET = array();
+ $_REQUEST = array();
$_POST['role'] = 'subscriber';
$_POST['email'] = 'user1@example.com';
$_POST['first_name'] = $this->slash_1;
@@ -97,7 +103,9 @@ class Tests_User_Slashes extends WP_UnitTestCase {
$this->assertEquals( $this->slash_7, $user->display_name );
$this->assertEquals( $this->slash_3, $user->description );
- $_POST = $_GET = $_REQUEST = array();
+ $_POST = array();
+ $_GET = array();
+ $_REQUEST = array();
$_POST['role'] = 'subscriber';
$_POST['email'] = 'user2@example.com';
$_POST['first_name'] = $this->slash_2;
diff --git a/tests/phpunit/tests/user/wpSetCurrentUser.php b/tests/phpunit/tests/user/wpSetCurrentUser.php
index 4871ffe5fc..ec720b814e 100644
--- a/tests/phpunit/tests/user/wpSetCurrentUser.php
+++ b/tests/phpunit/tests/user/wpSetCurrentUser.php
@@ -9,8 +9,10 @@ class Tests_User_WpSetCurrentUser extends WP_UnitTestCase {
protected static $user_ids = array();
public static function wpSetUpBeforeClass( $factory ) {
- self::$user_ids[] = self::$user_id = $factory->user->create();
- self::$user_ids[] = self::$user_id2 = $factory->user->create( array( 'user_login' => 'foo' ) );
+ self::$user_id = $factory->user->create();
+ self::$user_ids[] = self::$user_id;
+ self::$user_id2 = $factory->user->create( array( 'user_login' => 'foo' ) );
+ self::$user_ids[] = self::$user_id2;
}
public function test_set_by_id() {