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


PHP PHPUnit_TextUI_TestRunner::getTest方法代码示例

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


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

示例1: main

 public function main()
 {
     if (!is_dir(realpath($this->testdirectory))) {
         throw new BuildException("NativePHPUnitTask requires a Test Directory path given, '" . $this->testdirectory . "' given.");
     }
     set_include_path(realpath($this->testdirectory) . PATH_SEPARATOR . get_include_path());
     $printer = new NativePhpunitPrinter();
     $arguments = array('configuration' => $this->configuration, 'coverageClover' => $this->coverageClover, 'junitLogfile' => $this->junitlogfile, 'printer' => $printer);
     require_once "PHPUnit/TextUI/TestRunner.php";
     $runner = new PHPUnit_TextUI_TestRunner();
     $suite = $runner->getTest($this->test, $this->testfile, true);
     try {
         $result = $runner->doRun($suite, $arguments);
         /* @var $result PHPUnit_Framework_TestResult */
         if ($this->haltonfailure && $result->failureCount() > 0 || $this->haltonerror && $result->errorCount() > 0) {
             throw new BuildException("PHPUnit: " . $result->failureCount() . " Failures and " . $result->errorCount() . " Errors, " . "last failure message: " . $printer->getMessages());
         }
         $this->log("PHPUnit Success: " . count($result->passed()) . " tests passed, no " . "failures (" . $result->skippedCount() . " skipped, " . $result->notImplementedCount() . " not implemented)");
         // Hudson for example doesn't like the backslash in class names
         if (file_exists($this->coverageClover)) {
             $this->log("Generated Clover Coverage XML to: " . $this->coverageClover);
             $content = file_get_contents($this->coverageClover);
             $content = str_replace("\\", ".", $content);
             file_put_contents($this->coverageClover, $content);
             unset($content);
         }
     } catch (\Exception $e) {
         throw new BuildException("NativePhpunitTask failed: " . $e->getMessage());
     }
 }
开发者ID:alcaeus,项目名称:mongodb-odm,代码行数:30,代码来源:NativePhpunitTask.php

示例2: main

 /**
  * @access public
  * @static
  */
 public static function main()
 {
     $arguments = self::handleArguments();
     $runner = new PHPUnit_TextUI_TestRunner();
     if (is_object($arguments['test']) && $arguments['test'] instanceof PHPUnit_Framework_Test) {
         $suite = $arguments['test'];
     } else {
         $suite = $runner->getTest($arguments['test'], $arguments['testFile'], $arguments['syntaxCheck']);
     }
     if ($suite->testAt(0) instanceof PHPUnit_Framework_Warning && strpos($suite->testAt(0)->getMessage(), 'No tests found in class') !== FALSE) {
         $skeleton = new PHPUnit_Util_Skeleton($arguments['test'], $arguments['testFile']);
         $result = $skeleton->generate(TRUE);
         if (!$result['incomplete']) {
             eval(str_replace(array('<?php', '?>'), '', $result['code']));
             $suite = new PHPUnit_Framework_TestSuite($arguments['test'] . 'Test');
         }
     }
     try {
         $result = $runner->doRun($suite, $arguments);
     } catch (Exception $e) {
         throw new RuntimeException('Could not create and run test suite: ' . $e->getMessage());
     }
     if ($result->wasSuccessful()) {
         exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
     } else {
         if ($result->errorCount() > 0) {
             exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
         } else {
             exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
         }
     }
 }
开发者ID:ahmedadham88,项目名称:enhanced-social-network,代码行数:36,代码来源:Command.php

示例3: indexAction

 /**
  *
  */
 public function indexAction()
 {
     $argv = $this->getRequest()->getServer('argv');
     $test_to_run = isset($argv[3]) ? $argv[3] : Const_Tests::RUN_ALL_TESTS;
     $test_to_run = str_replace('_', '/', $test_to_run);
     foreach (Core_Files::listFiles(cfg()->tests_path) as $test) {
         if (!strstr($test, $test_to_run . '.php') && $test_to_run != Const_Tests::RUN_ALL_TESTS) {
             continue;
         }
         $class_path = str_replace(cfg()->tests_path, '', $test);
         $class_path_frag = explode('/', $class_path);
         $class_path_frag = array_map("ucfirst", $class_path_frag);
         $class_path_frag[count($class_path_frag) - 1] = str_replace('.php', '', $class_path_frag[count($class_path_frag) - 1]);
         $class = implode('_', $class_path_frag);
         $class_name = 'Tests_' . $class . 'File';
         echo '--------------------------------------' . PHP_EOL;
         echo 'Running test: ' . $class_name . PHP_EOL;
         echo '--------------------------------------' . PHP_EOL;
         $phpunit = new PHPUnit_TextUI_TestRunner();
         $phpunit->run($phpunit->getTest($class_name, $test), array('colors' => 'auto'));
         if ($test_to_run != Const_Tests::RUN_ALL_TESTS) {
             die;
         }
         echo PHP_EOL . PHP_EOL;
     }
     die;
 }
