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


PHP PHPUnit_Framework_TestResult::addListener方法代码示例

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


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

示例1: testEndEventsAreCounted

 /**
  * @covers PHPUnit_Framework_TestResult
  */
 public function testEndEventsAreCounted()
 {
     $this->result = new PHPUnit_Framework_TestResult();
     $listener = new BaseTestListenerSample();
     $this->result->addListener($listener);
     $test = new Success();
     $test->run($this->result);
     $this->assertEquals(1, $listener->endCount);
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:12,代码来源:BaseTestListenerTest.php

示例2: bindToResult

 public function bindToResult(\PHPUnit_Framework_TestResult $result)
 {
     if ($this->result !== $result) {
         $this->result = $result;
         $result->addListener($this);
     }
 }
开发者ID:magium,项目名称:magium,代码行数:7,代码来源:MasterListener.php

示例3: executeRun

 public function executeRun()
 {
     set_time_limit(0);
     $buffer = tempnam(sys_get_temp_dir(), 'phpunit');
     $listener = new PHPUnit_Util_Log_JSON($buffer);
     $testResult = new PHPUnit_Framework_TestResult();
     $testResult->addListener($listener);
     $path = str_replace('-', '/', $this->getRequestParameter('test'));
     $loader = new sfPhpunitProjectTestLoader($path);
     $loader->load();
     $loader->suite()->run($testResult);
     $result = '[' . str_replace('}{', '},{', file_get_contents($buffer)) . ']';
     $tests = array();
     foreach (json_decode($result) as $test) {
         if ('suiteStart' == $test->event) {
             continue;
         }
         if (!isset($tests[$test->suite])) {
             $tests[$test->suite]['methods'] = array();
             $tests[$test->suite]['status'] = 'pass';
         }
         $tests[$test->suite]['methods'][] = $test;
         if ('pass' != $test->status) {
             $tests[$test->suite]['status'] = 'fail';
         }
     }
     $this->result = $testResult;
     $this->tests = $tests;
     $this->path = $path;
 }
开发者ID:66Ton99,项目名称:sfPhpunitPlugin,代码行数:30,代码来源:sfPhpunitBaseActions.class.php

示例4: WebLauncher

 /**
  * Launches a test module for web inspection of results
  * @param string $module
  * @return boolean
  */
 function WebLauncher($module)
 {
     jf::$ErrorHandler->UnsetErrorHandler();
     $this->LoadFramework();
     self::$TestSuite = new \PHPUnit_Framework_TestSuite();
     self::$TestFiles[] = $this->ModuleFile($module);
     self::$TestSuite->addTestFile(self::$TestFiles[0]);
     $result = new \PHPUnit_Framework_TestResult();
     $listener = new TestListener();
     $result->addListener($listener);
     $Profiler = new Profiler();
     if (function_exists("xdebug_start_code_coverage")) {
         xdebug_start_code_coverage();
     }
     self::$TestSuite->run($result);
     if (function_exists("xdebug_start_code_coverage")) {
         $Coverage = xdebug_get_code_coverage();
     } else {
         $Coverage = null;
     }
     $Profiler->Stop();
     $listener->Finish();
     $this->OutputResult($result, $Profiler, $Coverage);
     return true;
 }
开发者ID:michalkoczwara,项目名称:WebGoatPHP,代码行数:30,代码来源:test.php

示例5: doEnhancedRun

 public function doEnhancedRun(\PHPUnit_Framework_Test $suite, \PHPUnit_Framework_TestResult $result, array $arguments = array())
 {
     $this->handleConfiguration($arguments);
     if (is_integer($arguments['repeat'])) {
         $suite = new \PHPUnit_Extensions_RepeatedTest($suite, $arguments['repeat'], $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
     }
     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['stopOnSkipped']) {
         $result->stopOnSkipped(TRUE);
     }
     if ($this->printer === NULL) {
         if (isset($arguments['printer']) && $arguments['printer'] instanceof \PHPUnit_Util_Printer) {
             $this->printer = $arguments['printer'];
         } else {
             $this->printer = new \Codeception\PHPUnit\ResultPrinter\UI(NULL, $arguments['verbose'], $arguments['colors'], $arguments['debug']);
         }
     }
     if (isset($arguments['report'])) {
         if ($arguments['report']) {
             $this->printer = new \Codeception\PHPUnit\ResultPrinter\Report();
         }
     }
     if (isset($arguments['html'])) {
         if ($arguments['html']) {
             $arguments['listeners'][] = new \Codeception\PHPUnit\ResultPrinter\HTML($arguments['html']);
         }
     }
     $arguments['listeners'][] = $this->printer;
     // clean up listeners between suites
     foreach ($arguments['listeners'] as $listener) {
         $result->removeListener($listener);
         $result->addListener($listener);
     }
     if ($arguments['strict']) {
         $result->strictMode(TRUE);
     }
     $suite->run($result, $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
     unset($suite);
     $result->flushListeners();
     return $result;
 }
开发者ID:nike-17,项目名称:Codeception,代码行数:58,代码来源:Runner.php

示例6:

 /**
  * Constructor
  *
  * @param PHPUnit_Framework_TestSuite $suite    The suite to test
  * @param PHPUnit_Framework_TestResult $result  Optional result object to use
  */
 function __construct(PHPUnit_Framework_TestSuite $suite, PHPUnit_Framework_TestResult $result = NULL)
 {
     if ($result === NULL) {
         $result = new PHPUnit_Framework_TestResult();
     }
     $result->addListener($this);
     $this->suite = $suite;
     $this->result = $result;
 }
开发者ID:laiello,项目名称:ko3,代码行数:15,代码来源:runner.php

示例7: run

 /**
  * Run a test
  */
 public function run(PHPUnit_Framework_TestSuite $suite)
 {
     $res = new PHPUnit_Framework_TestResult();
     if ($this->codecoverage) {
         $res->collectCodeCoverageInformation(TRUE);
     }
     $res->addListener($this);
     foreach ($this->formatters as $formatter) {
         $res->addListener($formatter);
     }
     /* Set PHPUnit error handler */
     if ($this->useCustomErrorHandler) {
         $oldErrorHandler = set_error_handler(array('PHPUnitTestRunner', 'handleError'), E_ALL | E_STRICT);
     }
     $suite->run($res, false, $this->groups, $this->excludeGroups);
     foreach ($this->formatters as $formatter) {
         $formatter->processResult($res);
     }
     /* Restore Phing error handler */
     if ($this->useCustomErrorHandler) {
         restore_error_handler();
     }
     if ($this->codecoverage) {
         $coverageInformation = $res->getCodeCoverageInformation();
         PHPUnit_Util_CodeCoverage::clearSummary();
         $summary = PHPUnit_Util_CodeCoverage::getSummary($coverageInformation);
         CoverageMerger::merge($this->project, $summary);
     }
     if ($res->errorCount() != 0) {
         $this->retCode = self::ERRORS;
     } else {
         if ($res->failureCount() != 0) {
             $this->retCode = self::FAILURES;
         } else {
             if ($res->notImplementedCount() != 0) {
                 $this->retCode = self::INCOMPLETES;
             } else {
                 if ($res->skippedCount() != 0) {
                     $this->retCode = self::SKIPPED;
                 }
             }
         }
     }
 }
开发者ID:halfer,项目名称:Meshing,代码行数:47,代码来源:PHPUnitTestRunner.php

示例8: run_tests

 protected function run_tests($tests, &$listener)
 {
     $suite = new PHPUnit_Framework_TestSuite('default');
     foreach ($tests as $case) {
         $suite->addTestSuite($case);
     }
     #return PHPUnit::run($suite);
     $result = new PHPUnit_Framework_TestResult();
     $result->addListener($listener);
     return $suite->run($result);
 }
开发者ID:rmccue,项目名称:Gorilla,代码行数:11,代码来源:Runner.php

示例9: doRun

 /**
  * Runs a test suite.
  *
  * @param           PHPUnit_Framework_Test $suite
  * @param  optional boolean                $wait
  * @return PHPUnit_Framework_TestResult
  * @access public
  */
 public function doRun(PHPUnit_Framework_Test $suite, $wait = false)
 {
     printf("PHPUnit %s by Sebastian Bergmann.\n\n", PHPUnit_Framework_Version);
     $result = new PHPUnit_Framework_TestResult();
     $result->addListener($this->fPrinter);
     $timer = new Benchmark_Timer();
     $timer->start();
     $suite->run($result);
     $timer->stop();
     $this->pause($wait);
     $this->fPrinter->printResult($result, $timer->timeElapsed());
     return $result;
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:21,代码来源:TestRunner.php

示例10: run

    /**
     * Main function - runs the tests and outputs HTML code
     *
     * @return void
     * @author Robert Lemke <robert@typo3.org>
     * @author Karsten Dambekalns <karsten@typo3.org>
     * @internal Preliminary solution - there surely will be nicer ways to implement a test runner
     */
    public function run()
    {
        $this->renderPageHeader();
        $this->renderTestForm();
        if (!empty($this->packageKey)) {
            $testcaseFileNamesAndPaths = $this->getTestcaseFilenames();
            if (count($testcaseFileNamesAndPaths) > 0) {
                $this->renderInfoAndProgressbar();
                $this->requireTestCaseFiles($testcaseFileNamesAndPaths);
                $testListener = new \F3\Testing\TestListener();
                $testListener->baseUri = $this->request->getBaseUri();
                $testResult = new \PHPUnit_Framework_TestResult();
                $testResult->addListener($testListener);
                $testResult->collectCodeCoverageInformation($this->collectCodeCoverage);
                $startTime = microtime(TRUE);
                foreach (get_declared_classes() as $className) {
                    if (substr($className, -4, 4) == 'Test') {
                        $class = new \ReflectionClass($className);
                        if ($class->isSubclassOf('PHPUnit_Framework_TestCase') && substr($className, 0, 8) !== 'PHPUnit_') {
                            $testSuite = new \PHPUnit_Framework_TestSuite($class);
                            $testSuite->run($testResult);
                        }
                    }
                }
                $endTime = microtime(TRUE);
                // Display test statistics:
                if ($testResult->wasSuccessful()) {
                    echo '<script type="text/javascript">document.getElementById("progress-bar").style.backgroundColor = "green";document.getElementById("progress-bar").style.backgroundImage = "none";</script>
						<h1 class="success">SUCCESS</h1>
						' . $testResult->count() . ' tests, ' . $testResult->failureCount() . ' failures, ' . $testResult->errorCount() . ' errors.
						</h1>';
                } else {
                    echo '
						<script>document.getElementById("progress-bar").style.backgroundColor = "red";document.getElementById("progress-bar").style.backgroundImage = "none";</script>
						<h1 class="failure">FAILURE</h1>
						' . $testResult->count() . ' tests, ' . $testResult->failureCount() . ' failures, ' . $testResult->errorCount() . ' errors.
					';
                }
                echo '<p>Peak memory usage was: ~' . floor(memory_get_peak_usage() / 1024 / 1024) . ' MByte.<br />';
                echo 'Test run took ' . round($endTime - $startTime, 4) . ' seconds.</p>';
                if ($this->collectCodeCoverage === TRUE) {
                    \F3\FLOW3\Utility\Files::emptyDirectoryRecursively($this->coverageOutputPath);
                    \PHPUnit_Util_Report::render($testResult, $this->coverageOutputPath);
                    echo '<a href="_Resources/CodeCoverageReport/index.html">See code coverage report...</a>';
                }
            } else {
                echo '<p>No testcase found. Did you specify the intended pattern?</p>';
            }
        }
        $this->renderPageFooter();
    }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:59,代码来源:TestRunnerWeb.php

示例11: run

 /**
  * Run a test
  */
 function run($test)
 {
     $res = new PHPUnit_Framework_TestResult();
     if ($this->codecoverage) {
         $res->collectCodeCoverageInformation(TRUE);
     }
     $res->addListener($this);
     foreach ($this->formatters as $formatter) {
         $res->addListener($formatter);
     }
     /* Set PHPUnit error handler */
     $oldErrorHandler = set_error_handler(array('PHPUnitTestRunner', 'handleError'), E_ALL | E_STRICT);
     $test->run($res, false, $this->groups, $this->excludeGroups);
     /* Restore Phing error handler */
     restore_error_handler();
     if ($this->codecoverage) {
         $coverageInformation = $res->getCodeCoverageInformation();
         foreach ($coverageInformation as $coverage_info) {
             CoverageMerger::merge($this->project, array($coverage_info['files']));
         }
     }
     if ($res->errorCount() != 0) {
         $this->retCode = self::ERRORS;
     } else {
         if ($res->failureCount() != 0) {
             $this->retCode = self::FAILURES;
         } else {
             if ($res->notImplementedCount() != 0) {
                 $this->retCode = self::INCOMPLETES;
             } else {
                 if ($res->skippedCount() != 0) {
                     $this->retCode = self::SKIPPED;
                 }
             }
         }
     }
 }
开发者ID:umesecke,项目名称:phing,代码行数:40,代码来源:PHPUnitTestRunner.php

示例12: _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

示例13: createTestResult

 /**
  * Create the test result and splice on our code coverage reports.
  *
  * @return PHPUnit_Framework_TestResult
  */
 protected function createTestResult()
 {
     $result = new PHPUnit_Framework_TestResult();
     $FixtureInjector = new FixtureInjector($this->_getFixtureManager(array()));
     $result->addListener($FixtureInjector);
     if (!empty($this->_params['codeCoverage'])) {
         if (method_exists($result, 'collectCodeCoverageInformation')) {
             $result->collectCodeCoverageInformation(true);
         }
         if (method_exists($result, 'setCodeCoverage')) {
             $Filter = new PHP_CodeCoverage_Filter();
             $Filter->addFileToBlacklist('systemlib.php');
             $result->setCodeCoverage(new PHP_CodeCoverage(null, $Filter));
         }
     }
     return $result;
 }
开发者ID:imsamurai,项目名称:cakephp-environment,代码行数:22,代码来源:CakeTestRunner.php

示例14: run

 public function run($name = null)
 {
     $tests = array();
     if (!isset($name)) {
         $tests = $this->testCases;
     } elseif (is_array($name)) {
         // run specified tests
     } elseif (is_string($name)) {
         // run test
         $tests[] = $name;
     }
     foreach ($tests as $name => $mixed) {
         if (is_numeric($name)) {
             $name = $mixed;
         }
         $name = strtolower($name);
         $path = $this->testCases[$name];
         require_once $path;
     }
     $testClasses = array();
     foreach (get_declared_classes() as $class) {
         if (stristr($class, 'Test') !== false && strpos($class, 'PHPUnit_') === false) {
             $testClasses[] = $class;
         }
     }
     $suite = new PHPUnit_Framework_TestSuite();
     foreach ($testClasses as $class) {
         if ($this->suite) {
             if (strcasecmp($this->suite, $class) == 0) {
                 $suite->addTestSuite($class);
             }
         } else {
             $suite->addTestSuite($class);
         }
     }
     $result = new PHPUnit_Framework_TestResult();
     require_once 'PHPUnit/Util/Log/JSON.php';
     $result->addListener(new PHPUnit_Util_Log_JSON());
     $this->suite = $suite;
     ob_start();
     $suite->run($result);
     $results = ob_get_contents();
     ob_end_clean();
     return $results;
 }
开发者ID:RandomSort,项目名称:PHPUnit-Test-Report,代码行数:45,代码来源:PHPUnit.php

示例15: run

 /**
  * Run a test
  */
 public function run(PHPUnit_Framework_TestSuite $suite)
 {
     $res = new PHPUnit_Framework_TestResult();
     if ($this->codecoverage) {
         $whitelist = CoverageMerger::getWhiteList($this->project);
         $this->codecoverage->filter()->addFilesToWhiteList($whitelist);
         $res->setCodeCoverage($this->codecoverage);
     }
     $res->addListener($this);
     foreach ($this->formatters as $formatter) {
         $res->addListener($formatter);
     }
     /* Set PHPUnit error handler */
     if ($this->useCustomErrorHandler) {
         $oldErrorHandler = set_error_handler(array($this, 'handleError'), E_ALL | E_STRICT);
     }
     $suite->run($res, false, $this->groups, $this->excludeGroups, $this->processIsolation);
     foreach ($this->formatters as $formatter) {
         $formatter->processResult($res);
     }
     /* Restore Phing error handler */
     if ($this->useCustomErrorHandler) {
         restore_error_handler();
     }
     if ($this->codecoverage) {
         CoverageMerger::merge($this->project, $this->codecoverage->getData());
     }
     if ($res->errorCount() != 0) {
         $this->retCode = self::ERRORS;
     } else {
         if ($res->failureCount() != 0) {
             $this->retCode = self::FAILURES;
         } else {
             if ($res->notImplementedCount() != 0) {
                 $this->retCode = self::INCOMPLETES;
             } else {
                 if ($res->skippedCount() != 0) {
                     $this->retCode = self::SKIPPED;
                 }
             }
         }
     }
 }
开发者ID:eduardobenito10,项目名称:jenkins-php-quickstart,代码行数:46,代码来源:PHPUnitTestRunner.php


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