Passed
Pull Request — master (#11)
by Dan
03:49
created
Tests/Cache/CacheTest.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,6 @@
 block discarded – undo
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
 /**
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,20 +261,20 @@  discard block
 block discarded – undo
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 testDeleteMultiple(){
271
+    public function testDeleteMultiple() {
272 272
 
273
-        $keys = ['foo','bar','baz'];
273
+        $keys = ['foo', 'bar', 'baz'];
274 274
         $deleteStatus = true;
275 275
         $expected = true;
276 276
 
277
-        foreach ($keys as $i => $key){
277
+        foreach ($keys as $i => $key) {
278 278
             $this->storageMock->expects($this->at($i))
279 279
                 ->method('delete')
280 280
                 ->with(
@@ -290,15 +290,15 @@  discard block
 block discarded – undo
290 290
     /**
291 291
      *
292 292
      */
293
-    public function testDeleteMultipleFailure(){
293
+    public function testDeleteMultipleFailure() {
294 294
 
295
-        $keys = ['foo','bar','baz'];
295
+        $keys = ['foo', 'bar', 'baz'];
296 296
         $expected = false;
297 297
         $deleteStatus = true;
298 298
 
299
-        foreach ($keys as $i => $key){
299
+        foreach ($keys as $i => $key) {
300 300
 
301
-            if ($i === 1){
301
+            if ($i === 1) {
302 302
                 $deleteStatus = false;
303 303
             }
304 304
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
     /**
318 318
      * Test that storage clear is called.
319 319
      */
320
-    public function testclear(){
320
+    public function testclear() {
321 321
         $this->storageMock->expects($this->once())
322 322
             ->method('clear');
323 323
         $this->cache->clear();
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
     /**
327 327
      * Test that array has keys.
328 328
      */
329
-    public function testArrayHasKeys(){
329
+    public function testArrayHasKeys() {
330 330
         $data = ['a' => 'foo', 'b' => 'bar'];
331 331
 
332 332
         $reflector = new \ReflectionClass(Cache::class);
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
     /**
341 341
      * Test exception thrown when array is missing keys.
342 342
      */
343
-    public function testArrayHasNoKeys(){
343
+    public function testArrayHasNoKeys() {
344 344
         $this->expectException(InvalidArgumentException::class);
345
-        $data = ['foo','bar'];
345
+        $data = ['foo', 'bar'];
346 346
         $reflector = new \ReflectionClass(Cache::class);
347 347
         $method = $reflector->getMethod('_hasKeys');
348 348
         $method->setAccessible(true);
@@ -352,8 +352,8 @@  discard block
 block discarded – undo
352 352
     /**
353 353
      * Test array contains a failure.
354 354
      */
355
-    public function testHasFailure(){
356
-        $results = [true,true,true,false,true];
355
+    public function testHasFailure() {
356
+        $results = [true, true, true, false, true];
357 357
         $reflector = new \ReflectionClass(Cache::class);
358 358
         $method = $reflector->getMethod('_hasFailure');
359 359
         $method->setAccessible(true);
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
     /**
366 366
      * Test array doesn't contain a failure.
367 367
      */
368
-    public function testHasNoFailure(){
369
-        $results = [true,true,true,true,true];
368
+    public function testHasNoFailure() {
369
+        $results = [true, true, true, true, true];
370 370
         $reflector = new \ReflectionClass(Cache::class);
371 371
         $method = $reflector->getMethod('_hasFailure');
372 372
         $method->setAccessible(true);
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
     /**
379 379
      * Test that array is Traversable
380 380
      */
381
-    public function testIsTraversable(){
382
-        $data = ['a','b','c','d'];
381
+    public function testIsTraversable() {
382
+        $data = ['a', 'b', 'c', 'd'];
383 383
         $reflector = new \ReflectionClass(Cache::class);
384 384
         $method = $reflector->getMethod('_isTraversable');
385 385
         $method->setAccessible(true);
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
     /**
392 392
      * Test that string is not Traversable
393 393
      */
394
-    public function testIsNotTraversable(){
394
+    public function testIsNotTraversable() {
395 395
         $this->expectException(InvalidArgumentException::class);
396 396
         $data = 'some-random-string';
397 397
         $reflector = new \ReflectionClass(Cache::class);
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
     /**
404 404
      * Test that instance of Iterator is traversable
405 405
      */
406
-    public function testIsTraversableIterator(){
406
+    public function testIsTraversableIterator() {
407 407
         $iterator = new class implements \Iterator {
408
-            public function current(){}
409
-            public function next(){}
410
-            public function key(){}
411
-            public function valid(){}
412
-            public function rewind(){}
408
+            public function current() {}
409
+            public function next() {}
410
+            public function key() {}
411
+            public function valid() {}
412
+            public function rewind() {}
413 413
         };
414 414
         $reflector = new \ReflectionClass(Cache::class);
415 415
         $method = $reflector->getMethod('_isTraversable');
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
     /**
424 424
      * Private functions
425 425
      */
426
-    public function test_isValidKeyValid(){}
427
-    public function test_isValidKeyInvalid(){}
428
-    public function test_checkTraversableArray(){}
429
-    public function test_checkTraversableTraversable(){}
430
-    public function test_checkTraversableException(){}
431
-    public function test_hasFailureNoFailure(){}
432
-    public function test_hasFailureException(){}
426
+    public function test_isValidKeyValid() {}
427
+    public function test_isValidKeyInvalid() {}
428
+    public function test_checkTraversableArray() {}
429
+    public function test_checkTraversableTraversable() {}
430
+    public function test_checkTraversableException() {}
431
+    public function test_hasFailureNoFailure() {}
432
+    public function test_hasFailureException() {}
433 433
 }
Please login to merge, or discard this patch.
Tests/Cache/Mock/AbstractCacheMock.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,5 +11,5 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Tests/Cache/Mock/AbstractStorageMock.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Tests/Cache/Storage/MemcacheStorageTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
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()
Please login to merge, or discard this patch.
Tests/Cache/Storage/NullStorageTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,35 +28,35 @@
 block discarded – undo
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
     
Please login to merge, or discard this patch.
Tests/Cache/Storage/AbstractStorageTest.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Tests/Cache/AbstractCacheTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,19 +31,19 @@
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
Src/Cache/Storage/MemcacheStorage.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Src/Cache/Storage/NullStorage.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.