本文整理汇总了PHP中Test::current_class方法的典型用法代码示例。如果您正苦于以下问题:PHP Test::current_class方法的具体用法?PHP Test::current_class怎么用?PHP Test::current_class使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Test
的用法示例。
在下文中一共展示了Test::current_class方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify
/**
* テストを実行する
* @param string $class クラス名
* @param strgin $method メソッド名
*/
public static final function verify($class, $method = null, $block_name = null)
{
if (!class_exists($class) && Rhaco::import($class)) {
$pos = strrpos($class, ".");
$class = substr($class, $pos !== false ? $pos + 1 : $pos);
}
$ref = Info::reflection($class);
self::$current_file = $ref->path;
self::$current_class = $ref->name;
foreach ($ref->methods as $name => $m) {
self::$current_method = $name;
if ($method === null || $method == $name) {
self::execute($m, $block_name);
}
}
self::$current_class = null;
self::$current_file = null;
self::$current_method = null;
return new self();
}
示例2: verify
/**
* テストを実行する
* @param string $class_path パッケージパス
* @param string $method メソッド名
* @param string $block_name ブロック名
*/
public static final function verify($class_path, $method = null, $block_name = null)
{
if (is_file(self::path(str_replace(".", "/", $class_path) . "_test.php"))) {
$file = App::path(str_replace(".", "/", $class_path) . ".php");
$test = self::path(str_replace(".", "/", $class_path) . "_test.php");
if (is_file($file)) {
if (empty($block_name)) {
include $test;
} else {
$read = File::read($test);
$block = $init = "";
foreach (preg_split("/(#\\s*[\\w_]+)\n/", $read, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE) as $v) {
if ($v[0][0] == "#") {
$block = trim(substr($v[0], 1));
} else {
if (empty($block)) {
$init = $v[0];
} else {
$blocks[$block] = $v;
}
}
}
if (isset($blocks[$block_name])) {
self::$current_map_test_file = $test;
self::$current_file = $test;
$line = sizeof(explode("\n", substr($read, 0, $blocks[$block_name][1]))) - sizeof(explode("\n", $init));
ob_start();
eval("?>" . $init . str_repeat("\n", $line) . $blocks[$block_name][0]);
$result = ob_get_clean();
if (preg_match("/(Parse|Fatal) error:.+/", $result, $match)) {
throw new ErrorException($match[0]);
}
self::$current_map_test_file = null;
}
}
} else {
throw new InvalidArgumentException($file . " not found (" . $test . ")");
}
} else {
$class = !class_exists($class_path) && !interface_exists($class_path) ? Lib::import($class_path) : $class_path;
$cname = str_replace(".", "_", $class_path);
$ref = new InfoClass($class);
$is_setup = false;
$is_teardown = false;
if (method_exists($ref->name(), "__test_setup__")) {
$m = new ReflectionMethod($ref->name(), "__test_setup__");
$is_setup = $m->isStatic();
}
if (method_exists($ref->name(), "__test_teardown__")) {
$m = new ReflectionMethod($ref->name(), "__test_teardown__");
$is_teardown = $m->isStatic();
}
self::$current_file = $ref->path();
self::$current_class = $ref->name();
foreach (array_merge(array("class" => $ref->class_method()), $ref->self_methods_all()) as $name => $m) {
self::$current_method = $name;
if ($method === null || $method == $name) {
self::execute($m, $block_name, $class, $is_setup, $is_teardown);
}
}
self::$current_class = null;
self::$current_file = null;
self::$current_method = null;
}
return new self();
}