Completed
Branch unittests (a61d5f)
by Ruben
02:26
created

VMProApiExtensionTest::testHasGuzzle6Client()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 14
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 14
loc 14
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 8
nc 2
nop 0
1
<?php
2
3
namespace MovingImage\Bundle\VMProApiBundle\Tests\DependencyInjection;
4
5
use MovingImage\Bundle\VMProApiBundle\DependencyInjection\VMProApiExtension;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
/**
9
 * Class VMProApiExtensionTest.
10
 *
11
 * @author Ruben Knol <[email protected]>
12
 */
13
class VMProApiExtensionTest extends AbstractTestCase
14
{
15
    /**
16
     * Assert whether an exception is thrown when required configuration
17
     * key 'vm_pro_api.credentials' is missing.
18
     *
19
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
20
     */
21
    public function testConfigurationLoadThrowsExceptionUnlessCredentials()
22
    {
23
        $loader = new VMProApiExtension();
24
        $config = $this->getEmptyConfig();
25
26
        unset($config['vm_pro_api']['credentials']);
27
        $loader->load($config, new ContainerBuilder());
28
    }
29
30
    /**
31
     * Assert whether an exception is thrown when required configuration
32
     * key 'vm_pro_api.credentials.username' is missing.
33
     *
34
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
35
     */
36 View Code Duplication
    public function testConfigurationLoadThrowsExceptionUnlessUsername()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    {
38
        $loader = new VMProApiExtension();
39
        $config = $this->getEmptyConfig();
40
41
        unset($config['vm_pro_api']['credentials']['username']);
42
        $loader->load($config, new ContainerBuilder());
43
    }
44
45
    /**
46
     * Assert whether an exception is thrown when required configuration
47
     * key 'vm_pro_api.credentials.password' is missing.
48
     *
49
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
50
     */
51 View Code Duplication
    public function testConfigurationLoadThrowsExceptionUnlessPassword()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        $loader = new VMProApiExtension();
54
        $config = $this->getEmptyConfig();
55
56
        unset($config['vm_pro_api']['credentials']['password']);
57
        $loader->load($config, new ContainerBuilder());
58
    }
59
60
    /**
61
     * Assert whether the configuration keys and values are successfully
62
     * written as parameters.
63
     */
64
    public function testParametersForFullConfig()
65
    {
66
        $container = new ContainerBuilder();
67
        $loader = new VMProApiExtension();
68
        $config = $this->getFullConfig();
69
70
        $loader->load($config, $container);
71
72
        $this->assertEquals('http://google.com/', $container->getParameter('vm_pro_api_base_url'));
73
        $this->assertEquals(5, $container->getParameter('vm_pro_api_default_vm_id'));
74
        $this->assertEquals('[email protected]', $container->getParameter('vm_pro_api_credentials_username'));
75
        $this->assertEquals('test_password', $container->getParameter('vm_pro_api_credentials_password'));
76
    }
77
78
    /**
79
     * Assert whether the configuration keys and values are successfully
80
     * written as parameters with the right default values.
81
     */
82
    public function testDefaultParameters()
83
    {
84
        $container = new ContainerBuilder();
85
        $loader = new VMProApiExtension();
86
        $config = $this->getEmptyConfig();
87
88
        $loader->load($config, $container);
89
90
        $this->assertEquals('https://api.video-cdn.net/v1/vms/', $container->getParameter('vm_pro_api_base_url'));
91
        $this->assertEquals(0, $container->getParameter('vm_pro_api_default_vm_id'));
92
    }
93
}
94