Completed
Push — master ( 6d99c0...0069ea )
by Konstantin
03:14 queued 01:25
created

PathsFilterTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testIsFeatureMatchFilter() 0 19 1
A testItDoesNotMatchPartialPaths() 0 18 1
A testItDoesNotMatchIfFileWithSameNameButNotPathExistsInFolder() 0 9 1
1
<?php
2
3
namespace Tests\Behat\Gherkin\Filter;
4
5
use Behat\Gherkin\Filter\PathsFilter;
6
use Behat\Gherkin\Node\FeatureNode;
7
8
class PathsFilterTest extends FilterTest
9
{
10
    public function testIsFeatureMatchFilter()
11
    {
12
        $feature = new FeatureNode(null, null, array(), null, array(), null, null, __FILE__, 1);
13
14
        $filter = new PathsFilter(array(__DIR__));
15
        $this->assertTrue($filter->isFeatureMatch($feature));
16
17
        $filter = new PathsFilter(array('/abc', '/def', dirname(__DIR__)));
18
        $this->assertTrue($filter->isFeatureMatch($feature));
19
20
        $filter = new PathsFilter(array('/abc', '/def', __DIR__));
21
        $this->assertTrue($filter->isFeatureMatch($feature));
22
23
        $filter = new PathsFilter(array('/abc', __DIR__, '/def'));
24
        $this->assertTrue($filter->isFeatureMatch($feature));
25
26
        $filter = new PathsFilter(array('/abc', '/def', '/wrong/path'));
27
        $this->assertFalse($filter->isFeatureMatch($feature));
28
    }
29
30
    public function testItDoesNotMatchPartialPaths()
31
    {
32
        $fixtures = __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR;
33
34
        $feature = new FeatureNode(null, null, array(), null, array(), null, null, $fixtures . 'full_path' . DIRECTORY_SEPARATOR . 'file1', 1);
35
36
        $filter = new PathsFilter(array($fixtures . 'full'));
37
        $this->assertFalse($filter->isFeatureMatch($feature));
38
39
        $filter = new PathsFilter(array($fixtures . 'full' . DIRECTORY_SEPARATOR));
40
        $this->assertFalse($filter->isFeatureMatch($feature));
41
42
        $filter = new PathsFilter(array($fixtures . 'full_path' . DIRECTORY_SEPARATOR));
43
        $this->assertTrue($filter->isFeatureMatch($feature));
44
45
        $filter = new PathsFilter(array($fixtures . 'full_path'));
46
        $this->assertTrue($filter->isFeatureMatch($feature));
47
    }
48
49
    public function testItDoesNotMatchIfFileWithSameNameButNotPathExistsInFolder()
50
    {
51
        $fixtures = __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR;
52
53
        $feature = new FeatureNode(null, null, array(), null, array(), null, null, $fixtures . 'full_path' . DIRECTORY_SEPARATOR . 'file1', 1);
54
55
        $filter = new PathsFilter(array($fixtures . 'full'));
56
        $this->assertFalse($filter->isFeatureMatch($feature));
57
    }
58
}
59