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


PHP Environment\Runtime类代码示例

本文整理汇总了PHP中SebastianBergmann\Environment\Runtime的典型用法代码示例。如果您正苦于以下问题:PHP Runtime类的具体用法?PHP Runtime怎么用?PHP Runtime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __construct

 /**
  * @param PHPUnit_Runner_TestSuiteLoader $loader
  * @param PHP_CodeCoverage_Filter        $filter
  * @since Method available since Release 3.4.0
  */
 public function __construct(PHPUnit_Runner_TestSuiteLoader $loader = null, PHP_CodeCoverage_Filter $filter = null)
 {
     if ($filter === null) {
         $filter = new PHP_CodeCoverage_Filter();
     }
     $this->codeCoverageFilter = $filter;
     $this->loader = $loader;
     $runtime = new Runtime();
     $this->canCollectCodeCoverage = $runtime->canCollectCodeCoverage();
 }
开发者ID:kpaxer,项目名称:shcms,代码行数:15,代码来源:TestRunner.php

示例2: __construct

 /**
  * Constructor.
  *
  * @param  PHP_CodeCoverage_Driver    $driver
  * @param  PHP_CodeCoverage_Filter    $filter
  * @throws PHP_CodeCoverage_Exception
  */
 public function __construct(PHP_CodeCoverage_Driver $driver = null, PHP_CodeCoverage_Filter $filter = null)
 {
     if ($driver === null) {
         $runtime = new Runtime();
         if (!$runtime->hasXdebug()) {
             throw new PHP_CodeCoverage_Exception('No code coverage driver available');
         }
         $driver = new PHP_CodeCoverage_Driver_Xdebug();
     }
     if ($filter === null) {
         $filter = new PHP_CodeCoverage_Filter();
     }
     $this->driver = $driver;
     $this->filter = $filter;
 }
开发者ID:iwillhappy1314,项目名称:laravel-admin,代码行数:22,代码来源:CodeCoverage.php

示例3: startJob

 /**
  * @param Job $job
  * @return bool
  */
 public function startJob(Job $job)
 {
     $this->pool->add($job);
     try {
         $runtime = new Runtime();
         $job->start($runtime->getBinary());
     } catch (ForkException $e) {
         $this->pool->remove($job);
         $job->startTest();
         $job->addError($e);
         $job->endTest();
         return false;
     }
     $job->startTest();
     return true;
 }
开发者ID:munkie,项目名称:karzer,代码行数:20,代码来源:JobRunner.php

