Passed
Push — main ( 700cae...bce8dd )
by Sílvio
01:08
created

StaticAccessTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 22
c 3
b 0
f 1
dl 0
loc 44
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testSetUp() 0 9 1
A testSetUpStaticWithOptionBuilder() 0 9 1
A testSetUpStatic() 0 8 1
A testFlushCacheDynamic() 0 4 1
A testFlushCacheStatic() 0 4 1
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use Silviooosilva\CacheerPhp\Cacheer;
5
use Silviooosilva\CacheerPhp\Config\Option\Builder\OptionBuilder;
6
7
final class StaticAccessTest extends TestCase
8
{
9
    public function testFlushCacheStatic(): void
10
    {
11
        $result = Cacheer::flushCache();
0 ignored issues
show
Bug Best Practice introduced by
The method Silviooosilva\CacheerPhp\Cacheer::flushCache() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

11
        /** @scrutinizer ignore-call */ 
12
        $result = Cacheer::flushCache();
Loading history...
12
        $this->assertIsBool($result);
13
    }
14
15
    public function testFlushCacheDynamic(): void
16
    {
17
        $cache = new Cacheer();
18
        $this->assertIsBool($cache->flushCache());
19
    }
20
21
    public function testSetUp(): void
22
    {
23
        $cache = new Cacheer();
24
        $options = [
25
            'driver' => 'file',
26
            'path' => '/tmp/cache',
27
        ];
28
        $cache->setUp($options);
29
        $this->assertSame($options, $cache->options);
30
    }
31
32
    public static function testSetUpStatic(): void
33
    {
34
        $options = [
35
            'driver' => 'file',
36
            'path' => '/tmp/cache',
37
        ];
38
       Cacheer::setUp($options);
0 ignored issues
show
Bug Best Practice introduced by
The method Silviooosilva\CacheerPhp\Cacheer::setUp() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
       Cacheer::/** @scrutinizer ignore-call */ 
39
                setUp($options);
Loading history...
39
       self::assertSame($options, Cacheer::getOptions());
0 ignored issues
show
Bug Best Practice introduced by
The method Silviooosilva\CacheerPhp\Cacheer::getOptions() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
       self::assertSame($options, Cacheer::/** @scrutinizer ignore-call */ getOptions());
Loading history...
40
    }
41
42
    public function testSetUpStaticWithOptionBuilder(): void
43
    {
44
        $options = OptionBuilder::forFile()
45
            ->dir('/tmp/cache')
46
            ->flushAfter()->hour(2)
47
            ->build();
48
49
        Cacheer::setUp($options);
0 ignored issues
show
Bug Best Practice introduced by
The method Silviooosilva\CacheerPhp\Cacheer::setUp() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        Cacheer::/** @scrutinizer ignore-call */ 
50
                 setUp($options);
Loading history...
50
        self::assertSame($options, Cacheer::getOptions());
0 ignored issues
show
Bug Best Practice introduced by
The method Silviooosilva\CacheerPhp\Cacheer::getOptions() is not static, but was called statically. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
        self::assertSame($options, Cacheer::/** @scrutinizer ignore-call */ getOptions());
Loading history...
51
    }
52
}