X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fbehat%2Fbehat%2Fsrc%2FBehat%2FBehat%2FOutput%2FNode%2FEventListener%2FAST%2FStepListener.php;fp=vendor%2Fbehat%2Fbehat%2Fsrc%2FBehat%2FBehat%2FOutput%2FNode%2FEventListener%2FAST%2FStepListener.php;h=0000000000000000000000000000000000000000;hp=0d62a56ef4fa51024ff84e0147d248b9b08b84cf;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/behat/behat/src/Behat/Behat/Output/Node/EventListener/AST/StepListener.php b/vendor/behat/behat/src/Behat/Behat/Output/Node/EventListener/AST/StepListener.php deleted file mode 100644 index 0d62a56ef..000000000 --- a/vendor/behat/behat/src/Behat/Behat/Output/Node/EventListener/AST/StepListener.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Behat\Behat\Output\Node\EventListener\AST; - -use Behat\Behat\EventDispatcher\Event\AfterStepSetup; -use Behat\Behat\EventDispatcher\Event\AfterStepTested; -use Behat\Behat\EventDispatcher\Event\ExampleTested; -use Behat\Behat\EventDispatcher\Event\ScenarioLikeTested; -use Behat\Behat\EventDispatcher\Event\ScenarioTested; -use Behat\Behat\Output\Node\Printer\SetupPrinter; -use Behat\Behat\Output\Node\Printer\StepPrinter; -use Behat\Gherkin\Node\ScenarioLikeInterface; -use Behat\Testwork\Output\Formatter; -use Behat\Testwork\Output\Node\EventListener\EventListener; -use Symfony\Component\EventDispatcher\Event; - -/** - * Listens to step events and call appropriate printers. - * - * @author Konstantin Kudryashov - */ -final class StepListener implements EventListener -{ - /** - * @var StepPrinter - */ - private $stepPrinter; - /** - * @var ScenarioLikeInterface - */ - private $scenario; - /** - * @var null|SetupPrinter - */ - private $setupPrinter; - - /** - * Initializes listener. - * - * @param StepPrinter $stepPrinter - * @param null|SetupPrinter $setupPrinter - */ - public function __construct(StepPrinter $stepPrinter, SetupPrinter $setupPrinter = null) - { - $this->stepPrinter = $stepPrinter; - $this->setupPrinter = $setupPrinter; - } - - /** - * {@inheritdoc} - */ - public function listenEvent(Formatter $formatter, Event $event, $eventName) - { - $this->captureScenarioOnScenarioEvent($event); - $this->forgetScenarioOnAfterEvent($eventName); - $this->printStepSetupOnBeforeEvent($formatter, $event); - $this->printStepOnAfterEvent($formatter, $event); - } - - /** - * Captures scenario into the ivar on scenario/background/example BEFORE event. - * - * @param Event $event - */ - private function captureScenarioOnScenarioEvent(Event $event) - { - if (!$event instanceof ScenarioLikeTested) { - return; - } - - $this->scenario = $event->getScenario(); - } - - /** - * Removes scenario from the ivar on scenario/background/example AFTER event. - * - * @param string $eventName - */ - private function forgetScenarioOnAfterEvent($eventName) - { - if (!in_array($eventName, array(ScenarioTested::AFTER, ExampleTested::AFTER))) { - return; - } - - $this->scenario = null; - } - - private function printStepSetupOnBeforeEvent(Formatter $formatter, Event $event) - { - if (!$event instanceof AfterStepSetup) { - return; - } - - if ($this->setupPrinter) { - $this->setupPrinter->printSetup($formatter, $event->getSetup()); - } - } - - /** - * Prints step on AFTER event. - * - * @param Formatter $formatter - * @param Event $event - */ - private function printStepOnAfterEvent(Formatter $formatter, Event $event) - { - if (!$event instanceof AfterStepTested) { - return; - } - - $this->stepPrinter->printStep($formatter, $this->scenario, $event->getStep(), $event->getTestResult()); - - if ($this->setupPrinter) { - $this->setupPrinter->printTeardown($formatter, $event->getTeardown()); - } - } -}