Ticket #57012: 57012.diff
File 57012.diff, 6.2 KB (added by , 2 years ago) |
---|
-
tests/phpunit/tests/query/fieldsClause.php
54 54 55 55 $expected = array(); 56 56 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, 64 60 ); 65 61 } 66 62 67 $this->assertEqual s( $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.' ); 68 64 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 69 65 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 70 66 71 67 // Test the second query's results match. 72 68 $q2 = new WP_Query( $query_args ); 73 $this->assertEqual s( $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.' ); 74 70 } 75 71 76 72 /** … … 86 82 87 83 $q = new WP_Query( $query_args ); 88 84 89 $expected = array_reverse( self::$post_ids );85 $expected = self::$post_ids; 90 86 91 $this->assertEqual s( $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.' ); 92 88 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 93 89 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 94 90 95 91 // Test the second query's results match. 96 92 $q2 = new WP_Query( $query_args ); 97 $this->assertEqual s( $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.' ); 98 94 } 99 95 100 96 /** … … 110 106 111 107 $q = new WP_Query( $query_args ); 112 108 113 $expected = array_map( 'get_post', array_reverse( self::$post_ids ));109 $expected = array_map( 'get_post', self::$post_ids ); 114 110 115 $this->assertEqual s( $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.' ); 116 112 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 117 113 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 118 114 119 115 // Test the second query's results match. 120 116 $q2 = new WP_Query( $query_args ); 121 $this->assertEqual s( $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.' ); 122 118 } 123 119 124 120 /** … … 139 135 140 136 $expected = array(); 141 137 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, 151 143 ); 152 144 } 153 145 154 $this->assertEqual s( $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.' ); 155 147 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 156 148 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 157 149 158 150 // Test the second query's results match. 159 151 $q2 = new WP_Query( $query_args ); 160 $this->assertEqual s( $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.' ); 161 153 } 162 154 163 155 /** … … 176 168 177 169 $q = new WP_Query( $query_args ); 178 170 179 // Fields => IDdoes 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; 181 173 182 $this->assertEqual s( $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.' ); 183 175 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 184 176 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 185 177 186 178 // Test the second query's results match. 187 179 $q2 = new WP_Query( $query_args ); 188 $this->assertEqual s( $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.' ); 189 181 } 190 182 191 183 /** … … 204 196 205 197 $q = new WP_Query( $query_args ); 206 198 207 $expected = array_map( 'get_post', array_reverse( self::$post_ids ));199 $expected = array_map( 'get_post', self::$post_ids ); 208 200 foreach ( $expected as $post ) { 209 201 $post->test_post_fields = 1; 210 202 $post->test_post_clauses = 2; 211 203 } 212 204 213 $this->assertEqual s( $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.' ); 214 206 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 215 207 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 216 208 217 209 // Test the second query's results match. 218 210 $q2 = new WP_Query( $query_args ); 219 $this->assertEqual s( $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.' ); 220 212 } 221 213 222 214 /**