ConfigurationTest::testSuccess()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Timegryd\OpcacheResetBundle\Tests\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Processor;
6
use Timegryd\OpcacheResetBundle\DependencyInjection\Configuration;
7
8
class ConfigurationTest extends \PHPUnit\Framework\TestCase
9
{
10
    /**
11
     * @var Configuration
12
     */
13
    protected $configuration;
14
15
    /**
16
     * @var Processor
17
     */
18
    protected $processor;
19
20
    protected function setUp()
21
    {
22
        $this->configuration = new Configuration();
23
        $this->processor = new Processor();
24
    }
25
26
    /**
27
     * @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
28
     */
29
    public function testEmpty()
30
    {
31
        $this->processor->processConfiguration($this->configuration, []);
32
    }
33
34
    /**
35
     * @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
36
     */
37
    public function testHostRequired()
38
    {
39
        $this->processor->processConfiguration($this->configuration, [
40
            'timegryd-opcache-reset' => [],
41
        ]);
42
    }
43
44
    /**
45
     * @expectedException Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
46
     */
47
    public function testDirRequired()
48
    {
49
        $this->processor->processConfiguration($this->configuration, [
50
            'timegryd-opcache-reset' => [
51
                'host' => 'example.com',
52
            ],
53
        ]);
54
    }
55
56
    public function testSuccess()
57
    {
58
        $actual = $this->processor->processConfiguration($this->configuration, [
59
            'timegryd_opcache_reset' => [
60
                'host' => 'example.com',
61
                'dir' => 'web-dir',
62
            ],
63
        ]);
64
65
        $expected = [
66
            'host' => 'example.com',
67
            'dir' => 'web-dir',
68
        ];
69
70
        $this->assertEquals($expected, $actual);
71
    }
72
}
73