mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-03 06:07:00 +00:00
Tests: Introduce assertSameSets() and assertSameSetsWithIndex(), and use them where appropriate.
This ensures that not only the array values being compared are equal, but also that their type is the same. These new methods replace most of the existing instances of `assertEqualSets()` and `assertEqualSetsWithIndex()`. Going forward, stricter type checking by using `assertSameSets()` or `assertSameSetsWithIndex()` should generally be preferred, to make the tests more reliable. Follow-up to [48937]. See #38266. git-svn-id: https://develop.svn.wordpress.org/trunk@48939 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -197,7 +197,7 @@ class Tests_User_CountUsers extends WP_UnitTestCase {
|
||||
restore_current_blog();
|
||||
|
||||
$count = count_users( $strategy, $site_id );
|
||||
$this->assertEqualSetsWithIndex(
|
||||
$this->assertSameSetsWithIndex(
|
||||
array(
|
||||
'tester' => 1,
|
||||
'none' => 0,
|
||||
@@ -278,7 +278,7 @@ class Tests_User_CountUsers extends WP_UnitTestCase {
|
||||
|
||||
$count2 = count_users( $strategy );
|
||||
|
||||
$this->assertEqualSets( $count, $count2 );
|
||||
$this->assertSameSets( $count, $count2 );
|
||||
}
|
||||
|
||||
function data_count_users_strategies() {
|
||||
|
||||
@@ -30,7 +30,7 @@ class Tests_User_DateQuery extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEqualSets( array( $u1 ), wp_list_pluck( $uq->results, 'ID' ) );
|
||||
$this->assertSameSets( array( $u1 ), wp_list_pluck( $uq->results, 'ID' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,6 +67,6 @@ class Tests_User_DateQuery extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEqualSets( array( $u1, $u2 ), wp_list_pluck( $uq->results, 'ID' ) );
|
||||
$this->assertSameSets( array( $u1, $u2 ), wp_list_pluck( $uq->results, 'ID' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -847,7 +847,7 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
$found = wp_list_pluck( $q->get_results(), 'ID' );
|
||||
$expected = array( self::$author_ids[0] );
|
||||
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
$this->assertSameSets( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -888,7 +888,7 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
$found = wp_list_pluck( $q->get_results(), 'ID' );
|
||||
$expected = array( self::$author_ids[1], self::$author_ids[2] );
|
||||
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
$this->assertSameSets( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -929,7 +929,7 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
$found = wp_list_pluck( $q->get_results(), 'ID' );
|
||||
$expected = array( self::$author_ids[2] );
|
||||
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
$this->assertSameSets( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -974,7 +974,7 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
$found = wp_list_pluck( $q->get_results(), 'ID' );
|
||||
$expected = array( self::$author_ids[1] );
|
||||
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
$this->assertSameSets( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1004,7 +1004,7 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
$found = wp_list_pluck( $q->get_results(), 'ID' );
|
||||
$expected = array( self::$author_ids[0], self::$author_ids[1] );
|
||||
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
$this->assertSameSets( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1042,7 +1042,7 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
$found = wp_list_pluck( $q->get_results(), 'ID' );
|
||||
$expected = array( self::$author_ids[0], self::$author_ids[1] );
|
||||
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
$this->assertSameSets( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1066,7 +1066,7 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
$expected = array( self::$author_ids[0] );
|
||||
|
||||
$this->assertContains( "AND user_nicename = 'peter'", $q->query_where );
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
$this->assertSameSets( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1104,7 +1104,7 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
$expected = array( self::$author_ids[0], self::$author_ids[1], self::$author_ids[2] );
|
||||
|
||||
$this->assertContains( "AND user_nicename IN ( 'peter','paul','mary' )", $q->query_where );
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
$this->assertSameSets( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1201,7 +1201,7 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
$expected = array( self::$author_ids[0] );
|
||||
|
||||
$this->assertContains( "AND user_login = '$user_login'", $q->query_where );
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
$this->assertSameSets( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1222,7 +1222,7 @@ class Tests_User_Query extends WP_UnitTestCase {
|
||||
$expected = array( self::$author_ids[0], self::$author_ids[1], self::$author_ids[2] );
|
||||
|
||||
$this->assertContains( "AND user_login IN ( '$user_login1','$user_login2','$user_login3' )", $q->query_where );
|
||||
$this->assertEqualSets( $expected, $found );
|
||||
$this->assertSameSets( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user