Completed
Push — master ( dcf43c...59d132 )
by Tijs
06:54
created

FallbacksTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 1
cbo 2
dl 0
loc 65
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGet() 0 16 1
A testPopulateFallbacks() 0 5 1
1
<?php
2
3
namespace SumoCoders\FrameworkCoreBundle\Tests\Service;
4
5
use SumoCoders\FrameworkCoreBundle\Service\Fallbacks;
6
7
class FallbacksTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * @var Fallbacks
11
     */
12
    private $fallbacks;
13
14
    /**
15
     * @var array
16
     */
17
    private $defaultData = array(
18
        'foo' => 'bar',
19
        'name' => array(
20
            'first' => 'John',
21
            'last' => 'Doe',
22
        ),
23
        'servers' => array(
24
            'web01',
25
            'web02',
26
        ),
27
        'a' => array(
28
            'very' => array(
29
                'deep' => array(
30
                    'array' => array(
31
                        'x' => 0,
32
                        'y' => 0,
33
                    )
34
                )
35
            ),
36
        ),
37
        'errorcodes' => array(
38
            404 => 'Not Found',
39
            500 => 'Internal server error',
40
        ),
41
    );
42
43
    /**
44
     * Test Fallbacks()
45
     */
46
    public function testPopulateFallbacks()
47
    {
48
        $this->fallbacks = new Fallbacks();
49
        $this->assertNull($this->fallbacks->get('foo')); // we no data is passed we can't grab anything
50
    }
51
52
    /**
53
     * Tests Fallbacks->get()
54
     */
55
    public function testGet()
56
    {
57
        $this->fallbacks = new Fallbacks($this->defaultData);
58
59
        $this->assertEquals($this->defaultData['foo'], $this->fallbacks->get('foo'));
60
        $this->assertEquals($this->defaultData['name']['first'], $this->fallbacks->get('name')['first']);
61
        $this->assertEquals($this->defaultData['servers'], $this->fallbacks->get('servers'));
62
        $this->assertEquals(
63
            $this->defaultData['a']['very']['deep']['array']['x'],
64
            $this->fallbacks->get('a')['very']['deep']['array']['x']
65
        );
66
        $this->assertEquals(
67
            $this->defaultData['errorcodes'][404],
68
            $this->fallbacks->get('errorcodes')[404]
69
        );
70
    }
71
}
72