3 namespace Tests\Behat\Gherkin\Filter;
5 use Behat\Gherkin\Filter\PathsFilter;
6 use Behat\Gherkin\Node\FeatureNode;
8 class PathsFilterTest extends FilterTest
10 public function testIsFeatureMatchFilter()
12 $feature = new FeatureNode(null, null, array(), null, array(), null, null, __FILE__, 1);
14 $filter = new PathsFilter(array(__DIR__));
15 $this->assertTrue($filter->isFeatureMatch($feature));
17 $filter = new PathsFilter(array('/abc', '/def', dirname(__DIR__)));
18 $this->assertTrue($filter->isFeatureMatch($feature));
20 $filter = new PathsFilter(array('/abc', '/def', __DIR__));
21 $this->assertTrue($filter->isFeatureMatch($feature));
23 $filter = new PathsFilter(array('/abc', __DIR__, '/def'));
24 $this->assertTrue($filter->isFeatureMatch($feature));
26 $filter = new PathsFilter(array('/abc', '/def', '/wrong/path'));
27 $this->assertFalse($filter->isFeatureMatch($feature));
30 public function testItDoesNotMatchPartialPaths()
32 $fixtures = __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR;
34 $feature = new FeatureNode(null, null, array(), null, array(), null, null, $fixtures . 'full_path' . DIRECTORY_SEPARATOR . 'file1', 1);
36 $filter = new PathsFilter(array($fixtures . 'full'));
37 $this->assertFalse($filter->isFeatureMatch($feature));
39 $filter = new PathsFilter(array($fixtures . 'full' . DIRECTORY_SEPARATOR));
40 $this->assertFalse($filter->isFeatureMatch($feature));
42 $filter = new PathsFilter(array($fixtures . 'full_path' . DIRECTORY_SEPARATOR));
43 $this->assertTrue($filter->isFeatureMatch($feature));
45 $filter = new PathsFilter(array($fixtures . 'full_path'));
46 $this->assertTrue($filter->isFeatureMatch($feature));
49 public function testItDoesNotMatchIfFileWithSameNameButNotPathExistsInFolder()
51 $fixtures = __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR;
53 $feature = new FeatureNode(null, null, array(), null, array(), null, null, $fixtures . 'full_path' . DIRECTORY_SEPARATOR . 'file1', 1);
55 $filter = new PathsFilter(array($fixtures . 'full'));
56 $this->assertFalse($filter->isFeatureMatch($feature));