Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Merge [4655].

  • Loading branch information...
commit 64fbd32a432e0ca7ef359645e11239d5c15acf64 1 parent 658d33e
@sebastianbergmann authored
Showing with 55 additions and 51 deletions.
  1. +55 −51 PHPUnit/Extensions/TicketListener.php
View
106 PHPUnit/Extensions/TicketListener.php
@@ -141,21 +141,23 @@ public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
*/
public function startTest(PHPUnit_Framework_Test $test)
{
- if ($this->ran) {
- return;
- }
+ if (!$test instanceof PHPUnit_Framework_Warning) {
+ if ($this->ran) {
+ return;
+ }
- $class = new ReflectionClass(get_class($test));
-
- foreach ($class->getMethods() as $method) {
- $docComment = $method->getDocComment();
+ $class = new ReflectionClass(get_class($test));
+
+ foreach ($class->getMethods() as $method) {
+ $docComment = $method->getDocComment();
- if (preg_match(self::REGEX_TICKET, $docComment, $matches)) {
- $this->ticketCounts[$matches[1]][$method->getName()] = 1;
+ if (preg_match(self::REGEX_TICKET, $docComment, $matches)) {
+ $this->ticketCounts[$matches[1]][$method->getName()] = 1;
+ }
}
- }
- $this->ran = TRUE;
+ $this->ran = TRUE;
+ }
}
/**
@@ -166,54 +168,56 @@ public function startTest(PHPUnit_Framework_Test $test)
*/
public function endTest(PHPUnit_Framework_Test $test, $time)
{
- 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;
- }
+ 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 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;
- }
+ else {
+ return;
+ }
- $method = new ReflectionMethod(get_class($test), $test->getName());
- $docComment = $method->getDocComment();
+ $method = new ReflectionMethod(get_class($test), $test->getName());
+ $docComment = $method->getDocComment();
- if (preg_match(self::REGEX_TICKET, $docComment, $matches)) {
- $ticketId = $matches[1];
-
- // Remove this test from the totals (if it passed).
- if ($test->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
- unset($this->ticketCounts[$ticketId][$test->getName()]);
- }
-
- // 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[$ticketId]) > 0) {
- // There exist remaining test cases with this reference.
- $adjustTicket = FALSE;
+ if (preg_match(self::REGEX_TICKET, $docComment, $matches)) {
+ $ticketId = $matches[1];
+
+ // Remove this test from the totals (if it passed).
+ if ($test->getStatus() == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
+ unset($this->ticketCounts[$ticketId][$test->getName()]);
+ }
+
+ // 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[$ticketId]) > 0) {
+ // There exist remaining test cases with this reference.
+ $adjustTicket = FALSE;
+ } else {
+ // No remaining tickets, go ahead and adjust.
+ $adjustTicket = TRUE;
+ }
} else {
- // No remaining tickets, go ahead and adjust.
$adjustTicket = TRUE;
}
- } else {
- $adjustTicket = TRUE;
- }
- if ($adjustTicket && in_array($ticketInfo[3]['status'], $ifStatus)) {
- $this->updateTicket($ticketId, $newStatus, $message, $resolution);
+ if ($adjustTicket && in_array($ticketInfo[3]['status'], $ifStatus)) {
+ $this->updateTicket($ticketId, $newStatus, $message, $resolution);
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.