Completed
Push — master ( 56570e...2c8793 )
by Gabriel
07:17
created

FileManagerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testWrite() 0 13 1
A testRead() 0 11 1
1
<?php
2
3
namespace Nip\Dispatcher\Tests\Resolver\Cache;
4
5
use Nip\Dispatcher\Resolver\Cache\DefinitionsCollection;
6
use Nip\Dispatcher\Resolver\Cache\FileManager;
7
use Nip\Dispatcher\Tests\AbstractTest;
8
9
/**
10
 * Class FileManagerTest
11
 * @package Nip\Dispatcher\Tests\Resolver\Cache
12
 */
13
class FileManagerTest extends AbstractTest
14
{
15
    public function testWrite()
16
    {
17
        $filePath = FileManager::filePath();
18
19
        $collection = new DefinitionsCollection([
20
            'test1' => 'Test1',
21
            'test2' => 'Test2'
22
        ]);
23
24
        FileManager::write($collection);
25
26
        self::assertFileExists($filePath);
27
    }
28
29
    public function testRead()
30
    {
31
        $filePath = TEST_FIXTURE_PATH . '/cache/dispatcher.php';
32
33
        $collection = new DefinitionsCollection([]);
34
35
        FileManager::read($collection, $filePath);
36
37
        static::assertCount(2, $collection->all());
0 ignored issues
show
Documentation introduced by
$collection->all() is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

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...
38
        self::assertSame('Test1', $collection->get('test1'));
39
    }
40
}
41