Changeset 48937 for trunk/tests/phpunit/tests/cache.php
- Timestamp:
- 09/02/2020 12:35:36 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/cache.php
r47942 r48937 36 36 37 37 $this->cache->add( $key, $val ); 38 $this->assert Equals( $val, $this->cache->get( $key ) );38 $this->assertSame( $val, $this->cache->get( $key ) ); 39 39 } 40 40 … … 45 45 // You can store zero in the cache. 46 46 $this->cache->add( $key, $val ); 47 $this->assert Equals( $val, $this->cache->get( $key ) );47 $this->assertSame( $val, $this->cache->get( $key ) ); 48 48 } 49 49 … … 64 64 // Add $key to the cache. 65 65 $this->assertTrue( $this->cache->add( $key, $val1 ) ); 66 $this->assert Equals( $val1, $this->cache->get( $key ) );66 $this->assertSame( $val1, $this->cache->get( $key ) ); 67 67 // $key is in the cache, so reject new calls to add(). 68 68 $this->assertFalse( $this->cache->add( $key, $val2 ) ); 69 $this->assert Equals( $val1, $this->cache->get( $key ) );69 $this->assertSame( $val1, $this->cache->get( $key ) ); 70 70 } 71 71 … … 79 79 $this->assertFalse( $this->cache->get( $key ) ); 80 80 $this->assertTrue( $this->cache->add( $key, $val ) ); 81 $this->assert Equals( $val, $this->cache->get( $key ) );81 $this->assertSame( $val, $this->cache->get( $key ) ); 82 82 $this->assertTrue( $this->cache->replace( $key, $val2 ) ); 83 $this->assert Equals( $val2, $this->cache->get( $key ) );83 $this->assertSame( $val2, $this->cache->get( $key ) ); 84 84 } 85 85 … … 91 91 // memcached accepts set() if the key does not exist. 92 92 $this->assertTrue( $this->cache->set( $key, $val1 ) ); 93 $this->assert Equals( $val1, $this->cache->get( $key ) );93 $this->assertSame( $val1, $this->cache->get( $key ) ); 94 94 // Second set() with same key should be allowed. 95 95 $this->assertTrue( $this->cache->set( $key, $val2 ) ); 96 $this->assert Equals( $val2, $this->cache->get( $key ) );96 $this->assertSame( $val2, $this->cache->get( $key ) ); 97 97 } 98 98 … … 109 109 $this->cache->add( $key, $val ); 110 110 // Item is visible to both cache objects. 111 $this->assert Equals( $val, $this->cache->get( $key ) );111 $this->assertSame( $val, $this->cache->get( $key ) ); 112 112 $this->cache->flush(); 113 113 // If there is no value get returns false. … … 123 123 $object_a->foo = 'bravo'; 124 124 $object_b = $this->cache->get( $key ); 125 $this->assert Equals( 'alpha', $object_b->foo );125 $this->assertSame( 'alpha', $object_b->foo ); 126 126 $object_b->foo = 'charlie'; 127 $this->assert Equals( 'bravo', $object_a->foo );127 $this->assertSame( 'bravo', $object_a->foo ); 128 128 129 129 $key = __FUNCTION__ . '_2'; … … 133 133 $object_a->foo = 'bravo'; 134 134 $object_b = $this->cache->get( $key ); 135 $this->assert Equals( 'alpha', $object_b->foo );135 $this->assertSame( 'alpha', $object_b->foo ); 136 136 $object_b->foo = 'charlie'; 137 $this->assert Equals( 'bravo', $object_a->foo );137 $this->assertSame( 'bravo', $object_a->foo ); 138 138 } 139 139 … … 145 145 $this->cache->set( $key, 0 ); 146 146 $this->cache->incr( $key ); 147 $this->assert Equals( 1, $this->cache->get( $key ) );147 $this->assertSame( 1, $this->cache->get( $key ) ); 148 148 149 149 $this->cache->incr( $key, 2 ); 150 $this->assert Equals( 3, $this->cache->get( $key ) );150 $this->assertSame( 3, $this->cache->get( $key ) ); 151 151 } 152 152 … … 158 158 wp_cache_set( $key, 0 ); 159 159 wp_cache_incr( $key ); 160 $this->assert Equals( 1, wp_cache_get( $key ) );160 $this->assertSame( 1, wp_cache_get( $key ) ); 161 161 162 162 wp_cache_incr( $key, 2 ); 163 $this->assert Equals( 3, wp_cache_get( $key ) );163 $this->assertSame( 3, wp_cache_get( $key ) ); 164 164 } 165 165 … … 171 171 $this->cache->set( $key, 0 ); 172 172 $this->cache->decr( $key ); 173 $this->assert Equals( 0, $this->cache->get( $key ) );173 $this->assertSame( 0, $this->cache->get( $key ) ); 174 174 175 175 $this->cache->set( $key, 3 ); 176 176 $this->cache->decr( $key ); 177 $this->assert Equals( 2, $this->cache->get( $key ) );177 $this->assertSame( 2, $this->cache->get( $key ) ); 178 178 179 179 $this->cache->decr( $key, 2 ); 180 $this->assert Equals( 0, $this->cache->get( $key ) );180 $this->assertSame( 0, $this->cache->get( $key ) ); 181 181 } 182 182 … … 191 191 wp_cache_set( $key, 0 ); 192 192 wp_cache_decr( $key ); 193 $this->assert Equals( 0, wp_cache_get( $key ) );193 $this->assertSame( 0, wp_cache_get( $key ) ); 194 194 195 195 wp_cache_set( $key, 3 ); 196 196 wp_cache_decr( $key ); 197 $this->assert Equals( 2, wp_cache_get( $key ) );197 $this->assertSame( 2, wp_cache_get( $key ) ); 198 198 199 199 wp_cache_decr( $key, 2 ); 200 $this->assert Equals( 0, wp_cache_get( $key ) );200 $this->assertSame( 0, wp_cache_get( $key ) ); 201 201 } 202 202 … … 207 207 // Verify set. 208 208 $this->assertTrue( $this->cache->set( $key, $val ) ); 209 $this->assert Equals( $val, $this->cache->get( $key ) );209 $this->assertSame( $val, $this->cache->get( $key ) ); 210 210 211 211 // Verify successful delete. … … 222 222 // Verify set. 223 223 $this->assertTrue( wp_cache_set( $key, $val ) ); 224 $this->assert Equals( $val, wp_cache_get( $key ) );224 $this->assertSame( $val, wp_cache_get( $key ) ); 225 225 226 226 // Verify successful delete. … … 247 247 // Single site ingnores switch_to_blog(). 248 248 $this->assertTrue( $this->cache->set( $key, $val ) ); 249 $this->assert Equals( $val, $this->cache->get( $key ) );249 $this->assertSame( $val, $this->cache->get( $key ) ); 250 250 $this->cache->switch_to_blog( 999 ); 251 $this->assert Equals( $val, $this->cache->get( $key ) );251 $this->assertSame( $val, $this->cache->get( $key ) ); 252 252 $this->assertTrue( $this->cache->set( $key, $val2 ) ); 253 $this->assert Equals( $val2, $this->cache->get( $key ) );253 $this->assertSame( $val2, $this->cache->get( $key ) ); 254 254 $this->cache->switch_to_blog( get_current_blog_id() ); 255 $this->assert Equals( $val2, $this->cache->get( $key ) );255 $this->assertSame( $val2, $this->cache->get( $key ) ); 256 256 } else { 257 257 // Multisite should have separate per-blog caches. 258 258 $this->assertTrue( $this->cache->set( $key, $val ) ); 259 $this->assert Equals( $val, $this->cache->get( $key ) );259 $this->assertSame( $val, $this->cache->get( $key ) ); 260 260 $this->cache->switch_to_blog( 999 ); 261 261 $this->assertFalse( $this->cache->get( $key ) ); 262 262 $this->assertTrue( $this->cache->set( $key, $val2 ) ); 263 $this->assert Equals( $val2, $this->cache->get( $key ) );263 $this->assertSame( $val2, $this->cache->get( $key ) ); 264 264 $this->cache->switch_to_blog( get_current_blog_id() ); 265 $this->assert Equals( $val, $this->cache->get( $key ) );265 $this->assertSame( $val, $this->cache->get( $key ) ); 266 266 $this->cache->switch_to_blog( 999 ); 267 $this->assert Equals( $val2, $this->cache->get( $key ) );267 $this->assertSame( $val2, $this->cache->get( $key ) ); 268 268 $this->cache->switch_to_blog( get_current_blog_id() ); 269 $this->assert Equals( $val, $this->cache->get( $key ) );269 $this->assertSame( $val, $this->cache->get( $key ) ); 270 270 } 271 271 272 272 // Global group. 273 273 $this->assertTrue( $this->cache->set( $key, $val, 'global-cache-test' ) ); 274 $this->assert Equals( $val, $this->cache->get( $key, 'global-cache-test' ) );274 $this->assertSame( $val, $this->cache->get( $key, 'global-cache-test' ) ); 275 275 $this->cache->switch_to_blog( 999 ); 276 $this->assert Equals( $val, $this->cache->get( $key, 'global-cache-test' ) );276 $this->assertSame( $val, $this->cache->get( $key, 'global-cache-test' ) ); 277 277 $this->assertTrue( $this->cache->set( $key, $val2, 'global-cache-test' ) ); 278 $this->assert Equals( $val2, $this->cache->get( $key, 'global-cache-test' ) );278 $this->assertSame( $val2, $this->cache->get( $key, 'global-cache-test' ) ); 279 279 $this->cache->switch_to_blog( get_current_blog_id() ); 280 $this->assert Equals( $val2, $this->cache->get( $key, 'global-cache-test' ) );280 $this->assertSame( $val2, $this->cache->get( $key, 'global-cache-test' ) ); 281 281 } 282 282 … … 304 304 // Save the first value to cache and verify. 305 305 wp_cache_set( $key, $val1 ); 306 $this->assert Equals( $val1, wp_cache_get( $key ) );306 $this->assertSame( $val1, wp_cache_get( $key ) ); 307 307 308 308 // Replace the value and verify. 309 309 wp_cache_replace( $key, $val2 ); 310 $this->assert Equals( $val2, wp_cache_get( $key ) );310 $this->assertSame( $val2, wp_cache_get( $key ) ); 311 311 312 312 // Non-existant key should fail.
Note: See TracChangeset
for help on using the changeset viewer.