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%2FFlow%2FOnlyFirstBackgroundFiresListener.php;fp=vendor%2Fbehat%2Fbehat%2Fsrc%2FBehat%2FBehat%2FOutput%2FNode%2FEventListener%2FFlow%2FOnlyFirstBackgroundFiresListener.php;h=0000000000000000000000000000000000000000;hp=ad3679c8f21a7f63069a5949e140b0a5da460a57;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/behat/behat/src/Behat/Behat/Output/Node/EventListener/Flow/OnlyFirstBackgroundFiresListener.php b/vendor/behat/behat/src/Behat/Behat/Output/Node/EventListener/Flow/OnlyFirstBackgroundFiresListener.php deleted file mode 100644 index ad3679c8f..000000000 --- a/vendor/behat/behat/src/Behat/Behat/Output/Node/EventListener/Flow/OnlyFirstBackgroundFiresListener.php +++ /dev/null @@ -1,202 +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\Flow; - -use Behat\Behat\EventDispatcher\Event\AfterStepSetup; -use Behat\Behat\EventDispatcher\Event\AfterStepTested; -use Behat\Behat\EventDispatcher\Event\BackgroundTested; -use Behat\Behat\EventDispatcher\Event\FeatureTested; -use Behat\Testwork\Output\Formatter; -use Behat\Testwork\Output\Node\EventListener\EventListener; -use Symfony\Component\EventDispatcher\Event; - -/** - * Behat only first background fires listener. - * - * This listener catches all in-background events and then proxies them further - * only if they meet one of two conditions: - * - * 1. It is a first background - * 2. It is a failing step - * - * @author Konstantin Kudryashov - */ -class OnlyFirstBackgroundFiresListener implements EventListener -{ - /** - * @var EventListener - */ - private $descendant; - /** - * @var Boolean - */ - private $firstBackgroundEnded = false; - /** - * @var Boolean - */ - private $inBackground = false; - /** - * @var Boolean - */ - private $stepSetupHadOutput = false; - - /** - * Initializes listener. - * - * @param EventListener $descendant - */ - public function __construct(EventListener $descendant) - { - $this->descendant = $descendant; - } - - /** - * {@inheritdoc} - */ - public function listenEvent(Formatter $formatter, Event $event, $eventName) - { - $this->flushStatesIfBeginningOfTheFeature($eventName); - $this->markBeginningOrEndOfTheBackground($eventName); - - if ($this->isSkippableEvent($event)) { - return; - } - - $this->markFirstBackgroundPrintedAfterBackground($eventName); - - $this->descendant->listenEvent($formatter, $event, $eventName); - } - - /** - * Flushes state if the event is the BEFORE feature. - * - * @param string $eventName - */ - private function flushStatesIfBeginningOfTheFeature($eventName) - { - if (FeatureTested::BEFORE !== $eventName) { - return; - } - - $this->firstBackgroundEnded = false; - $this->inBackground = false; - } - - /** - * Marks beginning or end of the background. - * - * @param string $eventName - */ - private function markBeginningOrEndOfTheBackground($eventName) - { - if (BackgroundTested::BEFORE === $eventName) { - $this->inBackground = true; - } - - if (BackgroundTested::AFTER === $eventName) { - $this->inBackground = false; - } - } - - /** - * Marks first background printed. - * - * @param string $eventName - */ - private function markFirstBackgroundPrintedAfterBackground($eventName) - { - if (BackgroundTested::AFTER !== $eventName) { - return; - } - - $this->firstBackgroundEnded = true; - } - - /** - * Checks if provided event is skippable. - * - * @param Event $event - * - * @return Boolean - */ - private function isSkippableEvent(Event $event) - { - if (!$this->firstBackgroundEnded) { - return false; - } - - return $event instanceof BackgroundTested || $this->isNonFailingConsequentBackgroundStep($event); - } - - /** - * Checks if provided event is a non-failing step in consequent background. - * - * @param Event $event - * - * @return Boolean - */ - private function isNonFailingConsequentBackgroundStep(Event $event) - { - if (!$this->inBackground) { - return false; - } - - return !$this->isStepEventWithOutput($event); - } - - /** - * Checks if provided event is a step event which setup or teardown produced any output. - * - * @param Event $event - * - * @return Boolean - */ - private function isStepEventWithOutput(Event $event) - { - return $this->isBeforeStepEventWithOutput($event) || $this->isAfterStepWithOutput($event); - } - - /** - * Checks if provided event is a BEFORE step with setup that produced output. - * - * @param Event $event - * - * @return Boolean - */ - private function isBeforeStepEventWithOutput(Event $event) - { - if ($event instanceof AfterStepSetup && $event->hasOutput()) { - $this->stepSetupHadOutput = true; - - return true; - } - - return false; - } - - /** - * Checks if provided event is an AFTER step with teardown that produced output. - * - * @param Event $event - * - * @return Boolean - */ - private function isAfterStepWithOutput(Event $event) - { - if ($event instanceof AfterStepTested && ($this->stepSetupHadOutput || $event->hasOutput())) { - $this->stepSetupHadOutput = false; - - return true; - } - - return false; - } -}