@@ -144,11 +144,13 @@ Feature: Granular cache flushing operations
144144 $cache_option = function(){
145145 wp_cache_set( 'my_option', 'value', 'options' );
146146 wp_cache_set( 'alloptions', array( 'my_option' => 'value' ), 'options' );
147+ wp_cache_set( 'notoptions', array( 'my_option' => true ), 'options' );
147148 };
148149 $verify_cache_cleared = function(){
149150 $option = wp_cache_get( 'my_option', 'options' );
150151 $alloptions = wp_cache_get( 'alloptions', 'options' );
151- if ( false !== $option || false !== $alloptions ) {
152+ $notoptions = wp_cache_get( 'notoptions', 'options' );
153+ if ( false !== $option || false !== $alloptions || false !== $notoptions ) {
152154 WP_CLI::error( 'Cache was not properly cleared.' );
153155 }
154156 };
@@ -262,7 +264,7 @@ Feature: Granular cache flushing operations
262264 | 0 |
263265 | -1 |
264266
265- @require-wp-6- 1 @skip-object-cache
267+ @require-wp-6. 1 @skip-object-cache
266268 Scenario : Flush all post caches on WordPress 6.1+
267269 Given a WP install
268270 And a wp-content/mu-plugins/test-harness.php file:
@@ -272,13 +274,15 @@ Feature: Granular cache flushing operations
272274 wp_cache_set( 'post_1', array( 'ID' => 1 ), 'posts' );
273275 wp_cache_set( 'post_2', array( 'ID' => 2 ), 'posts' );
274276 wp_cache_set( 'meta_1', array( 'key' => 'value' ), 'post_meta' );
277+ wp_cache_set( 1, array( 1 ), 'category_relationships' );
275278 };
276279 $verify_group_cleared = function(){
277280 if ( function_exists( 'wp_cache_supports' ) && wp_cache_supports( 'flush_group' ) ) {
278281 $post1 = wp_cache_get( 'post_1', 'posts' );
279282 $post2 = wp_cache_get( 'post_2', 'posts' );
280283 $meta = wp_cache_get( 'meta_1', 'post_meta' );
281- if ( false !== $post1 || false !== $post2 || false !== $meta ) {
284+ $rel = wp_cache_get( 1, 'category_relationships' );
285+ if ( false !== $post1 || false !== $post2 || false !== $meta || false !== $rel ) {
282286 WP_CLI::error( 'Group cache was not properly cleared.' );
283287 }
284288 }
@@ -293,7 +297,7 @@ Feature: Granular cache flushing operations
293297 Success: Post caches cleared.
294298 """
295299
296- @require-wp-6- 1 @skip-object-cache
300+ @require-wp-6. 1 @skip-object-cache
297301 Scenario : Flush all term caches on WordPress 6.1+
298302 Given a WP install
299303 And a wp-content/mu-plugins/test-harness.php file:
@@ -324,7 +328,7 @@ Feature: Granular cache flushing operations
324328 Success: Term caches cleared.
325329 """
326330
327- @require-wp-6- 1 @skip-object-cache
331+ @require-wp-6. 1 @skip-object-cache
328332 Scenario : Flush all comment caches on WordPress 6.1+
329333 Given a WP install
330334 And a wp-content/mu-plugins/test-harness.php file:
@@ -355,7 +359,7 @@ Feature: Granular cache flushing operations
355359 Success: Comment caches cleared.
356360 """
357361
358- @require-wp-6- 1 @skip-object-cache
362+ @require-wp-6. 1 @skip-object-cache
359363 Scenario : Flush all user caches on WordPress 6.1+
360364 Given a WP install
361365 And a wp-content/mu-plugins/test-harness.php file:
@@ -365,13 +369,21 @@ Feature: Granular cache flushing operations
365369 wp_cache_set( 'user_1', array( 'ID' => 1 ), 'users' );
366370 wp_cache_set( 'user_2', array( 'ID' => 2 ), 'users' );
367371 wp_cache_set( 'meta_1', array(), 'user_meta' );
372+ wp_cache_set( 'old@example.com', 1, 'useremail' );
373+ wp_cache_set( 'oldlogin', 1, 'userlogins' );
374+ wp_cache_set( 'oldslug', 1, 'userslugs' );
368375 };
369376 $verify_group_cleared = function(){
370377 if ( function_exists( 'wp_cache_supports' ) && wp_cache_supports( 'flush_group' ) ) {
371378 $user1 = wp_cache_get( 'user_1', 'users' );
372379 $user2 = wp_cache_get( 'user_2', 'users' );
373380 $meta = wp_cache_get( 'meta_1', 'user_meta' );
374- if ( false !== $user1 || false !== $user2 || false !== $meta ) {
381+ $lookups = array(
382+ wp_cache_get( 'old@example.com', 'useremail' ),
383+ wp_cache_get( 'oldlogin', 'userlogins' ),
384+ wp_cache_get( 'oldslug', 'userslugs' ),
385+ );
386+ if ( false !== $user1 || false !== $user2 || false !== $meta || array( false, false, false ) !== $lookups ) {
375387 WP_CLI::error( 'Group cache was not properly cleared.' );
376388 }
377389 }
@@ -386,7 +398,7 @@ Feature: Granular cache flushing operations
386398 Success: User caches cleared.
387399 """
388400
389- @require-wp-6- 1 @skip-object-cache
401+ @require-wp-6. 1 @skip-object-cache
390402 Scenario : Flush all option caches on WordPress 6.1+
391403 Given a WP install
392404 And a wp-content/mu-plugins/test-harness.php file:
@@ -414,3 +426,14 @@ Feature: Granular cache flushing operations
414426 """
415427 Success: Option caches cleared.
416428 """
429+
430+ @less-than-wp-6.1
431+ Scenario : Flushing all post caches requires WordPress 6.1+
432+ Given a WP install
433+
434+ When I try `wp cache flush-post`
435+ Then STDERR should be:
436+ """
437+ Error: Flushing all post caches requires WordPress 6.1+
438+ """
439+ And the return code should be 1
0 commit comments