/**
* @param null|string $testName
* @return string
*/
protected function _getPrefix($testName = null)
{
if (null === $testName) {
$objects = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
foreach ($objects as $object) {
if (isset($object['object']) && $object['object'] instanceof \PHPUnit_Framework_TestCase) {
$testName = $object['class'] . '_' . $object['function'];
break;
}
}
}
$testName = str_replace(__NAMESPACE__ . '\\', '', $testName);
$testName = Str::splitCamelCase($testName, '_', true);
$testName = preg_replace('/^test_/', '', $testName);
$testName = preg_replace('/_test$/', '', $testName);
$testName = str_replace('_test_test_', '_', $testName);
$testName = str_replace(array('/', '\\', '_', '-'), '', $testName);
$testName = strtolower($testName);
if (!$testName) {
$testName = uniqid('', true);
$testName = str_replace('.', '', $testName);
}
return $testName;
}