mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Cache API: Make the placement of wp_cache_flush_group() more consistent.
Includes: * Placing `WP_Object_Cache::flush_group()` next to `::flush()`. * Placing `wp_cache_supports_group_flush()` next to `wp_cache_flush_group()`. * Placing the `wp_cache_flush_group()` unit test next to the `::flush()` method test. * Removing test name from assertion messages, as it is already mentioned directly above in case of failure. * Adjusting function descriptions per the documentation standards. Follow-up to [52706], [53763]. See #55647, #4476. git-svn-id: https://develop.svn.wordpress.org/trunk@53767 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -129,6 +129,36 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
$this->assertFalse( $this->cache->get( $key ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 4476
|
||||
* @ticket 9773
|
||||
*
|
||||
* @covers ::wp_cache_flush_group
|
||||
*/
|
||||
public function test_wp_cache_flush_group() {
|
||||
$key = 'my-key';
|
||||
$val = 'my-val';
|
||||
|
||||
wp_cache_set( $key, $val, 'group-test' );
|
||||
wp_cache_set( $key, $val, 'group-kept' );
|
||||
|
||||
$this->assertSame( $val, wp_cache_get( $key, 'group-test' ), 'group-test should contain my-val' );
|
||||
|
||||
if ( wp_using_ext_object_cache() ) {
|
||||
$this->setExpectedIncorrectUsage( 'wp_cache_flush_group' );
|
||||
}
|
||||
|
||||
$results = wp_cache_flush_group( 'group-test' );
|
||||
|
||||
if ( wp_using_ext_object_cache() ) {
|
||||
$this->assertFalse( $results );
|
||||
} else {
|
||||
$this->assertTrue( $results );
|
||||
$this->assertFalse( wp_cache_get( $key, 'group-test' ), 'group-test should return false' );
|
||||
$this->assertSame( $val, wp_cache_get( $key, 'group-kept' ), 'group-kept should still contain my-val' );
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure objects are cloned going to and from the cache.
|
||||
public function test_object_refs() {
|
||||
$key = __FUNCTION__ . '_1';
|
||||
@@ -415,36 +445,4 @@ class Tests_Cache extends WP_UnitTestCase {
|
||||
|
||||
$this->assertSame( $expected, $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 4476
|
||||
* @ticket 9773
|
||||
*
|
||||
* test wp_cache_flush_group
|
||||
*
|
||||
* @covers ::wp_cache_flush_group
|
||||
*/
|
||||
public function test_wp_cache_flush_group() {
|
||||
$key = 'my-key';
|
||||
$val = 'my-val';
|
||||
|
||||
wp_cache_set( $key, $val, 'group-test' );
|
||||
wp_cache_set( $key, $val, 'group-kept' );
|
||||
|
||||
$this->assertSame( $val, wp_cache_get( $key, 'group-test' ), 'test_wp_cache_flush_group: group-test should contain my-val' );
|
||||
|
||||
if ( wp_using_ext_object_cache() ) {
|
||||
$this->setExpectedIncorrectUsage( 'wp_cache_flush_group' );
|
||||
}
|
||||
|
||||
$results = wp_cache_flush_group( 'group-test' );
|
||||
|
||||
if ( wp_using_ext_object_cache() ) {
|
||||
$this->assertFalse( $results );
|
||||
} else {
|
||||
$this->assertTrue( $results );
|
||||
$this->assertFalse( wp_cache_get( $key, 'group-test' ), 'test_wp_cache_flush_group: group-test should return false' );
|
||||
$this->assertSame( $val, wp_cache_get( $key, 'group-kept' ), 'test_wp_cache_flush_group: group-kept should still contain my-val' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user