Changeset 1065 in tests for trunk/tests/post/query.php
- Timestamp:
- 10/02/2012 04:28:14 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/tests/post/query.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/post/query.php
r1062 r1065 49 49 $this->assertEquals( array( $post_id, $post_id2, $post_id3, $post_id4 ), $post_ids ); 50 50 } 51 52 function test_meta_key_not_exists() { 53 $post_id = $this->factory->post->create(); 54 add_post_meta( $post_id, 'foo', rand_str() ); 55 $post_id2 = $this->factory->post->create(); 56 add_post_meta( $post_id2, 'bar', rand_str() ); 57 $post_id3 = $this->factory->post->create(); 58 add_post_meta( $post_id3, 'bar', rand_str() ); 59 $post_id4 = $this->factory->post->create(); 60 add_post_meta( $post_id4, 'baz', rand_str() ); 61 $post_id5 = $this->factory->post->create(); 62 add_post_meta( $post_id5, 'foo', rand_str() ); 63 64 $query = new WP_Query( array( 65 'meta_query' => array( 66 array( 67 'key' => 'foo', 68 'compare' => 'NOT EXISTS', 69 ), 70 ), 71 ) ); 72 73 $posts = $query->get_posts(); 74 $this->assertEquals( 3, count( $posts ) ); 75 76 $query = new WP_Query( array( 77 'meta_query' => array( 78 array( 79 'key' => 'foo', 80 'compare' => 'NOT EXISTS', 81 ), 82 array( 83 'key' => 'bar', 84 'compare' => 'NOT EXISTS', 85 ), 86 ), 87 ) ); 88 89 $posts = $query->get_posts(); 90 $this->assertEquals( 1, count( $posts ) ); 91 92 $query = new WP_Query( array( 93 'meta_query' => array( 94 array( 95 'key' => 'foo', 96 'compare' => 'NOT EXISTS', 97 ), 98 array( 99 'key' => 'bar', 100 'compare' => 'NOT EXISTS', 101 ), 102 array( 103 'key' => 'baz', 104 'compare' => 'NOT EXISTS', 105 ), 106 ) 107 ) ); 108 109 $posts = $query->get_posts(); 110 $this->assertEquals( 0, count( $posts ) ); 111 } 51 112 }
Note: See TracChangeset
for help on using the changeset viewer.