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


PHP PHPUnit_Framework_TestResult::addFailure方法代码示例

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


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

示例1: runStep

 public function runStep(Step $step)
 {
     $result = null;
     $this->fire(Events::STEP_BEFORE, new StepEvent($this, $step));
     try {
         $result = $step->run($this->moduleContainer);
     } catch (ConditionalAssertionFailed $f) {
         $this->testResult->addFailure(clone $this, $f, $this->testResult->time());
     } catch (\Exception $e) {
         $this->fire(Events::STEP_AFTER, new StepEvent($this, $step));
         throw $e;
     }
     $this->fire(Events::STEP_AFTER, new StepEvent($this, $step));
     return $result;
 }
开发者ID:codeception,项目名称:base,代码行数:15,代码来源:Actor.php

示例2: run

 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     PHPUnit_Framework_Assert::resetCount();
     if ($result === NULL) {
         $result = new PHPUnit_Framework_TestResult();
     }
     $this->suite->publishTestArticles();
     // Add articles needed by the tests.
     $backend = new ParserTestSuiteBackend();
     $result->startTest($this);
     // Support the transition to PHPUnit 3.5 where PHPUnit_Util_Timer is replaced with PHP_Timer
     if (class_exists('PHP_Timer')) {
         PHP_Timer::start();
     } else {
         PHPUnit_Util_Timer::start();
     }
     $r = false;
     try {
         # Run the test.
         # On failure, the subclassed backend will throw an exception with
         # the details.
         $pt = new PHPUnitParserTest();
         $r = $pt->runTest($this->test['test'], $this->test['input'], $this->test['result'], $this->test['options'], $this->test['config']);
     } catch (PHPUnit_Framework_AssertionFailedError $e) {
         // PHPUnit_Util_Timer -> PHP_Timer support (see above)
         if (class_exists('PHP_Timer')) {
             $result->addFailure($this, $e, PHP_Timer::stop());
         } else {
             $result->addFailure($this, $e, PHPUnit_Util_Timer::stop());
         }
     } catch (Exception $e) {
         // PHPUnit_Util_Timer -> PHP_Timer support (see above)
         if (class_exists('PHP_Timer')) {
             $result->addFailure($this, $e, PHP_Timer::stop());
         } else {
             $result->addFailure($this, $e, PHPUnit_Util_Timer::stop());
         }
     }
     // PHPUnit_Util_Timer -> PHP_Timer support (see above)
     if (class_exists('PHP_Timer')) {
         $result->endTest($this, PHP_Timer::stop());
     } else {
         $result->endTest($this, PHPUnit_Util_Timer::stop());
     }
     $backend->recorder->record($this->test['test'], $r);
     $this->addToAssertionCount(PHPUnit_Framework_Assert::getCount());
     return $result;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:48,代码来源:ParserHelpers.php

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

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

示例5: run

 /**
  * Runs a test and collects its result in a TestResult instance.
  *
  * @param  PHPUnit_Framework_TestResult $result
  * @return PHPUnit_Framework_TestResult
  */
 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     $sections = $this->parse();
     $code = $this->render($sections['FILE']);
     if ($result === null) {
         $result = new PHPUnit_Framework_TestResult();
     }
     $php = PHPUnit_Util_PHP::factory();
     $skip = false;
     $time = 0;
     $settings = $this->settings;
     $result->startTest($this);
     if (isset($sections['INI'])) {
         $settings = array_merge($settings, $this->parseIniSection($sections['INI']));
     }
     if (isset($sections['SKIPIF'])) {
         $jobResult = $php->runJob($sections['SKIPIF'], $settings);
         if (!strncasecmp('skip', ltrim($jobResult['stdout']), 4)) {
             if (preg_match('/^\\s*skip\\s*(.+)\\s*/i', $jobResult['stdout'], $message)) {
                 $message = substr($message[1], 2);
             } else {
                 $message = '';
             }
             $result->addFailure($this, new PHPUnit_Framework_SkippedTestError($message), 0);
             $skip = true;
         }
     }
     if (!$skip) {
         PHP_Timer::start();
         $jobResult = $php->runJob($code, $settings);
         $time = PHP_Timer::stop();
         if (isset($sections['EXPECT'])) {
             $assertion = 'assertEquals';
             $expected = $sections['EXPECT'];
         } else {
             $assertion = 'assertStringMatchesFormat';
             $expected = $sections['EXPECTF'];
         }
         $output = preg_replace('/\\r\\n/', "\n", trim($jobResult['stdout']));
         $expected = preg_replace('/\\r\\n/', "\n", trim($expected));
         try {
             PHPUnit_Framework_Assert::$assertion($expected, $output);
         } catch (PHPUnit_Framework_AssertionFailedError $e) {
             $result->addFailure($this, $e, $time);
         } catch (Throwable $t) {
             $result->addError($this, $t, $time);
         } catch (Exception $e) {
             $result->addError($this, $e, $time);
         }
     }
     $result->endTest($this, $time);
     return $result;
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:59,代码来源:PhptTestCase.php

