Completed
Push — master ( e401e5...bd7189 )
by Julien
01:48
created

ArrayDefinitionTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Fwk\Di\Definitions;
4
use Fwk\Di\Container;
5
6
/**
7
 * Test class for CallableDefinition.
8
 * Generated by PHPUnit on 2013-06-28 at 00:09:38.
9
 */
10
class ArrayDefinitionTest extends \PHPUnit_Framework_TestCase {
11
12
    /**
13
     * @var ArrayDefinition
14
     */
15
    protected $object;
16
17
    public function setUp()
18
    {
19
        $me = $this;
0 ignored issues
show
Unused Code introduced by
$me is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
20
        $this->object = new ArrayDefinition(array(
21
            'testArg'   => 'normalString',
22
            'property'  => ':propTest',
23
            'reference'  => '@testRef'
24
        ));
25
    }
26
    
27
    protected function getContainer()
28
    {
29
        $container = new Container();
30
        $container->set('testRef', 'testReferenceOk');
31
        $container->setProperty('propTest', 'testPropertyOk');
32
        
33
        return $container;
34
    }
35
    
36
    public function testArrayResultIsComplete()
37
    {
38
        $array = $this->object->invoke($this->getContainer());
39
        $this->assertTrue(is_array($array));
40
        $this->assertArrayHasKey('property', $array);
41
        $this->assertArrayHasKey('reference', $array);
42
        $this->assertArrayHasKey('testArg', $array);
43
        
44
        $this->assertEquals('testPropertyOk', $array['property']);
45
        $this->assertEquals('testReferenceOk', $array['reference']);
46
        $this->assertEquals('normalString', $array['testArg']);
47
    }
48
    
49
    public function testGettersAndSetters()
50
    {
51
        $arr = $this->object->getArray();
52
        $this->assertEquals($arr, $this->object->getArray());
53
        $arr['newProp'] = "ohyeah";
54
        $this->assertNotEquals($arr, $this->object->getArray());
55
        $this->object->setArray($arr);
56
        $this->assertEquals($arr, $this->object->getArray());
57
    }
58
}