LoevgaardDandomainConsignmentExtensionTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 43
rs 10
c 2
b 1
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGettersSetters() 0 9 1
A testThrowsInvalidConfigException() 0 9 1
A testThrowsLogicException() 0 7 1
A getEmptyConfig() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\DandomainConsignmentBundle\Tests\DependencyInjection;
6
7
use Loevgaard\DandomainConsignmentBundle\DependencyInjection\LoevgaardDandomainConsignmentExtension;
8
use PHPUnit\Framework\TestCase;
9
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
10
use Symfony\Component\DependencyInjection\ContainerBuilder;
11
use Symfony\Component\Yaml\Parser;
12
13
class LoevgaardDandomainConsignmentExtensionTest extends TestCase
14
{
15
    public function testThrowsInvalidConfigException()
16
    {
17
        $this->expectException(InvalidConfigurationException::class);
18
19
        $loader = new LoevgaardDandomainConsignmentExtension();
20
        $config = $this->getEmptyConfig();
21
        unset($config['report_dir']);
22
        $loader->load([$config], new ContainerBuilder());
23
    }
24
25
    public function testGettersSetters()
26
    {
27
        $loader = new LoevgaardDandomainConsignmentExtension();
28
        $config = $this->getEmptyConfig();
29
        $container = new ContainerBuilder();
30
        $loader->load([$config], $container);
31
32
        $this->assertSame($config['report_dir'], $container->getParameter('loevgaard_dandomain_consignment.report_dir'));
33
    }
34
35
    public function testThrowsLogicException()
36
    {
37
        $this->expectException(\LogicException::class);
38
39
        $extension = new LoevgaardDandomainConsignmentExtension();
40
        $extension->prepend(new ContainerBuilder());
41
    }
42
43
    /**
44
     * @return array
45
     */
46
    protected function getEmptyConfig()
47
    {
48
        $yaml = <<<EOF
49
report_dir: report_dir
50
EOF;
51
        $parser = new Parser();
52
53
        return $parser->parse($yaml);
54
    }
55
}
56