This commit is contained in:
2020-10-06 14:27:47 +07:00
commit 586be80cf6
16613 changed files with 3274099 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
<?php
namespace Codeception\Step;
use Codeception\Step;
class Action extends Step
{
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Codeception\Step\Argument;
/**
* Implemented in Step arguments where literal values need to be modified in test execution output (e.g. passwords).
*/
interface FormattedOutput
{
/**
* Returns the argument's value formatted for output.
*
* @return string
*/
public function getOutput();
/**
* Returns the argument's literal value.
*
* @return string
*/
public function __toString();
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Codeception\Step\Argument;
class PasswordArgument implements FormattedOutput
{
/**
* @var string
*/
private $password;
public function __construct($password)
{
$this->password = $password;
}
/**
* {@inheritdoc}
*/
public function getOutput()
{
return '******';
}
/**
* {@inheritdoc}
*/
public function __toString()
{
return $this->password;
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Codeception\Step;
use Codeception\Step as CodeceptionStep;
class Assertion extends CodeceptionStep
{
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Codeception\Step;
use Codeception\Lib\ModuleContainer;
use Codeception\Step as CodeceptionStep;
class Comment extends CodeceptionStep
{
public function __toString()
{
return (string) $this->getAction();
}
public function toString($maxLength)
{
return mb_strcut($this->__toString(), 0, $maxLength, 'utf-8');
}
public function getHtml($highlightColor = '#732E81')
{
return '<strong>' . $this->getAction() . '</strong>';
}
public function getPhpCode($maxLength)
{
return '// ' . $this->getAction();
}
public function run(ModuleContainer $container = null)
{
// don't do anything, let's rest
}
public function getPrefix()
{
return '';
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Codeception\Step;
use Codeception\Step as CodeceptionStep;
class Condition extends CodeceptionStep
{
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Codeception\Step;
use Codeception\Exception\ConditionalAssertionFailed;
use Codeception\Lib\ModuleContainer;
class ConditionalAssertion extends Assertion
{
public function run(ModuleContainer $container = null)
{
try {
parent::run($container);
} catch (\PHPUnit\Framework\AssertionFailedError $e) {
throw new ConditionalAssertionFailed($e->getMessage(), $e->getCode(), $e);
}
}
public function getAction()
{
$action = 'can' . ucfirst($this->action);
$action = preg_replace('/^canDont/', 'cant', $action);
return $action;
}
public function getHumanizedAction()
{
return $this->humanize($this->action . ' ' . $this->getHumanizedArguments());
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Codeception\Step;
use Codeception\Step as CodeceptionStep;
use Codeception\Lib\ModuleContainer;
class Executor extends CodeceptionStep
{
protected $callable = null;
public function __construct(\Closure $callable, $arguments = [])
{
parent::__construct('execute callable function', []);
$this->callable = $callable;
}
public function run(ModuleContainer $container = null)
{
$callable = $this->callable;
return $callable();
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Codeception\Step;
use Codeception\Step as CodeceptionStep;
use Codeception\Lib\ModuleContainer;
class Incomplete extends CodeceptionStep
{
public function run(ModuleContainer $container = null)
{
throw new \PHPUnit\Framework\IncompleteTestError($this->getAction());
}
public function __toString()
{
return $this->getAction();
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Codeception\Step;
use Codeception\Lib\ModuleContainer;
use Codeception\Step as CodeceptionStep;
class Meta extends CodeceptionStep
{
public function run(ModuleContainer $container = null)
{
}
public function setTraceInfo($file, $line)
{
$this->file = $file;
$this->line = $line;
}
public function setPrefix($actor)
{
$this->prefix = $actor;
}
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;
}
public function setFailed($failed)
{
$this->failed = $failed;
}
}

View File

@@ -0,0 +1,3 @@
# Steps
Steps are used in scenarios. They do not keep any logic, but responsible for formatting. Exception for `ConditionalAssertion` which acts like `Assertion` but acts differently on fail.

View File

@@ -0,0 +1,18 @@
<?php
namespace Codeception\Step;
use Codeception\Step as CodeceptionStep;
use Codeception\Lib\ModuleContainer;
class Skip extends CodeceptionStep
{
public function run(ModuleContainer $container = null)
{
throw new \PHPUnit\Framework\SkippedTestError($this->getAction());
}
public function __toString()
{
return $this->getAction();
}
}