Tester\TestCase::run PHP Method

run() public method

Runs the test case.
public run ( ) : void
return void
    public function run()
    {
        if (func_num_args()) {
            throw new \LogicException('Calling TestCase::run($method) is deprecated. Use TestCase::runTest($method) instead.');
        }
        $methods = array_values(preg_grep(self::METHOD_PATTERN, array_map(function (\ReflectionMethod $rm) {
            return $rm->getName();
        }, (new \ReflectionObject($this))->getMethods())));
        if (isset($_SERVER['argv']) && ($tmp = preg_filter('#--method=([\\w-]+)$#Ai', '$1', $_SERVER['argv']))) {
            $method = reset($tmp);
            if ($method === self::LIST_METHODS) {
                Environment::$checkAssertions = FALSE;
                header('Content-Type: text/plain');
                echo '[' . implode(',', $methods) . ']';
                return;
            }
            $this->runTest($method);
        } else {
            foreach ($methods as $method) {
                $this->runTest($method);
            }
        }
    }

Usage Example

Example #1
0
function run(\Tester\TestCase $testCase)
{
    $testCase->run(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : NULL);
}