Passed
Push — develop ( b553cc...c26b5c )
by Mathieu
01:46
created

HelperTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 21
dl 0
loc 52
rs 10
c 2
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A testDataGetKeyIsNull() 0 7 1
A testFlatten() 0 4 1
A testCamelCase() 0 4 1
A testHead() 0 4 1
A testP() 0 6 1
A testLast() 0 4 1
A testValue() 0 9 1
1
<?php
2
class HelperTest extends \PHPUnit\Framework\TestCase
3
{
4
    public function testDataGetKeyIsNull()
5
    {
6
        $dataArr = array('test' => 42);
7
8
        $this->assertEquals($dataArr, dataGet($dataArr, null));
9
        $this->assertEquals(42, dataGet($dataArr, 'test'));
10
        $this->assertEquals(43, dataGet($dataArr, 'test-unknown', 43));
11
    }
12
13
    public function testP()
14
    {
15
        $this->expectOutputString("<pre>\n1\n</pre><pre>\nArray\n(\n    [a] => 1\n)\n\n</pre>");
16
        _p(1);
17
18
        _p(['a' => 1]);
19
    }
20
21
    public function testHead()
22
    {
23
        $arr = ['a' => 1, 'b' => 2, 'c' => 3];
24
        $this->assertSame(1, head($arr));
25
    }
26
27
    public function testLast()
28
    {
29
        $arr = ['a' => 1, 'b' => 2, 'c' => 3];
30
        $this->assertSame(3, last($arr));
31
    }
32
33
    public function testFlatten()
34
    {
35
        $arr = ['a' => 1, 'b' => 2, 'c' => ['s1' => 3, 's2' => 4]];
36
        $this->assertSame([1, 2, 3, 4], flatten($arr));
37
    }
38
39
    public function testValue()
40
    {
41
        $value = 1;
42
        $this->assertSame(1, value($value));
43
44
        $value = function() {
45
            return 2;
46
        };
47
        $this->assertSame(2, value($value));
48
    }
49
50
    function testCamelCase()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
51
    {
52
        $str = 'this_is_a_test';
53
        $this->assertSame('ThisIsATest', camelCase($str));
54
55
    }
56
}
57