@@ -7,40 +7,40 @@ discard block |
||
| 7 | 7 | class ArrayCacheStoreTest extends TestCase |
| 8 | 8 | { |
| 9 | 9 | |
| 10 | - private $cache; |
|
| 10 | + private $cache; |
|
| 11 | 11 | |
| 12 | - protected function setUp(): void |
|
| 13 | - { |
|
| 12 | + protected function setUp(): void |
|
| 13 | + { |
|
| 14 | 14 | $this->cache = new Cacheer(); |
| 15 | 15 | $this->cache->setDriver()->useArrayDriver(); |
| 16 | 16 | $this->cache->setConfig()->setTimeZone('America/Toronto'); |
| 17 | - } |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - protected function tearDown(): void |
|
| 20 | - { |
|
| 19 | + protected function tearDown(): void |
|
| 20 | + { |
|
| 21 | 21 | $this->cache->flushCache(); |
| 22 | - } |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | 24 | public function testUsingArrayDriverSetsProperInstance() |
| 25 | - { |
|
| 25 | + { |
|
| 26 | 26 | $this->assertInstanceOf(ArrayCacheStore::class, $this->cache->cacheStore); |
| 27 | - } |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - public function testPutAndGetCacheInArray() |
|
| 30 | - { |
|
| 31 | - $cacheKey = 'test_key'; |
|
| 32 | - $cacheData = ['name' => 'John Doe', 'email' => '[email protected]']; |
|
| 29 | + public function testPutAndGetCacheInArray() |
|
| 30 | + { |
|
| 31 | + $cacheKey = 'test_key'; |
|
| 32 | + $cacheData = ['name' => 'John Doe', 'email' => '[email protected]']; |
|
| 33 | 33 | |
| 34 | - $this->cache->putCache($cacheKey, $cacheData, '', 3600); |
|
| 34 | + $this->cache->putCache($cacheKey, $cacheData, '', 3600); |
|
| 35 | 35 | |
| 36 | - $result = $this->cache->getCache($cacheKey); |
|
| 36 | + $result = $this->cache->getCache($cacheKey); |
|
| 37 | 37 | |
| 38 | - $this->assertNotEmpty($result); |
|
| 39 | - $this->assertEquals($cacheData, $result); |
|
| 40 | - } |
|
| 38 | + $this->assertNotEmpty($result); |
|
| 39 | + $this->assertEquals($cacheData, $result); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function testExpiredCacheInArray() |
|
| 43 | - { |
|
| 42 | + public function testExpiredCacheInArray() |
|
| 43 | + { |
|
| 44 | 44 | $cacheKey = 'expired_key'; |
| 45 | 45 | $cacheData = ['name' => 'Expired User', 'email' => '[email protected]']; |
| 46 | 46 | |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | $this->assertEquals("Cache stored successfully", $this->cache->getMessage()); |
| 51 | 51 | $this->assertEmpty($this->cache->getCache($cacheKey)); |
| 52 | 52 | $this->assertFalse($this->cache->isSuccess()); |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | - public function testOverwriteExistingCacheInArray() |
|
| 57 | - { |
|
| 56 | + public function testOverwriteExistingCacheInArray() |
|
| 57 | + { |
|
| 58 | 58 | $cacheKey = 'overwrite_key'; |
| 59 | 59 | $initialCacheData = ['name' => 'Initial Data', 'email' => '[email protected]']; |
| 60 | 60 | $newCacheData = ['name' => 'New Data', 'email' => '[email protected]']; |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | $this->cache->appendCache($cacheKey, $newCacheData); |
| 66 | 66 | $this->assertEquals("Cache appended successfully", $this->cache->getMessage()); |
| 67 | 67 | $this->assertEquals($newCacheData, $this->cache->getCache($cacheKey)); |
| 68 | - } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | - public function testPutManyCacheItemsInArray() |
|
| 72 | - { |
|
| 73 | - $items = [ |
|
| 71 | + public function testPutManyCacheItemsInArray() |
|
| 72 | + { |
|
| 73 | + $items = [ |
|
| 74 | 74 | [ |
| 75 | 75 | 'cacheKey' => 'user_1_profile', |
| 76 | 76 | 'cacheData' => [ |
@@ -96,10 +96,10 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | $this->assertEquals($item['cacheData'], $this->cache->getCache($item['cacheKey'])); |
| 98 | 98 | } |
| 99 | - } |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - public function testHasCacheFromArray() |
|
| 102 | - { |
|
| 101 | + public function testHasCacheFromArray() |
|
| 102 | + { |
|
| 103 | 103 | $cacheKey = 'test_key'; |
| 104 | 104 | $cacheData = ['name' => 'Sílvio Silva', 'role' => 'Developer']; |
| 105 | 105 | |
@@ -111,10 +111,10 @@ discard block |
||
| 111 | 111 | $result = $this->cache->has($cacheKey); |
| 112 | 112 | $this->assertTrue($result); |
| 113 | 113 | $this->assertTrue($this->cache->isSuccess()); |
| 114 | - } |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | 116 | public function testRenewCacheFromArray() |
| 117 | - { |
|
| 117 | + { |
|
| 118 | 118 | $cacheKey = 'expired_key'; |
| 119 | 119 | $cacheData = ['name' => 'Expired User', 'email' => '[email protected]']; |
| 120 | 120 | |
@@ -129,10 +129,10 @@ discard block |
||
| 129 | 129 | $this->cache->renewCache($cacheKey, 7200); |
| 130 | 130 | $this->assertTrue($this->cache->isSuccess()); |
| 131 | 131 | $this->assertNotEmpty($this->cache->getCache($cacheKey)); |
| 132 | - } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - public function testRenewCacheWithNamespaceFromArray() |
|
| 135 | - { |
|
| 134 | + public function testRenewCacheWithNamespaceFromArray() |
|
| 135 | + { |
|
| 136 | 136 | $cacheKey = 'expired_key'; |
| 137 | 137 | $namespace = 'expired_namespace'; |
| 138 | 138 | $cacheData = ['name' => 'Expired User', 'email' => '[email protected]']; |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $this->cache->renewCache($cacheKey, 7200, $namespace); |
| 147 | 147 | $this->assertTrue($this->cache->isSuccess()); |
| 148 | 148 | $this->assertNotEmpty($this->cache->getCache($cacheKey, $namespace)); |
| 149 | - } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | 151 | public function testClearCacheDataFromArray() |
| 152 | 152 | { |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $this->assertEquals("Cache flushed successfully", $this->cache->getMessage()); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - public function test_remember_saves_and_recover_values() |
|
| 185 | + public function test_remember_saves_and_recover_values() |
|
| 186 | 186 | { |
| 187 | 187 | $this->cache->flushCache(); |
| 188 | 188 | |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | |
| 220 | - public function test_get_and_forget() |
|
| 220 | + public function test_get_and_forget() |
|
| 221 | 221 | { |
| 222 | 222 | $cacheKey = 'cache_key_test'; |
| 223 | 223 | $this->cache->putCache($cacheKey, 10); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $this->assertNull($noCacheData); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - public function test_store_if_not_present_with_add_function() |
|
| 241 | + public function test_store_if_not_present_with_add_function() |
|
| 242 | 242 | { |
| 243 | 243 | $existentKey = 'cache_key_test'; |
| 244 | 244 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - public function test_increment_function() { |
|
| 265 | + public function test_increment_function() { |
|
| 266 | 266 | |
| 267 | 267 | $cacheKey = 'test_increment'; |
| 268 | 268 | $cacheData = 2025; |