public prettifyTestMethod ( string $name ) : string | ||
$name | string | |
리턴 | string |
public function prettifyTestMethod($name)
{
$buffer = '';
if (!is_string($name) || strlen($name) == 0) {
return $buffer;
}
$string = preg_replace('#\\d+$#', '', $name, -1, $count);
if (in_array($string, $this->strings)) {
$name = $string;
} else {
if ($count == 0) {
$this->strings[] = $string;
}
}
if (strpos($name, '_') !== FALSE) {
return str_replace('_', ' ', $name);
}
$max = strlen($name);
if (substr($name, 0, 4) == 'test') {
$offset = 4;
} else {
$offset = 0;
$name[0] = strtoupper($name[0]);
}
$wasNumeric = FALSE;
for ($i = $offset; $i < $max; $i++) {
if ($i > $offset && ord($name[$i]) >= 65 && ord($name[$i]) <= 90) {
$buffer .= ' ' . strtolower($name[$i]);
} else {
$isNumeric = is_numeric($name[$i]);
if (!$wasNumeric && $isNumeric) {
$buffer .= ' ';
$wasNumeric = TRUE;
}
if ($wasNumeric && !$isNumeric) {
$wasNumeric = FALSE;
}
$buffer .= $name[$i];
}
}
return $buffer;
}
/** * A test started. * * @param PHPUnit_Framework_Test $test */ public function startTest(PHPUnit_Framework_Test $test) { if ($test instanceof $this->testTypeOfInterest) { $class = get_class($test); if ($this->testClass != $class) { if ($this->testClass != '') { $this->doEndClass(); } $this->currentTestClassPrettified = $this->prettifier->prettifyTestClass($class); $this->startClass($class); $this->testClass = $class; $this->tests = array(); } $prettified = FALSE; if ($test instanceof PHPUnit_Framework_TestCase && !$test instanceof PHPUnit_Framework_Warning) { $annotations = $test->getAnnotations(); if (isset($annotations['method']['testdox'][0])) { $this->currentTestMethodPrettified = $annotations['method']['testdox'][0]; $prettified = TRUE; } } if (!$prettified) { $this->currentTestMethodPrettified = $this->prettifier->prettifyTestMethod($test->getName(FALSE)); } $this->testStatus = PHPUnit_Runner_BaseTestRunner::STATUS_PASSED; } }