/** * @BeforeStep @maintains-authentication-state */ public function beforeStepObtainAuthenticationState(StepEvent $event) { // Don't bother if an exception has occurred. if ($event->hasException()) { return; } $session = $this->getSession(); $page = $session->getPage(); $element = $page->findById("nav-profile"); $this->authenticationStateLoggedIn = $element && $element->isVisible(); // Let the end user know what we did. (This is mostly because this *is* a demo.) if ($this->authenticationStateLoggedIn) { $this->printDebug('[BeforeStepEvent] A user is signed in.'); } else { $this->printDebug('[BeforeStepEvent] A user is not signed in.'); } }
/** * Listens to "step.after" event. * * @param StepEvent $event */ public function afterStep(StepEvent $event) { if ($event->hasException()) { $this->exceptions[] = $event->getException(); $this->exceptionsCount++; } ++$this->stepsCount; }
/** * Converts the behat-Result to the serverSide format. * * @param StepEvent $event The event containing the behat StepResult. * @return stub_php\stepResult */ public function convertResultToStepResult(StepEvent $event) { switch ($event->getResult()) { case StepEvent::PASSED: return stub_php\stepResult::SUCCESS; case StepEvent::UNDEFINED: case StepEvent::PENDING: case StepEvent::SKIPPED: return stub_php\stepResult::SKIPPED; case StepEvent::FAILED: if ($event->hasException() && !$this->_isAssertionError($event->getException())) { return stub_php\stepResult::ERROR; } else { return stub_php\stepResult::FAILURE; } default: return stub_php\stepResult::ERROR; } }
/** * Listens to "step.after" event. * * @param StepEvent $event */ public function afterStep(StepEvent $event) { if ($event->hasException()) { if ($event->getResult() === StepEvent::SKIPPED || $event->getResult() === StepEvent::PENDING || $event->getResult() === StepEvent::UNDEFINED) { $this->pendingCount++; } else { $this->exceptions[] = $event->getException(); $this->exceptionsCount++; $this->failureCount++; } } ++$this->stepsCount; ++$this->scenarioStepsCount; }