4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Behat\Output\Node\Printer\Pretty;
13 use Behat\Behat\Output\Node\Printer\ExamplePrinter;
14 use Behat\Gherkin\Node\ExampleNode;
15 use Behat\Gherkin\Node\FeatureNode;
16 use Behat\Testwork\Output\Formatter;
17 use Behat\Testwork\Output\Printer\OutputPrinter;
18 use Behat\Testwork\Tester\Result\TestResult;
21 * Prints example header (usually simply an example row) and footer.
23 * @author Konstantin Kudryashov <ever.zet@gmail.com>
25 final class PrettyExamplePrinter implements ExamplePrinter
28 * @var PrettyPathPrinter
37 * Initializes printer.
39 * @param PrettyPathPrinter $pathPrinter
40 * @param integer $indentation
42 public function __construct(PrettyPathPrinter $pathPrinter, $indentation = 6)
44 $this->pathPrinter = $pathPrinter;
45 $this->indentText = str_repeat(' ', intval($indentation));
51 public function printHeader(Formatter $formatter, FeatureNode $feature, ExampleNode $example)
53 $this->printTitle($formatter->getOutputPrinter(), $example);
54 $this->pathPrinter->printScenarioPath($formatter, $feature, $example, mb_strlen($this->indentText, 'utf8'));
60 public function printFooter(Formatter $formatter, TestResult $result)
65 * Prints example title.
67 * @param OutputPrinter $printer
68 * @param ExampleNode $example
70 private function printTitle(OutputPrinter $printer, ExampleNode $example)
72 $printer->write(sprintf('%s%s', $this->indentText, $example->getTitle()));