开发者ID:bozhich,项目名称:PHP-on-Rails,代码行数:30,代码来源:Index.php

示例4: getTest

 public function getTest($suiteClassName, $suiteClassFile = '', $suffixes = '')
 {
     $cacheKey = $this->getCacheKey($suiteClassName, $suiteClassFile, $suffixes);
     if (isset(self::$loaderCache[$cacheKey])) {
         return self::$loaderCache[$cacheKey];
     }
     $cacheContent = parent::getTest($suiteClassName, $suiteClassFile, $suffixes);
     self::$loaderCache[$cacheKey] = $cacheContent;
     return $cacheContent;
 }
开发者ID:julianseeger,项目名称:php-real-coverage,代码行数:10,代码来源:MultirunRunner.php

示例5: suite

 /**
  * TestSuite
  */
 public static function suite()
 {
     $suite = new PHPUnit_Framework_TestSuite('sfReplicaThumbnailPlugin');
     // Replica tests
     $suite->addTestFile(DIR_SF_REPLICA . '/lib/vendor/Replica/test/AllTests.php');
     PHPUnit_Util_Filter::removeDirectoryFromWhitelist(DIR_SF_REPLICA . '/lib/vendor');
     // Plugin tests
     $runner = new PHPUnit_TextUI_TestRunner(new PHPUnit_Runner_StandardTestSuiteLoader());
     $suite->addTest($runner->getTest(dirname(__FILE__) . '/unit'));
     return $suite;
 }
开发者ID:pycmam,项目名称:sfReplicaThumbnailPlugin,代码行数:14,代码来源:AllTests.php

示例6: execute

 /**
  * Execute the Command
  *
  * @access protected
  * @param InputInterface $input
  * @param OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!file_exists(\Skeleton\Test\Config::$test_directory)) {
         $output->writeln('<error>Config::$test_directory is not set to a valid directory</error>');
         return 1;
     }
     $directory = \Skeleton\Test\Config::$test_directory;
     $phpunit = new \PHPUnit_TextUI_TestRunner();
     $printer = new \PrettyResultPrinter\Printer();
     $test_results = $phpunit->run($phpunit->getTest($directory, '', '.php'), ['colors' => 'always', 'verbose' => true, 'debug' => false, 'tap' => true, 'printer' => $printer]);
 }
开发者ID:tigron,项目名称:skeleton-test,代码行数:18,代码来源:all.php

示例7: main

 /**
  */
 public static function main($exit = TRUE)
 {
     $arguments = self::handleArguments();
     $runner = new PHPUnit_TextUI_TestRunner();
     if (is_object($arguments['test']) && $arguments['test'] instanceof PHPUnit_Framework_Test) {
         $suite = $arguments['test'];
     } else {
         $suite = $runner->getTest($arguments['test'], $arguments['testFile'], $arguments['syntaxCheck']);
     }
     if ($suite->testAt(0) instanceof PHPUnit_Framework_Warning && strpos($suite->testAt(0)->getMessage(), 'No tests found in class') !== FALSE) {
         $message = $suite->testAt(0)->getMessage();
         $start = strpos($message, '"') + 1;
         $end = strpos($message, '"', $start);
         $className = substr($message, $start, $end - $start);
         require_once 'PHPUnit/Util/Skeleton/Test.php';
         $skeleton = new PHPUnit_Util_Skeleton_Test($className, $arguments['testFile']);
         $result = $skeleton->generate(TRUE);
         if (!$result['incomplete']) {
             eval(str_replace(array('<?php', '?>'), '', $result['code']));
             $suite = new PHPUnit_Framework_TestSuite($arguments['test'] . 'Test');
         }
     }
     if ($arguments['listGroups']) {
         PHPUnit_TextUI_TestRunner::printVersionString();
         print "Available test group(s):\n";
         $groups = $suite->getGroups();
         sort($groups);
         foreach ($groups as $group) {
             print " - {$group}\n";
         }
         exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
     }
     try {
         $result = $runner->doRun($suite, $arguments);
     } catch (Exception $e) {
         throw new RuntimeException('Could not create and run test suite: ' . $e->getMessage());
     }
     if ($exit) {
         if ($result->wasSuccessful()) {
             exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
         } else {
             if ($result->errorCount() > 0) {
                 exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
             } else {
                 exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
             }
         }
     }
 }
开发者ID:amptools-net,项目名称:midori-php,代码行数:51,代码来源:Command.php

