Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Output / Node / Printer / Progress / ProgressStepPrinter.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\Behat\Output\Node\Printer\Progress;
12
13 use Behat\Behat\Output\Node\Printer\Helper\ResultToStringConverter;
14 use Behat\Behat\Output\Node\Printer\StepPrinter;
15 use Behat\Behat\Tester\Result\StepResult;
16 use Behat\Gherkin\Node\ScenarioLikeInterface as Scenario;
17 use Behat\Gherkin\Node\StepNode;
18 use Behat\Testwork\Output\Formatter;
19 use Behat\Testwork\Tester\Result\TestResult;
20
21 /**
22  * Behat progress step printer.
23  *
24  * @author Konstantin Kudryashov <ever.zet@gmail.com>
25  */
26 final class ProgressStepPrinter implements StepPrinter
27 {
28     /**
29      * @var ResultToStringConverter
30      */
31     private $resultConverter;
32     /**
33      * @var integer
34      */
35     private $stepsPrinted = 0;
36
37     /**
38      * Initializes printer.
39      *
40      * @param ResultToStringConverter $resultConverter
41      */
42     public function __construct(ResultToStringConverter $resultConverter)
43     {
44         $this->resultConverter = $resultConverter;
45     }
46
47     /**
48      * {@inheritdoc}
49      */
50     public function printStep(Formatter $formatter, Scenario $scenario, StepNode $step, StepResult $result)
51     {
52         $printer = $formatter->getOutputPrinter();
53         $style = $this->resultConverter->convertResultToString($result);
54
55         switch ($result->getResultCode()) {
56             case TestResult::PASSED:
57                 $printer->write("{+$style}.{-$style}");
58                 break;
59             case TestResult::SKIPPED:
60                 $printer->write("{+$style}-{-$style}");
61                 break;
62             case TestResult::PENDING:
63                 $printer->write("{+$style}P{-$style}");
64                 break;
65             case StepResult::UNDEFINED:
66                 $printer->write("{+$style}U{-$style}");
67                 break;
68             case TestResult::FAILED:
69                 $printer->write("{+$style}F{-$style}");
70                 break;
71         }
72
73         if (++$this->stepsPrinted % 70 == 0) {
74             $printer->writeln(' ' . $this->stepsPrinted);
75         }
76     }
77 }