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

DefinitionCollectionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 15
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testReplace() 0 12 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 DefinitionCollectionTest extends AbstractTest
14
{
15
    public function testReplace()
16
    {
17
        $collection = new DefinitionsCollection([
18
            'test1' => 'Test1',
19
            'test2' => 'Test2'
20
        ]);
21
22
        $collection->replace(['test1' => 'Test11', 'test3' => 'Test3']);
23
24
        static::assertCount(3, $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...
25
        self::assertSame('Test11', $collection->get('test1'));
26
    }
27
}
28