示例8: main

 public static function main()
 {
     $options = Console_Getopt::getopt($_SERVER['argv'], '', array('wait'));
     if (PEAR::isError($options)) {
         // ...
         exit;
     }
     $test = isset($options[1][0]) ? $options[1][0] : false;
     $wait = isset($options[0][0][0]) ? true : false;
     if ($test) {
         $testRunner = new PHPUnit_TextUI_TestRunner();
         try {
             $result = $testRunner->doRun($testRunner->getTest($test), $wait);
         } catch (Exception $e) {
             // ...
         }
     } else {
         // ...
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:20,代码来源:TestRunner.php

示例9: run

 /**
  * @param array   $argv
  * @param boolean $exit
  */
 public function run(array $argv, $exit = TRUE)
 {
     $this->handleArguments($argv);
     $runner = new PHPUnit_TextUI_TestRunner($this->arguments['loader']);
     if (is_object($this->arguments['test']) && $this->arguments['test'] instanceof PHPUnit_Framework_Test) {
         $suite = $this->arguments['test'];
     } else {
         $suite = $runner->getTest($this->arguments['test'], $this->arguments['testFile'], $this->arguments['syntaxCheck']);
     }
     if (count($suite) == 0) {
         $skeleton = new PHPUnit_Util_Skeleton_Test($suite->getName(), $this->arguments['testFile']);
         $result = $skeleton->generate(TRUE);
         if (!$result['incomplete']) {
             eval(str_replace(array('<?php', '?>'), '', $result['code']));
             $suite = new PHPUnit_Framework_TestSuite($this->arguments['test'] . 'Test');
         }
     }
     if ($this->arguments['listGroups']) {
         PHPUnit_TextUI_TestRunner::printVersionString();
         print "Available test group(s):\n";
         $groups = $suite->getGroups();
         sort($groups);
         foreach ($groups as $group) {
             print " - {$group}\n";
         }
         exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
     }
     unset($this->arguments['test']);
     unset($this->arguments['testFile']);
     try {
         $result = $runner->doRun($suite, $this->arguments);
     } catch (PHPUnit_Framework_Exception $e) {
         print $e->getMessage() . "\n";
     }
     if ($exit) {
         if (isset($result) && $result->wasSuccessful()) {
             exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
         } else {
             if (!isset($result) || $result->errorCount() > 0) {
                 exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
             } else {
                 exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
             }
         }
     }
 }
开发者ID:johncrenshaw,项目名称:phpunit,代码行数:50,代码来源:Command.php

示例10: execute

 public function execute($config_group = 'default')
 {
     ini_set('memory_limit', '512M');
     $this->_get_phpunit_options($config_group);
     require_once Kohana::find_file('vendor', 'PHPUnit/Util/Filter');
     require_once Kohana::find_file('vendor', 'PHPUnit/Framework/TestSuite');
     require_once Kohana::find_file('vendor', 'PHPUnit/TextUI/TestRunner');
     $this->_whitelist();
     $this->_blacklist();
     // We want all warnings so PHPUnit can take care of them.
     error_reporting(E_ALL | E_STRICT);
     // Hand control of errors and exceptions to PHPUnit
     restore_exception_handler();
     restore_error_handler();
     // Turn off the output biffer.
     ob_end_flush();
     //define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
     $this->_get_test_suite();
     $arguments = $this->_phpunit_options;
     $runner = new PHPUnit_TextUI_TestRunner();
     if (is_object($arguments['test']) and $arguments['test'] instanceof PHPUnit_Framework_Test) {
         $suite = $arguments['test'];
     } else {
         $suite = $runner->getTest($arguments['test'], $arguments['testFile'], $arguments['syntaxCheck']);
     }
     if ($suite->testAt(0) instanceof PHPUnit_Framework_Warning and strpos($suite->testAt(0)->getMessage(), 'No tests found in class') !== FALSE) {
         $message = $suite->testAt(0)->getMessage();
         $start = strpos($message, '"') + 1;
         $end = strpos($message, '"', $start);
         $className = substr($message, $start, $end - $start);
         require Kohana::find_file('vendor', 'PHPUnit/Util/Skeleton/Test');
         $skeleton = new PHPUnit_Util_Skeleton_Test($className, $arguments['testFile']);
         $result = $skeleton->generate(TRUE);
         if (!$result['incomplete']) {
             eval(str_replace(array('<?php', '?>'), '', $result['code']));
             $suite = new PHPUnit_Framework_TestSuite($arguments['test'] . 'Test');
         }
     }
     if ($arguments['listGroups']) {
         PHPUnit_TextUI_TestRunner::printVersionString();
         print "Available test group(s):\n";
         $groups = $suite->getGroups();
         sort($groups);
         foreach ($groups as $group) {
             print " - {$group}\n";
         }
         exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
     }
     try {
         $result = $runner->doRun($suite, $arguments);
     } catch (Exception $e) {
         throw new RuntimeException('Could not create and run test suite: ' . $e->getMessage());
     }
     if ($result->wasSuccessful()) {
         exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
     } else {
         if ($result->errorCount() > 0) {
             exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
         } else {
             exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
         }
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:63,代码来源:PHPUnit.php


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