Changeset 20335
- Timestamp:
- 07/19/09 22:06:29 (4 years ago)
- Files:
-
- tools/lime/branches/2.0-experimental/lib/LimeTest.php (modified) (5 diffs)
- tools/lime/branches/2.0-experimental/lib/output/LimeOutputConsoleDetailed.php (modified) (8 diffs)
- tools/lime/branches/2.0-experimental/test/unit/LimeTest/skip.phpt (modified) (1 diff)
- tools/lime/branches/2.0-experimental/test/unit/LimeTest/skip_name.phpt (modified) (1 diff)
- tools/lime/branches/2.0-experimental/test/unit/LimeTest/todo.phpt (modified) (1 diff)
- tools/lime/branches/2.0-experimental/test/unit/LimeTest/todo_name.phpt (modified) (1 diff)
- tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputConsoleDetailedTest.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tools/lime/branches/2.0-experimental/lib/LimeTest.php
r20332 r20335 43 43 44 44 $this->output = $this->options['output'] ? $this->options['output'] : $this->getDefaultOutput($this->options['force_colors']); 45 $this->output->plan($plan, $file); 45 46 if (!is_null($plan)) 47 { 48 $this->output->plan($plan, $file); 49 } 46 50 47 51 $this->options['base_dir'] = realpath($this->options['base_dir']); … … 262 266 public function unlike($exp, $regex, $message = '') 263 267 { 264 $error = sprintf(" '%s'\nmatches '%s'", $exp, $regex);268 $error = sprintf(" '%s'\nmatches '%s'", $exp, $regex); 265 269 266 270 return $this->test(!preg_match($regex, $exp), $message, $error); … … 303 307 if (!method_exists($object, $method)) 304 308 { 305 $failedMessages[] = sprintf(" method '%s' does not exist", $method);309 $failedMessages[] = sprintf("method '%s' does not exist", $method); 306 310 $result = false; 307 311 } … … 323 327 { 324 328 $type = is_object($var) ? get_class($var) : gettype($var); 325 $error = sprintf(" variable isn't a '%s' it's a '%s'", $class, $type);329 $error = sprintf("variable isn't a '%s' it's a '%s'", $class, $type); 326 330 327 331 return $this->test($type == $class, $message, $error); … … 407 411 public function todo($message = '') 408 412 { 409 $this->skip( 'TODO: '.$message);413 $this->skip(trim('TODO '.$message)); 410 414 } 411 415 tools/lime/branches/2.0-experimental/lib/output/LimeOutputConsoleDetailed.php
r20324 r20335 13 13 { 14 14 protected 15 $expected = null, 15 16 $passed = 0, 16 $expected = 0,17 17 $actual = 0, 18 18 $printer = null; … … 26 26 { 27 27 $this->expected = $amount; 28 29 28 $this->printer->printLine('1..'.$amount); 30 29 } … … 35 34 $this->passed++; 36 35 37 $this->printer->printText('ok '.$this->actual, LimePrinter::OK); 38 $this->printer->printLine(' - '.$message); 36 if (empty($message)) 37 { 38 $this->printer->printLine('ok '.$this->actual, LimePrinter::OK); 39 } 40 else 41 { 42 $this->printer->printText('ok '.$this->actual, LimePrinter::OK); 43 $this->printer->printLine(' - '.$message); 44 } 39 45 } 40 46 … … 43 49 $this->actual++; 44 50 45 $this->printer->printText('not ok '.$this->actual, LimePrinter::NOT_OK); 46 $this->printer->printLine(' - '.$message); 51 if (empty($message)) 52 { 53 $this->printer->printLine('not ok '.$this->actual, LimePrinter::NOT_OK); 54 } 55 else 56 { 57 $this->printer->printText('not ok '.$this->actual, LimePrinter::NOT_OK); 58 $this->printer->printLine(' - '.$message); 59 } 60 47 61 $this->printer->printLine(sprintf('# Failed test (%s at line %s)', $file, $line), LimePrinter::COMMENT); 48 62 … … 59 73 { 60 74 $this->actual++; 75 $this->passed++; 61 76 62 $this->printer->printText('skip '.$this->actual, LimePrinter::SKIP); 63 $this->printer->printLine(' - '.$message); 77 if (empty($message)) 78 { 79 $this->printer->printLine('skip '.$this->actual, LimePrinter::SKIP); 80 } 81 else 82 { 83 $this->printer->printText('skip '.$this->actual, LimePrinter::SKIP); 84 $this->printer->printLine(' - '.$message); 85 } 64 86 } 65 87 … … 81 103 public function flush() 82 104 { 105 if (is_null($this->expected)) 106 { 107 $this->plan($this->actual, null); 108 } 109 83 110 if ($this->passed == $this->expected) 84 111 { … … 87 114 else if ($this->passed != $this->actual) 88 115 { 89 $this->printer->printBox(sprintf(' Looks like you failed %s tests of %s.', $this-> passed, $this->actual), LimePrinter::ERROR);116 $this->printer->printBox(sprintf(' Looks like you failed %s tests of %s.', $this->actual - $this->passed, $this->actual), LimePrinter::ERROR); 90 117 } 91 118 92 119 if ($this->actual > $this->expected) 93 120 { 94 $this->printer->printBox(sprintf(' Looks like you planned %s tests but ran %s extra.', $this->expected, $this->actual -$this->expected), LimePrinter::ERROR);121 $this->printer->printBox(sprintf(' Looks like you planned %s tests but ran %s extra.', $this->expected, $this->actual - $this->expected), LimePrinter::ERROR); 95 122 } 96 123 else if ($this->actual < $this->expected) … … 98 125 $this->printer->printBox(sprintf(' Looks like you planned %s tests but only ran %s.', $this->expected, $this->actual), LimePrinter::ERROR); 99 126 } 100 else101 {102 }103 127 } 104 128 } tools/lime/branches/2.0-experimental/test/unit/LimeTest/skip.phpt
r19496 r20335 7 7 ?> 8 8 --EXPECT-- 9 ok 1 # SKIP 9 skip 1 10 10 1..1 11 11 Looks like everything went fine. tools/lime/branches/2.0-experimental/test/unit/LimeTest/skip_name.phpt
r19496 r20335 7 7 ?> 8 8 --EXPECT-- 9 ok 1 # SKIPtest name10 ok 2 # SKIPtest name9 skip 1 - test name 10 skip 2 - test name 11 11 1..2 12 12 Looks like everything went fine. tools/lime/branches/2.0-experimental/test/unit/LimeTest/todo.phpt
r19496 r20335 7 7 ?> 8 8 --EXPECT-- 9 ok 1 #TODO9 skip 1 - TODO 10 10 1..1 11 11 Looks like everything went fine. tools/lime/branches/2.0-experimental/test/unit/LimeTest/todo_name.phpt
r19496 r20335 7 7 ?> 8 8 --EXPECT-- 9 ok 1 #TODO test name9 skip 1 - TODO test name 10 10 1..1 11 11 Looks like everything went fine. tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputConsoleDetailedTest.php
r20324 r20335 14 14 LimeAnnotationSupport::enable(); 15 15 16 $t = new LimeTest( 26);16 $t = new LimeTest(33); 17 17 18 18 // @Before … … 50 50 $output->pass('A passed test', '/test/file', 11); 51 51 $output->pass('Another passed test', '/test/file', 22); 52 // assertions 53 $printer->verify(); 54 55 56 // @Test: pass() prints no message if none is given 57 58 // fixtures 59 $printer->printLine('ok 1', LimePrinter::OK); 60 $printer->replay(); 61 // test 62 $output->pass('', '/test/file', 11); 52 63 // assertions 53 64 $printer->verify(); … … 73 84 74 85 86 // @Test: fail() prints no message if none is given 87 88 // fixtures 89 $printer->printLine('not ok 1', LimePrinter::NOT_OK); 90 $printer->printLine('# Failed test (/test/file at line 11)', LimePrinter::COMMENT); 91 $printer->replay(); 92 // test 93 $output->fail('', '/test/file', 11); 94 // assertions 95 $printer->verify(); 96 97 75 98 // @Test: skip() prints and counts skipped tests 76 99 … … 88 111 89 112 113 // @Test: skip() prints no message if none is given 114 115 // fixtures 116 $printer->printLine('skip 1', LimePrinter::SKIP); 117 $printer->replay(); 118 // test 119 $output->skip('', '/test/file', 11); 120 // assertions 121 $printer->verify(); 122 123 90 124 // @Test: warning() prints a warning 91 125 … … 166 200 167 201 // fixtures 168 $output->plan( 2, '/test/file');202 $output->plan(3, '/test/file'); 169 203 $output->pass('First test', '/test/file', 11); 170 204 $output->fail('Second test', '/test/file', 22); 171 $printer->reset(); 172 $printer->printBox(' Looks like you failed 1 tests of 2.', LimePrinter::ERROR); 205 $output->pass('Third test', '/test/file', 33); 206 $printer->reset(); 207 $printer->printBox(' Looks like you failed 1 tests of 3.', LimePrinter::ERROR); 173 208 $printer->replay(); 174 209 // test … … 191 226 // assertions 192 227 $printer->verify(); 228 229 // @Test: Case 6 - No plan 230 231 // fixtures 232 $output->pass('First test', '/test/file', 11); 233 $printer->reset(); 234 $printer->printLine('1..1'); 235 $printer->printBox(' Looks like everything went fine.', LimePrinter::HAPPY); 236 $printer->replay(); 237 // test 238 $output->flush(); 239 // assertions 240 $printer->verify(); 241 242 // @Test: Case 7 - Skipped tests 243 244 // fixtures 245 $output->plan(1, '/test/file'); 246 $output->skip('First test', '/test/file', 11); 247 $printer->reset(); 248 $printer->printBox(' Looks like everything went fine.', LimePrinter::HAPPY); 249 $printer->replay(); 250 // test 251 $output->flush(); 252 // assertions 253 $printer->verify();