See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 401] [Versions 39 and 402]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace Moodle\BehatExtension\Locator; 18 19 use Behat\Behat\Gherkin\Specification\LazyFeatureIterator; 20 use Behat\Gherkin\Gherkin; 21 use Behat\Testwork\Specification\Locator\SpecificationLocator; 22 use Behat\Testwork\Specification\NoSpecificationsIterator; 23 use Behat\Testwork\Suite\Suite; 24 25 // phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod 26 27 /** 28 * Skips gherkin features using a file with the list of scenarios. 29 * 30 * @package core 31 * @copyright 2016 onwards Rajesh Taneja 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 */ 34 final class FilesystemSkipPassedListLocator implements SpecificationLocator { 35 /** 36 * @var Gherkin 37 */ 38 private $gherkin; 39 40 /** 41 * Initializes locator. 42 * 43 * @param Gherkin $gherkin 44 */ 45 public function __construct(Gherkin $gherkin) { 46 $this->gherkin = $gherkin; 47 } 48 49 /** 50 * Returns array of strings representing examples of supported specification locators. 51 * 52 * @return string[] 53 */ 54 public function getLocatorExamples() { 55 return []; 56 } 57 58 /** 59 * Locates specifications and wraps them into iterator. 60 * 61 * @param Suite $suite 62 * @param string $locator 63 * 64 * @return SpecificationIterator 65 */ 66 public function locateSpecifications(Suite $suite, $locator) { 67 if (!is_file($locator) || 'passed' !== pathinfo($locator, PATHINFO_EXTENSION)) { 68 return new NoSpecificationsIterator($suite); 69 } 70 71 $scenarios = json_decode(trim(file_get_contents($locator)), true); 72 if (empty($scenarios) || empty($scenarios[$suite->getName()])) { 73 return new NoSpecificationsIterator($suite); 74 } 75 76 $suitepaths = $this->getSuitePaths($suite); 77 78 $scenarios = array_diff($suitepaths, array_values($scenarios[$suite->getName()])); 79 80 return new LazyFeatureIterator($suite, $this->gherkin, $scenarios); 81 } 82 83 /** 84 * Returns array of feature paths configured for the provided suite. 85 * 86 * @param Suite $suite 87 * 88 * @return string[] 89 * 90 * @throws SuiteConfigurationException If `paths` setting is not an array 91 */ 92 private function getSuitePaths(Suite $suite) { 93 if (!is_array($suite->getSetting('paths'))) { 94 throw new SuiteConfigurationException( 95 sprintf( 96 '"paths" setting of the "%s" suite is expected to be an array, %s given.', 97 $suite->getName(), 98 gettype($suite->getSetting('paths')) 99 ), 100 $suite->getName() 101 ); 102 } 103 104 return $suite->getSetting('paths'); 105 } 106 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body