/** * Listens to "step.after" event. * * @param StepEvent $event * * @uses printStep() */ public function afterStep(StepEvent $event) { if ($this->inBackground && $this->isBackgroundPrinted) { return; } if ($this->isStepChainParent($event->getStep())) { $isStepChainParent = true; $this->inChain = false; } if (!$this->inBackground && $this->inOutlineExample) { $this->delayedStepEvents[] = $event; return; } if ($this->inChain) { $this->chainedSteps[] = $event; return; } $this->printStep($event->getStep(), $event->getResult(), $event->getDefinition(), $event->getSnippet(), $event->getException()); if (isset($this->chainedSteps) && count($this->chainedSteps) && isset($isStepChainParent) && $isStepChainParent) { foreach ($this->chainedSteps as $event) { $this->write($this->indent); $this->printStep($event->getStep(), $event->getResult(), $event->getDefinition(), $event->getSnippet(), $event->getException()); } $this->chainedSteps = []; } }
/** * Listens to "step.after" event. * * @param StepEvent $event * * @uses printStep() */ public function afterStep(StepEvent $event) { if ($this->inBackground && $this->isBackgroundPrinted) { return; } if (!$this->inBackground && $this->inOutlineExample) { $this->delayedStepEvents[] = $event; return; } $this->printStep($event->getStep(), $event->getResult(), $event->getDefinition(), $event->getSnippet(), $event->getException()); }
/** * Listens to "step.after" event. * * @param Behat\Behat\Event\StepEvent $event * * @uses printStep() */ public function afterStep(StepEvent $event) { $this->printStep($event->getStep(), $event->getResult(), $event->getDefinition(), $event->getSnippet(), $event->getException()); }
/** * Searches and runs provided step delegating all the process to the parent class * * Method overwritten to look for: * - Moodle exceptions * - Moodle debugging() calls * - PHP debug messages (depends on the PHP debug level) * * @param StepNode $step step node * @return StepEvent */ protected function executeStep(StepNode $step) { // Redirect to the parent to run the step. $afterEvent = parent::executeStep($step); // Catch Moodle Behat skip exception. if ($afterEvent->getException() instanceof SkippedException) { return new StepEvent($afterEvent->getStep(), $afterEvent->getLogicalParent(), $afterEvent->getContext(), StepEvent::SKIPPED, $afterEvent->getDefinition(), $afterEvent->getException(), null); } // We set $this->dispatchafterstep to true when a step is in the lower level // but if a step is throwing an exception it doesn't arrive to the point where // we set dispatchafterstep to true and the event is not dispatched; here we // set it but we also check failredstep so the parent steps (in a chain) don't // continue dispatching the event. if ($afterEvent->getResult() !== StepEvent::PASSED && $this->failedstep === false) { $this->dispatchafterstep = true; } // Extra step, looking for a moodle exception, a debugging() message or a PHP debug message. $checkingStep = new StepNode('Then', self::EXCEPTIONS_STEP_TEXT, $step->getLine()); $afterExceptionCheckingEvent = parent::executeStep($checkingStep); // If it find something wrong we overwrite the original step result. if ($afterExceptionCheckingEvent->getResult() == StepEvent::FAILED) { // Creating a mix of both StepEvents to report about it as a failure in the original step. $afterEvent = new StepEvent($afterEvent->getStep(), $afterEvent->getLogicalParent(), $afterEvent->getContext(), $afterExceptionCheckingEvent->getResult(), $afterEvent->getDefinition(), $afterExceptionCheckingEvent->getException(), null); } return $afterEvent; }
/** * Listens to "step.after" event. * * @param StepEvent $event * * @uses printStep() */ public function afterStep(StepEvent $event) { $step = $event->getStep(); $newStep = array('type' => $step->getType(), 'text' => $step->getText(), 'arguments' => array(), ''); foreach ($step->getArguments() as $argument) { $newStep['arguments'][] = (string) $argument; } $definition = $event->getDefinition(); if ($definition) { $this->definitions[$definition->getRegex()] = array('regex' => $definition->getRegex(), 'description' => $definition->getDescription(), 'path' => $this->relativizePathsInString($definition->getPath()), 'type' => $definition->getType()); $newStep['definition'] = $definition->getRegex(); } else { $newStep['definition'] = false; } if ($this->inBackground) { $this->currentFeature['background'][$newStep['type'] . $newStep['text']] = $newStep; } else { $this->currentScenario['steps'][] = $newStep; } }