Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Output / Node / Printer / Progress / ProgressStatisticsPrinter.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\CounterPrinter;
14 use Behat\Behat\Output\Node\Printer\ListPrinter;
15 use Behat\Behat\Output\Node\Printer\StatisticsPrinter;
16 use Behat\Behat\Output\Statistics\Statistics;
17 use Behat\Testwork\Output\Formatter;
18 use Behat\Testwork\Tester\Result\TestResult;
19
20 /**
21  * Behat progress statistics printer.
22  *
23  * @author Konstantin Kudryashov <ever.zet@gmail.com>
24  */
25 final class ProgressStatisticsPrinter implements StatisticsPrinter
26 {
27     /**
28      * @var CounterPrinter
29      */
30     private $counterPrinter;
31     /**
32      * @var ListPrinter
33      */
34     private $listPrinter;
35
36     /**
37      * Initializes printer.
38      *
39      * @param CounterPrinter $counterPrinter
40      * @param ListPrinter    $listPrinter
41      */
42     public function __construct(CounterPrinter $counterPrinter, ListPrinter $listPrinter)
43     {
44         $this->counterPrinter = $counterPrinter;
45         $this->listPrinter = $listPrinter;
46     }
47
48     /**
49      * {@inheritdoc}
50      */
51     public function printStatistics(Formatter $formatter, Statistics $statistics)
52     {
53         $printer = $formatter->getOutputPrinter();
54
55         $printer->writeln();
56         $printer->writeln();
57
58         $hookStats = $statistics->getFailedHookStats();
59         $this->listPrinter->printFailedHooksList($printer, 'failed_hooks_title', $hookStats);
60
61         $stepStats = $statistics->getFailedSteps();
62         $this->listPrinter->printStepList($printer, 'failed_steps_title', TestResult::FAILED, $stepStats);
63
64         $stepStats = $statistics->getPendingSteps();
65         $this->listPrinter->printStepList($printer, 'pending_steps_title', TestResult::PENDING, $stepStats);
66
67         $this->counterPrinter->printCounters($printer, 'scenarios_count', $statistics->getScenarioStatCounts());
68         $this->counterPrinter->printCounters($printer, 'steps_count', $statistics->getStepStatCounts());
69
70         if ($formatter->getParameter('timer')) {
71             $timer = $statistics->getTimer();
72             $memory = $statistics->getMemory();
73
74             $formatter->getOutputPrinter()->writeln(sprintf('%s (%s)', $timer, $memory));
75         }
76     }
77 }