Security update for permissions_by_term
[yaffs-website] / vendor / behat / gherkin / tests / Behat / Gherkin / Loader / DirectoryLoaderTest.php
1 <?php
2
3 namespace Tests\Behat\Gherkin\Loader;
4
5 use Behat\Gherkin\Loader\DirectoryLoader;
6
7 class DirectoryLoaderTest extends \PHPUnit_Framework_TestCase
8 {
9     private $gherkin;
10     private $loader;
11     private $featuresPath;
12
13     protected function setUp()
14     {
15         $this->gherkin      = $this->createGherkinMock();
16         $this->loader       = new DirectoryLoader($this->gherkin);
17
18         $this->featuresPath = realpath(__DIR__ . '/../Fixtures/directories');
19     }
20
21     protected function createGherkinMock()
22     {
23         $gherkin = $this->getMockBuilder('Behat\Gherkin\Gherkin')
24             ->disableOriginalConstructor()
25             ->getMock();
26
27         return $gherkin;
28     }
29
30     protected function createGherkinFileLoaderMock()
31     {
32         $loader = $this->getMockBuilder('Behat\Gherkin\Loader\GherkinFileLoader')
33             ->disableOriginalConstructor()
34             ->getMock();
35
36         return $loader;
37     }
38
39     public function testSupports()
40     {
41         $this->assertFalse($this->loader->supports('non-existent path'));
42         $this->assertFalse($this->loader->supports('non-existent path:2'));
43
44         $this->assertFalse($this->loader->supports(__DIR__ . ':d'));
45         $this->assertFalse($this->loader->supports(__DIR__ . '/../Fixtures/features/pystring.feature'));
46         $this->assertTrue($this->loader->supports(__DIR__));
47         $this->assertTrue($this->loader->supports(__DIR__ . '/../Fixtures/features'));
48     }
49
50     public function testUndefinedFileLoad()
51     {
52         $this->gherkin
53             ->expects($this->once())
54             ->method('resolveLoader')
55             ->with($this->featuresPath.DIRECTORY_SEPARATOR.'phps'.DIRECTORY_SEPARATOR.'some_file.php')
56             ->will($this->returnValue(null));
57
58         $this->assertEquals(array(), $this->loader->load($this->featuresPath . '/phps'));
59     }
60
61     public function testBasePath()
62     {
63         $this->gherkin
64             ->expects($this->once())
65             ->method('resolveLoader')
66             ->with($this->featuresPath.DIRECTORY_SEPARATOR.'phps'.DIRECTORY_SEPARATOR.'some_file.php')
67             ->will($this->returnValue(null));
68
69         $this->loader->setBasePath($this->featuresPath);
70
71         $this->assertEquals(array(), $this->loader->load('phps'));
72     }
73
74     public function testDefinedFileLoad()
75     {
76         $loaderMock = $this->createGherkinFileLoaderMock();
77
78         $this->gherkin
79             ->expects($this->once())
80             ->method('resolveLoader')
81             ->with($this->featuresPath.DIRECTORY_SEPARATOR.'phps'.DIRECTORY_SEPARATOR.'some_file.php')
82             ->will($this->returnValue($loaderMock));
83
84         $loaderMock
85             ->expects($this->once())
86             ->method('load')
87             ->with($this->featuresPath.DIRECTORY_SEPARATOR.'phps'.DIRECTORY_SEPARATOR.'some_file.php')
88             ->will($this->returnValue(array('feature1', 'feature2')));
89
90         $this->assertEquals(array('feature1', 'feature2'), $this->loader->load($this->featuresPath . '/phps'));
91     }
92 }