@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Ds\Cache\Cache; |
| 6 | 6 | use Ds\Cache\CacheStorageInterface; |
| 7 | -use Ds\Cache\NullStorage; |
|
| 8 | 7 | use Psr\SimpleCache\InvalidArgumentException; |
| 9 | 8 | |
| 10 | 9 | /** |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | { |
| 40 | 40 | $key = 21021000; |
| 41 | 41 | $this->expectException(InvalidArgumentException::class); |
| 42 | - $this->cache->set($key,'value'); |
|
| 42 | + $this->cache->set($key, 'value'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | /** |
| 206 | 206 | * |
| 207 | 207 | */ |
| 208 | - public function testGetMultiple(){ |
|
| 208 | + public function testGetMultiple() { |
|
| 209 | 209 | |
| 210 | 210 | $expected = [ |
| 211 | 211 | 'foo' => 'fooValue', |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | $i = 0; |
| 217 | 217 | |
| 218 | - foreach ($expected as $key => $value){ |
|
| 218 | + foreach ($expected as $key => $value) { |
|
| 219 | 219 | |
| 220 | 220 | $this->storageMock->expects($this->at($i)) |
| 221 | 221 | ->method('get') |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | /** |
| 236 | 236 | * |
| 237 | 237 | */ |
| 238 | - public function testSetMultiple(){ |
|
| 238 | + public function testSetMultiple() { |
|
| 239 | 239 | |
| 240 | 240 | $keys = [ |
| 241 | 241 | 'foo' => 'fooValue', |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | $i = 0; |
| 250 | 250 | $expires = 60 * 60; |
| 251 | 251 | |
| 252 | - foreach ($keys as $key => $value){ |
|
| 252 | + foreach ($keys as $key => $value) { |
|
| 253 | 253 | $this->storageMock->expects($this->at($i)) |
| 254 | 254 | ->method('set') |
| 255 | 255 | ->with( |
@@ -261,14 +261,14 @@ discard block |
||
| 261 | 261 | $i++; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - $actual = $this->cache->setMultiple($keys,$expires); |
|
| 264 | + $actual = $this->cache->setMultiple($keys, $expires); |
|
| 265 | 265 | $this->assertEquals($expected, $actual); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
| 269 | 269 | * |
| 270 | 270 | */ |
| 271 | - public function testSetMultipleWithFailure(){ |
|
| 271 | + public function testSetMultipleWithFailure() { |
|
| 272 | 272 | |
| 273 | 273 | $keys = [ |
| 274 | 274 | 'foo' => 'fooValue', |
@@ -282,11 +282,11 @@ discard block |
||
| 282 | 282 | $i = 0; |
| 283 | 283 | $expires = 60 * 60; |
| 284 | 284 | |
| 285 | - foreach ($keys as $key => $value){ |
|
| 285 | + foreach ($keys as $key => $value) { |
|
| 286 | 286 | |
| 287 | 287 | $status = $addStatus; |
| 288 | 288 | |
| 289 | - if ($i === 1){ |
|
| 289 | + if ($i === 1) { |
|
| 290 | 290 | $status = false; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -301,20 +301,20 @@ discard block |
||
| 301 | 301 | $i++; |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - $actual = $this->cache->setMultiple($keys,$expires); |
|
| 304 | + $actual = $this->cache->setMultiple($keys, $expires); |
|
| 305 | 305 | $this->assertEquals($expected, $actual); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
| 309 | 309 | * |
| 310 | 310 | */ |
| 311 | - public function testDeleteMultiple(){ |
|
| 311 | + public function testDeleteMultiple() { |
|
| 312 | 312 | |
| 313 | - $keys = ['foo','bar','baz']; |
|
| 313 | + $keys = ['foo', 'bar', 'baz']; |
|
| 314 | 314 | $deleteStatus = true; |
| 315 | 315 | $expected = true; |
| 316 | 316 | |
| 317 | - foreach ($keys as $i => $key){ |
|
| 317 | + foreach ($keys as $i => $key) { |
|
| 318 | 318 | $this->storageMock->expects($this->at($i)) |
| 319 | 319 | ->method('delete') |
| 320 | 320 | ->with( |
@@ -330,15 +330,15 @@ discard block |
||
| 330 | 330 | /** |
| 331 | 331 | * |
| 332 | 332 | */ |
| 333 | - public function testDeleteMultipleFailure(){ |
|
| 333 | + public function testDeleteMultipleFailure() { |
|
| 334 | 334 | |
| 335 | - $keys = ['foo','bar','baz']; |
|
| 335 | + $keys = ['foo', 'bar', 'baz']; |
|
| 336 | 336 | $expected = false; |
| 337 | 337 | $deleteStatus = true; |
| 338 | 338 | |
| 339 | - foreach ($keys as $i => $key){ |
|
| 339 | + foreach ($keys as $i => $key) { |
|
| 340 | 340 | |
| 341 | - if ($i === 1){ |
|
| 341 | + if ($i === 1) { |
|
| 342 | 342 | $deleteStatus = false; |
| 343 | 343 | } |
| 344 | 344 | |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | /** |
| 358 | 358 | * Test that storage clear is called. |
| 359 | 359 | */ |
| 360 | - public function testclear(){ |
|
| 360 | + public function testclear() { |
|
| 361 | 361 | $this->storageMock->expects($this->once()) |
| 362 | 362 | ->method('clear'); |
| 363 | 363 | $this->cache->clear(); |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | /** |
| 367 | 367 | * Test that array has keys. |
| 368 | 368 | */ |
| 369 | - public function testArrayHasKeys(){ |
|
| 369 | + public function testArrayHasKeys() { |
|
| 370 | 370 | $data = ['a' => 'foo', 'b' => 'bar']; |
| 371 | 371 | |
| 372 | 372 | $reflector = new \ReflectionClass(Cache::class); |
@@ -380,9 +380,9 @@ discard block |
||
| 380 | 380 | /** |
| 381 | 381 | * Test exception thrown when array is missing keys. |
| 382 | 382 | */ |
| 383 | - public function testArrayHasNoKeys(){ |
|
| 383 | + public function testArrayHasNoKeys() { |
|
| 384 | 384 | $this->expectException(InvalidArgumentException::class); |
| 385 | - $data = ['foo','bar']; |
|
| 385 | + $data = ['foo', 'bar']; |
|
| 386 | 386 | $reflector = new \ReflectionClass(Cache::class); |
| 387 | 387 | $method = $reflector->getMethod('_hasKeys'); |
| 388 | 388 | $method->setAccessible(true); |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | /** |
| 393 | 393 | * Test array contains a failure. |
| 394 | 394 | */ |
| 395 | - public function testHasFailure(){ |
|
| 396 | - $results = [true,true,true,false,true]; |
|
| 395 | + public function testHasFailure() { |
|
| 396 | + $results = [true, true, true, false, true]; |
|
| 397 | 397 | $reflector = new \ReflectionClass(Cache::class); |
| 398 | 398 | $method = $reflector->getMethod('_hasFailure'); |
| 399 | 399 | $method->setAccessible(true); |
@@ -405,8 +405,8 @@ discard block |
||
| 405 | 405 | /** |
| 406 | 406 | * |
| 407 | 407 | */ |
| 408 | - public function testHasNoFailure(){ |
|
| 409 | - $results = [true,true,true,true,true]; |
|
| 408 | + public function testHasNoFailure() { |
|
| 409 | + $results = [true, true, true, true, true]; |
|
| 410 | 410 | $reflector = new \ReflectionClass(Cache::class); |
| 411 | 411 | $method = $reflector->getMethod('_hasFailure'); |
| 412 | 412 | $method->setAccessible(true); |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | /** |
| 419 | 419 | * Test that array is Traversable |
| 420 | 420 | */ |
| 421 | - public function testIsTraversable(){ |
|
| 422 | - $data = ['a','b','c','d']; |
|
| 421 | + public function testIsTraversable() { |
|
| 422 | + $data = ['a', 'b', 'c', 'd']; |
|
| 423 | 423 | $reflector = new \ReflectionClass(Cache::class); |
| 424 | 424 | $method = $reflector->getMethod('_isTraversable'); |
| 425 | 425 | $method->setAccessible(true); |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | /** |
| 432 | 432 | * Test that string is not Traversable |
| 433 | 433 | */ |
| 434 | - public function testIsNotTraversable(){ |
|
| 434 | + public function testIsNotTraversable() { |
|
| 435 | 435 | $this->expectException(InvalidArgumentException::class); |
| 436 | 436 | $data = 'some-random-string'; |
| 437 | 437 | $reflector = new \ReflectionClass(Cache::class); |
@@ -443,13 +443,13 @@ discard block |
||
| 443 | 443 | /** |
| 444 | 444 | * Test that instance of Iterator is traversable |
| 445 | 445 | */ |
| 446 | - public function testIsTraversableIterator(){ |
|
| 446 | + public function testIsTraversableIterator() { |
|
| 447 | 447 | $iterator = new class implements \Iterator { |
| 448 | - public function current(){} |
|
| 449 | - public function next(){} |
|
| 450 | - public function key(){} |
|
| 451 | - public function valid(){} |
|
| 452 | - public function rewind(){} |
|
| 448 | + public function current() {} |
|
| 449 | + public function next() {} |
|
| 450 | + public function key() {} |
|
| 451 | + public function valid() {} |
|
| 452 | + public function rewind() {} |
|
| 453 | 453 | }; |
| 454 | 454 | $reflector = new \ReflectionClass(Cache::class); |
| 455 | 455 | $method = $reflector->getMethod('_isTraversable'); |
@@ -11,5 +11,5 @@ |
||
| 11 | 11 | * |
| 12 | 12 | * @package Tests\Cache\Mock |
| 13 | 13 | */ |
| 14 | -class AbstractCacheMock extends AbstractCache{ |
|
| 14 | +class AbstractCacheMock extends AbstractCache { |
|
| 15 | 15 | } |
| 16 | 16 | \ No newline at end of file |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * |
| 12 | 12 | * @package Tests\Cache\Mock |
| 13 | 13 | */ |
| 14 | -class AbstractStorageMock extends AbstractStorage{ |
|
| 14 | +class AbstractStorageMock extends AbstractStorage { |
|
| 15 | 15 | |
| 16 | 16 | public function set($key, $value, $ttl = null) |
| 17 | 17 | { |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | { |
| 37 | 37 | $this->ttl = new \DateInterval('P1M'); |
| 38 | 38 | $this->memcacheMock = $this->getMockBuilder('\Memcached')->getMock(); |
| 39 | - $this->memcacheStorage = new MemcacheStorage($this->memcacheMock,'localhost',11211, $this->ttl); |
|
| 39 | + $this->memcacheStorage = new MemcacheStorage($this->memcacheMock, 'localhost', 11211, $this->ttl); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function testAddServer() |
@@ -28,35 +28,35 @@ |
||
| 28 | 28 | /** |
| 29 | 29 | * |
| 30 | 30 | */ |
| 31 | - public function testHas(){ |
|
| 31 | + public function testHas() { |
|
| 32 | 32 | $this->assertEquals($this->cacheStorage->has('key', 'value'), false); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * |
| 37 | 37 | */ |
| 38 | - public function testSet(){ |
|
| 38 | + public function testSet() { |
|
| 39 | 39 | $this->assertEquals($this->cacheStorage->set('key', 'value', 10), true); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * |
| 44 | 44 | */ |
| 45 | - public function testGet(){ |
|
| 45 | + public function testGet() { |
|
| 46 | 46 | $this->assertEquals($this->cacheStorage->get('key'), null); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * |
| 51 | 51 | */ |
| 52 | - public function testDelete(){ |
|
| 52 | + public function testDelete() { |
|
| 53 | 53 | $this->assertEquals($this->cacheStorage->delete('key'), true); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * |
| 58 | 58 | */ |
| 59 | - public function testClear(){ |
|
| 59 | + public function testClear() { |
|
| 60 | 60 | $this->assertEquals($this->cacheStorage->clear(), true); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * Test immutable setter AbstractStorage::withTtl |
| 35 | 35 | */ |
| 36 | - public function testWithTtl(){ |
|
| 36 | + public function testWithTtl() { |
|
| 37 | 37 | $newDateInterval = new \DateInterval('P2M'); |
| 38 | 38 | $newTtl = $this->abstractStorage->withTtl($newDateInterval); |
| 39 | 39 | $this->assertNotSame($this->abstractStorage->getTtl(), $newTtl->getTtl()); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | /** |
| 43 | 43 | * Test getter AbstractStorage::getTtl |
| 44 | 44 | */ |
| 45 | - public function testGetTtl(){ |
|
| 45 | + public function testGetTtl() { |
|
| 46 | 46 | $ttl = $this->abstractStorage->getTtl(); |
| 47 | 47 | $this->assertSame($this->ttl, $ttl); |
| 48 | 48 | } |
@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * Get get ttl when provided with null |
| 52 | 52 | */ |
| 53 | - public function testGetTtlTimestampWhenNull(){ |
|
| 53 | + public function testGetTtlTimestampWhenNull() { |
|
| 54 | 54 | $dateTime = new \DateTime(); |
| 55 | - $dateTime->add( $this->ttl ); |
|
| 55 | + $dateTime->add($this->ttl); |
|
| 56 | 56 | $expected = $dateTime->getTimestamp(); |
| 57 | 57 | $actual = $this->abstractStorage->getTtlTimestamp(null); |
| 58 | 58 | $this->assertEquals($expected, $actual); |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * Test get ttl when provided with an integer. |
| 63 | 63 | */ |
| 64 | - public function testGetTtlTimestampWhenInt(){ |
|
| 65 | - $expected = 60*60*7; |
|
| 64 | + public function testGetTtlTimestampWhenInt() { |
|
| 65 | + $expected = 60 * 60 * 7; |
|
| 66 | 66 | $actual = $this->abstractStorage->getTtlTimestamp($expected); |
| 67 | 67 | $this->assertEquals($expected, $actual); |
| 68 | 68 | } |
@@ -31,19 +31,19 @@ |
||
| 31 | 31 | /** |
| 32 | 32 | * Test that NullStorage Adaptor is called by default. |
| 33 | 33 | */ |
| 34 | - public function testConstructNullStorage(){ |
|
| 34 | + public function testConstructNullStorage() { |
|
| 35 | 35 | $cache = new Cache(); |
| 36 | 36 | $storage = $cache->getCacheStorage(); |
| 37 | - $this->assertInstanceOf(NullStorage::class,$storage); |
|
| 37 | + $this->assertInstanceOf(NullStorage::class, $storage); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Test CacheStorage is updated from construct. |
| 42 | 42 | */ |
| 43 | - public function testConstructWithStorage(){ |
|
| 43 | + public function testConstructWithStorage() { |
|
| 44 | 44 | $cache = new Cache($this->storageMock); |
| 45 | 45 | $storage = $cache->getCacheStorage(); |
| 46 | - $this->assertSame($this->storageMock,$storage); |
|
| 46 | + $this->assertSame($this->storageMock, $storage); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return bool |
| 69 | 69 | */ |
| 70 | - public function has($key){ |
|
| 71 | - if (!empty($this->mmc->get($key))){ |
|
| 70 | + public function has($key) { |
|
| 71 | + if (!empty($this->mmc->get($key))) { |
|
| 72 | 72 | return true; |
| 73 | 73 | } |
| 74 | 74 | return false; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return bool True on success and false on failure. |
| 115 | 115 | */ |
| 116 | - public function clear(){ |
|
| 116 | + public function clear() { |
|
| 117 | 117 | return $this->flush(); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * NullStorage constructor. |
| 24 | 24 | */ |
| 25 | - public function __construct(){} |
|
| 25 | + public function __construct() {} |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @return mixed The value of the item from the cache, or $default in case of cache miss. |
| 49 | 49 | * |
| 50 | 50 | */ |
| 51 | - public function get($key){ |
|
| 51 | + public function get($key) { |
|
| 52 | 52 | return null; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return bool |
| 66 | 66 | */ |
| 67 | - public function has($key){ |
|
| 67 | + public function has($key) { |
|
| 68 | 68 | return false; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @return bool True on success and false on failure. |
| 87 | 87 | */ |
| 88 | - public function clear(){ |
|
| 88 | + public function clear() { |
|
| 89 | 89 | return true; |
| 90 | 90 | } |
| 91 | 91 | } |