|
<?php |
|
|
|
// project\vendor\behat\behat\src\Behat\Behat\Definition\Cli\AvailableScenariosController.php |
|
|
|
namespace Behat\Behat\Definition\Cli; |
|
|
|
use Behat\Gherkin\Node\FeatureNode; |
|
use Behat\Testwork\Cli\Controller; |
|
use Behat\Testwork\Specification\SpecificationFinder; |
|
use Behat\Testwork\Suite\SuiteRepository; |
|
use Symfony\Component\Console\Command\Command as SymfonyCommand; |
|
use Symfony\Component\Console\Input\InputInterface; |
|
use Symfony\Component\Console\Input\InputOption; |
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
use Behat\Behat\Definition\DefinitionWriter; |
|
|
|
/** |
|
* this class manage what does the command |
|
* @author netraagal |
|
*/ |
|
class AvailableScenariosController implements Controller |
|
{ |
|
|
|
/** |
|
* @var SuiteRepository |
|
*/ |
|
private $suiteRepository; |
|
/** |
|
* @var DefinitionWriter |
|
*/ |
|
private $writer; |
|
/** |
|
* @var SpecificationFinder |
|
*/ |
|
private $specificationFinder; |
|
|
|
/** |
|
* @param SuiteRepository $suiteRepository |
|
* @param DefinitionWriter $writer |
|
* @param SpecificationFinder $specificationFinder |
|
*/ |
|
public function __construct( |
|
SuiteRepository $suiteRepository, |
|
DefinitionWriter $writer, |
|
SpecificationFinder $specificationFinder) |
|
{ |
|
$this->suiteRepository = $suiteRepository; |
|
$this->writer = $writer; |
|
$this->specificationFinder = $specificationFinder; |
|
} |
|
|
|
/** |
|
* @param SymfonyCommand $command |
|
* return AvailableScenariosController |
|
*/ |
|
public function configure(SymfonyCommand $command): self |
|
{ |
|
$command |
|
->addOption( |
|
'--list-scenarios', |
|
null, |
|
InputOption::VALUE_NONE, |
|
'Output registered feature and scenario definitions' |
|
); |
|
return $this; |
|
} |
|
|
|
/** |
|
* @param InputInterface $input |
|
* @param OutputInterface $output |
|
* @return bool |
|
*/ |
|
public function execute(InputInterface $input, OutputInterface $output): bool |
|
{ |
|
if (!$input->getOption('list-scenarios')) { |
|
return false; |
|
} |
|
|
|
foreach ($this->suiteRepository->getSuites() as $suite) { |
|
$iterators = $this->specificationFinder->findSuitesSpecifications([$suite]); |
|
foreach ($iterators as $iterator) { |
|
foreach ($iterator as $item) { |
|
$output->writeln($item->getDescription()); |
|
$this->printFeatures($item->getScenarios(), $output); |
|
} |
|
} |
|
} |
|
return true; |
|
} |
|
|
|
/** |
|
* @param array $feature |
|
* @param OutputInterface $output |
|
* @return AvailableScenariosController |
|
*/ |
|
private function printFeatures(array $feature, OutputInterface $output): self |
|
{ |
|
foreach($feature as $scenario) { |
|
$output->writeln($scenario->getTitle()); |
|
} |
|
|
|
return $this; |
|
} |
|
|
|
} |
The solution to this is to create your own extension.