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


PHP PHPUnit_Framework_TestSuite::setBackupGlobals方法代码示例

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


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

示例1: createAndPerform

 private function createAndPerform($filename, $test_suite_function, array $args = array())
 {
     $suite = new PHPUnit_Framework_TestSuite();
     $suite->addTestFile($filename);
     $suite->setBackupGlobals($this->backupGlobals);
     $suite->setBackupStaticAttributes($this->backupStaticAttributes);
     $result = call_user_func_array(array($suite, $test_suite_function), $args);
     unset($suite);
     return $result;
 }
开发者ID:TheOnlyMerlin,项目名称:phpunit-extensions,代码行数:10,代码来源:FileSystemTestSuite.php

示例2: run

 public function run(rex_test_locator $locator, $colors = false)
 {
     $suite = new PHPUnit_Framework_TestSuite();
     // disable backup of globals, since we have some rex_sql objectes referenced from variables in global space.
     // PDOStatements are not allowed to be serialized
     $suite->setBackupGlobals(false);
     $suite->addTestFiles($locator->getIterator());
     rex_error_handler::unregister();
     $runner = new PHPUnit_TextUI_TestRunner();
     $backtrace = debug_backtrace(false);
     array_unshift($backtrace, ['file' => __FILE__, 'line' => __LINE__ + 3]);
     $runner->setPrinter(new rex_tests_result_printer($backtrace, $colors));
     $result = $runner->doRun($suite);
     rex_error_handler::register();
     return $result;
 }
开发者ID:staabm,项目名称:redaxo,代码行数:16,代码来源:test_runner.php

示例3: _run_tests

 private function _run_tests($classes, $classname = '')
 {
     $suite = new PHPUnit_Framework_TestSuite();
     // Turn off BackUpGlobal until https://github.com/sebastianbergmann/phpunit/issues/451 is fixed
     $suite->setBackupGlobals(false);
     foreach ($classes as $testcase) {
         if (!$classname or strtolower($testcase) === strtolower($classname)) {
             $suite->addTestSuite($testcase);
         }
     }
     $result = new PHPUnit_Framework_TestResult();
     require_once 'PHPUnit/TextUI/ResultPrinter.php';
     $this->printer = new WPUnitCommandResultsPrinter();
     $result->addListener($this->printer);
     return array($suite->run($result), $this->printer);
 }
开发者ID:humanmade,项目名称:hm-dev,代码行数:16,代码来源:hm-dev.wp-cli.test.php

示例4: run

	public function run()
	{
		$result = "";
		
		foreach($this->files as $oneDirectory => $testCollection)
		{
			$suite = new PHPUnit_Framework_TestSuite();
			$suite->setBackupGlobals(false);
			$suite->setName($oneDirectory);
			$this->includeCases($testCollection, $suite);
			$this->suite->addTestSuite($suite);
		}
		
		if($this->includeCoverage)
		{
			$this->importCodeCoverage();
			$this->setCodeCoverageIgnores();
		}
		
		$this->suite->run($this->result);
		$xml = new SimpleXMLElement($this->listener->getXML());
		$casesReport = new HTMLReport();
	   	$result .= $casesReport->report($xml);
	   	
		if($this->includeCoverage)
		{
			$CodeCoverage = $this->result->getCodeCoverage();
			$coverageReport = new CodeCoverageReport();
			$result .= $coverageReport->report($CodeCoverage);
			
			//$writer = new PHP_CodeCoverage_Report_HTML;
			//$writer->process($CodeCoverage, dirname(__FILE__).'/tmp/');
		}
		
		$this->report = $result;
	}
开发者ID:ramielrowe,项目名称:Radford-Reservation-System,代码行数:36,代码来源:TestRunner.php

