PHPUnit_Framework_TestCase::main PHP Method

main() public static method

public static main ( $className )
    public static function main($className)
    {
        echo 'Testing ', $className, ' ';
        if (class_exists($className, false)) {
            $class = new $className();
            if (method_exists($class, 'setUp')) {
                $class->setUp();
            }
            $reflectionClass = new ReflectionClass($class);
            $hasSetup = $reflectionClass->hasMethod('setUp');
            gc_collect_cycles();
            $m = microtime(true);
            $mm = memory_get_usage(true);
            $mf = memory_get_usage(false);
            foreach ($reflectionClass->getMethods() as $method) {
                $methodName = $method->getName();
                if (substr($methodName, 0, 4) == 'test') {
                    if ($hasSetup) {
                        $class->setUp();
                    }
                    $class->{$methodName}();
                }
            }
            echo '[OK]', ' (', memory_get_usage(true) - $mm, ') (', memory_get_usage(false) - $mf, ') (', sprintf("%.4f", (microtime(true) - $m) * 1000), ')', PHP_EOL;
        } else {
            echo '[FAILED]', PHP_EOL;
        }
    }

Usage Example

Exemplo n.º 1
0
                        $class->setUp();
                    }
                    $class->{$methodName}();
                }
            }
            echo '[OK]', ' (', memory_get_usage(true), ') (', memory_get_usage(false), ')', PHP_EOL;
        } else {
            echo '[FAILED]', PHP_EOL;
        }
    }
}
if (PHP_OS == 'Linux') {
    if (isset($_SERVER['LOGNAME']) && $_SERVER['LOGNAME'] == 'gutierrezandresfelipe') {
        chdir('/home/gutierrezandresfelipe/cphalcon');
    }
}
if (!extension_loaded('phalcon')) {
    throw new Exception("Sorry, but phalcon extension is not loaded");
}
try {
    if (isset($_SERVER['argv'][1])) {
        echo $_SERVER['argv'][1], PHP_EOL;
        $file = $_SERVER['argv'][1];
        require $_SERVER['argv'][1];
        PHPUnit_Framework_TestCase::main('Phalcon\\Test\\Url\\UnitTest');
    }
} catch (Exception $e) {
    echo $e->getMessage(), PHP_EOL;
    echo $e->getTraceAsString(), PHP_EOL;
    //print_r($e->getTrace());
}
All Usage Examples Of PHPUnit_Framework_TestCase::main