public function runStep(\Codeception\Step $step) { $this->trace[] = $step; if ($step->getName() == 'Comment') { $this->dispatcher->dispatch('comment.before', new \Codeception\Event\Step($this, $step)); $this->dispatcher->dispatch('comment.after', new \Codeception\Event\Step($this, $step)); return; } $action = $step->getAction(); $arguments = $step->getArguments(); if (!isset(\Codeception\SuiteManager::$actions[$action])) { $this->stopped = true; $this->fail("Action {$action} not defined"); return; } $this->dispatcher->dispatch('step.before', new \Codeception\Event\Step($this, $step)); $activeModule = \Codeception\SuiteManager::$modules[\Codeception\SuiteManager::$actions[$action]]; try { if (is_callable(array($activeModule, $action))) { call_user_func_array(array($activeModule, $action), $arguments); } else { throw new \RuntimeException("Action can't be called"); } } catch (\PHPUnit_Framework_ExpectationFailedException $fail) { $this->dispatcher->dispatch('step.after', new \Codeception\Event\Step($this, $step)); throw $fail; } $this->dispatcher->dispatch('step.after', new \Codeception\Event\Step($this, $step)); }
public function runStep(\Codeception\Step $step) { $this->trace[] = $step; $this->fire('step.before', new \Codeception\Event\Step($this, $step)); try { $result = $step->run(); } catch (\Exception $e) { $this->fire('step.after', new \Codeception\Event\Step($this, $step)); throw $e; } $this->fire('step.after', new \Codeception\Event\Step($this, $step)); return $result; }
public function runStep(Step $step) { $result = null; $this->fire(Events::STEP_BEFORE, new StepEvent($this, $step)); try { $result = $step->run($this->moduleContainer); } catch (ConditionalAssertionFailed $f) { $this->testResult->addFailure(clone $this, $f, $this->testResult->time()); } catch (\Exception $e) { $this->fire(Events::STEP_AFTER, new StepEvent($this, $step)); throw $e; } $this->fire(Events::STEP_AFTER, new StepEvent($this, $step)); return $result; }
public function runStep(\Codeception\Step $step) { $this->trace[] = $step; $this->fire('step.before', new \Codeception\Event\Step($this, $step)); try { $result = $step->run(); } catch (ConditionalAssertionFailed $f) { $result = $this->getTestResultObject(); $result->addFailure(clone $this, $f, $result->time()); } catch (\Exception $e) { $this->fire('step.after', new \Codeception\Event\Step($this, $step)); throw $e; } $this->fire('step.after', new \Codeception\Event\Step($this, $step)); return $result; }
public function runStep(Step $step) { $this->trace[] = $step; $this->fire(Events::STEP_BEFORE, new StepEvent($this, $step)); try { $result = $step->run(); } catch (ConditionalAssertionFailed $f) { $result = $this->getTestResultObject(); $result->addFailure(clone $this, $f, $result->time()); } catch (\Exception $e) { $this->fire(Events::STEP_AFTER, new StepEvent($this, $step)); throw $e; } $this->fire(Events::STEP_AFTER, new StepEvent($this, $step)); return $result; }
public function runStep(Step $step) { $this->steps[] = $step; $result = null; $this->metadata->getService('dispatcher')->dispatch(Events::STEP_BEFORE, new StepEvent($this->test, $step)); try { $result = $step->run($this->metadata->getService('modules')); } catch (ConditionalAssertionFailed $f) { $result = $this->test->getTestResultObject(); $result->addFailure(clone $this->test, $f, $result->time()); } catch (\Exception $e) { $this->metadata->getService('dispatcher')->dispatch(Events::STEP_AFTER, new StepEvent($this->test, $step)); throw $e; } $this->metadata->getService('dispatcher')->dispatch(Events::STEP_AFTER, new StepEvent($this->test, $step)); $step->executed = true; return $result; }
protected function getArgumentsAsString(array $arguments) { $lastArgAsString = ''; $lastArg = end($arguments); if (is_string($lastArg) && strpos($lastArg, "\n") !== false) { $lastArgAsString = "\r\n " . str_replace("\n", "\n ", $lastArg); array_pop($arguments); } return parent::getArgumentsAsString($arguments) . $lastArgAsString; }
public function getArgumentsAsString($maxLength = 200) { $argumentBackup = $this->arguments; $lastArgAsString = ''; $lastArg = end($this->arguments); if (is_string($lastArg) && strpos($lastArg, "\n") !== false) { $lastArgAsString = "\r\n " . str_replace("\n", "\n ", $lastArg); array_pop($this->arguments); } $result = parent::getArgumentsAsString($maxLength) . $lastArgAsString; $this->arguments = $argumentBackup; return $result; }
private function printStep(Step $step) { if ($step instanceof Comment and $step->__toString() == '') { return; // don't print empty comments } $msg = $this->message(' '); if ($this->metaStep) { $msg->append(' '); } $msg->append($step->getPrefix()); $prefixLength = $msg->getLength(); if (!$this->metaStep) { $msg->style('bold'); } $maxLength = $this->width - $prefixLength; $msg->append($step->toString($maxLength)); if ($this->metaStep) { $msg->style('info'); } $msg->writeln(); }
public function __construct(\Closure $callable, $arguments = []) { parent::__construct('execute callable function', []); $this->callable = $callable; }
/** * @param $step * @return string */ protected function renderStep(Step $step) { $stepTemplate = new \Text_Template($this->templatePath . 'step.html'); $stepTemplate->setVar(['action' => $step->getHtml(), 'error' => $step->hasFailed() ? 'failedStep' : '']); return $stepTemplate->render(); }
public function __construct(\Closure $callable, $arguments = array()) { // TODO: add serialization to function http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/ parent::__construct('execute callable function', array()); $this->callable = $callable; }
/** * After each step * * @param Step $step */ public function _afterStep(Step $step) { if ($step->getAction() === 'seeNoDifferenceToReferenceImage') { // cleanup the temp image if (file_exists($this->moduleFileSystemUtil->getTempImagePath($step->getArguments()[0]))) { @unlink($this->moduleFileSystemUtil->getTempImagePath($step->getArguments()[0])); } } }
public function _afterStep(Step $step) { $this->debug(__CLASS__ . '::_afterStep ' . $step->getHumanizedActionWithoutArguments()); // if there was an interruption; fail the step $this->failOnInterruption(); parent::_afterStep($step); }
public function _afterStep(Step $step) { if (!$this->insideApplication) { return; } $actions = ['amOnPage', 'click', 'fillField', 'selectOption', 'checkOption', 'uncheckOption', 'unselectOption', 'doubleClick', 'appendField', 'clickWithRightButton', 'dragAndDrop']; if (in_array($step->getAction(), $actions)) { $this->webDriver->executeAsyncScript($this->waitForAngular, [$this->config['el']]); } }