RegexFilterTest::testPassesThroughFilterSuccess()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 15
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 15
loc 15
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
use Enzyme\Loopy\Each;
4
use Enzyme\Loopy\Filters\Regex;
5
6 View Code Duplication
class RegexFilterTest 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 Regex('/[0-9]+/');
11
        $expected = true;
12
13
        $key = 1;
14
        $value = 6;
15
        $this->assertEquals($expected, $filter->passes($key, $value));
16
17
        $filter = new Regex('/[0-9]+/');
18
19
        $key = null;
20
        $value = 1010;
21
        $this->assertEquals($expected, $filter->passes($key, $value));
22
    }
23
24
    public function testPassesThroughFilterFailure()
25
    {
26
        $filter = new Regex('/[0-9]+/');
27
        $expected = false;
28
29
        $key = 1;
30
        $value = null;
31
        $this->assertEquals($expected, $filter->passes($key, $value));
32
33
        $key = null;
34
        $value = 'aaaa';
35
        $this->assertEquals($expected, $filter->passes($key, $value));
36
    }
37
38
    public function testFilterWorksAsExpected()
39
    {
40
        $filter = new Regex('/[0-9]+/');
41
        $expected = [5, 6];
42
        $array = ['a', 5, 'b', 6, 'c'];
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
}