ConfigExtensionTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Admingenerator\GeneratorBundle\Tests\Twig\Extension;
4
5
use Admingenerator\GeneratorBundle\Twig\Extension\ConfigExtension;
6
7
/**
8
 * This class test the Admingenerator\GeneratorBundle\Twig\Extension\ConfigExtension
9
 *
10
 * @author Piotr Gołębiewski <[email protected]>
11
 */
12
class ConfigExtensionTest extends \PHPUnit_Framework_TestCase
13
{
14
    /**
15
     * @var ConfigExtension
16
     */
17
    private $extension;
18
    
19
    /**
20
     * @var array
21
     */
22
    private $exampleConfig = array(
23
        'array1' => array('val0' => 'val0FromArray1', 'val1' => 'val1FromArray1'),
24
        'array2' => array('val0FromArray2', 'val1FromArray2'),
25
    );
26
27
    public function setUp()
28
    {
29
        $this->extension = new ConfigExtension($this->exampleConfig);
30
    }
31
32
    public function testGetAdmingeneratorConfig()
33
    {
34
        $this->assertEquals(
35
            $this->exampleConfig['array1']['val0'],
36
            $this->extension->getAdmingeneratorConfig('array1.val0')
37
        );
38
        
39
        $this->assertEquals(
40
            $this->exampleConfig['array2'],
41
            $this->extension->getAdmingeneratorConfig('array2')
42
        );
43
    }
44
45
    /**
46
     * @expectedException     \InvalidArgumentException
47
     */
48
    public function testGetAdmingeneratorConfigReturnsExceptionOnUnknownKey()
49
    {
50
        $this->extension->getAdmingeneratorConfig('unknown.key');
51
    }
52
}
53