Changeset 29855 for trunk/tests/phpunit/tests/meta.php
- Timestamp:
- 10/08/2014 03:11:14 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/meta.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/meta.php
r29650 r29855 163 163 } 164 164 165 /** 166 * @ticket 16814 167 */ 165 168 function test_meta_type_cast() { 166 169 $post_id1 = $this->factory->post->create(); 167 170 add_post_meta( $post_id1, 'num_as_longtext', 123 ); 171 add_post_meta( $post_id1, 'num_as_longtext_desc', 10 ); 168 172 $post_id2 = $this->factory->post->create(); 169 173 add_post_meta( $post_id2, 'num_as_longtext', 99 ); 174 add_post_meta( $post_id2, 'num_as_longtext_desc', 100 ); 170 175 171 176 $posts = new WP_Query( array( … … 182 187 $this->assertEquals( array( $post_id2, $post_id1 ), $posts->posts ); 183 188 $this->assertEquals( 2, substr_count( $posts->request, 'CAST(' ) ); 189 190 // Make sure the newer meta_query syntax behaves in a consistent way 191 $posts = new WP_Query( array( 192 'fields' => 'ids', 193 'post_type' => 'any', 194 'meta_query' => array( 195 array( 196 'key' => 'num_as_longtext', 197 'value' => '0', 198 'compare' => '>', 199 'type' => 'UNSIGNED', 200 ), 201 ), 202 'orderby' => 'meta_value', 203 'order' => 'ASC' 204 ) ); 205 206 $this->assertEquals( array( $post_id2, $post_id1 ), $posts->posts ); 207 $this->assertEquals( 2, substr_count( $posts->request, 'CAST(' ) ); 208 209 // The legacy `meta_key` value should take precedence. 210 $posts = new WP_Query( array( 211 'fields' => 'ids', 212 'post_type' => 'any', 213 'meta_key' => 'num_as_longtext', 214 'meta_compare' => '>', 215 'meta_type' => 'UNSIGNED', 216 'meta_query' => array( 217 array( 218 'key' => 'num_as_longtext_desc', 219 'value' => '0', 220 'compare' => '>', 221 'type' => 'UNSIGNED', 222 ), 223 ), 224 'orderby' => 'meta_value', 225 'order' => 'ASC' 226 ) ); 227 228 $this->assertEquals( array( $post_id2, $post_id1 ), $posts->posts ); 229 $this->assertEquals( 2, substr_count( $posts->request, 'CAST(' ) ); 184 230 } 185 231
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)