Security update for permissions_by_term
[yaffs-website] / vendor / behat / gherkin / tests / Behat / Gherkin / Filter / PathsFilterTest.php
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 }