mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-06 17:29:05 +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:
@@ -18,7 +18,7 @@ class Tests_Functions_AllowedProtocols extends WP_UnitTestCase {
|
||||
foreach ( $this->data_example_urls() as $example ) {
|
||||
$example_protocols[] = $example[0];
|
||||
}
|
||||
$this->assertEqualSets( $example_protocols, wp_allowed_protocols() );
|
||||
$this->assertSameSets( $example_protocols, wp_allowed_protocols() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,9 +73,9 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
|
||||
'foo',
|
||||
'key',
|
||||
array(
|
||||
'bar',
|
||||
'bar' => 'foo',
|
||||
'value' => 'baz',
|
||||
'bar',
|
||||
),
|
||||
),
|
||||
'objects' => array(
|
||||
@@ -144,9 +144,9 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
|
||||
'foo',
|
||||
'key',
|
||||
array(
|
||||
'bar',
|
||||
'bar' => 'foo',
|
||||
'value' => 'baz',
|
||||
'bar',
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -161,7 +161,7 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
|
||||
* @param array $expected Expected result.
|
||||
*/
|
||||
public function test_wp_list_pluck( $list, $field, $index_key, $expected ) {
|
||||
$this->assertEqualSetsWithIndex( $expected, wp_list_pluck( $list, $field, $index_key ) );
|
||||
$this->assertSameSetsWithIndex( $expected, wp_list_pluck( $list, $field, $index_key ) );
|
||||
}
|
||||
|
||||
public function data_test_wp_list_filter() {
|
||||
@@ -1023,14 +1023,14 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
|
||||
$input = array( 'foo', 'bar' );
|
||||
$util = new WP_List_Util( $input );
|
||||
|
||||
$this->assertEqualSets( $input, $util->get_input() );
|
||||
$this->assertSameSets( $input, $util->get_input() );
|
||||
}
|
||||
|
||||
public function test_wp_list_util_get_output_immediately() {
|
||||
$input = array( 'foo', 'bar' );
|
||||
$util = new WP_List_Util( $input );
|
||||
|
||||
$this->assertEqualSets( $input, $util->get_output() );
|
||||
$this->assertSameSets( $input, $util->get_output() );
|
||||
}
|
||||
|
||||
public function test_wp_list_util_get_output() {
|
||||
|
||||
Reference in New Issue
Block a user