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


PHP PHPUnit_Framework_Test类代码示例

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


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

示例1: doEnhancedRun

 public function doEnhancedRun(\PHPUnit_Framework_Test $suite, \PHPUnit_Framework_TestResult $result, array $arguments = [])
 {
     unset($GLOBALS['app']);
     // hook for not to serialize globals
     $this->handleConfiguration($arguments);
     $result->convertErrorsToExceptions(false);
     if (empty(self::$persistentListeners)) {
         $this->applyReporters($result, $arguments);
     }
     $arguments['listeners'][] = $this->printer;
     // clean up listeners between suites
     foreach ($arguments['listeners'] as $listener) {
         $result->addListener($listener);
     }
     $filterFactory = new \PHPUnit_Runner_Filter_Factory();
     if ($arguments['groups']) {
         $filterFactory->addFilter(new \ReflectionClass('PHPUnit_Runner_Filter_Group_Include'), $arguments['groups']);
     }
     if ($arguments['excludeGroups']) {
         $filterFactory->addFilter(new \ReflectionClass('PHPUnit_Runner_Filter_Group_Exclude'), $arguments['excludeGroups']);
     }
     if ($arguments['filter']) {
         $filterFactory->addFilter(new \ReflectionClass('PHPUnit_Runner_Filter_Test'), $arguments['filter']);
     }
     $suite->injectFilter($filterFactory);
     $suite->run($result);
     unset($suite);
     foreach ($arguments['listeners'] as $listener) {
         $result->removeListener($listener);
     }
     return $result;
 }
开发者ID:namnv609,项目名称:Codeception,代码行数:32,代码来源:Runner.php

示例2: groupsForTest

 public function groupsForTest(\PHPUnit_Framework_Test $test)
 {
     $groups = [];
     if ($test instanceof ScenarioDriven) {
         $groups = $test->getScenario()->getGroups();
     }
     if ($test instanceof Reported) {
         $info = $test->getReportFields();
         if (isset($info['class'])) {
             $groups = array_merge($groups, \PHPUnit_Util_Test::getGroups($info['class'], $info['name']));
         }
         $filename = $info['file'];
     } else {
         $groups = array_merge($groups, \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false)));
         $filename = (new \ReflectionClass($test))->getFileName();
     }
     foreach ($this->testsInGroups as $group => $tests) {
         foreach ($tests as $testPattern) {
             if ($filename == $testPattern) {
                 $groups[] = $group;
             }
             if (strpos($filename . ':' . $test->getName(false), $testPattern) === 0) {
                 $groups[] = $group;
             }
         }
     }
     return array_unique($groups);
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:28,代码来源:GroupManager.php

示例3: endTest

 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     if (!$test->hasFailed()) {
         $this->logger->write('OK', SeleniumTestSuite::RESULT_OK);
         $this->tests_ok++;
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:7,代码来源:SeleniumTestListener.php

示例4: endTest

 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     $this->tests++;
     switch ($test->getStatus()) {
         case PHPUnit_Runner_BaseTestRunner::STATUS_PASSED:
             echo '.';
             break;
         case PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE:
             echo 'F';
             break;
         case PHPUnit_Runner_BaseTestRunner::STATUS_ERROR:
             echo 'E';
             break;
         case PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE:
             echo 'I';
             break;
         case PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED:
             echo 'S';
             break;
     }
     if ($this->tests % 60 == 0) {
         echo "\n";
     }
     $this->totalTime += $time;
 }
开发者ID:humansky,项目名称:qframe,代码行数:25,代码来源:Listener.php

示例5: endTest

 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     if ($test instanceof \Codeception\TestCase\Cept) {
         $this->currentTestCase->setAttribute('name', $test->toString());
     }
     return parent::endTest($test, $time);
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:7,代码来源:JUnit.php

示例6: endTest

 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     $startTime = $this->timer[$test->getName()];
     $duration = number_format($this->getCurrentTime() - $startTime, 4);
     $message = $test->getName() . ' executed in ' . $duration . 's';
     $this->log->addInfo($message);
 }
开发者ID:bogdananton,项目名称:php-project-snapshot-build,代码行数:7,代码来源:TestListener.php

示例7: endTest

 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     if ($test instanceof \PHPUnit_Framework_TestCase) {
         $this->numAssertions += $test->getNumAssertions();
     }
     $this->lastTestFailed = false;
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:7,代码来源:UI.php

