X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fbehat%2Fbehat%2Fsrc%2FBehat%2FBehat%2FGherkin%2FSpecification%2FLocator%2FFilesystemRerunScenariosListLocator.php;fp=vendor%2Fbehat%2Fbehat%2Fsrc%2FBehat%2FBehat%2FGherkin%2FSpecification%2FLocator%2FFilesystemRerunScenariosListLocator.php;h=d5ac5b3a379779fee4a334c814ef7b839a9ddda3;hp=0000000000000000000000000000000000000000;hb=1270d9129ce8f27c9b28b10518e32132c58e0aca;hpb=c27c0f0cdaa3f354b1fe54a56ae7e854be6e3f68 diff --git a/vendor/behat/behat/src/Behat/Behat/Gherkin/Specification/Locator/FilesystemRerunScenariosListLocator.php b/vendor/behat/behat/src/Behat/Behat/Gherkin/Specification/Locator/FilesystemRerunScenariosListLocator.php new file mode 100644 index 000000000..d5ac5b3a3 --- /dev/null +++ b/vendor/behat/behat/src/Behat/Behat/Gherkin/Specification/Locator/FilesystemRerunScenariosListLocator.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Behat\Behat\Gherkin\Specification\Locator; + +use Behat\Behat\Gherkin\Specification\LazyFeatureIterator; +use Behat\Gherkin\Gherkin; +use Behat\Testwork\Specification\Locator\SpecificationLocator; +use Behat\Testwork\Specification\NoSpecificationsIterator; +use Behat\Testwork\Suite\Suite; + +/** + * Loads gherkin features using a file with the list of scenarios. + * + * @author Konstantin Kudryashov + */ +final class FilesystemRerunScenariosListLocator implements SpecificationLocator +{ + /** + * @var Gherkin + */ + private $gherkin; + + /** + * Initializes locator. + * + * @param Gherkin $gherkin + */ + public function __construct(Gherkin $gherkin) + { + $this->gherkin = $gherkin; + } + + /** + * {@inheritdoc} + */ + public function getLocatorExamples() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function locateSpecifications(Suite $suite, $locator) + { + if (!is_file($locator) || 'rerun' !== pathinfo($locator, PATHINFO_EXTENSION)) { + return new NoSpecificationsIterator($suite); + } + + $scenarios = json_decode(trim(file_get_contents($locator)), true); + if (empty($scenarios) || empty($scenarios[$suite->getName()])) { + return new NoSpecificationsIterator($suite); + } + + return new LazyFeatureIterator($suite, $this->gherkin, $scenarios[$suite->getName()]); + } +}