Completed
Push — master ( decbf1...2cb4ba )
by Tristan
02:34
created

EqualFilterTest::testPassesThroughFilterSuccess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 15
Ratio 100 %
Metric Value
dl 15
loc 15
rs 9.4286
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
use Enzyme\Loopy\Each;
4
use Enzyme\Loopy\Filters\Equal;
5
6 View Code Duplication
class EqualFilterTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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