示例6: run

 /**
  * Runs a test and collects its result in a TestResult instance.
  *
  * @param  \PHPUnit_Framework_TestResult $result
  * @return \PHPUnit_Framework_TestResult
  */
 public function run(\PHPUnit_Framework_TestResult $result = null)
 {
     if ($result === null) {
         $result = new \PHPUnit_Framework_TestResult();
     }
     $zept = $this->zeptHydrator->zeptToDto($this->filename, $this->settings);
     $result->startTest($this);
     if ($zept->isSkip()) {
         $result->addFailure($this, new \PHPUnit_Framework_SkippedTestError($zept->getSkipMessage()), 0);
     } else {
         $result = $this->doRun($result, $zept);
     }
     return $result;
 }
开发者ID:fezfez,项目名称:zephir-testcase,代码行数:20,代码来源:ZeptTestCase.php

示例7: processChildResult

 /**
  * Processes the TestResult object from an isolated process.
  *
  * @param PHPUnit_Framework_TestCase   $test
  * @param PHPUnit_Framework_TestResult $result
  * @param string                       $stdout
  * @param string                       $stderr
  * @since Method available since Release 3.5.0
  */
 protected function processChildResult(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result, $stdout, $stderr)
 {
     if (!empty($stderr)) {
         $time = 0;
         $result->addError($test, new RuntimeException(trim($stderr)), $time);
     } else {
         $childResult = @unserialize($stdout);
         if ($childResult !== FALSE) {
             if (!empty($childResult['output'])) {
                 print $childResult['output'];
             }
             $test->setResult($childResult['testResult']);
             $test->addToAssertionCount($childResult['numAssertions']);
             $childResult = $childResult['result'];
             if ($result->getCollectCodeCoverageInformation()) {
                 $codeCoverageInformation = $childResult->getRawCodeCoverageInformation();
                 if (isset($codeCoverageInformation[0]) && is_array($codeCoverageInformation[0])) {
                     $result->getCodeCoverage()->append($codeCoverageInformation[0], $test);
                 }
             }
             $time = $childResult->time();
             $notImplemented = $childResult->notImplemented();
             $skipped = $childResult->skipped();
             $errors = $childResult->errors();
             $failures = $childResult->failures();
             if (!empty($notImplemented)) {
                 $result->addError($test, $notImplemented[0]->thrownException(), $time);
             } else {
                 if (!empty($skipped)) {
                     $result->addError($test, $skipped[0]->thrownException(), $time);
                 } else {
                     if (!empty($errors)) {
                         $result->addError($test, $errors[0]->thrownException(), $time);
                     } else {
                         if (!empty($failures)) {
                             $result->addFailure($test, $failures[0]->thrownException(), $time);
                         }
                     }
                 }
             }
         } else {
             $time = 0;
             $result->addError($test, new RuntimeException(trim($stdout)), $time);
         }
     }
     $result->endTest($test, $time);
 }
开发者ID:qcodo,项目名称:qcodo,代码行数:56,代码来源:PHP.php

