Completed
Push — master ( f306e2...1c3e11 )
by Joachim
11:02
created

LoevgaardDandomainStockExtensionTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

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\DandomainStockBundle\Tests\DependencyInjection;
6
7
use Loevgaard\DandomainStockBundle\DependencyInjection\LoevgaardDandomainStockExtension;
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 LoevgaardDandomainStockExtensionTest extends TestCase
14
{
15
    public function testThrowsExceptionUnlessAltapayUsernameSet()
16
    {
17
        $this->expectException(InvalidConfigurationException::class);
18
19
        $loader = new LoevgaardDandomainStockExtension();
20
        $config = $this->getEmptyConfig();
21
        unset($config['dandomain_order_state_ids']);
22
        $loader->load([$config], new ContainerBuilder());
23
    }
24
25
    public function testGettersSetters()
26
    {
27
        $loader = new LoevgaardDandomainStockExtension();
28
        $config = $this->getEmptyConfig();
29
        $container = new ContainerBuilder();
30
        $loader->load([$config], $container);
31
32
        $this->assertSame($config['dandomain_order_state_ids'], $container->getParameter('loevgaard_dandomain_stock.dandomain_order_state_ids'));
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    protected function getEmptyConfig()
39
    {
40
        $yaml = <<<'EOF'
41
dandomain_order_state_ids: [3]
42
EOF;
43
        $parser = new Parser();
44
45
        return $parser->parse($yaml);
46
    }
47
}
48