Skip to content

Commit 409d5b2

Browse files
committed
adding a skipped status to tests
1 parent 5ae4224 commit 409d5b2

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

tests/Cache/AbstractTestCase.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function prepareData()
4949
public function testAsResultCache()
5050
{
5151
if (!$this->_isEnabled()) {
52+
$this->skip();
5253
return;
5354
}
5455
$this->_clearCache();
@@ -82,6 +83,7 @@ public function testAsResultCache()
8283
public function testCacheCore()
8384
{
8485
if (!$this->_isEnabled()) {
86+
$this->skip();
8587
return;
8688
}
8789
$this->_clearCache();
@@ -100,6 +102,7 @@ public function testCacheCore()
100102
public function testDeleteByPrefix()
101103
{
102104
if (!$this->_isEnabled()) {
105+
$this->skip();
103106
return;
104107
}
105108
$this->_clearCache();
@@ -119,6 +122,7 @@ public function testDeleteByPrefix()
119122
public function testDeleteBySuffix()
120123
{
121124
if (!$this->_isEnabled()) {
125+
$this->skip();
122126
return;
123127
}
124128
$this->_clearCache();
@@ -138,6 +142,7 @@ public function testDeleteBySuffix()
138142
public function testDeleteByRegex()
139143
{
140144
if (!$this->_isEnabled()) {
145+
$this->skip();
141146
return;
142147
}
143148
$this->_clearCache();

tests/DoctrineTest/GroupTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ public function run(DoctrineTest_Reporter $reporter = null, $filter = null)
7979
$testCase->addMessage($message);
8080
}
8181

82-
$this->_passed += $testCase->getPassCount();
83-
$this->_failed += $testCase->getFailCount();
82+
$this->_passed += $testCase->getPassCount();
83+
$this->_failed += $testCase->getFailCount();
84+
$this->_skipped += $testCase->getSkipCount();
8485

8586
$this->_testCases[$k] = null;
8687

tests/DoctrineTest/Reporter.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public function format($message, $type)
1919
$color = 'green';
2020
} elseif ($type == 'ERROR') {
2121
$color = 'red';
22+
} elseif ($type == 'COMMENT') {
23+
$color = 'yellow';
2224
} else {
2325
$color = 'black';
2426
}
@@ -37,10 +39,21 @@ public function paintMessages()
3739
$class = get_class($this->_test);
3840
$messages = $this->_test->getMessages();
3941
$failed = ($this->_test->getFailCount() || count($messages)) ? true:false;
42+
$skipped = $this->_test->getSkipCount() ? true : false;
4043

4144
if ($class != 'GroupTest') {
4245
$strRepeatLength = $max - strlen($class);
43-
echo $class . str_repeat('.', $strRepeatLength) . $this->format($failed ? 'failed':'passed', $failed ? 'ERROR':'INFO') . "\n";
46+
$message = 'passed';
47+
$type = 'INFO';
48+
if ($failed) {
49+
$message = 'failed';
50+
$type = 'ERROR';
51+
} elseif ($skipped) {
52+
$message = 'skipped';
53+
$type = 'COMMENT';
54+
}
55+
56+
echo $class . str_repeat('.', $strRepeatLength) . $this->format($message, $type) . "\n";
4457
}
4558

4659
if (! empty($messages)) {

tests/DoctrineTest/Reporter/Cli.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function paintFooter()
1414
echo $this->format('Tested: ' . $this->_test->getTestCaseCount() . ' test cases.', 'INFO') . "\n";
1515
echo $this->format('Successes: ' . $this->_test->getPassCount() . ' passes.', 'INFO') . "\n";
1616
echo $this->format('Failures: ' . $this->_test->getFailCount() . ' fails.', $this->_test->getFailCount() ? 'ERROR':'INFO') . "\n";
17+
echo $this->format('Skips: ' . $this->_test->getSkipCount() . ' skips.', $this->_test->getSkipCount() ? 'COMMENT':'INFO') . "\n";
1718
echo $this->format('Number of new Failures: ' . $this->_test->getNumNewFails(), $this->_test->getNumNewFails() ? 'ERROR':'INFO') . ' ' . implode(', ', $this->_test->getNewFails()) . "\n";
1819
echo $this->format('Number of fixed Failures: ' . $this->_test->getNumFixedFails(), $this->_test->getNumFixedFails() ? 'INFO':'HEADER') . ' ' . implode(', ', $this->_test->getFixedFails()) . "\n";
1920
}

tests/DoctrineTest/UnitTestCase.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ class UnitTestCase
55

66
protected $_failed = 0;
77

8+
protected $_skipped = 0;
9+
810
protected $_messages = array();
911

10-
protected static $_passesAndFails = array('passes' => array(), 'fails' => array());
12+
protected static $_passesAndFails = array('passes' => array(), 'fails' => array(), 'skips' => array());
1113

12-
protected static $_lastRunsPassesAndFails = array('passes' => array(), 'fails' => array());
14+
protected static $_lastRunsPassesAndFails = array('passes' => array(), 'fails' => array(), 'skips' => array());
1315

1416
public function init()
1517
{
@@ -116,6 +118,15 @@ public function pass()
116118
$this->_passed++;
117119
}
118120

121+
public function skip()
122+
{
123+
$class = get_class($this);
124+
if (! isset(self::$_passesAndFails['skips'][$class])) {
125+
self::$_passesAndFails['skips'][$class] = $class;
126+
}
127+
$this->_skipped++;
128+
}
129+
119130
public function fail($message = '')
120131
{
121132
$this->_fail($message);
@@ -177,6 +188,11 @@ public function getPassCount()
177188
return $this->_passed;
178189
}
179190

191+
public function getSkipCount()
192+
{
193+
return $this->_skipped;
194+
}
195+
180196
public function getPassesAndFailsCachePath()
181197
{
182198
$dir = dirname(__FILE__) . '/doctrine_tests';
@@ -225,7 +241,6 @@ public function getNewFails()
225241
}
226242
}
227243
return $newFails;
228-
;
229244
}
230245

231246
public function getFixedFails()
@@ -239,7 +254,6 @@ public function getFixedFails()
239254
}
240255
}
241256
return $fixed;
242-
;
243257
}
244258

245259
public function getNumNewFails()

tests/Ticket/DC841TestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function testSelectJoinWith()
7878

7979
public function testSelectWithStaticParameter()
8080
{
81+
$this->skip();
8182
return; // doesn't work
8283
Doctrine::getTable('Ticket_DC841_Model')
8384
->createQuery('t')

0 commit comments

Comments
 (0)