Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / Suite / Cli / InitializationController.php
1 <?php
2
3 /*
4  * This file is part of the Behat Testwork.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Testwork\Suite\Cli;
12
13 use Behat\Testwork\Cli\Controller;
14 use Behat\Testwork\Suite\SuiteBootstrapper;
15 use Behat\Testwork\Suite\SuiteRepository;
16 use Symfony\Component\Console\Command\Command;
17 use Symfony\Component\Console\Input\InputInterface;
18 use Symfony\Component\Console\Input\InputOption;
19 use Symfony\Component\Console\Output\OutputInterface;
20
21 /**
22  * Initializes registered test suites.
23  *
24  * @author Konstantin Kudryashov <ever.zet@gmail.com>
25  */
26 final class InitializationController implements Controller
27 {
28     /**
29      * @var SuiteRepository
30      */
31     private $repository;
32     /**
33      * @var SuiteBootstrapper
34      */
35     private $bootstrapper;
36
37     /**
38      * Initializes controller.
39      *
40      * @param SuiteRepository   $repository
41      * @param SuiteBootstrapper $bootstrapper
42      */
43     public function __construct(SuiteRepository $repository, SuiteBootstrapper $bootstrapper)
44     {
45         $this->repository = $repository;
46         $this->bootstrapper = $bootstrapper;
47     }
48
49     /**
50      * {@inheritdoc}
51      */
52     public function configure(Command $command)
53     {
54         $command->addOption('--init', null, InputOption::VALUE_NONE,
55             'Initialize all registered test suites.'
56         );
57     }
58
59     /**
60      * {@inheritdoc}
61      */
62     public function execute(InputInterface $input, OutputInterface $output)
63     {
64         if (!$input->getOption('init')) {
65             return null;
66         }
67
68         $suites = $this->repository->getSuites();
69         $this->bootstrapper->bootstrapSuites($suites);
70
71         $output->write(PHP_EOL);
72
73         return 0;
74     }
75 }