X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fbehat%2Fbehat%2Fsrc%2FBehat%2FBehat%2FOutput%2FNode%2FPrinter%2FPretty%2FPrettyExamplePrinter.php;fp=vendor%2Fbehat%2Fbehat%2Fsrc%2FBehat%2FBehat%2FOutput%2FNode%2FPrinter%2FPretty%2FPrettyExamplePrinter.php;h=2d5babf839fb197ad313e3e889a1e0cd5aa41cf7;hp=0000000000000000000000000000000000000000;hb=1270d9129ce8f27c9b28b10518e32132c58e0aca;hpb=c27c0f0cdaa3f354b1fe54a56ae7e854be6e3f68 diff --git a/vendor/behat/behat/src/Behat/Behat/Output/Node/Printer/Pretty/PrettyExamplePrinter.php b/vendor/behat/behat/src/Behat/Behat/Output/Node/Printer/Pretty/PrettyExamplePrinter.php new file mode 100644 index 000000000..2d5babf83 --- /dev/null +++ b/vendor/behat/behat/src/Behat/Behat/Output/Node/Printer/Pretty/PrettyExamplePrinter.php @@ -0,0 +1,74 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Behat\Behat\Output\Node\Printer\Pretty; + +use Behat\Behat\Output\Node\Printer\ExamplePrinter; +use Behat\Gherkin\Node\ExampleNode; +use Behat\Gherkin\Node\FeatureNode; +use Behat\Testwork\Output\Formatter; +use Behat\Testwork\Output\Printer\OutputPrinter; +use Behat\Testwork\Tester\Result\TestResult; + +/** + * Prints example header (usually simply an example row) and footer. + * + * @author Konstantin Kudryashov + */ +final class PrettyExamplePrinter implements ExamplePrinter +{ + /** + * @var PrettyPathPrinter + */ + private $pathPrinter; + /** + * @var string + */ + private $indentText; + + /** + * Initializes printer. + * + * @param PrettyPathPrinter $pathPrinter + * @param integer $indentation + */ + public function __construct(PrettyPathPrinter $pathPrinter, $indentation = 6) + { + $this->pathPrinter = $pathPrinter; + $this->indentText = str_repeat(' ', intval($indentation)); + } + + /** + * {@inheritdoc} + */ + public function printHeader(Formatter $formatter, FeatureNode $feature, ExampleNode $example) + { + $this->printTitle($formatter->getOutputPrinter(), $example); + $this->pathPrinter->printScenarioPath($formatter, $feature, $example, mb_strlen($this->indentText, 'utf8')); + } + + /** + * {@inheritdoc} + */ + public function printFooter(Formatter $formatter, TestResult $result) + { + } + + /** + * Prints example title. + * + * @param OutputPrinter $printer + * @param ExampleNode $example + */ + private function printTitle(OutputPrinter $printer, ExampleNode $example) + { + $printer->write(sprintf('%s%s', $this->indentText, $example->getTitle())); + } +}