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

testItDoesNotMatchIfFileWithSameNameButNotPathExistsInFolder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 0
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