当前位置: 首页>>代码示例>>PHP>>正文


PHP TestCase::collect方法代码示例

本文整理汇总了PHP中TestCase::collect方法的典型用法代码示例。如果您正苦于以下问题:PHP TestCase::collect方法的具体用法?PHP TestCase::collect怎么用?PHP TestCase::collect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestCase的用法示例。


在下文中一共展示了TestCase::collect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:JanVoracek,项目名称:nette,代码行数:88,代码来源:TestRunner.php


注:本文中的TestCase::collect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。