Completed
Push — master ( 3229d6...c9eeb2 )
by Baldur
03:55
created

testCacheServiceSet()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace LAShowroom\TaxJarBundle\Tests\Container;
4
5
use LAShowroom\TaxJarBundle\DependencyInjection\LAShowroomTaxJarExtension;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class LAShowroomTaxJarExtensionTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var LAShowroomTaxJarExtension
13
     */
14
    private $extension;
15
16
    /**
17
     * Root name of the configuration
18
     *
19
     * @var string
20
     */
21
    private $root;
22
23
    public function setUp()
24
    {
25
        parent::setUp();
26
27
        $this->extension = $this->getExtension();
28
        $this->root = "la_showroom_tax_jar";
29
    }
30
31
    /**
32
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
33
     * @expectedExceptionMessage The child node "api_token" at path "la_showroom_tax_jar" must be configured.
34
     */
35
    public function testApiTokenRequired()
36
    {
37
        $this->extension->load([], $container = $this->getContainer());
38
    }
39
40
    public function testApiTokenCorrectlySet()
41
    {
42
        $this->extension->load([
43
            'la_showroom_tax_jar' => [
44
                'api_token' => 'doge',
45
            ]
46
        ], $container = $this->getContainer());
47
48
        $this->assertEquals('doge', $container->getParameter('la_showroom_tax_jar.api_token'));
49
    }
50
51
    public function testCacheServiceSet()
52
    {
53
        $this->extension->load([
54
            'la_showroom_tax_jar' => [
55
                'api_token' => 'doge',
56
                'cache' => 'such_cache',
57
            ]
58
        ], $container = $this->getContainer());
59
60
        $this->assertEquals(
61
            [
62
                'setCacheItemPool',
63
                [
64
                    new Reference('such_cache'),
65
                ],
66
            ],
67
            $container->getDefinition('la_showroom_tax_jar.client')->getMethodCalls()[0]
68
        );
69
    }
70
71
    /**
72
     * @return LAShowroomTaxJarExtension
73
     */
74
    protected function getExtension()
75
    {
76
        return new LAShowroomTaxJarExtension();
77
    }
78
79
    /**
80
     * @return ContainerBuilder
81
     */
82
    private function getContainer()
83
    {
84
        $container = new ContainerBuilder();
85
86
        return $container;
87
    }
88
}
89