Changeset 54829
- Timestamp:
- 11/12/2022 02:49:25 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/query/fieldsClause.php
r54768 r54829 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.' );68 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 69 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 70 71 // Test the second query's results match. 72 $q2 = new WP_Query( $query_args ); 73 $this->assertEqual s( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );63 $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); 64 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 65 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 66 67 // Test the second query's results match. 68 $q2 = new WP_Query( $query_args ); 69 $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); 74 70 } 75 71 … … 87 83 $q = new WP_Query( $query_args ); 88 84 89 $expected = array_reverse( self::$post_ids );90 91 $this->assertEqual s( $expected, $q->posts, 'Posts property for first query is not of expected form.' );92 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 93 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 94 95 // Test the second query's results match. 96 $q2 = new WP_Query( $query_args ); 97 $this->assertEqual s( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );85 $expected = self::$post_ids; 86 87 $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); 88 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 89 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 90 91 // Test the second query's results match. 92 $q2 = new WP_Query( $query_args ); 93 $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); 98 94 } 99 95 … … 111 107 $q = new WP_Query( $query_args ); 112 108 113 $expected = array_map( 'get_post', array_reverse( self::$post_ids ));114 115 $this->assertEqual s( $expected, $q->posts, 'Posts property for first query is not of expected form.' );116 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 117 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 118 119 // Test the second query's results match. 120 $q2 = new WP_Query( $query_args ); 121 $this->assertEqual s( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );109 $expected = array_map( 'get_post', self::$post_ids ); 110 111 $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); 112 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 113 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 114 115 // Test the second query's results match. 116 $q2 = new WP_Query( $query_args ); 117 $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); 122 118 } 123 119 … … 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.' );155 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 156 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 157 158 // Test the second query's results match. 159 $q2 = new WP_Query( $query_args ); 160 $this->assertEqual s( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );146 $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); 147 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 148 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 149 150 // Test the second query's results match. 151 $q2 = new WP_Query( $query_args ); 152 $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); 161 153 } 162 154 … … 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 );181 182 $this->assertEqual s( $expected, $q->posts, 'Posts property for first query is not of expected form.' );183 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 184 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 185 186 // Test the second query's results match. 187 $q2 = new WP_Query( $query_args ); 188 $this->assertEqual s( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );171 // `fields => ids` does not include the additional fields. 172 $expected = self::$post_ids; 173 174 $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); 175 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 176 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 177 178 // Test the second query's results match. 179 $q2 = new WP_Query( $query_args ); 180 $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); 189 181 } 190 182 … … 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 $post->test_post_fields = 1;210 $post->test_post_clauses = 2;201 $post->test_post_fields = '1'; 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.' );214 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 215 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 216 217 // Test the second query's results match. 218 $q2 = new WP_Query( $query_args ); 219 $this->assertEqual s( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' );205 $this->assertEqualSets( $expected, $q->posts, 'Posts property for first query is not of expected form.' ); 206 $this->assertSame( 5, $q->found_posts, 'Number of found posts is not five.' ); 207 $this->assertEquals( 1, $q->max_num_pages, 'Number of found pages is not one.' ); 208 209 // Test the second query's results match. 210 $q2 = new WP_Query( $query_args ); 211 $this->assertEqualSets( $expected, $q2->posts, 'Posts property for second query is not in the expected form.' ); 220 212 } 221 213
Note: See TracChangeset
for help on using the changeset viewer.