示例8: addError

    /**
     * Adds an error to the list of errors.
     *
     * @param  PHPUnit_Framework_Test $test
     * @param  Exception              $e
     * @param  float                  $time
     */
    public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
    {
        $message = "\n" . $e->getMessage();

        if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
            /** @var $e PHPUnit_Framework_ExpectationFailedException */
        	//$message .= "\n" . $e->getComparisonFailure()->toString();
        }

        $name = $test->getName(false);
        
        $mail = new Enlight_Components_Mail();
        
        $mail->addTo($this->mailRecipients);
        $mail->setSubject('PHPUnit test "' . $name . '" failed.');
        $mail->setBodyText($message);

        if($test instanceof Enlight_Components_Test_Selenium_TestCase
          && $e instanceof PHPUnit_Framework_ExpectationFailedException
          && $screenshot = $test->getFullScreenshot()) {
            $filename = basename($test->getFullScreenshotUrl());
            /** @var $test Enlight_Components_Test_Selenium_TestCase */
            $mail->createAttachment(
                $screenshot,
                Zend_Mime::TYPE_OCTETSTREAM,
                Zend_Mime::DISPOSITION_ATTACHMENT,
                Zend_Mime::ENCODING_BASE64,
                $filename
            );
        }
        
        $mail->send($this->mailTransport);
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:40,代码来源:MailListener.php

示例9: endTest

 /**
  * endTest is called after each test and checks if \Mockery::close() has
  * been called, and will let the test fail if it hasn't.
  *
  * @param  PHPUnit_Framework_Test $test
  * @param  float                  $time
  */
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     if (!$test instanceof \PHPUnit_Framework_TestCase) {
         // We need the getTestResultObject and getStatus methods which are
         // not part of the interface.
         return;
     }
     if ($test->getStatus() !== \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
         // If the test didn't pass there is no guarantee that
         // verifyMockObjects and assertPostConditions have been called.
         // And even if it did, the point here is to prevent false
         // negatives, not to make failing tests fail for more reasons.
         return;
     }
     try {
         // The self() call is used as a sentinel. Anything that throws if
         // the container is closed already will do.
         \Mockery::self();
     } catch (\LogicException $_) {
         return;
     }
     $e = new \PHPUnit_Framework_ExpectationFailedException(sprintf("Mockery's expectations have not been verified. Make sure that \\Mockery::close() is called at the end of the test. Consider using %s\\MockeryPHPUnitIntegration or extending %s\\MockeryTestCase.", __NAMESPACE__, __NAMESPACE__));
     $result = $test->getTestResultObject();
     $result->addFailure($test, $e, $time);
 }
开发者ID:padraic,项目名称:mockery,代码行数:32,代码来源:TestListener.php

示例10: doEnhancedRun

 public function doEnhancedRun(\PHPUnit_Framework_Test $suite, \PHPUnit_Framework_TestResult $result, array $arguments = array())
 {
     unset($GLOBALS['app']);
     // hook for not to serialize globals
     $arguments = array_merge($this->defaultArguments, $arguments);
     $this->handleConfiguration($arguments);
     $result->convertErrorsToExceptions(false);
     if ($arguments['report']) {
         $this->printer = new Report();
     }
     if (empty(self::$persistentListeners)) {
         $this->applyReporters($result, $arguments);
     }
     $arguments['listeners'][] = $this->printer;
     // clean up listeners between suites
     foreach ($arguments['listeners'] as $listener) {
         $result->addListener($listener);
     }
     $suite->run($result, $arguments['filter'], $arguments['groups'], $arguments['excludeGroups'], $arguments['processIsolation']);
     unset($suite);
     foreach ($arguments['listeners'] as $listener) {
         $result->removeListener($listener);
     }
     return $result;
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:25,代码来源:Runner.php

示例11: addTest

 /**
  * @param PHPUnit_Framework_Test $test
  * @param array                  $groups
  */
 public function addTest(PHPUnit_Framework_Test $test, $groups = array())
 {
     if ($test instanceof PHPUnit_Framework_Warning && preg_match('/^No tests found in class/', $test->getMessage())) {
         return;
     }
     parent::addTest($test, $groups);
 }
开发者ID:kumatch,项目名称:stagehand-testrunner,代码行数:11,代码来源:MethodFilterTestSuite.php

示例12: endTest

 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     // copied from parent:endTest()
     if ($test instanceof PHPUnit_Framework_TestCase) {
         $this->numAssertions += $test->getNumAssertions();
     } else {
         if ($test instanceof PHPUnit_Extensions_PhptTestCase) {
             $this->numAssertions++;
         }
     }
     $this->lastTestFailed = false;
     // custom printing code
     if (get_class($test) == 'PHPUnit_Framework_TestSuite') {
         // this occurs when the test suite setup has thrown an error
         $this->out(" SETUP FAIL", 'fg-red', true);
     } elseif ($test->hasFailed()) {
         $this->out(" FAIL", 'fg-red', true);
     } else {
         $numAssertions = $test instanceof PHPUnit_Framework_TestCase ? $test->getNumAssertions() : 1;
         if ($numAssertions > 0) {
             $this->out(' OK (' . $numAssertions . ' assertions)', 'fg-green', true);
         } else {
             $this->out(' SKIPPED (0 assertions)', 'fg-yellow', true);
         }
     }
 }
