Test Failed
Push — master ( 08b784...be7bf5 )
by Adam
01:46
created

CacheTest::testCacheDelete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
namespace DBAL\Tests\Caching;
3
4
use PHPUnit\Framework\TestCase;
5
6
abstract class CacheTest extends TestCase{
0 ignored issues
show
Coding Style introduced by
CacheTest does not seem to conform to the naming convention (^Abstract|Factory$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
7
    
8
    protected $host = '127.0.0.1';
9
    protected $port = false;
10
        
11
    protected $cache;
12
    
13
    public function setUp() {
14
        $this->cache->connect($this->host, $this->port);
0 ignored issues
show
Documentation introduced by
$this->port is of type boolean, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
15
    }
16
    
17
    public function tearDown() {
18
        unset($this->cache);
19
    }
20
    
21
    public function testConnect(){
22
        $this->assertObjectHasAttribute('cache', $this->cache->connect($this->host, $this->port));
0 ignored issues
show
Documentation introduced by
$this->port is of type boolean, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
23
    }
24
    
25
    public function testCacheAdd(){
26
        $this->assertTrue($this->cache->save('key1', 'testvalue', 60));
27
    }
28
    
29
    public function testCacheRetrieve(){
30
        $this->assertAttributeEquals('testvalue', $this->cache->fetch('key1'));
0 ignored issues
show
Bug introduced by
The call to assertAttributeEquals() misses a required argument $actualClassOrObject.

This check looks for function calls that miss required arguments.

Loading history...
31
    }
32
    
33
    public function testCacheOverride(){
34
        $this->cache->replace('key1', 'newvalue', 60);
35
        $this->cache->AttributeEquals('newvalue', $this->cache->fetch('key1'));
36
    }
37
    
38
    public function testCacheDelete(){
39
        $this->cache->assertTrue($this->cache->delete('key1'));
40
        $this->cache->assertFalse();
41
    }
42
    
43
    public function testCacheClear(){
44
        $this->cache->save('key1', 'testvalue', 60);
45
        $this->assertTrue($this->cache->deleteAll());
46
    }
47
}
48