NamePrettifier.php in Zircon Profile 8
File
vendor/phpunit/phpunit/src/Util/TestDox/NamePrettifier.php
View source
<?php
class PHPUnit_Util_TestDox_NamePrettifier {
protected $prefix = 'Test';
protected $suffix = 'Test';
protected $strings = array();
public function prettifyTestClass($name) {
$title = $name;
if ($this->suffix !== null && $this->suffix == substr($name, -1 * strlen($this->suffix))) {
$title = substr($title, 0, strripos($title, $this->suffix));
}
if ($this->prefix !== null && $this->prefix == substr($name, 0, strlen($this->prefix))) {
$title = substr($title, strlen($this->prefix));
}
if (substr($title, 0, 1) == '\\') {
$title = substr($title, 1);
}
return $title;
}
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;
}
elseif ($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;
}
public function setPrefix($prefix) {
$this->prefix = $prefix;
}
public function setSuffix($suffix) {
$this->suffix = $suffix;
}
}