X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fbehat%2Fgherkin%2Ftests%2FBehat%2FGherkin%2FLoader%2FDirectoryLoaderTest.php;fp=vendor%2Fbehat%2Fgherkin%2Ftests%2FBehat%2FGherkin%2FLoader%2FDirectoryLoaderTest.php;h=de3270866ea5982fa1dd2100b1db29675ef23e51;hp=0000000000000000000000000000000000000000;hb=1270d9129ce8f27c9b28b10518e32132c58e0aca;hpb=c27c0f0cdaa3f354b1fe54a56ae7e854be6e3f68 diff --git a/vendor/behat/gherkin/tests/Behat/Gherkin/Loader/DirectoryLoaderTest.php b/vendor/behat/gherkin/tests/Behat/Gherkin/Loader/DirectoryLoaderTest.php new file mode 100644 index 000000000..de3270866 --- /dev/null +++ b/vendor/behat/gherkin/tests/Behat/Gherkin/Loader/DirectoryLoaderTest.php @@ -0,0 +1,92 @@ +gherkin = $this->createGherkinMock(); + $this->loader = new DirectoryLoader($this->gherkin); + + $this->featuresPath = realpath(__DIR__ . '/../Fixtures/directories'); + } + + protected function createGherkinMock() + { + $gherkin = $this->getMockBuilder('Behat\Gherkin\Gherkin') + ->disableOriginalConstructor() + ->getMock(); + + return $gherkin; + } + + protected function createGherkinFileLoaderMock() + { + $loader = $this->getMockBuilder('Behat\Gherkin\Loader\GherkinFileLoader') + ->disableOriginalConstructor() + ->getMock(); + + return $loader; + } + + public function testSupports() + { + $this->assertFalse($this->loader->supports('non-existent path')); + $this->assertFalse($this->loader->supports('non-existent path:2')); + + $this->assertFalse($this->loader->supports(__DIR__ . ':d')); + $this->assertFalse($this->loader->supports(__DIR__ . '/../Fixtures/features/pystring.feature')); + $this->assertTrue($this->loader->supports(__DIR__)); + $this->assertTrue($this->loader->supports(__DIR__ . '/../Fixtures/features')); + } + + public function testUndefinedFileLoad() + { + $this->gherkin + ->expects($this->once()) + ->method('resolveLoader') + ->with($this->featuresPath.DIRECTORY_SEPARATOR.'phps'.DIRECTORY_SEPARATOR.'some_file.php') + ->will($this->returnValue(null)); + + $this->assertEquals(array(), $this->loader->load($this->featuresPath . '/phps')); + } + + public function testBasePath() + { + $this->gherkin + ->expects($this->once()) + ->method('resolveLoader') + ->with($this->featuresPath.DIRECTORY_SEPARATOR.'phps'.DIRECTORY_SEPARATOR.'some_file.php') + ->will($this->returnValue(null)); + + $this->loader->setBasePath($this->featuresPath); + + $this->assertEquals(array(), $this->loader->load('phps')); + } + + public function testDefinedFileLoad() + { + $loaderMock = $this->createGherkinFileLoaderMock(); + + $this->gherkin + ->expects($this->once()) + ->method('resolveLoader') + ->with($this->featuresPath.DIRECTORY_SEPARATOR.'phps'.DIRECTORY_SEPARATOR.'some_file.php') + ->will($this->returnValue($loaderMock)); + + $loaderMock + ->expects($this->once()) + ->method('load') + ->with($this->featuresPath.DIRECTORY_SEPARATOR.'phps'.DIRECTORY_SEPARATOR.'some_file.php') + ->will($this->returnValue(array('feature1', 'feature2'))); + + $this->assertEquals(array('feature1', 'feature2'), $this->loader->load($this->featuresPath . '/phps')); + } +}