Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / Tester / Cli / StrictController.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
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\Tester\Cli;
12
13 use Behat\Testwork\Cli\Controller;
14 use Behat\Testwork\Tester\Result\Interpretation\StrictInterpretation;
15 use Behat\Testwork\Tester\Result\ResultInterpreter;
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  * Configures Testwork to interpret test results strictly.
23  *
24  * @author Konstantin Kudryashov <ever.zet@gmail.com>
25  */
26 final class StrictController implements Controller
27 {
28     /**
29      * @var ResultInterpreter
30      */
31     private $resultInterpreter;
32     /**
33      * @var Boolean
34      */
35     private $strict;
36
37     /**
38      * Initializes controller.
39      *
40      * @param ResultInterpreter $resultInterpreter
41      * @param Boolean           $strict
42      */
43     public function __construct(ResultInterpreter $resultInterpreter, $strict = false)
44     {
45         $this->resultInterpreter = $resultInterpreter;
46         $this->strict = $strict;
47     }
48
49     /**
50      * {@inheritdoc}
51      */
52     public function configure(Command $command)
53     {
54         $command->addOption('--strict', null, InputOption::VALUE_NONE,
55             'Passes only if all tests are explicitly passing.'
56         );
57     }
58
59     /**
60      * {@inheritdoc}
61      */
62     public function execute(InputInterface $input, OutputInterface $output)
63     {
64         if (!$this->strict && !$input->getOption('strict')) {
65             return;
66         }
67
68         $this->resultInterpreter->registerResultInterpretation(new StrictInterpretation());
69     }
70 }