ArrayUtilsTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testObjectToArray() 0 24 1
A testRemoveKeys() 0 20 1
1
<?php
2
3
namespace OAuth\Unit\UserData\Utils;
4
5
use OAuth\UserData\Utils\ArrayUtils;
6
7
class ArrayUtilsTest extends \PHPUnit_Framework_TestCase
8
{
9
10
    /**
11
     * @covers Oauth\UserData\Utils\ArrayUtils::objectToArray
12
     */
13
    public function testObjectToArray()
14
    {
15
        $object = json_decode(
16
            '{
17
                "foo" : "bar",
18
                "nested" : {
19
                    "foo" : "bar"
20
                },
21
                "arr" : [1, 2, 3]
22
            }'
23
        );
24
25
        $expected = array(
26
            'foo' => 'bar',
27
            'nested' => array(
28
                'foo' => 'bar'
29
            ),
30
            'arr' => array(1, 2, 3)
31
        );
32
33
        $actual = ArrayUtils::objectToArray($object);
34
35
        $this->assertEquals($expected, $actual);
36
    }
37
38
    /**
39
     * @covers Oauth\UserData\Utils\ArrayUtils::removeKeys
40
     */
41
    public function testRemoveKeys()
42
    {
43
        $array = array(
44
            'foo' => 1,
45
            'bar' => 2,
46
            'baz' => 3,
47
            'doo' => 4
48
        );
49
50
        $keys = array('foo', 'doo');
51
52
        $expected = array(
53
            'bar' => 2,
54
            'baz' => 3
55
        );
56
57
        $actual = ArrayUtils::removeKeys($array, $keys);
58
59
        $this->assertEquals($expected, $actual);
60
    }
61
}
62