4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Behat\Gherkin\Specification\Locator;
13 use Behat\Behat\Gherkin\Specification\LazyFeatureIterator;
14 use Behat\Gherkin\Gherkin;
15 use Behat\Testwork\Specification\Locator\SpecificationLocator;
16 use Behat\Testwork\Specification\NoSpecificationsIterator;
17 use Behat\Testwork\Suite\Suite;
20 * Loads gherkin features using a file with the list of scenarios.
22 * @author Konstantin Kudryashov <ever.zet@gmail.com>
24 final class FilesystemRerunScenariosListLocator implements SpecificationLocator
32 * Initializes locator.
34 * @param Gherkin $gherkin
36 public function __construct(Gherkin $gherkin)
38 $this->gherkin = $gherkin;
44 public function getLocatorExamples()
52 public function locateSpecifications(Suite $suite, $locator)
54 if (!is_file($locator) || 'rerun' !== pathinfo($locator, PATHINFO_EXTENSION)) {
55 return new NoSpecificationsIterator($suite);
58 $scenarios = json_decode(trim(file_get_contents($locator)), true);
59 if (empty($scenarios) || empty($scenarios[$suite->getName()])) {
60 return new NoSpecificationsIterator($suite);
63 return new LazyFeatureIterator($suite, $this->gherkin, $scenarios[$suite->getName()]);