Make WordPress Core

Ticket #57012: 57012.diff

File 57012.diff, 6.2 KB (added by SergeyBiryukov, 2 years ago)
  • tests/phpunit/tests/query/fieldsClause.php

     
    5454
    5555                $expected = array();
    5656                foreach ( self::$post_ids as $post_id ) {
    57                         // Use array_shift to populate in the reverse order.
    58                         array_unshift(
    59                                 $expected,
    60                                 (object) array(
    61                                         'ID'          => $post_id,
    62                                         'post_parent' => 0,
    63                                 )
     57                        $expected[] = (object) array(
     58                                'ID'          => $post_id,
     59                                'post_parent' => 0,
    6460                        );
    6561                }
    6662
    67                 $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
     63                $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    6864                $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    6965                $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    7066
    7167                // Test the second query's results match.
    7268                $q2 = new WP_Query( $query_args );
    73                 $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
     69                $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
    7470        }
    7571
    7672        /**
     
    8682
    8783                $q = new WP_Query( $query_args );
    8884
    89                 $expected = array_reverse( self::$post_ids );
     85                $expected = self::$post_ids;
    9086
    91                 $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
     87                $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    9288                $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    9389                $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    9490
    9591                // Test the second query's results match.
    9692                $q2 = new WP_Query( $query_args );
    97                 $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
     93                $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
    9894        }
    9995
    10096        /**
     
    110106
    111107                $q = new WP_Query( $query_args );
    112108
    113                 $expected = array_map( 'get_post', array_reverse( self::$post_ids ) );
     109                $expected = array_map( 'get_post', self::$post_ids );
    114110
    115                 $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
     111                $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    116112                $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    117113                $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    118114
    119115                // Test the second query's results match.
    120116                $q2 = new WP_Query( $query_args );
    121                 $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
     117                $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
    122118        }
    123119
    124120        /**
     
    139135
    140136                $expected = array();
    141137                foreach ( self::$post_ids as $post_id ) {
    142                         // Use array_shift to populate in the reverse order.
    143                         array_unshift(
    144                                 $expected,
    145                                 (object) array(
    146                                         'ID'                => $post_id,
    147                                         'post_parent'       => 0,
    148                                         'test_post_fields'  => 1,
    149                                         'test_post_clauses' => 2,
    150                                 )
     138                        $expected[] = (object) array(
     139                                'ID'                => $post_id,
     140                                'post_parent'       => 0,
     141                                'test_post_fields'  => 1,
     142                                'test_post_clauses' => 2,
    151143                        );
    152144                }
    153145
    154                 $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
     146                $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    155147                $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    156148                $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    157149
    158150                // Test the second query's results match.
    159151                $q2 = new WP_Query( $query_args );
    160                 $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
     152                $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
    161153        }
    162154
    163155        /**
     
    176168
    177169                $q = new WP_Query( $query_args );
    178170
    179                 // Fields => ID does not include the additional fields.
    180                 $expected = array_reverse( self::$post_ids );
     171                // `fields => ids` does not include the additional fields.
     172                $expected = self::$post_ids;
    181173
    182                 $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
     174                $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    183175                $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    184176                $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    185177
    186178                // Test the second query's results match.
    187179                $q2 = new WP_Query( $query_args );
    188                 $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
     180                $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
    189181        }
    190182
    191183        /**
     
    204196
    205197                $q = new WP_Query( $query_args );
    206198
    207                 $expected = array_map( 'get_post', array_reverse( self::$post_ids ) );
     199                $expected = array_map( 'get_post', self::$post_ids );
    208200                foreach ( $expected as $post ) {
    209201                        $post->test_post_fields  = 1;
    210202                        $post->test_post_clauses = 2;
    211203                }
    212204
    213                 $this->assertEquals( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
     205                $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' );
    214206                $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' );
    215207                $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' );
    216208
    217209                // Test the second query's results match.
    218210                $q2 = new WP_Query( $query_args );
    219                 $this->assertEquals( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
     211                $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );
    220212        }
    221213
    222214        /**