| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Yiisoft\Cache\Tests\Memcached; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use DateInterval; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Psr\SimpleCache\CacheInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Yiisoft\Cache\Cache; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Yiisoft\Cache\Dependency\TagDependency; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Yiisoft\Cache\Memcached; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Yiisoft\Cache\Tests\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | class MemcachedDecoratorExtraTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     protected function createCacheInstance(): CacheInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |         return new Cache(new Memcached()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     public function testAdd(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         /** @var Cache $cache */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $cache = $this->prepare($cache); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         // should not change existing keys | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $this->assertSameExceptObject('a', $cache->get('test_string')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $this->assertFalse($cache->add('test_string', 'b')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         // should store data if it's not there yet | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->assertNull($cache->get('add_test')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->assertTrue($cache->add('add_test', 13)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $this->assertSameExceptObject(13, $cache->get('add_test')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     public function testAddMultiple(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         /** @var Cache $cache */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $cache = $this->prepare($cache); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $this->assertNull($cache->get('add_test')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $this->assertTrue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             $cache->addMultiple( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |                 [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |                     'test_integer' => 13, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |                     'add_test' => 13, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |                 ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $this->assertSameExceptObject(1, $cache->get('test_integer')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->assertSameExceptObject(13, $cache->get('add_test')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     public function testGetOrSet(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $cache = $this->prepare($cache); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $expected = get_class($cache); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $this->assertSameExceptObject(null, $cache->get('something')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $this->assertSameExceptObject($expected, $cache->getOrSet('something', static function (CacheInterface $cache): string { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             return get_class($cache); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         })); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $this->assertSameExceptObject($expected, $cache->get('something')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     public function testGetOrSetWithDependencies(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         /** @var Cache $cache */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         $dependency = new TagDependency('test'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         $expected = 'SilverFire'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $loginClosure = static function (): string { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             return 'SilverFire'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $this->assertSameExceptObject($expected, $cache->getOrSet('some-login', $loginClosure, null, $dependency)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         // Call again with another login to make sure that value is cached | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $loginClosure = static function (): string { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |             return 'SamDark'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         $cache->getOrSet('some-login', $loginClosure, null, $dependency); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         $this->assertSameExceptObject($expected, $cache->getOrSet('some-login', $loginClosure, null, $dependency)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         TagDependency::invalidate($cache, 'test'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $expected = 'SamDark'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $this->assertSameExceptObject($expected, $cache->getOrSet('some-login', $loginClosure, null, $dependency)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |     public function testWithArrayKeys(): void | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |         $key = [42]; | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |         $cache->clear(); | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |         $this->assertNull($cache->get($key)); | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |         $cache->set($key, 42); | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |         $this->assertSame(42, $cache->get($key)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     public function testWithObjectKeys(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         $key = new class { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             public $value = 42; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |         $cache->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         $this->assertNull($cache->get($key)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         $cache->set($key, 42); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         $this->assertSame(42, $cache->get($key)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     public function testNormalizeKey(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         /** @var Cache $cache */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         $cache->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $cache->enableKeyNormalization(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         $cache->set('test_normalized', 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         $cache->disableKeyNormalization(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         $cache->set('test_not_normalized', 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         $cache->disableKeyNormalization(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         $this->assertFalse($cache->has('test_normalized')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |         $this->assertSameExceptObject(1, $cache->get('2753a58fdc3bf713af86cb3a97a55e57')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         $this->assertSameExceptObject(2, $cache->get('test_not_normalized')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     public function testGetWithPrefix(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         /** @var Cache $cache */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         $cache->setKeyPrefix('prefix'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         $cache = $this->prepare($cache); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         $this->assertSameExceptObject(1, $cache->get('test_integer')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     public function testKeyPrefix(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         /** @var Cache $cache */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         $cache->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         $cache->disableKeyNormalization(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         $cache->setKeyPrefix('prefix'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         $cache->set('test_with_prefix', 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         $cache->setKeyPrefix(''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         $cache->set('test_without_prefix', 2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         $cache->setKeyPrefix(''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         $this->assertFalse($cache->has('test_with_prefix')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         $this->assertSameExceptObject(1, $cache->get('prefixtest_with_prefix')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |         $this->assertSameExceptObject(2, $cache->get('test_without_prefix')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * @dataProvider featuresProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      * @param $features | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     public function testFeatures($features): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         /** @var Cache $cache */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         $cache->setKeyPrefix($features[0]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         $features[1] ? $cache->enableKeyNormalization() : $cache->disableKeyNormalization(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         $this->featuresTest($cache); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |     public function featuresProvider() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         // [prefix, normalization] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |             [['', false]], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             [['testprefix', false]], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             [['testprefix', true]], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             [['', true]], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |     private function featuresTest(Cache $cache) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |         $this->prepare($cache); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         $dataWithPrefix = $this->getDataProviderData('for_multiple_'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         $cache->setMultiple($dataWithPrefix); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         $data = array_merge($this->getDataProviderData(), $dataWithPrefix, ['nonexistent-key' => null]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         $dataWithDefault = $data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         $dataWithDefault['nonexistent-key'] = 'default'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         foreach ($data as $key => $value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |             if ($key === 'nonexistent-key') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |                 $this->assertFalse($cache->has($key)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |                 $this->assertSameExceptObject(null, $cache->get($key)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |                 $this->assertSameExceptObject('default', $cache->get($key, 'default')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |                 $this->assertTrue($cache->has($key)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |                 $this->assertSameExceptObject($value, $cache->get($key)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |                 $this->assertSameExceptObject($value, $cache->get($key, 'default')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         $this->assertSameExceptObject($data, $cache->getMultiple(array_keys($data))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |         $this->assertSameExceptObject($dataWithDefault, $cache->getMultiple(array_keys($data), 'default')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     public function testDefaultTtl(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |         $cache->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |         /** @var Cache $cache */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |         $cache->setDefaultTtl(2); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |         $this->assertSameExceptObject(2, $cache->getDefaultTtl()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |     public function testDateIntervalTtl(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         $interval = new DateInterval('PT3S'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         $cache = $this->createCacheInstance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |         $cache->clear(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         /** @var Cache $cache */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |         $cache->setDefaultTtl($interval); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         $this->assertSameExceptObject(3, $cache->getDefaultTtl()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 240 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 241 |  |  |  |