FiltersTest::testMatchesYieldsReport()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
namespace Ionut\Sylar\Tests\Unit;
4
5
6
use Ionut\Sylar\Filters;
7
use Ionut\Sylar\NormalizedValue;
8
use Ionut\Sylar\NormalizedValueVariant;
9
use Ionut\Sylar\Tests\TestCase;
10
11
class FiltersTest extends TestCase
12
{
13
    public function testMatchesYieldsReport()
14
    {
15
        $filter = $this->getMock(Filters\FilterInterface::class);
16
        $filter
17
            ->expects($this->once())
18
            ->method('matches')
19
            ->with($this->anything())
20
            ->will($this->returnValue('somereport'));
21
22
        $filters = new Filters([$filter]);
23
24
        $this->assertEquals(
25
            ['somereport'],
26
            iterator_to_array($filters->matches(new NormalizedValue('test')))
27
        );
28
    }
29
30
    public function testMatchesYieldsNothingWhenFiltersReturnFalse()
31
    {
32
        $filter = $this->getMock(Filters\FilterInterface::class);
33
        $filter
34
            ->expects($this->once())
35
            ->method('matches')
36
            ->with($this->anything())
37
            ->will($this->returnValue(null));
38
        $filters = new Filters([$filter]);
39
40
        $this->assertEquals(
41
            [],
42
            iterator_to_array($filters->matches(new NormalizedValue('test')))
43
        );
44
    }
45
}