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


PHP PHPUnit_Framework_TestResult类代码示例

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


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

示例1: parseTestSuite

 /**
  * Parse the test suite result
  *
  * @param \PHPUnit_Framework_TestResult $result
  * @return array<string,double|integer|array>
  */
 private function parseTestSuite($result)
 {
     $passed = 0;
     $error = 0;
     $failed = 0;
     $notImplemented = 0;
     $skipped = 0;
     $tests = [];
     foreach ($result->passed() as $key => $value) {
         $tests[] = $this->parseTest('passed', $key);
         $passed++;
     }
     foreach ($result->failures() as $obj) {
         $tests[] = $this->parseTest('failed', $obj);
         $failed++;
     }
     foreach ($result->skipped() as $obj) {
         $tests[] = $this->parseTest('skipped', $obj);
         $skipped++;
     }
     foreach ($result->notImplemented() as $obj) {
         $tests[] = $this->parseTest('notImplemented', $obj);
         $notImplemented++;
     }
     foreach ($result->errors() as $obj) {
         $tests[] = $this->parseTest('error', $obj);
         $error++;
     }
     usort($tests, function ($a, $b) {
         return strnatcmp($a['class'], $b['class']);
     });
     return ['time' => $result->time(), 'total' => count($tests), 'passed' => $passed, 'error' => $error, 'failed' => $failed, 'notImplemented' => $notImplemented, 'skipped' => $skipped, 'tests' => $tests];
 }
开发者ID:visualphpunit,项目名称:visualphpunit,代码行数:39,代码来源:Parser.php

示例2: process

 /**
  * @param  PHPUnit_Framework_TestResult $result
  */
 public function process(PHPUnit_Framework_TestResult $result, $minLines = 5, $minMatches = 70)
 {
     $codeCoverage = $result->getCodeCoverageInformation();
     $summary = PHPUnit_Util_CodeCoverage::getSummary($codeCoverage);
     $files = array_keys($summary);
     $metrics = new PHPUnit_Util_Metrics_Project($files, $summary, TRUE, $minLines, $minMatches);
     $document = new DOMDocument('1.0', 'UTF-8');
     $document->formatOutput = TRUE;
     $cpd = $document->createElement('pmd-cpd');
     $cpd->setAttribute('version', 'PHPUnit ' . PHPUnit_Runner_Version::id());
     $document->appendChild($cpd);
     foreach ($metrics->getDuplicates() as $duplicate) {
         $xmlDuplication = $cpd->appendChild($document->createElement('duplication'));
         $xmlDuplication->setAttribute('lines', $duplicate['numLines']);
         $xmlDuplication->setAttribute('tokens', $duplicate['numTokens']);
         $xmlFile = $xmlDuplication->appendChild($document->createElement('file'));
         $xmlFile->setAttribute('path', $duplicate['fileA']->getPath());
         $xmlFile->setAttribute('line', $duplicate['firstLineA']);
         $xmlFile = $xmlDuplication->appendChild($document->createElement('file'));
         $xmlFile->setAttribute('path', $duplicate['fileB']->getPath());
         $xmlFile->setAttribute('line', $duplicate['firstLineB']);
         $xmlDuplication->appendChild($document->createElement('codefragment', PHPUnit_Util_XML::prepareString(join('', array_slice($duplicate['fileA']->getLines(), $duplicate['firstLineA'] - 1, $duplicate['numLines'])))));
     }
     $this->write($document->saveXML());
     $this->flush();
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:29,代码来源:CPD.php

示例3: paintFooter

 /**
  * Paints the end of the test with a summary of
  * the passes and failures.
  *
  * @param PHPUnit_Framework_TestResult $result Result object
  *
  * @return void
  */
 public function paintFooter($result)
 {
     ob_end_flush();
     $colour = $result->failureCount() + $result->errorCount() > 0 ? "red" : "green";
     echo "</ul>\n";
     echo "<div style=\"";
     echo "padding: 8px; margin: 1em 0; background-color: {$colour}; color: white;";
     echo "\">";
     echo $result->count() - $result->skippedCount() . "/" . $result->count();
     echo " test methods complete:\n";
     echo "<strong>" . count($result->passed()) . "</strong> passes, ";
     echo "<strong>" . $result->failureCount() . "</strong> fails, ";
     echo "<strong>" . $this->numAssertions . "</strong> assertions and ";
     echo "<strong>" . $result->errorCount() . "</strong> exceptions.";
     echo "</div>\n";
     echo '<div style="padding:0 0 5px;">';
     echo '<p><strong>Time:</strong> ' . $result->time() . ' seconds</p>';
     echo '<p><strong>Peak memory:</strong> ' . number_format(memory_get_peak_usage()) . ' bytes</p>';
     echo $this->_paintLinks();
     echo '</div>';
     if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
         $coverage = $result->getCodeCoverage();
         if (method_exists($coverage, 'getSummary')) {
             $report = $coverage->getSummary();
             echo $this->paintCoverage($report);
         }
         if (method_exists($coverage, 'getData')) {
             $report = $coverage->getData();
             echo $this->paintCoverage($report);
         }
     }
     $this->paintDocumentEnd();
 }
