From 15b27486157df25be7878625202d138cfb3f988d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 4 Aug 2022 15:42:57 +0000 Subject: [PATCH] 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 --- tests/phpunit/tests/cache.php | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/phpunit/tests/cache.php b/tests/phpunit/tests/cache.php index d6b059adba..57922ad1d2 100644 --- a/tests/phpunit/tests/cache.php +++ b/tests/phpunit/tests/cache.php @@ -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 */