示例4: runJob

 /**
  * Runs a single job (PHP code) using a separate PHP process.
  *
  * @param string $job
  * @param array  $settings
  *
  * @return array
  *
  * @throws PHPUnit_Framework_Exception
  */
 public function runJob($job, array $settings = [])
 {
     $runtime = new Runtime();
     $process = proc_open($runtime->getBinary() . $this->settingsToParameters($settings), [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes);
     if (!is_resource($process)) {
         throw new PHPUnit_Framework_Exception('Unable to spawn worker process');
     }
     $this->process($pipes[0], $job);
     fclose($pipes[0]);
     $stdout = stream_get_contents($pipes[1]);
     fclose($pipes[1]);
     $stderr = stream_get_contents($pipes[2]);
     fclose($pipes[2]);
     proc_close($process);
     $this->cleanup();
     return ['stdout' => $stdout, 'stderr' => $stderr];
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:27,代码来源:Default.php

示例5: runJob

 /**
  *
  * {@inheritdoc} Reading from STDOUT or STDERR hangs forever on Windows if the output is
  *               too large.
  *              
  * @see https://bugs.php.net/bug.php?id=51800
  */
 public function runJob($job, array $settings = array())
 {
     $runtime = new Runtime();
     if (false === ($stdout_handle = tmpfile())) {
         throw new PHPUnit_Framework_Exception('A temporary file could not be created; verify that your TEMP environment variable is writable');
     }
     $process = proc_open($runtime->getBinary() . $this->settingsToParameters($settings), array(0 => array('pipe', 'r'), 1 => $stdout_handle, 2 => array('pipe', 'w')), $pipes);
     if (!is_resource($process)) {
         throw new PHPUnit_Framework_Exception('Unable to spawn worker process');
     }
     $this->process($pipes[0], $job);
     fclose($pipes[0]);
     $stderr = stream_get_contents($pipes[2]);
     fclose($pipes[2]);
     proc_close($process);
     rewind($stdout_handle);
     $stdout = stream_get_contents($stdout_handle);
     fclose($stdout_handle);
     $this->cleanup();
     return array('stdout' => $stdout, 'stderr' => $stderr);
 }
开发者ID:sapwoo,项目名称:portfolio,代码行数:28,代码来源:Windows.php

示例6: testVendorUrlCanBeRetrieved

 /**
  * @covers \SebastianBergmann\Environment\Runtime::getVendorUrl
  *
  * @uses   \SebastianBergmann\Environment\Runtime::isHHVM
  */
 public function testVendorUrlCanBeRetrieved()
 {
     $this->assertInternalType('string', $this->env->getVendorUrl());
 }
开发者ID:baardbaard,项目名称:bb-twitterfeed,代码行数:9,代码来源:RuntimeTest.php

示例7: setCommonTemplateVariables

 /**
  * @param Text_Template                $template
  * @param PHP_CodeCoverage_Report_Node $node
  */
 protected function setCommonTemplateVariables(Text_Template $template, PHP_CodeCoverage_Report_Node $node)
 {
     $runtime = new Runtime();
     $template->setVar(array('id' => $node->getId(), 'full_path' => $node->getPath(), 'path_to_root' => $this->getPathToRoot($node), 'breadcrumbs' => $this->getBreadcrumbs($node), 'date' => $this->date, 'version' => $this->version, 'runtime_name' => $runtime->getName(), 'runtime_version' => $runtime->getVersion(), 'runtime_link' => $runtime->getVendorUrl(), 'generator' => $this->generator, 'low_upper_bound' => $this->lowUpperBound, 'high_lower_bound' => $this->highLowerBound));
 }
开发者ID:MachiavelliQ,项目名称:www,代码行数:9,代码来源:Renderer.php

示例8: selectDriver

 /**
  * @return PHP_CodeCoverage_Driver
  * @throws PHP_CodeCoverage_RuntimeException
  */
 private function selectDriver()
 {
     $runtime = new Runtime();
     if (!$runtime->canCollectCodeCoverage()) {
         throw new PHP_CodeCoverage_RuntimeException('No code coverage driver available');
     }
     if ($runtime->isHHVM()) {
         return new PHP_CodeCoverage_Driver_HHVM();
     } elseif ($runtime->isPHPDBG()) {
         return new PHP_CodeCoverage_Driver_PHPDBG();
     } else {
         return new PHP_CodeCoverage_Driver_Xdebug();
     }
 }
开发者ID:xiaobudongzhang,项目名称:php-code-coverage,代码行数:18,代码来源:CodeCoverage.php

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

示例10: __construct

 /**
  * Constructor.
  *
  * @param  PHP_CodeCoverage_Driver $driver
  * @param  PHP_CodeCoverage_Filter $filter
  * @throws PHP_CodeCoverage_Exception
  */
 public function __construct(PHP_CodeCoverage_Driver $driver = null, PHP_CodeCoverage_Filter $filter = null)
 {
     if ($filter === null) {
         $filter = new PHP_CodeCoverage_Filter();
     }
     $parser = new PHP_CodeCoverage_Parser();
     if ($driver === null) {
         $runtime = new Runtime();
         if ($runtime->isHHVM()) {
             $driver = new PHP_CodeCoverage_Driver_HHVM($filter, $parser);
         } elseif ($runtime->hasXdebug()) {
             $driver = new PHP_CodeCoverage_Driver_Xdebug($filter, $parser);
         } else {
             throw new PHP_CodeCoverage_Exception('No code coverage driver available');
         }
     }
     $this->driver = $driver;
     $this->filter = $filter;
     $this->parser = $parser;
 }
开发者ID:limweb,项目名称:webappservice,代码行数:27,代码来源:CodeCoverage.php

示例11: run

 /**
  * Runs a TestCase.
  *
  * @param PHPUnit_Framework_Test $test
  */
 public function run(PHPUnit_Framework_Test $test)
 {
     PHPUnit_Framework_Assert::resetCount();
     $error = false;
     $failure = false;
     $incomplete = false;
     $risky = false;
     $skipped = false;
     $this->startTest($test);
     $errorHandlerSet = false;
     if ($this->convertErrorsToExceptions) {
         $oldErrorHandler = set_error_handler(array('PHPUnit_Util_ErrorHandler', 'handleError'), E_ALL | E_STRICT);
         if ($oldErrorHandler === null) {
             $errorHandlerSet = true;
         } else {
             restore_error_handler();
         }
     }
     $runtime = new Runtime();
     $canCollectCodeCoverage = $runtime->canCollectCodeCoverage();
     $collectCodeCoverage = $canCollectCodeCoverage && $this->codeCoverage !== null && !$test instanceof PHPUnit_Extensions_SeleniumTestCase && !$test instanceof PHPUnit_Framework_Warning;
     if ($collectCodeCoverage) {
         // We need to blacklist test source files when no whitelist is used.
         if (!$this->codeCoverage->filter()->hasWhitelist()) {
             $classes = $this->getHierarchy(get_class($test), true);
             foreach ($classes as $class) {
                 $this->codeCoverage->filter()->addFileToBlacklist($class->getFileName());
             }
         }
         $this->codeCoverage->start($test);
     }
     PHP_Timer::start();
     try {
         if (!$test instanceof PHPUnit_Framework_Warning && $this->beStrictAboutTestSize && extension_loaded('pcntl') && class_exists('PHP_Invoker')) {
             switch ($test->getSize()) {
                 case PHPUnit_Util_Test::SMALL:
                     $_timeout = $this->timeoutForSmallTests;
                     break;
                 case PHPUnit_Util_Test::MEDIUM:
                     $_timeout = $this->timeoutForMediumTests;
                     break;
                 case PHPUnit_Util_Test::LARGE:
                     $_timeout = $this->timeoutForLargeTests;
                     break;
             }
             $invoker = new PHP_Invoker();
             $invoker->invoke(array($test, 'runBare'), array(), $_timeout);
         } else {
             $test->runBare();
         }
     } catch (PHPUnit_Framework_AssertionFailedError $e) {
         $failure = true;
         if ($e instanceof PHPUnit_Framework_RiskyTestError) {
             $risky = true;
         } elseif ($e instanceof PHPUnit_Framework_IncompleteTestError) {
             $incomplete = true;
         } elseif ($e instanceof PHPUnit_Framework_SkippedTestError) {
             $skipped = true;
         }
     } catch (Exception $e) {
         $error = true;
     }
     $time = PHP_Timer::stop();
     $test->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
     if ($this->beStrictAboutTestsThatDoNotTestAnything && $test->getNumAssertions() == 0) {
         $risky = true;
     }
     if ($collectCodeCoverage) {
         $append = !$risky && !$incomplete && !$skipped;
         $linesToBeCovered = array();
         $linesToBeUsed = array();
         if ($append && $test instanceof PHPUnit_Framework_TestCase) {
             $linesToBeCovered = PHPUnit_Util_Test::getLinesToBeCovered(get_class($test), $test->getName());
             $linesToBeUsed = PHPUnit_Util_Test::getLinesToBeUsed(get_class($test), $test->getName());
         }
         try {
             $this->codeCoverage->stop($append, $linesToBeCovered, $linesToBeUsed);
         } catch (PHP_CodeCoverage_Exception_UnintentionallyCoveredCode $cce) {
             $this->addFailure($test, new PHPUnit_Framework_UnintentionallyCoveredCodeError('This test executed code that is not listed as code to be covered or used:' . PHP_EOL . $cce->getMessage()), $time);
         } catch (PHPUnit_Framework_InvalidCoversTargetException $cce) {
             $this->addFailure($test, new PHPUnit_Framework_InvalidCoversTargetError($cce->getMessage()), $time);
         } catch (PHP_CodeCoverage_Exception $cce) {
             $error = true;
             if (!isset($e)) {
                 $e = $cce;
             }
         }
     }
     if ($errorHandlerSet === true) {
         restore_error_handler();
     }
     if ($error === true) {
         $this->addError($test, $e, $time);
     } elseif ($failure === true) {
         $this->addFailure($test, $e, $time);
//.........这里部分代码省略.........
开发者ID:JJHdez,项目名称:OpenTpmW,代码行数:101,代码来源:TestResult.php

示例12: getRuntimeString

 /**
  * @return string
  */
 private function getRuntimeString()
 {
     $runtime = new Runtime();
     $buffer = sprintf('<a href="%s" target="_top">%s %s</a>', $runtime->getVendorUrl(), $runtime->getName(), $runtime->getVersion());
     if ($runtime->hasXdebug() && !$runtime->hasPHPDBGCodeCoverage()) {
         $buffer .= sprintf(' with <a href="https://xdebug.org/">Xdebug %s</a>', phpversion('xdebug'));
     }
     return $buffer;
 }
开发者ID:nsandlin,项目名称:linepig,代码行数:12,代码来源:Renderer.php

示例13: getPhpBinary

 private function getPhpBinary()
 {
     $runtime = new Runtime();
     return $runtime->getBinary();
 }
开发者ID:pahenrus,项目名称:child-process,代码行数:5,代码来源:AbstractProcessTest.php

示例14: getCommand

 /**
  * Returns the command based into the configurations.
  *
  * @param array $settings
  *
  * @return string
  */
 public function getCommand(array $settings)
 {
     $command = $this->runtime->getBinary();
     $command .= $this->settingsToParameters($settings);
     if (true === $this->stderrRedirection) {
         $command .= ' 2>&1';
     }
     return $command;
 }
开发者ID:noikiy,项目名称:phpunit,代码行数:16,代码来源:PHP.php

示例15: getCommand

 /**
  * Returns the command based into the configurations.
  *
  * @param array $settings
  *
  * @return string
  */
 public function getCommand(array $settings)
 {
     $command = $this->runtime->getBinary();
     $command .= $this->settingsToParameters($settings);
     if ('phpdbg' === PHP_SAPI) {
         $command .= ' -qrr ' . escapeshellarg(__DIR__ . '/PHP/eval-stdin.php');
     }
     if (true === $this->stderrRedirection) {
         $command .= ' 2>&1';
     }
     return $command;
 }
开发者ID:radmen,项目名称:phpunit,代码行数:19,代码来源:PHP.php


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