ConfigurationTest::testValidDefaultCurrency()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Flagbit\Bundle\CurrencyBundle\Tests;
4
5
use Flagbit\Bundle\CurrencyBundle\DependencyInjection\Configuration;
6
use PHPUnit\Framework\TestCase;
7
use Symfony\Component\Config\Definition\Processor;
8
9
class ConfigurationTest extends TestCase
10
{
11
    protected function process($config)
12
    {
13
        $processor = new Processor();
14
15
        return $processor->processConfiguration(new Configuration(), $config);
16
    }
17
18
    public function provideValidCurrency()
19
    {
20
        return [
21
            ['EUR'],
22
            ['USD'],
23
            ['CHF'],
24
        ];
25
    }
26
27
    /**
28
     * Test Default Currency to prevent BC breaks
29
     */
30 View Code Duplication
    public function testProcessedDefaultCurrency()
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...
31
    {
32
        $config = [[]];
33
34
        $config = $this->process($config);
35
36
        $this->assertEquals('EUR', $config['default_currency']);
37
    }
38
39
    /**
40
     * @dataProvider provideValidCurrency
41
     */
42 View Code Duplication
    public function testValidDefaultCurrency($currency)
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...
43
    {
44
        $config = [
45
            [
46
                'default_currency' => $currency,
47
            ]
48
        ];
49
50
        $config = $this->process($config);
51
52
        $this->assertEquals($currency, $config['default_currency']);
53
    }
54
55
    public function provideInvalidCurrency()
56
    {
57
        return [
58
            ['foobar'],
59
            ['eur'],
60
        ];
61
    }
62
63
    /**
64
     * @dataProvider provideInvalidCurrency
65
     * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
66
     */
67
    public function testInvalidDefaultCurrency($currency)
68
    {
69
        $config = [
70
            [
71
                'default_currency' => $currency,
72
            ]
73
        ];
74
75
        $this->process($config);
76
    }
77
}
78