Completed
Push — master ( cbacc9...efee19 )
by Joachim
01:41
created

LoevgaardDandomainConsignmentExtensionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testThrowsExceptionUnlessAltapayUsernameSet() 0 9 1
A testGettersSetters() 0 9 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 testThrowsExceptionUnlessAltapayUsernameSet()
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
    /**
36
     * @return array
37
     */
38
    protected function getEmptyConfig()
39
    {
40
        $yaml = <<<EOF
41
report_dir: report_dir
42
EOF;
43
        $parser = new Parser();
44
45
        return $parser->parse($yaml);
46
    }
47
}
48