Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Output / Node / Printer / JUnit / JUnitFeaturePrinter.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\JUnit;
12
13 use Behat\Behat\Output\Node\Printer\FeaturePrinter;
14 use Behat\Behat\Output\Statistics\PhaseStatistics;
15 use Behat\Behat\Tester\Result\StepResult;
16 use Behat\Gherkin\Node\FeatureNode;
17 use Behat\Testwork\Output\Formatter;
18 use Behat\Testwork\Output\Printer\JUnitOutputPrinter;
19 use Behat\Testwork\Tester\Result\TestResult;
20
21 /**
22  * Prints the <testsuite> element.
23  *
24  * @author Wouter J <wouter@wouterj.nl>
25  */
26 final class JUnitFeaturePrinter implements FeaturePrinter
27 {
28     /**
29      * @var PhaseStatistics
30      */
31     private $statistics;
32
33     public function __construct(PhaseStatistics $statistics)
34     {
35         $this->statistics = $statistics;
36     }
37
38     /**
39      * {@inheritDoc}
40      */
41     public function printHeader(Formatter $formatter, FeatureNode $feature)
42     {
43         $stats = $this->statistics->getScenarioStatCounts();
44
45         if (0 === count($stats)) {
46             $totalCount = 0;
47         } else {
48             $totalCount = array_sum($stats);
49         }
50
51         /** @var JUnitOutputPrinter $outputPrinter */
52         $outputPrinter = $formatter->getOutputPrinter();
53
54         $outputPrinter->addTestsuite(array(
55             'name' => $feature->getTitle(),
56             'tests' => $totalCount,
57             'skipped' => $stats[TestResult::SKIPPED],
58             'failures' => $stats[TestResult::FAILED],
59             'errors' => $stats[TestResult::PENDING] + $stats[StepResult::UNDEFINED],
60         ));
61         $this->statistics->reset();
62     }
63
64     /**
65      * {@inheritDoc}
66      */
67     public function printFooter(Formatter $formatter, TestResult $result)
68     {
69     }
70 }