testThrowsExceptionUnlessAltapayUsernameSet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
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