diff --git a/tests/phpunit/tests/query/fieldsClause.php b/tests/phpunit/tests/query/fieldsClause.php index 4522923a8a..d873857a65 100644 --- a/tests/phpunit/tests/query/fieldsClause.php +++ b/tests/phpunit/tests/query/fieldsClause.php @@ -54,23 +54,19 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase { $expected = array(); foreach ( self::$post_ids as $post_id ) { - // Use array_shift to populate in the reverse order. - array_unshift( - $expected, - (object) array( - 'ID' => $post_id, - 'post_parent' => 0, - ) + $expected[] = (object) array( + 'ID' => $post_id, + 'post_parent' => 0, ); } - $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); + $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); // Test the second query's results match. $q2 = new WP_Query( $query_args ); - $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); + $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); } /** @@ -86,15 +82,15 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase { $q = new WP_Query( $query_args ); - $expected = array_reverse( self::$post_ids ); + $expected = self::$post_ids; - $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); + $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); // Test the second query's results match. $q2 = new WP_Query( $query_args ); - $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); + $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); } /** @@ -110,15 +106,15 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase { $q = new WP_Query( $query_args ); - $expected = array_map( 'get_post', array_reverse( self::$post_ids ) ); + $expected = array_map( 'get_post', self::$post_ids ); - $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); + $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); // Test the second query's results match. $q2 = new WP_Query( $query_args ); - $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); + $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); } /** @@ -139,25 +135,21 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase { $expected = array(); foreach ( self::$post_ids as $post_id ) { - // Use array_shift to populate in the reverse order. - array_unshift( - $expected, - (object) array( - 'ID' => $post_id, - 'post_parent' => 0, - 'test_post_fields' => 1, - 'test_post_clauses' => 2, - ) + $expected[] = (object) array( + 'ID' => $post_id, + 'post_parent' => 0, + 'test_post_fields' => '1', + 'test_post_clauses' => '2', ); } - $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); + $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); // Test the second query's results match. $q2 = new WP_Query( $query_args ); - $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); + $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); } /** @@ -176,16 +168,16 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase { $q = new WP_Query( $query_args ); - // Fields => ID does not include the additional fields. - $expected = array_reverse( self::$post_ids ); + // `fields => ids` does not include the additional fields. + $expected = self::$post_ids; - $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); + $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); // Test the second query's results match. $q2 = new WP_Query( $query_args ); - $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); + $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); } /** @@ -204,19 +196,19 @@ class Tests_Query_FieldsClause extends WP_UnitTestCase { $q = new WP_Query( $query_args ); - $expected = array_map( 'get_post', array_reverse( self::$post_ids ) ); + $expected = array_map( 'get_post', self::$post_ids ); foreach ( $expected as $post ) { - $post->test_post_fields = 1; - $post->test_post_clauses = 2; + $post->test_post_fields = '1'; + $post->test_post_clauses = '2'; } - $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); + $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); // Test the second query's results match. $q2 = new WP_Query( $query_args ); - $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); + $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); } /**