开发者ID:mymizan,项目名称:phreeze,代码行数:26,代码来源:VerboseTestResultPrinter.php

示例13: endTest

 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     if ($test instanceof Spec\TestCaseInterface) {
         $levels = 0;
         if ($parent = $test->getSuite()) {
             while ($parent = $parent->getParent()) {
                 $levels++;
             }
         }
         $output = str_repeat("  ", $levels) . $test->getTitle();
         if ($this->lastTestResult !== self::PASSED) {
             switch ($this->lastTestResult) {
                 case self::FAILED:
                     $output .= ' (FAILED - ' . count($this->exceptions) . ')';
                     $output = "[31m{$output}[0m";
                     break;
                 case self::ERROR:
                     $output .= ' (ERROR - ' . count($this->exceptions) . ')';
                     $output = "[31m{$output}[0m";
                     break;
                 case self::INCOMPLETE:
                     $output .= ' (INCOMPLETE)';
                     $output = "[30;1m{$output}[0m";
                     break;
                 case self::SKIPPED:
                     $output .= ' (SKIPPED)';
                     $output = "[30;1m{$output}[0m";
                     break;
             }
         } else {
             $output = "[32m" . $output . "[0m";
         }
         $this->write($output . PHP_EOL);
     }
 }
开发者ID:rafeca,项目名称:Spec-PHP,代码行数:35,代码来源:Story.php

示例14: endTest

 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     $steps = [];
     $success = $this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED;
     if ($success) {
         $this->successful++;
     }
     if ($test instanceof ScenarioDriven) {
         $steps = $test->getScenario()->getSteps();
     }
     $this->timeTaken += $time;
     switch ($this->testStatus) {
         case \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE:
             $scenarioStatus = 'scenarioFailed';
             break;
         case \PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED:
             $scenarioStatus = 'scenarioSkipped';
             break;
         case \PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE:
             $scenarioStatus = 'scenarioIncomplete';
             break;
         case \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR:
             $scenarioStatus = 'scenarioFailed';
             break;
         default:
             $scenarioStatus = 'scenarioSuccess';
     }
     $stepsBuffer = '';
     $metaStep = null;
     $subStepsBuffer = '';
     foreach ($steps as $step) {
         /** @var $step Step  **/
         if ($step->getMetaStep()) {
             $subStepsBuffer .= $this->renderStep($step);
             $metaStep = $step->getMetaStep();
             continue;
         }
         if ($step->getMetaStep() != $metaStep) {
             $stepsBuffer .= $this->renderSubsteps($metaStep, $subStepsBuffer);
             $subStepsBuffer = '';
         }
         $metaStep = $step->getMetaStep();
         $stepsBuffer .= $this->renderStep($step);
     }
     if ($subStepsBuffer and $metaStep) {
         $stepsBuffer .= $this->renderSubsteps($metaStep, $subStepsBuffer);
     }
     $scenarioTemplate = new \Text_Template($this->templatePath . 'scenario.html');
     $failure = '';
     $name = Descriptor::getTestSignature($test);
     if (isset($this->failures[$name])) {
         $failTemplate = new \Text_Template($this->templatePath . 'fail.html');
         $failTemplate->setVar(['fail' => nl2br($this->failures[$name])]);
         $failure = $failTemplate->render();
     }
     $toggle = $stepsBuffer ? '<span class="toggle">+</span>' : '';
     $scenarioTemplate->setVar(['id' => ++$this->id, 'name' => ucfirst(Descriptor::getTestAsString($test)), 'scenarioStatus' => $scenarioStatus, 'steps' => $stepsBuffer, 'toggle' => $toggle, 'failure' => $failure, 'time' => round($time, 2)]);
     $this->scenarios .= $scenarioTemplate->render();
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:59,代码来源:HTML.php

示例15: endTest

 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     $current = time();
     $took = $current - $this->time;
     if ($took > $this->timeLimit) {
         echo "\nName: " . $test->getName() . " took " . $took . " second(s) (from: {$this->time}, to: {$current})\n";
     }
 }
开发者ID:alister,项目名称:expenses-avenger,代码行数:8,代码来源:TestTimesListener.php


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