Tests: Move wp_cache_replace() test to a more appropriate place.

This matches the location of other `wp_cache_*()` tests following the respective `WP_Object_Cache` method tests.

Follow-up to [1275/tests].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53830 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2022-08-04 15:42:57 +00:00
parent 54106e0359
commit 15b2748615
+22 -22
View File
@@ -144,6 +144,28 @@ class Tests_Cache extends WP_UnitTestCase {
$this->assertSame( $val2, $this->cache->get( $key ) );
}
public function test_wp_cache_replace() {
$key = 'my-key';
$val1 = 'first-val';
$val2 = 'second-val';
$fake_key = 'my-fake-key';
// Save the first value to cache and verify.
wp_cache_set( $key, $val1 );
$this->assertSame( $val1, wp_cache_get( $key ) );
// Replace the value and verify.
wp_cache_replace( $key, $val2 );
$this->assertSame( $val2, wp_cache_get( $key ) );
// Non-existent key should fail.
$this->assertFalse( wp_cache_replace( $fake_key, $val1 ) );
// Make sure $fake_key is not stored.
$this->assertFalse( wp_cache_get( $fake_key ) );
}
public function test_set() {
$key = __FUNCTION__;
$val1 = 'val1';
@@ -383,28 +405,6 @@ class Tests_Cache extends WP_UnitTestCase {
}
}
public function test_wp_cache_replace() {
$key = 'my-key';
$val1 = 'first-val';
$val2 = 'second-val';
$fake_key = 'my-fake-key';
// Save the first value to cache and verify.
wp_cache_set( $key, $val1 );
$this->assertSame( $val1, wp_cache_get( $key ) );
// Replace the value and verify.
wp_cache_replace( $key, $val2 );
$this->assertSame( $val2, wp_cache_get( $key ) );
// Non-existent key should fail.
$this->assertFalse( wp_cache_replace( $fake_key, $val1 ) );
// Make sure $fake_key is not stored.
$this->assertFalse( wp_cache_get( $fake_key ) );
}
/**
* @ticket 54574
*/