Passed
Push — master ( abee1f...edc958 )
by Kirill
03:08
created

PhpLoaderTest::testScope()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 15
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Tests\Config;
13
14
class PhpLoaderTest extends BaseTest
15
{
16
    public function testGetConfig(): void
17
    {
18
        $cf = $this->getFactory();
19
20
        $this->assertEquals(
21
            [
22
                'id'       => 'hello world',
23
                'autowire' => new \Spiral\Core\Container\Autowire('something')
24
            ],
25
            $cf->getConfig('test')
26
        );
27
    }
28
29
    /**
30
     * @expectedException \Spiral\Config\Exception\LoaderException
31
     */
32
    public function testEmpty(): void
33
    {
34
        $cf = $this->getFactory();
35
        $cf->getConfig('empty');
36
    }
37
38
    /**
39
     * @expectedException \Spiral\Config\Exception\LoaderException
40
     */
41
    public function testBroken(): void
42
    {
43
        $cf = $this->getFactory();
44
        $cf->getConfig('broken');
45
    }
46
47
    public function testScope(): void
48
    {
49
        $cf = $this->getFactory();
50
        $config = $cf->getConfig('scope');
51
        $this->assertEquals(['value' => 'value!'], $config);
52
53
        $this->container->bind(Value::class, new Value('other!'));
0 ignored issues
show
Bug introduced by
new Spiral\Tests\Config\Value('other!') of type Spiral\Tests\Config\Value is incompatible with the type array|callable|string expected by parameter $resolver of Spiral\Core\Container::bind(). ( Ignorable by Annotation )

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

53
        $this->container->bind(Value::class, /** @scrutinizer ignore-type */ new Value('other!'));
Loading history...
54
55
        $config = $cf->getConfig('scope2');
56
        $this->assertEquals(['value' => 'other!'], $config);
57
58
        $cf = clone $cf;
59
60
        $config = $cf->getConfig('scope');
61
        $this->assertEquals(['value' => 'other!'], $config);
62
    }
63
}
64