testGettersSetters()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\DandomainStockBundle\Tests\DependencyInjection;
6
7
use Loevgaard\ConsignorShipmentServerBundle\DependencyInjection\LoevgaardConsignorShipmentServerExtension;
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 LoevgaardConsignorShipmentServerExtensionTest extends TestCase
14
{
15
    public function testThrowsExceptionUnlessAltapayUsernameSet()
16
    {
17
        $this->expectException(InvalidConfigurationException::class);
18
19
        $loader = new LoevgaardConsignorShipmentServerExtension();
20
        $config = $this->getEmptyConfig();
21
        unset($config['actor']);
22
        $loader->load([$config], new ContainerBuilder());
23
    }
24
25
    public function testGettersSetters()
26
    {
27
        $loader = new LoevgaardConsignorShipmentServerExtension();
28
        $config = $this->getEmptyConfig();
29
        $container = new ContainerBuilder();
30
        $loader->load([$config], $container);
31
32
        $this->assertSame($config['actor'], $container->getParameter('loevgaard_consignor_shipment_server.actor'));
33
        $this->assertSame($config['key'], $container->getParameter('loevgaard_consignor_shipment_server.key'));
34
    }
35
36
    /**
37
     * @return array
38
     */
39
    protected function getEmptyConfig()
40
    {
41
        $yaml = <<<EOF
42
actor: actor
43
key: key
44
EOF;
45
        $parser = new Parser();
46
47
        return $parser->parse($yaml);
48
    }
49
}
50