Exemple #1
0
 /**
  * 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);
 }
 public function endTest(Test $test, $time)
 {
     $this->currentTest = null;
     if ($test instanceof TestCase && $test->getStatus() === TestRunner::STATUS_PASSED) {
         $this->storage->record($this->run, $test, $time, StorageInterface::STATUS_PASSED);
     }
 }
Exemple #3
0
 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;
 }
Exemple #4
0
 /**
  * A test ended.
  *
  * @param  PHPUnit_Framework_Test $test
  * @param  float                  $time
  */
 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     if (!$test instanceof PHPUnit_Framework_Warning) {
         if ($test->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
             $ifStatus = array('assigned', 'new', 'reopened');
             $newStatus = 'closed';
             $message = 'Automatically closed by PHPUnit (test passed).';
             $resolution = 'fixed';
             $cumulative = TRUE;
         } else {
             if ($test->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) {
                 $ifStatus = array('closed');
                 $newStatus = 'reopened';
                 $message = 'Automatically reopened by PHPUnit (test failed).';
                 $resolution = '';
                 $cumulative = FALSE;
             } else {
                 return;
             }
         }
         $name = $test->getName();
         $tickets = PHPUnit_Util_Test::getTickets(get_class($test), $name);
         foreach ($tickets as $ticket) {
             // Remove this test from the totals (if it passed).
             if ($test->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
                 unset($this->ticketCounts[$ticket][$name]);
             }
             // Only close tickets if ALL referenced cases pass
             // but reopen tickets if a single test fails.
             if ($cumulative) {
                 // Determine number of to-pass tests:
                 if (count($this->ticketCounts[$ticket]) > 0) {
                     // There exist remaining test cases with this reference.
                     $adjustTicket = FALSE;
                 } else {
                     // No remaining tickets, go ahead and adjust.
                     $adjustTicket = TRUE;
                 }
             } else {
                 $adjustTicket = TRUE;
             }
             if ($adjustTicket && in_array($ticketInfo[3]['status'], $ifStatus)) {
                 $this->updateTicket($ticket, $newStatus, $message, $resolution);
             }
         }
     }
 }
 /**
  * A test ended.
  *
  * @param \PHPUnit_Framework_Test $test
  * @param float                   $time
  *
  * @return void
  */
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     if ($test instanceof \PHPUnit_Framework_TestCase) {
         $assertionCount = $test->getNumAssertions();
         $this->numAssertions += $assertionCount;
         if ($test->getStatus() == \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) {
             $status = 'failures';
         } elseif ($test->getStatus() == \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR) {
             $status = 'errors';
         } elseif ($test->getStatus() == \PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE) {
             $status = 'incompletes';
         } elseif ($test->getStatus() == \PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED) {
             $status = 'skips';
         } elseif ($test->getStatus() == \PHPUnit_Runner_BaseTestRunner::STATUS_RISKY) {
             $status = 'risky';
         } else {
             $status = 'tests';
         }
         if (count($this->suites) - $this->endedSuites > 1) {
             $suiteName = end($this->suites);
             $this->stats[$suiteName][$status]++;
             $this->stats[$suiteName]['assertions'] += $assertionCount;
         }
         // updates also top test suite
         $suiteName = reset($this->suites);
         $this->stats[$suiteName][$status]++;
         $this->stats[$suiteName]['assertions'] += $assertionCount;
     }
     if (method_exists($test, 'hasOutput') && $test->hasOutput()) {
         $output = $test->getActualOutput();
     } else {
         $output = '';
     }
     $testName = $test->getName();
     $context = array('testName' => $testName, 'testDescriptionArr' => \PHPUnit_Util_Test::describe($test, false), 'testDescriptionStr' => $test->toString(), 'operation' => __FUNCTION__, 'output' => $output);
     if (isset($assertionCount)) {
         $context['assertionCount'] = $assertionCount;
     }
     $this->logger->info(sprintf("Test '%s' ended.", $testName), $context);
 }
Exemple #6
0
 /**
  * A test ended.
  *
  * @param PHPUnit_Framework_Test $test
  * @param float                  $time
  */
 public function endTest(\PHPUnit_Framework_Test $test, $time)
 {
     if (false === $test instanceof $this->testTypeOfInterest) {
         return;
     }
     $assertion = array('@type' => 'earl:Assertion', 'earl:assertedBy' => $this->options['developer-url'], 'earl:mode' => 'earl:automatic', 'earl:test' => $test->getTestId(), 'earl:result' => array('@type' => 'earl:TestResult', 'earl:outcome' => $this->earlStatuses[$test->getStatus()], 'dc:date' => date('c')));
     $this->assertions[] = $assertion;
 }
 /**
  * A test ended.
  *
  * @param PHPUnit_Framework_Test $test Test case
  * @param float                  $time Time taken
  *
  * @return void
  */
 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     $this->runs[] = array('name' => $test->getName(), 'size' => $test->getSize(), 'status' => $test->getStatus(), 'statusMessage' => $test->getStatusMessage(), 'assertions' => $test->getNumAssertions(), 'result' => $test->getResult(), 'annotations' => $test->getAnnotations(), 'timeTaken' => $time, 'output' => $test->getActualOutput());
 }