FiltersTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testMatchesYieldsReport() 0 16 1
A testMatchesYieldsNothingWhenFiltersReturnFalse() 0 15 1
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
}