Changeset 41849 for trunk/tests/phpunit/tests/post/getPages.php
- Timestamp:
- 10/12/2017 03:19:30 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post/getPages.php
r35246 r41849 97 97 98 98 /** 99 * @ticket 40669 100 */ 101 public function test_cache_should_be_invalidated_by_add_post_meta() { 102 $posts = self::factory()->post->create_many( 2, array( 103 'post_type' => 'page', 104 ) ); 105 106 add_post_meta( $posts[0], 'foo', 'bar' ); 107 108 $cached = get_pages( array( 109 'meta_key' => 'foo', 110 'meta_value' => 'bar', 111 ) ); 112 113 $cached_ids = wp_list_pluck( $cached, 'ID' ); 114 $this->assertEqualSets( array( $posts[0] ), $cached_ids ); 115 116 add_post_meta( $posts[1], 'foo', 'bar' ); 117 118 $found = get_pages( array( 119 'meta_key' => 'foo', 120 'meta_value' => 'bar', 121 ) ); 122 123 $found_ids = wp_list_pluck( $found, 'ID' ); 124 $this->assertEqualSets( $posts, $found_ids ); 125 } 126 127 /** 128 * @ticket 40669 129 */ 130 public function test_cache_should_be_invalidated_by_update_post_meta() { 131 $posts = self::factory()->post->create_many( 2, array( 132 'post_type' => 'page', 133 ) ); 134 135 add_post_meta( $posts[0], 'foo', 'bar' ); 136 add_post_meta( $posts[1], 'foo', 'bar' ); 137 138 $cached = get_pages( array( 139 'meta_key' => 'foo', 140 'meta_value' => 'bar', 141 ) ); 142 143 $cached_ids = wp_list_pluck( $cached, 'ID' ); 144 $this->assertEqualSets( $posts, $cached_ids ); 145 146 update_post_meta( $posts[1], 'foo', 'baz' ); 147 148 $found = get_pages( array( 149 'meta_key' => 'foo', 150 'meta_value' => 'bar', 151 ) ); 152 153 $found_ids = wp_list_pluck( $found, 'ID' ); 154 $this->assertEqualSets( array( $posts[0] ), $found_ids ); 155 } 156 157 /** 158 * @ticket 40669 159 */ 160 public function test_cache_should_be_invalidated_by_delete_post_meta() { 161 $posts = self::factory()->post->create_many( 2, array( 162 'post_type' => 'page', 163 ) ); 164 165 add_post_meta( $posts[0], 'foo', 'bar' ); 166 add_post_meta( $posts[1], 'foo', 'bar' ); 167 168 $cached = get_pages( array( 169 'meta_key' => 'foo', 170 'meta_value' => 'bar', 171 ) ); 172 173 $cached_ids = wp_list_pluck( $cached, 'ID' ); 174 $this->assertEqualSets( $posts, $cached_ids ); 175 176 delete_post_meta( $posts[1], 'foo' ); 177 178 $found = get_pages( array( 179 'meta_key' => 'foo', 180 'meta_value' => 'bar', 181 ) ); 182 183 $found_ids = wp_list_pluck( $found, 'ID' ); 184 $this->assertEqualSets( array( $posts[0] ), $found_ids ); 185 } 186 187 /** 188 * @ticket 40669 189 */ 190 public function test_cache_should_be_invalidated_by_delete_post_meta_by_key() { 191 $posts = self::factory()->post->create_many( 2, array( 192 'post_type' => 'page', 193 ) ); 194 195 add_post_meta( $posts[0], 'foo', 'bar' ); 196 add_post_meta( $posts[1], 'foo', 'bar' ); 197 198 $cached = get_pages( array( 199 'meta_key' => 'foo', 200 'meta_value' => 'bar', 201 ) ); 202 203 $cached_ids = wp_list_pluck( $cached, 'ID' ); 204 $this->assertEqualSets( $posts, $cached_ids ); 205 206 delete_post_meta_by_key( 'foo' ); 207 208 $found = get_pages( array( 209 'meta_key' => 'foo', 210 'meta_value' => 'bar', 211 ) ); 212 213 $found_ids = wp_list_pluck( $found, 'ID' ); 214 $this->assertEqualSets( array(), $found_ids ); 215 } 216 217 /** 99 218 * @ticket 20376 100 219 */
Note: See TracChangeset
for help on using the changeset viewer.