本文整理汇总了PHP中TestCase::setPhp方法的典型用法代码示例。如果您正苦于以下问题:PHP TestCase::setPhp方法的具体用法?PHP TestCase::setPhp怎么用?PHP TestCase::setPhp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestCase
的用法示例。
在下文中一共展示了TestCase::setPhp方法的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: run
/**
* Runs all tests.
* @return void
*/
public function run()
{
$count = 0;
$failed = $passed = $skipped = array();
exec($this->phpEnvironment . escapeshellarg($this->phpBinary) . ' -v', $output);
if (!isset($output[0])) {
return FALSE;
} elseif (strpos($output[0], 'cgi-fcgi') === FALSE) {
echo "Nette Framework Tests suite requires php-cgi, " . $this->phpBinary . " given.\n\n";
return FALSE;
}
echo $this->log("{$output['0']} | {$this->phpBinary} {$this->phpArgs} {$this->phpEnvironment}\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 $file) {
$file = (string) $file;
$info = pathinfo($file);
if (!isset($info['extension']) || $info['extension'] !== 'phpt') {
continue;
}
$tests[] = $file;
}
}
$running = array();
while ($tests || $running) {
for ($i = count($running); $tests && $i < $this->jobs; $i++) {
$file = array_shift($tests);
$count++;
$testCase = new TestCase($file);
$testCase->setPhp($this->phpBinary, $this->phpArgs, $this->phpEnvironment);
try {
$parallel = $this->jobs > 1 && count($running) + count($tests) > 1;
$running[$file] = $testCase->run(!$parallel);
} catch (TestCaseException $e) {
echo 's';
$skipped[] = $this->log($this->format('Skipped', $file, $testCase, $e));
}
}
if (count($running) > 1) {
usleep(self::RUN_USLEEP);
// stream_select() doesn't work with proc_open()
}
foreach ($running as $file => $testCase) {
if ($testCase->isReady()) {
try {
$testCase->collect();
echo '.';
$passed[] = array($testCase->getName(), $file);
} catch (TestCaseException $e) {
if ($e->getCode() === TestCaseException::SKIPPED) {
echo 's';
$skipped[] = $this->log($this->format('Skipped', $file, $testCase, $e));
} else {
echo 'F';
$failed[] = $this->log($this->format('FAILED', $file, $testCase, $e));
}
}
unset($running[$file]);
}
}
}
$failedCount = count($failed);
$skippedCount = count($skipped);
if ($this->displaySkipped) {
echo "\n", implode($skipped);
}
if (!$count) {
echo $this->log("No tests found\n");
} elseif ($failedCount) {
echo "\n", implode($failed);
echo $this->log("\nFAILURES! ({$count} tests, {$failedCount} failures, {$skippedCount} skipped)");
return FALSE;
} else {
echo $this->log("\n\nOK ({$count} tests, {$skippedCount} skipped)");
}
return TRUE;
}