@@ -145,26 +145,6 @@ public function test_add_non_persistent_groups_does_not_allow_duplicate_groups()
145145 $ this ->assertCount ( 1 , array_keys ( $ this ->object_cache ->no_mc_groups , 'group-1 ' ) );
146146 }
147147
148- public function test_found_is_set_when_using_non_persistent_groups (): void {
149- /**
150- * wp> wp_cache_add_non_persistent_groups( [ 'example' ] );
151- * NULL
152- * wp> wp_cache_set( 'example', 'example', 'example' );
153- * bool(true)
154- * wp> wp_cache_get( 'example', 'example', false, $found );
155- * string(7) "example"
156- * wp> $found
157- * bool(false)
158- */
159-
160- $ groups = [ 'example ' ];
161- $ this ->object_cache ->add_non_persistent_groups ( $ groups );
162- $ this ->object_cache ->set ( 'example ' , 'example ' , 'example ' );
163- $ this ->object_cache ->get ( 'example ' , 'example ' , false , $ found );
164-
165- $ this ->assertTrue ( $ found );
166- }
167-
168148 // Tests for increment.
169149
170150 public function test_incr_increments_a_numeric_value (): void {
@@ -848,26 +828,49 @@ public function test_set_can_be_performed_per_group(): void {
848828 }
849829
850830 public function test_set_updated_found_status_with_memcache_result (): void {
851- // Need this to ensure cache is set witout going to memcache.
831+ // Need this to ensure cache is set witout going to memcache and using non persistent groups .
852832 $ group = 'do-not-persist-me ' ;
853833 $ this ->object_cache ->add_non_persistent_groups ( [ $ group ] );
854834
855835 $ this ->object_cache ->set ( 'foo ' , 'data ' , $ group );
856836 $ key = $ this ->object_cache ->key ( 'foo ' , $ group );
857837
858- // Check it's false until we use memcache.
859- $ this ->assertFalse ( $ this ->object_cache ->cache [ $ key ][ 'found ' ] );
838+ // Check it's true even though we're not using memcache.
839+ $ this ->assertTrue ( $ this ->object_cache ->cache [ $ key ][ 'found ' ] );
860840
861841 // Remove non-persistent group.
862842 $ this ->object_cache ->no_mc_groups = [];
863843
864844 // Re-set.
865845 $ this ->object_cache ->set ( 'foo ' , 'data ' , $ group );
866846
867- // Cached found value should now be true.
847+ // Cached found value should still be true.
868848 $ this ->assertTrue ( $ this ->object_cache ->cache [ $ key ][ 'found ' ] );
869849 }
870850
851+ /**
852+ * @see https://github.com/Automattic/wp-memcached/issues/61
853+ */
854+ public function test_found_is_set_when_using_non_persistent_groups (): void {
855+ /**
856+ * wp> wp_cache_add_non_persistent_groups( [ 'example' ] );
857+ * NULL
858+ * wp> wp_cache_set( 'example', 'example', 'example' );
859+ * bool(true)
860+ * wp> wp_cache_get( 'example', 'example', false, $found );
861+ * string(7) "example"
862+ * wp> $found
863+ * bool(false)
864+ */
865+
866+ $ groups = [ 'example ' ];
867+ $ this ->object_cache ->add_non_persistent_groups ( $ groups );
868+ $ this ->object_cache ->set ( 'example ' , 'example ' , 'example ' );
869+ $ this ->object_cache ->get ( 'example ' , 'example ' , false , $ found );
870+
871+ $ this ->assertTrue ( $ found );
872+ }
873+
871874 // Tests for switch_to_blog.
872875
873876 public function test_switch_to_blog_sets_blog_prefix_depending_on_multi_site_status (): void {
0 commit comments