Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Output / Node / Printer / Pretty / PrettyStatisticsPrinter.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\Pretty;
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  * Prints exercise statistics.
22  *
23  * @author Konstantin Kudryashov <ever.zet@gmail.com>
24  */
25 final class PrettyStatisticsPrinter 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         $scenarioStats = $statistics->getSkippedScenarios();
56         $this->listPrinter->printScenariosList($printer, 'skipped_scenarios_title', TestResult::SKIPPED, $scenarioStats);
57
58         $scenarioStats = $statistics->getFailedScenarios();
59         $this->listPrinter->printScenariosList($printer, 'failed_scenarios_title', TestResult::FAILED, $scenarioStats);
60
61         $this->counterPrinter->printCounters($printer, 'scenarios_count', $statistics->getScenarioStatCounts());
62         $this->counterPrinter->printCounters($printer, 'steps_count', $statistics->getStepStatCounts());
63
64         if ($formatter->getParameter('timer')) {
65             $timer = $statistics->getTimer();
66             $memory = $statistics->getMemory();
67
68             $formatter->getOutputPrinter()->writeln(sprintf('%s (%s)', $timer, $memory));
69         }
70     }
71 }