ConfigTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testMergeFile() 0 16 1
1
<?php
2
3
namespace Nip\Config\Tests;
4
5
use Nip\Config\Config;
6
7
/**
8
 * Class ApplicationTest
9
 */
10
class ConfigTest extends AbstractTest
11
{
12
13
    /**
14
     * @var Config
15
     */
16
    protected $config;
17
18
    /**
19
     */
20
    public function setUp()
21
    {
22
        parent::setUp();
23
        $this->config = new Config();
24
    }
25
26
    public function testMergeFile()
27
    {
28
        static::assertInstanceOf(Config::class, $this->config);
29
        static::assertEquals([], $this->config->toArray());
30
31
        $this->config->mergeFile(TEST_FIXTURE_PATH.'/general.ini');
32
33
        static::assertInstanceOf(Config::class, $this->config);
34
        static::assertCount(6, $this->config->toArray());
0 ignored issues
show
Documentation introduced by
$this->config->toArray() 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...
35
        static::assertInstanceOf(Config::class, $this->config->get('SITE'));
36
        static::assertTrue($this->config->has('META'));
37
        static::assertTrue($this->config->has('META.title'));
38
        static::assertEquals('My Site', $this->config->get('META')->get('title'));
39
        static::assertEquals('My Site', $this->config->get('META.title'));
40
        static::assertFalse($this->config->has('META.title1'));
41
    }
42
}
43