开发者ID:Marcin11,项目名称:_mojePanstwo-Portal,代码行数:41,代码来源:CakeHtmlReporter.php

示例4: run

 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     $result->startTest($this);
     $this->testCase->runBare();
     $this->testCase->runBare();
     $result->endTest($this, 0);
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:7,代码来源:DoubleTestCase.php

示例5: bindToResult

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

示例6: createTestResult

/**
 * Create the test result and splice on our code coverage reports.
 *
 * @return PHPUnit_Framework_TestResult
 */
	protected function createTestResult() {
		$result = new PHPUnit_Framework_TestResult;
		if (isset($this->_params['codeCoverage'])) {
			$result->collectCodeCoverageInformation(true);
		}
		return $result;
    }
开发者ID:sherix88,项目名称:sigedu,代码行数:12,代码来源:CakeTestRunner.php

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

示例8: printResult

 /**
  * @param  \PHPUnit_Framework_TestResult $result
  */
 public function printResult(\PHPUnit_Framework_TestResult $result)
 {
     if (!$this->silent) {
         $this->printHeader($result->time());
         if ($result->errorCount() > 0) {
             $this->printErrors($result);
         }
         if ($result->failureCount() > 0) {
             if ($result->errorCount() > 0) {
                 print "\n--\n\n";
             }
             $this->printFailures($result);
         }
         if ($result->notImplementedCount() > 0) {
             if ($result->failureCount() > 0) {
                 print "\n--\n\n";
             }
             $this->printIncompletes($result);
         }
         if ($result->skippedCount() > 0) {
             if ($result->notImplementedCount() > 0) {
                 print "\n--\n\n";
             }
             $this->printSkipped($result);
         }
     }
     $this->printFooter($result);
 }
开发者ID:pago,项目名称:pantr,代码行数:31,代码来源:ResultPrinter.php

示例9: testAccessTestsAreSkippedWhenNoAclIsGiven

 public function testAccessTestsAreSkippedWhenNoAclIsGiven()
 {
     $suite = new PHPUnit_Framework_TestSuite();
     $suite->addTestSuite('AccessNavigationTestWithNoAcl');
     $suite->run($result = new PHPUnit_Framework_TestResult());
     $this->assertEquals(1, $result->skippedCount());
 }
开发者ID:JellyBellyDev,项目名称:zle,代码行数:7,代码来源:NavigationTestTest.php

示例10: run

 public function run(\PHPUnit_Framework_TestResult $result = null)
 {
     if (!$result) {
         $result = new \PHPUnit_Framework_TestResult();
     }
     $reader = new \Fulfil\Test\SpecTest\Reader();
     $tests = $reader->read($testFile);
     foreach ($tests as $test) {
         foreach ($test->data as $case) {
             \PHP_Timer::start();
             $result->startTest($this);
             try {
                 $ctx = new \Fulfil\Context();
                 $test->test->apply($case->in, $ctx);
                 $flat = $ctx->flatten();
             } catch (\Exception $ex) {
                 // yum
             }
             $time = \PHP_Timer::stop();
             try {
                 \PHPUnit_Framework_Assert::assertEquals($case->valid, $flat->valid);
             } catch (\PHPUnit_Framework_AssertionFailedError $e) {
                 $result->addFailure($this, $e, $time);
             }
             $result->endTest($this, $time);
         }
     }
     return $result;
 }
开发者ID:shabbyrobe,项目名称:fulfil,代码行数:29,代码来源:Old.php

示例11: run

 public function run(\PHPUnit_Framework_TestResult $result = null)
 {
     if (!$result) {
         $result = new \PHPUnit_Framework_TestResult();
     }
     $opt = null;
     \PHP_Timer::start();
     $result->startTest($this);
     try {
         $opt = \Docopt::handle($this->doc, array('argv' => $this->argv, 'exit' => false));
     } catch (\Exception $ex) {
         // gulp
     }
     $found = null;
     if ($opt) {
         if (!$opt->success) {
             $found = array('user-error');
         } elseif (empty($opt->args)) {
             $found = array();
         } else {
             $found = $opt->args;
         }
     }
     $time = \PHP_Timer::stop();
     try {
         \PHPUnit_Framework_Assert::assertEquals($this->expect, $found);
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         $result->addFailure($this, $e, $time);
     }
     $result->endTest($this, $time);
     return $result;
 }
开发者ID:rokite,项目名称:docopt.php,代码行数:32,代码来源:LanguageAgnosticTest.php

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

示例13: testAclIsTested

 public function testAclIsTested()
 {
     $suite = new PHPUnit_Framework_TestSuite();
     $suite->addTestSuite('FooAclTest');
     $suite->run($result = new PHPUnit_Framework_TestResult());
     $this->assertTrue($result->wasSuccessful(), 'Test should be run successfully');
     $this->assertEquals(2, $result->count());
 }
开发者ID:JellyBellyDev,项目名称:zle,代码行数:8,代码来源:AclTestTest.php

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

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


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