Test Failed
Branch master (9acec7)
by Agel_Nash
02:58
created

APIhelpersTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
dl 0
loc 29
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetKeyWithArrayKey() 0 3 1
A testGetKeyWithNoKey() 0 4 1
A testGetKeyWithEmptyKey() 0 4 1
1
<?php namespace DocLister\Tests;
2
3
use APIhelpers;
4
5
class APIhelpersTest extends \PHPUnit_Framework_TestCase
6
{
7
    protected $data = array(
8
        'subArray' => array(
9
            'a',
10
            'b',
11
            'c'
12
        ),
13
        'empty'    => null,
14
        'scalar'   => 'my string',
15
        'only_value',
16
        '10'       => 'value_with_number_key',
17
    );
18
19
    public function testGetKeyWithEmptyKey()
20
    {
21
        $this->assertEquals(null, APIhelpers::getkey($this->data, 'empty'));
22
        $this->assertEquals(null, APIhelpers::getkey($this->data, 'empty', 'my default'));
23
    }
24
25
    public function testGetKeyWithNoKey()
26
    {
27
        $this->assertEquals('only_value', APIhelpers::getkey($this->data, 0));
28
        $this->assertEquals('value_with_number_key', APIhelpers::getkey($this->data, 10));
29
    }
30
31
    public function testGetKeyWithArrayKey()
32
    {
33
        $this->assertEquals(array('a', 'b', 'c'), APIhelpers::getkey($this->data, 'subArray'));
34
    }
35
}
36