LoevgaardConsignorShipmentServerExtensionTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testThrowsExceptionUnlessAltapayUsernameSet() 0 9 1
A testGettersSetters() 0 10 1
A getEmptyConfig() 0 10 1
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