Failed Conditions
Pull Request — master (#790)
by Guilherme
07:57
created

ConfigurationTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 38
ccs 0
cts 32
cp 0
rs 10
c 0
b 0
f 0
wmc 7
1
<?php
2
/**
3
 * This file is part of the login-cidadao project or it's bundles.
4
 *
5
 * (c) Guilherme Donato <guilhermednt on github>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace PROCERGS\LoginCidadao\PhoneVerificationBundle\Tests\DependencyInjection;
12
13
use PHPUnit\Framework\TestCase;
14
use PROCERGS\LoginCidadao\PhoneVerificationBundle\DependencyInjection\Configuration;
15
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16
use Symfony\Component\Config\Definition\Processor;
17
18
class ConfigurationTest extends TestCase
19
{
20
    public static function getConfig($maxFailures = 2, $resetTimeout = 10)
21
    {
22
        return [
23
            'max_failures' => $maxFailures ?: 2,
24
            'reset_timeout' => $resetTimeout ?: 10,
25
        ];
26
    }
27
28
    public function testGetConfigTreeBuilder()
29
    {
30
        $configuration = new Configuration();
31
        $this->assertInstanceOf(TreeBuilder::class, $configuration->getConfigTreeBuilder());
32
    }
33
34
    public function testEmptyConfig()
35
    {
36
        $processor = new Processor();
37
        $config = $processor->processConfiguration(new Configuration(), []);
38
        $this->assertEquals(self::getConfig(), $config);
39
    }
40
41
    public function testMaxFailures()
42
    {
43
        $processor = new Processor();
44
        $config = $processor->processConfiguration(new Configuration(), [['max_failures' => 5]]);
45
        $this->assertEquals(self::getConfig(5), $config);
46
    }
47
48
    public function testResetTimeout()
49
    {
50
        $processor = new Processor();
51
        $config = $processor->processConfiguration(new Configuration(), [['reset_timeout' => 20]]);
52
        $this->assertEquals(self::getConfig(null, 20), $config);
53
    }
54
}
55