示例5: main

 /**
  * The main entry point
  *
  * @throws BuildException
  */
 public function main()
 {
     if ($this->codecoverage && !extension_loaded('xdebug')) {
         throw new Exception("PHPUnitTask depends on Xdebug being installed to gather code coverage information.");
     }
     $this->loadPHPUnit();
     $suite = new PHPUnit_Framework_TestSuite('AllTests');
     if ($this->configuration) {
         $arguments = $this->handlePHPUnitConfiguration($this->configuration);
         if ($arguments['backupGlobals'] === false) {
             $suite->setBackupGlobals(false);
         }
         if ($arguments['backupStaticAttributes'] === true) {
             $suite->setBackupStaticAttributes(true);
         }
     }
     if ($this->printsummary) {
         $fe = new FormatterElement();
         $fe->setParent($this);
         $fe->setType("summary");
         $fe->setUseFile(false);
         $this->formatters[] = $fe;
     }
     $autoloadSave = spl_autoload_functions();
     if ($this->bootstrap) {
         require $this->bootstrap;
     }
     foreach ($this->batchtests as $batchTest) {
         $this->appendBatchTestToTestSuite($batchTest, $suite);
     }
     $this->execute($suite);
     if ($this->testfailed) {
         throw new BuildException($this->testfailuremessage);
     }
     $autoloadNew = spl_autoload_functions();
     foreach ($autoloadNew as $autoload) {
         spl_autoload_unregister($autoload);
     }
     foreach ($autoloadSave as $autoload) {
         spl_autoload_register($autoload);
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:47,代码来源:PHPUnitTask.php

示例6: doRun

 public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array())
 {
     $this->handleConfiguration($arguments);
     $this->processSuiteFilters($suite, $arguments);
     //      -----------------------
     //      get the tests that failed last time this same command (without rerun) was used
     //      from file and rerun them
     if (isset($arguments['rerun'])) {
         $cache = new CacheUtil();
         $key = $cache->generateKey($_SERVER['argv']);
         if ($cache->fileExists($key)) {
             $rerunnableTests = $cache->readCache($key);
             $suite = new PHPUnit_Framework_TestSuite();
             foreach ($rerunnableTests as $testName) {
                 $class = new ReflectionClass($testName['testClassName']);
                 $methodName = $testName['testMethodName'];
                 $test = $suite::createTest($class, $methodName);
                 $suite->addTest($test);
             }
         }
     }
     //      ------------------------------
     if (isset($arguments['bootstrap'])) {
         $GLOBALS['__PHPUNIT_BOOTSTRAP'] = $arguments['bootstrap'];
     }
     if ($arguments['backupGlobals'] === false) {
         $suite->setBackupGlobals(false);
     }
     if ($arguments['backupStaticAttributes'] === true) {
         $suite->setBackupStaticAttributes(true);
     }
     if ($arguments['disallowChangesToGlobalState'] === true) {
         $suite->setDisallowChangesToGlobalState(true);
     }
     if (is_integer($arguments['repeat'])) {
         $test = new PHPUnit_Extensions_RepeatedTest($suite, $arguments['repeat'], $arguments['processIsolation']);
         $suite = new PHPUnit_Framework_TestSuite();
         $suite->addTest($test);
     }
     $result = $this->createTestResult();
     if (!$arguments['convertErrorsToExceptions']) {
         $result->convertErrorsToExceptions(false);
     }
     if (!$arguments['convertNoticesToExceptions']) {
         PHPUnit_Framework_Error_Notice::$enabled = false;
     }
     if (!$arguments['convertWarningsToExceptions']) {
         PHPUnit_Framework_Error_Warning::$enabled = false;
     }
     if ($arguments['stopOnError']) {
         $result->stopOnError(true);
     }
     if ($arguments['stopOnFailure']) {
         $result->stopOnFailure(true);
     }
     if ($arguments['stopOnIncomplete']) {
         $result->stopOnIncomplete(true);
     }
     if ($arguments['stopOnRisky']) {
         $result->stopOnRisky(true);
     }
     if ($arguments['stopOnSkipped']) {
         $result->stopOnSkipped(true);
     }
     if ($this->printer === null) {
         if (isset($arguments['printer']) && $arguments['printer'] instanceof PHPUnit_Util_Printer) {
             $this->printer = $arguments['printer'];
         } else {
             $printerClass = 'PHPUnit_TextUI_ResultPrinter';
             if (isset($arguments['printer']) && is_string($arguments['printer']) && class_exists($arguments['printer'], false)) {
                 $class = new ReflectionClass($arguments['printer']);
                 if ($class->isSubclassOf('PHPUnit_TextUI_ResultPrinter')) {
                     $printerClass = $arguments['printer'];
                 }
             }
             $this->printer = new $printerClass(isset($arguments['stderr']) ? 'php://stderr' : null, $arguments['verbose'], $arguments['colors'], $arguments['debug'], $arguments['columns']);
         }
     }
     if (!$this->printer instanceof PHPUnit_Util_Log_TAP) {
         $this->printer->write(PHPUnit_Runner_Version::getVersionString() . "\n");
         self::$versionStringPrinted = true;
         if ($arguments['verbose']) {
             $this->printer->write(sprintf("\nRuntime:\t%s", $this->runtime->getNameWithVersion()));
             if ($this->runtime->hasXdebug()) {
                 $this->printer->write(sprintf(' with Xdebug %s', phpversion('xdebug')));
             }
             if (isset($arguments['configuration'])) {
                 $this->printer->write(sprintf("\nConfiguration:\t%s", $arguments['configuration']->getFilename()));
             }
             $this->printer->write("\n");
         }
         if (isset($arguments['deprecatedStrictModeOption'])) {
             print "Warning:\tDeprecated option \"--strict\" used\n";
         } elseif (isset($arguments['deprecatedStrictModeSetting'])) {
             print "Warning:\tDeprecated configuration setting \"strict\" used\n";
         }
         if (isset($arguments['deprecatedSeleniumConfiguration'])) {
             print "Warning:\tDeprecated configuration setting \"selenium\" used\n";
         }
     }
//.........这里部分代码省略.........
开发者ID:KarlCOG,项目名称:cog-phpunit-rerun,代码行数:101,代码来源:RerunTestRunner.php

示例7: run

 /**
  *  Runs supplied tests through PHPUnit.
  *
  *  @param array $tests        The directories/filenames containing the tests to be run through PHPUnit.
  *  @access public
  *  @return string
  */
 public function run($tests)
 {
     $suite = new PHPUnit_Framework_TestSuite();
     $suite->setBackupGlobals(false);
     $tests = $this->_parse_tests($tests);
     $original_classes = get_declared_classes();
     foreach ($tests as $test) {
         require $test;
     }
     $new_classes = get_declared_classes();
     $tests = array_diff($new_classes, $original_classes);
     foreach ($tests as $test) {
         if ($this->_classname_only($test) == 'PHPUnit_Framework_TestCase') {
             continue;
         }
         //  if ( stripos($this->_classname_only($test), 'test') !== false ) {
         // match phpunit automatic XML Test Suite -- only *Test classes
         if (substr($this->_classname_only($test), -4) == 'Test') {
             $suite->addTestSuite($test);
         }
     }
     $result = new PHPUnit_Framework_TestResult();
     $listener = new ArrayLog();
     $result->addListener($listener);
     // We need to temporarily turn off html_errors to ensure correct parsing of test debug output
     $html_errors = ini_get('html_errors');
     ob_start();
     ini_set('html_errors', 0);
     $suite->run($result);
     //$results = ob_get_contents();
     $results = ob_get_clean();
     ini_set('html_errors', $html_errors);
     //ob_end_clean();
     $results = $listener->getResults();
     //var_dump($results);
     //$results=json_decode($results);
     //var_dump($results);
     //var_dump(json_last_error());
     return $results;
 }
开发者ID:geekwright,项目名称:xvpu,代码行数:47,代码来源:VPU.php

示例8: runSuite

 private function runSuite(PHPUnit_Framework_TestSuite $suite)
 {
     if ($this->arguments['backupGlobals'] === false) {
         $suite->setBackupGlobals(false);
     }
     if ($this->arguments['backupStaticAttributes'] === true) {
         $suite->setBackupStaticAttributes(true);
     }
     if (is_integer($this->arguments['repeat'])) {
         $suite = new PHPUnit_Extensions_RepeatedTest($suite, $this->arguments['repeat'], $this->arguments['filter'], $this->arguments['groups'], $this->arguments['excludeGroups'], $this->arguments['processIsolation']);
     }
     $suite->run($this->result, $this->arguments['filter'], $this->arguments['groups'], $this->arguments['excludeGroups'], $this->arguments['processIsolation']);
 }
开发者ID:TheOnlyMerlin,项目名称:phpunit-extensions,代码行数:13,代码来源:Command.php

示例9: getTestSuite

 private function getTestSuite()
 {
     $suite = new \PHPUnit_Framework_TestSuite('All tests');
     // Note: This code won't work unless the backup globals option is disabled
     // see: http://www.phpunit.de/ticket/899
     $suite->setBackupGlobals(false);
     if ($this->files instanceof \PHPUnit_Framework_Test) {
         $suite->addTest($this->files);
     } else {
         $suite->addTestFiles($this->files);
     }
     return $suite;
 }
开发者ID:pago,项目名称:pantr,代码行数:13,代码来源:PHPUnit.php


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