示例8: run

 /**
  * Runs a test and collects its result in a TestResult instance.
  *
  * @param  PHPUnit_Framework_TestResult $result
  * @param  array                        $options
  * @return PHPUnit_Framework_TestResult
  */
 public function run(PHPUnit_Framework_TestResult $result = NULL, array $options = array())
 {
     if (!class_exists('PEAR_RunTest', FALSE)) {
         throw new PHPUnit_Framework_Exception('Class PEAR_RunTest not found.');
     }
     if (isset($GLOBALS['_PEAR_destructor_object_list']) && is_array($GLOBALS['_PEAR_destructor_object_list']) && !empty($GLOBALS['_PEAR_destructor_object_list'])) {
         $pearDestructorObjectListCount = count($GLOBALS['_PEAR_destructor_object_list']);
     } else {
         $pearDestructorObjectListCount = 0;
     }
     if ($result === NULL) {
         $result = new PHPUnit_Framework_TestResult();
     }
     $coverage = $result->getCollectCodeCoverageInformation();
     $options = array_merge($options, $this->options);
     if (!isset($options['include_path'])) {
         $options['include_path'] = get_include_path();
     }
     if ($coverage) {
         $options['coverage'] = TRUE;
     } else {
         $options['coverage'] = FALSE;
     }
     $currentErrorReporting = error_reporting(E_ERROR | E_WARNING | E_PARSE);
     $runner = new PEAR_RunTest(new PHPUnit_Extensions_PhptTestCase_Logger(), $options);
     if ($coverage) {
         $runner->xdebug_loaded = TRUE;
     } else {
         $runner->xdebug_loaded = FALSE;
     }
     $result->startTest($this);
     PHP_Timer::start();
     $buffer = $runner->run($this->filename, $options);
     $time = PHP_Timer::stop();
     error_reporting($currentErrorReporting);
     $base = basename($this->filename);
     $path = dirname($this->filename);
     $coverageFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.xdebug', $base);
     $diffFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.diff', $base);
     $expFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.exp', $base);
     $logFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.log', $base);
     $outFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.out', $base);
     $phpFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.php', $base);
     if (is_object($buffer) && $buffer instanceof PEAR_Error) {
         $result->addError($this, new PHPUnit_Framework_Exception($buffer->getMessage()), $time);
     } else {
         if ($buffer == 'SKIPPED') {
             $result->addFailure($this, new PHPUnit_Framework_SkippedTestError(), 0);
         } else {
             if ($buffer != 'PASSED') {
                 $expContent = file_get_contents($expFile);
                 $outContent = file_get_contents($outFile);
                 $result->addFailure($this, new PHPUnit_Framework_ComparisonFailure($expContent, $outContent, $expContent, $outContent), $time);
             }
         }
     }
     foreach (array($diffFile, $expFile, $logFile, $phpFile, $outFile) as $file) {
         if (file_exists($file)) {
             unlink($file);
         }
     }
     if ($coverage && file_exists($coverageFile)) {
         eval('$coverageData = ' . file_get_contents($coverageFile) . ';');
         unset($coverageData[$phpFile]);
         $result->getCodeCoverage()->append($coverageData, $this);
         unlink($coverageFile);
     }
     $result->endTest($this, $time);
     // Do not invoke PEAR's destructor mechanism for PHP 4
     // as it raises an E_STRICT.
     if ($pearDestructorObjectListCount == 0) {
         unset($GLOBALS['_PEAR_destructor_object_list']);
     } else {
         $count = count($GLOBALS['_PEAR_destructor_object_list']) - $pearDestructorObjectListCount;
         for ($i = 0; $i < $count; $i++) {
             array_pop($GLOBALS['_PEAR_destructor_object_list']);
         }
     }
     return $result;
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:87,代码来源:PhptTestCase.php

示例9: processChildResult

 /**
  * Processes the TestResult object from an isolated process.
  *
  * @param PHPUnit_Framework_TestCase   $test
  * @param PHPUnit_Framework_TestResult $result
  * @param string                       $stdout
  * @param string                       $stderr
  * @since Method available since Release 3.5.0
  */
 protected function processChildResult(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result, $stdout, $stderr)
 {
     $time = 0;
     if (!empty($stderr)) {
         $result->addError($test, new PHPUnit_Framework_Exception(trim($stderr)), $time);
     } else {
         set_error_handler(function ($errno, $errstr, $errfile, $errline) {
             throw new ErrorException($errstr, $errno, $errno, $errfile, $errline);
         });
         try {
             $childResult = unserialize($stdout);
             restore_error_handler();
         } catch (ErrorException $e) {
             restore_error_handler();
             $childResult = FALSE;
             $result->addError($test, new PHPUnit_Framework_Exception(trim($stdout), 0, $e), $time);
         }
         if ($childResult !== FALSE) {
             if (!empty($childResult['output'])) {
                 print $childResult['output'];
             }
             $test->setResult($childResult['testResult']);
             $test->addToAssertionCount($childResult['numAssertions']);
             $childResult = $childResult['result'];
             if ($result->getCollectCodeCoverageInformation()) {
                 $result->getCodeCoverage()->merge($childResult->getCodeCoverage());
             }
             $time = $childResult->time();
             $notImplemented = $childResult->notImplemented();
             $skipped = $childResult->skipped();
             $errors = $childResult->errors();
             $failures = $childResult->failures();
             if (!empty($notImplemented)) {
                 $result->addError($test, $this->getException($notImplemented[0]), $time);
             } else {
                 if (!empty($skipped)) {
                     $result->addError($test, $this->getException($skipped[0]), $time);
                 } else {
                     if (!empty($errors)) {
                         $result->addError($test, $this->getException($errors[0]), $time);
                     } else {
                         if (!empty($failures)) {
                             $result->addFailure($test, $this->getException($failures[0]), $time);
                         }
                     }
                 }
             }
         }
     }
     $result->endTest($test, $time);
 }
开发者ID:samurailens,项目名称:sop,代码行数:60,代码来源:PHP.php

示例10: processChildResult

 /**
  * Processes the TestResult object from an isolated process.
  *
  * @param PHPUnit_Framework_Test $test        	
  * @param PHPUnit_Framework_TestResult $result        	
  * @param string $stdout        	
  * @param string $stderr        	
  * @since Method available since Release 3.5.0
  */
 private function processChildResult(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result, $stdout, $stderr)
 {
     $time = 0;
     if (!empty($stderr)) {
         $result->addError($test, new PHPUnit_Framework_Exception(trim($stderr)), $time);
     } else {
         set_error_handler(function ($errno, $errstr, $errfile, $errline) {
             throw new ErrorException($errstr, $errno, $errno, $errfile, $errline);
         });
         try {
             if (strpos($stdout, "#!/usr/bin/env php\n") === 0) {
                 $stdout = substr($stdout, 19);
             }
             $childResult = unserialize(str_replace("#!/usr/bin/env php\n", '', $stdout));
             restore_error_handler();
         } catch (ErrorException $e) {
             restore_error_handler();
             $childResult = false;
             $result->addError($test, new PHPUnit_Framework_Exception(trim($stdout), 0, $e), $time);
         }
         if ($childResult !== false) {
             if (!empty($childResult['output'])) {
                 $output = $childResult['output'];
             }
             $test->setResult($childResult['testResult']);
             $test->addToAssertionCount($childResult['numAssertions']);
             $childResult = $childResult['result'];
             if ($result->getCollectCodeCoverageInformation()) {
                 $result->getCodeCoverage()->merge($childResult->getCodeCoverage());
             }
             $time = $childResult->time();
             $notImplemented = $childResult->notImplemented();
             $risky = $childResult->risky();
             $skipped = $childResult->skipped();
             $errors = $childResult->errors();
             $failures = $childResult->failures();
             if (!empty($notImplemented)) {
                 $result->addError($test, $this->getException($notImplemented[0]), $time);
             } elseif (!empty($risky)) {
                 $result->addError($test, $this->getException($risky[0]), $time);
             } elseif (!empty($skipped)) {
                 $result->addError($test, $this->getException($skipped[0]), $time);
             } elseif (!empty($errors)) {
                 $result->addError($test, $this->getException($errors[0]), $time);
             } elseif (!empty($failures)) {
                 $result->addFailure($test, $this->getException($failures[0]), $time);
             }
         }
     }
     $result->endTest($test, $time);
     if (!empty($output)) {
         print $output;
     }
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:63,代码来源:PHP.php

示例11: addFailure

 function addFailure(&$test, &$t, $time = 0)
 {
     parent::addFailure($test, $t, $time);
     echo "F";
 }
开发者ID:marcioyonamine,项目名称:php-openid,代码行数:5,代码来源:texttest.php

示例12: run

 /**
  * Runs a test and collects its result in a TestResult instance.
  *
  * @param  PHPUnit_Framework_TestResult $result
  * @param  array $options Array with ini settings for the php instance run,
  *                        key being the name if the setting, value the ini value.
  * @return PHPUnit_Framework_TestResult
  * @access public
  */
 public function run(PHPUnit_Framework_TestResult $result = NULL, $options = array())
 {
     if (!class_exists('PEAR_RunTest', FALSE)) {
         throw new RuntimeException('Class PEAR_RunTest not found.');
     }
     if ($result === NULL) {
         $result = new PHPUnit_Framework_TestResult();
     }
     if (!is_array($options)) {
         throw new InvalidArgumentException();
     }
     $options = array_merge($options, $this->options);
     $coverage = $result->getCollectCodeCoverageInformation();
     if ($coverage) {
         $options = array('coverage' => TRUE);
     } else {
         $options = array();
     }
     $runner = new PEAR_RunTest(new PHPUnit_Extensions_PhptTestCase_Logger(), $options);
     if ($coverage) {
         $runner->xdebug_loaded = TRUE;
     } else {
         $runner->xdebug_loaded = FALSE;
     }
     $result->startTest($this);
     PHPUnit_Util_Timer::start();
     $buffer = $runner->run($this->filename, $options);
     $time = PHPUnit_Util_Timer::stop();
     $base = basename($this->filename);
     $path = dirname($this->filename);
     $coverageFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.xdebug', $base);
     $diffFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.diff', $base);
     $expFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.exp', $base);
     $logFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.log', $base);
     $outFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.out', $base);
     $phpFile = $path . DIRECTORY_SEPARATOR . str_replace('.phpt', '.php', $base);
     if (is_object($buffer) && $buffer instanceof PEAR_Error) {
         $result->addError($this, new RuntimeException($buffer->getMessage()), $time);
     } else {
         if ($buffer == 'SKIPPED') {
             $result->addFailure($this, new PHPUnit_Framework_SkippedTestError(), 0);
         } else {
             if ($buffer != 'PASSED') {
                 $result->addFailure($this, PHPUnit_Framework_ComparisonFailure::diffEqual(file_get_contents($expFile), file_get_contents($outFile), FALSE, $this->getName()), $time);
             }
         }
     }
     foreach (array($diffFile, $expFile, $logFile, $phpFile, $outFile) as $file) {
         if (file_exists($file)) {
             unlink($file);
         }
     }
     if ($coverage) {
         eval('$coverageData = ' . file_get_contents($coverageFile) . ';');
         unset($coverageData[$phpFile]);
         $codeCoverageInformation = array('test' => $this, 'files' => $coverageData);
         $result->appendCodeCoverageInformation($this, $codeCoverageInformation);
         unlink($coverageFile);
     }
     $result->endTest($this, $time);
     return $result;
 }
开发者ID:ahmedadham88,项目名称:enhanced-social-network,代码行数:71,代码来源:PhptTestCase.php

示例13: addFailure

 public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
 {
     if (!$this->_askForRetry($test, $e, $time)) {
         parent::addFailure($test, $e, $time);
     }
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:6,代码来源:TestResult.php

示例14: run

 public function run(PHPUnit_Framework_TestResult $result = NULL)
 {
     if ($result === NULL) {
         $result = new PHPUnit_Framework_TestResult();
         $result->startTest($this);
         $counter = 0;
         foreach ($this->queries as $query_data) {
             $query = 'EXPLAIN ' . $query_data['query'];
             $parameters = $query_data['parameters'];
             $parameters_print = '';
             try {
                 if (!empty($parameters)) {
                     $res = Dal::query($query, $parameters);
                     $parameters_print = 'PARAMETERS:' . "\n";
                     foreach ($parameters as $param) {
                         $parameters_print .= '- ' . $param . "\n";
                     }
                 } else {
                     $res = Dal::query($query);
                 }
             } catch (PAException $e) {
                 try {
                     PHPUnit_Framework_Assert::assertEquals($e->getCode(), DB_QUERY_FAILED);
                 } catch (PHPUnit_Framework_AssertionFailedError $e) {
                     $result->addFailure($this, $e);
                 } catch (Exception $e) {
                     $result->addError($this, $e);
                 }
             }
             $tables = array();
             print "{{{ ==================================================================\n";
             $query_row = wordwrap($explain . "QUERY: \"{$query}\"", 70);
             print $query_row . "\n";
             if (!empty($parameters_print)) {
                 print "----------------------------------------------------------------------\n";
                 print $parameters_print;
             }
             while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
                 print "----------------------------------------------------------------------\n";
                 print 'ID: ' . $row->id . "\n";
                 print 'SELECT TYPE: ' . $row->select_type . "\n";
                 print 'TABLE: ' . $row->table . "\n";
                 if (!empty($row->table)) {
                     $tables[] = $row->table;
                 }
                 print 'TYPE: ' . $row->type . "\n";
                 print 'POSSIBLE KEYS: ' . $row->possible_keys . "\n";
                 print 'KEY: ' . $row->key . "\n";
                 print 'KEY LENGTH: ' . $row->key_len . "\n";
                 print 'REFERENCE: ' . $row->ref . "\n";
                 print 'ROWS: ' . $row->rows . "\n";
                 print 'EXTRA: ' . $row->Extra . "\n";
                 $counter++;
             }
             // Now show all the tables used in the query.
             foreach ($tables as $table) {
                 print "----------------------------------------------------------------------\n";
                 try {
                     $create_table = Dal::query_one("SHOW CREATE TABLE {$table}");
                 } catch (PAException $e) {
                     if ($e->getCode() != DB_QUERY_FAILED) {
                         throw $e;
                     }
                     $bits = preg_split("/(\\s+|,)/", $query);
                     $pos = array_search($table, $bits);
                     if ($pos === NULL) {
                         throw new PAException(GENERAL_SOME_ERROR, "Failed to find real name for table {$table} in query {$sql}");
                     }
                     $table = strtolower($bits[$pos - 1]) == 'as' ? $bits[$pos - 2] : $bits[$pos - 1];
                     $create_table = Dal::query_one("SHOW CREATE TABLE {$table}");
                 }
                 echo $create_table[1] . "\n";
             }
             print "================================================================== }}}\n";
         }
         $result->endTest($this);
         return $result;
     }
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:79,代码来源:MysqlPerformanceTest.php

示例15: run

 /**
  * Runs a test and collects its result in a TestResult instance.
  *
  * @param PHPUnit_Framework_TestResult $result
  *
  * @return PHPUnit_Framework_TestResult
  */
 public function run(PHPUnit_Framework_TestResult $result = null)
 {
     $sections = $this->parse();
     $code = $this->render($sections['FILE']);
     if ($result === null) {
         $result = new PHPUnit_Framework_TestResult();
     }
     $skip = false;
     $xfail = false;
     $time = 0;
     $settings = $this->settings;
     $result->startTest($this);
     if (isset($sections['INI'])) {
         $settings = array_merge($settings, $this->parseIniSection($sections['INI']));
     }
     if (isset($sections['ENV'])) {
         $env = $this->parseEnvSection($sections['ENV']);
         $this->phpUtil->setEnv($env);
     }
     // Redirects STDERR to STDOUT
     $this->phpUtil->setUseStderrRedirection(true);
     if ($result->enforcesTimeLimit()) {
         $this->phpUtil->setTimeout($result->getTimeoutForLargeTests());
     }
     if (isset($sections['SKIPIF'])) {
         $jobResult = $this->phpUtil->runJob($sections['SKIPIF'], $settings);
         if (!strncasecmp('skip', ltrim($jobResult['stdout']), 4)) {
             if (preg_match('/^\\s*skip\\s*(.+)\\s*/i', $jobResult['stdout'], $message)) {
                 $message = substr($message[1], 2);
             } else {
                 $message = '';
             }
             $result->addFailure($this, new PHPUnit_Framework_SkippedTestError($message), 0);
             $skip = true;
         }
     }
     if (isset($sections['XFAIL'])) {
         $xfail = trim($sections['XFAIL']);
     }
     if (!$skip) {
         if (isset($sections['STDIN'])) {
             $this->phpUtil->setStdin($sections['STDIN']);
         }
         if (isset($sections['ARGS'])) {
             $this->phpUtil->setArgs($sections['ARGS']);
         }
         PHP_Timer::start();
         $jobResult = $this->phpUtil->runJob($code, $settings);
         $time = PHP_Timer::stop();
         try {
             $this->assertPhptExpectation($sections, $jobResult['stdout']);
         } catch (PHPUnit_Framework_AssertionFailedError $e) {
             if ($xfail !== false) {
                 $result->addFailure($this, new PHPUnit_Framework_IncompleteTestError($xfail, 0, $e), $time);
             } else {
                 $result->addFailure($this, $e, $time);
             }
         } catch (Throwable $t) {
             $result->addError($this, $t, $time);
         }
         if ($result->allCompletelyImplemented() && $xfail !== false) {
             $result->addFailure($this, new PHPUnit_Framework_IncompleteTestError('XFAIL section but test passes'), $time);
         }
         $this->phpUtil->setStdin('');
         $this->phpUtil->setArgs('');
         if (isset($sections['CLEAN'])) {
             $cleanCode = $this->render($sections['CLEAN']);
             $this->phpUtil->runJob($cleanCode, $this->settings);
         }
     }
     $result->endTest($this, $time);
     return $result;
 }
开发者ID:sebastianbergmann,项目名称:phpunit,代码行数:80,代码来源:PhptTestCase.php


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