本文整理汇总了PHP中TestCase::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP TestCase::getName方法的具体用法?PHP TestCase::getName怎么用?PHP TestCase::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestCase
的用法示例。
在下文中一共展示了TestCase::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Runs all tests.
* @return void
*/
public function run()
{
$count = 0;
$failed = $passed = $skipped = array();
if (is_file($this->path)) {
$files = array($this->path);
} else {
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path));
}
exec($this->phpEnvironment . escapeshellarg($this->phpBinary) . ' -v', $output);
echo "{$output['0']} | {$this->phpBinary} {$this->phpArgs} {$this->phpEnvironment}\n\n";
foreach ($files as $entry) {
$entry = (string) $entry;
$info = pathinfo($entry);
if (!isset($info['extension']) || $info['extension'] !== 'phpt') {
continue;
}
$count++;
$testCase = new TestCase($entry);
$testCase->setPhp($this->phpBinary, $this->phpArgs, $this->phpEnvironment);
try {
$testCase->run();
$this->out('.');
$passed[] = array($testCase->getName(), $entry);
} catch (TestCaseException $e) {
if ($e->getCode() === TestCaseException::SKIPPED) {
$this->out('s');
$skipped[] = array($testCase->getName(), $entry, $e->getMessage());
} else {
$this->out('F');
$failed[] = array($testCase->getName(), $entry, $e->getMessage());
}
}
}
$failedCount = count($failed);
$skippedCount = count($skipped);
if ($this->displaySkipped && $skippedCount) {
$this->out("\n\nSkipped:\n");
foreach ($skipped as $i => $item) {
list($name, $file, $message) = $item;
$this->out("\n" . ($i + 1) . ") {$name}\n {$message}\n {$file}\n");
}
}
if (!$count) {
$this->out("No tests found\n");
} elseif ($failedCount) {
$this->out("\n\nFailures:\n");
foreach ($failed as $item) {
list($name, $file, $message) = $item;
$this->out("\n-> {$name}\n file: {$file}\n {$message}\n");
}
$this->out("\nFAILURES! ({$count} tests, {$failedCount} failures, {$skippedCount} skipped)\n");
return FALSE;
} else {
$this->out("\n\nOK ({$count} tests, {$skippedCount} skipped)\n");
}
return TRUE;
}
示例2: run
/**
* Runs all tests.
* @return void
*/
public function run()
{
$count = 0;
$failed = $passed = $skipped = array();
if (is_file($this->path)) {
$files = array($this->path);
} else {
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->path));
}
foreach ($files as $entry) {
$entry = (string) $entry;
$info = pathinfo($entry);
if (!isset($info['extension']) || $info['extension'] !== 'phpt') {
continue;
}
$count++;
$testCase = new TestCase($entry);
$testCase->setPhp($this->phpBinary, $this->phpArgs, $this->phpEnvironment);
try {
$testCase->run();
echo '.';
$passed[] = array($testCase->getName(), $entry);
} catch (TestCaseException $e) {
if ($e->getCode() === TestCaseException::SKIPPED) {
echo 's';
$skipped[] = array($testCase->getName(), $entry, $e->getMessage());
} else {
echo 'F';
$failed[] = array($testCase->getName(), $entry, $e->getMessage());
}
}
}
$failedCount = count($failed);
$skippedCount = count($skipped);
if ($this->displaySkipped && $skippedCount) {
echo "\n\nSkipped:\n";
foreach ($skipped as $i => $item) {
list($name, $file, $message) = $item;
echo "\n", ($i + 1), ") $name\n $message\n $file\n";
}
}
if (!$count) {
echo "No tests found\n";
} elseif ($failedCount) {
echo "\n\nFailures:\n";
foreach ($failed as $i => $item) {
list($name, $file, $message) = $item;
echo "\n", ($i + 1), ") $name\n $message\n $file\n";
}
echo "\nFAILURES! ($count tests, $failedCount failures, $skippedCount skipped)\n";
return FALSE;
} else {
echo "\n\nOK ($count tests, $skippedCount skipped)\n";
}
return TRUE;
}
示例3: run
/**
* Runs all tests.
* @return void
*/
public function run()
{
$count = 0;
$failed = $passed = $skipped = array();
exec($this->phpEnvironment . escapeshellarg($this->phpBinary) . ' -v', $output);
echo "{$output['0']} | {$this->phpBinary} {$this->phpArgs} {$this->phpEnvironment}\n\n";
$tests = array();
foreach ($this->paths as $path) {
if (is_file($path)) {
$files = array($path);
} else {
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
}
foreach ($files as $entry) {
$entry = (string) $entry;
$info = pathinfo($entry);
if (!isset($info['extension']) || $info['extension'] !== 'phpt') {
continue;
}
$tests[] = $entry;
}
}
$running = array();
while ($tests || $running) {
for ($i = count($running); $tests && $i < $this->jobs; $i++) {
$entry = array_shift($tests);
$count++;
$testCase = new TestCase($entry);
$testCase->setPhp($this->phpBinary, $this->phpArgs, $this->phpEnvironment);
try {
$parallel = $this->jobs > 1 && count($running) + count($tests) > 1;
$running[$entry] = $testCase->run(!$parallel);
} catch (TestCaseException $e) {
$this->out('s');
$skipped[] = array($testCase->getName(), $entry, $e->getMessage());
}
}
if (count($running) > 1) {
usleep(self::RUN_USLEEP);
// stream_select() doesn't work with proc_open()
}
foreach ($running as $entry => $testCase) {
if ($testCase->isReady()) {
try {
$testCase->collect();
$this->out('.');
$passed[] = array($testCase->getName(), $entry);
} catch (TestCaseException $e) {
if ($e->getCode() === TestCaseException::SKIPPED) {
$this->out('s');
$skipped[] = array($testCase->getName(), $entry, $e->getMessage());
} else {
$this->out('F');
$failed[] = array($testCase->getName(), $entry, $e->getMessage());
}
}
unset($running[$entry]);
}
}
}
$failedCount = count($failed);
$skippedCount = count($skipped);
if ($this->displaySkipped && $skippedCount) {
$this->out("\n\nSkipped:\n");
foreach ($skipped as $i => $item) {
list($name, $file, $message) = $item;
$this->out("\n" . ($i + 1) . ") {$name}\n {$message}\n {$file}\n");
}
}
if (!$count) {
$this->out("No tests found\n");
} elseif ($failedCount) {
$this->out("\n\nFailures:\n");
foreach ($failed as $item) {
list($name, $file, $message) = $item;
$this->out("\n-> {$name}\n file: {$file}\n {$message}\n");
}
$this->out("\nFAILURES! ({$count} tests, {$failedCount} failures, {$skippedCount} skipped)\n");
return FALSE;
} else {
$this->out("\n\nOK ({$count} tests, {$skippedCount} skipped)\n");
}
return TRUE;
}
示例4: writeStatus
/**
* Write status of currently executing test case
*
* @param unittest.TestCase case
*/
private function writeStatus(TestCase $case)
{
$this->cur++;
$perc = floor($this->cur / $this->sum * self::PROGRESS_WIDTH);
$this->out->writef("]2;Running: [%s%s] %s::%s()", str_repeat('*', $perc), str_repeat('-', self::PROGRESS_WIDTH - $perc), $case->getClassName(), $case->getName());
}