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


PHP TestCase::run方法代码示例

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


在下文中一共展示了TestCase::run方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:kravco,项目名称:nette,代码行数:62,代码来源:TestRunner.php

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

示例3: run

 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     return parent::run($result);
 }
开发者ID:vjroby,项目名称:MarketTradeProcessor,代码行数:4,代码来源:EloquentMessageRepositoryTest.php

示例4: 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

示例5: testDoSomethingElse

    public function testDoSomethingElse()
    {
        $this->impl->testDoSomethingElse();
    }
}
$t = new LimeTest();
// @Before
$output = $t->mock('LimeOutputInterface', array('nice' => true));
$configuration = $t->stub('LimeConfiguration');
$configuration->getTestOutput()->returns($output);
$configuration->replay();
$test = new TestCase($configuration);
$output->reset();
$test->impl = $t->mock('Test');
// @Test: The methods setUp() and tearDown() are called before and after each test method
// fixtures
$test->impl->setUp();
$test->impl->testDoSomething();
$test->impl->tearDown();
$test->impl->setUp();
$test->impl->testDoSomethingElse();
$test->impl->tearDown();
$test->impl->replay();
// test
$test->run();
// @Test: The method names are converted to passed tests
$output->method('pass')->parameter(1)->is('Do something');
$output->method('pass')->parameter(1)->is('Do something else');
$output->replay();
// test
$test->run();
开发者ID:b00giZm,项目名称:lime,代码行数:31,代码来源:LimeTestCaseTest.php

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


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