SkipNullsFilterTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testPassesThroughFilterSuccess() 0 13 1
A testPassesThroughFilterFailure() 0 13 1
A testFilterWorksAsExpected() 0 14 1
1
<?php
2
3
use Enzyme\Loopy\Each;
4
use Enzyme\Loopy\Filters\SkipNulls;
5
6
class SkipNullsFilterTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
    public function testPassesThroughFilterSuccess()
9
    {
10
        $filter = new SkipNulls;
11
        $expected = true;
12
13
        $key = 1;
14
        $value = 1;
15
        $this->assertEquals($expected, $filter->passes($key, $value));
16
17
        $key = null;
18
        $value = 1;
19
        $this->assertEquals($expected, $filter->passes($key, $value));
20
    }
21
22
    public function testPassesThroughFilterFailure()
23
    {
24
        $filter = new SkipNulls;
25
        $expected = false;
26
27
        $key = 1;
28
        $value = null;
29
        $this->assertEquals($expected, $filter->passes($key, $value));
30
31
        $key = null;
32
        $value = null;
33
        $this->assertEquals($expected, $filter->passes($key, $value));
34
    }
35
36
    public function testFilterWorksAsExpected()
37
    {
38
        $filter = new SkipNulls;
39
        $expected = [1, 2, 4];
40
        $array = [1, 2, null, 4];
41
42
        $actual = [];
43
44
        Each::shallow($filter)->begin($array, function($bag) use(&$actual) {
45
            $actual[] = $bag->value();
46
        });
47
48
        $this->assertEquals($expected, $actual);
49
    }
50
}