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:
parent
969c17d82d
commit
fe28df65e3
@ -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 ] );
|
||||
|
@ -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' );
|
||||
|
@ -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' );
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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 ) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 );
|
||||
|
@ -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 );
|
||||
|
@ -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 );
|
||||
|
@ -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(
|
||||
|
@ -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' );
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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'] );
|
||||
|
@ -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" />
|
||||
|
@ -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 ) );
|
||||
|
@ -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 ) );
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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>";
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -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 );
|
||||
|
@ -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',
|
||||
|
@ -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() {
|
||||
|
@ -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 ) {
|
||||
|
@ -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++ ) {
|
||||
|
@ -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;
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user