Changeset 21230
- Timestamp:
- 08/18/09 21:44:37 (4 years ago)
- Files:
-
- tools/lime/branches/2.0-experimental/lib/LimeShell.php (modified) (1 diff)
- tools/lime/branches/2.0-experimental/lib/LimeTest.php (modified) (2 diffs)
- tools/lime/branches/2.0-experimental/lib/LimeTestSuite.php (modified) (5 diffs)
- tools/lime/branches/2.0-experimental/lib/output/LimeOutputArray.php (modified) (1 diff)
- tools/lime/branches/2.0-experimental/lib/output/LimeOutputConsoleDetailed.php (modified) (2 diffs)
- tools/lime/branches/2.0-experimental/lib/output/LimeOutputConsoleSummary.php (modified) (6 diffs)
- tools/lime/branches/2.0-experimental/lib/output/LimeOutputCoverage.php (modified) (2 diffs)
- tools/lime/branches/2.0-experimental/lib/output/LimeOutputInspectable.php (added)
- tools/lime/branches/2.0-experimental/lib/output/LimeOutputInterface.php (modified) (1 diff)
- tools/lime/branches/2.0-experimental/lib/output/LimeOutputNone.php (modified) (1 diff)
- tools/lime/branches/2.0-experimental/lib/output/LimeOutputPipe.php (modified) (3 diffs)
- tools/lime/branches/2.0-experimental/lib/output/LimeOutputRaw.php (modified) (1 diff)
- tools/lime/branches/2.0-experimental/lib/output/LimeOutputXml.php (modified) (1 diff)
- tools/lime/branches/2.0-experimental/test/unit/LimePrinterTest.php (modified) (1 diff)
- tools/lime/branches/2.0-experimental/test/unit/LimeShellTest.php (modified) (2 diffs)
- tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputArrayTest.php (modified) (3 diffs)
- tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputConsoleDetailedTest.php (modified) (2 diffs)
- tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputConsoleSummaryTest.php (modified) (8 diffs)
- tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputInspectableTest.php (modified) (2 diffs)
- tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputPipeTest.php (modified) (11 diffs)
- tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputRawTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tools/lime/branches/2.0-experimental/lib/LimeShell.php
r20981 r21230 147 147 } 148 148 149 public function executeCallback($callback,$file, array $arguments = array())149 public function spawn($file, array $arguments = array()) 150 150 { 151 $handle = popen($this->buildCommand($file, $arguments), 'r'); 152 153 while (!feof($handle)) 154 { 155 $line = fread($handle, 2048); 156 call_user_func($callback, $line); 157 } 151 return popen($this->buildCommand($file, $arguments), 'r'); 158 152 } 159 153 tools/lime/branches/2.0-experimental/lib/LimeTest.php
r20975 r21230 60 60 } 61 61 62 $this->output-> start($file);62 $this->output->focus($file); 63 63 64 64 if (!is_null($plan)) … … 73 73 public function __destruct() 74 74 { 75 $this->output->close(); 75 76 $this->output->flush(); 76 77 tools/lime/branches/2.0-experimental/lib/LimeTestSuite.php
r20968 r21230 19 19 public function __construct(array $options = array()) 20 20 { 21 $this->options = array (21 $this->options = array_merge(array( 22 22 'base_dir' => null, 23 23 'executable' => null, … … 26 26 'verbose' => false, 27 27 'serialize' => false, 28 ); 28 'processes' => 1, 29 ), $options); 29 30 30 31 foreach (LimeShell::parseArguments($GLOBALS['argv']) as $argument => $value) … … 32 33 $this->options[str_replace('-', '_', $argument)] = $value; 33 34 } 34 35 $this->options = array_merge($this->options, $options);36 35 37 36 $this->options['base_dir'] = realpath($this->options['base_dir']); … … 41 40 $factory = new LimeOutputFactory($this->options); 42 41 43 $this->options['output'] = $factory->create($this->options['output']); 42 $type = $this->options['output']; 43 $output = $factory->create($type); 44 } 45 else 46 { 47 $output = $this->options['output']; 48 $type = get_class($output); 44 49 } 45 50 46 $this->output = new LimeOutputInspectable($this->options['output']); 51 if ($this->options['processes'] > 1 && !$output->supportsThreading()) 52 { 53 throw new LogicException(sprintf('The output "%s" does not support threading', $type)); 54 } 55 56 $this->output = new LimeOutputInspectable($output); 47 57 } 48 58 … … 56 66 // sort the files to be able to predict the order 57 67 sort($this->files); 68 reset($this->files); 58 69 59 $connector = new LimeOutputPipe($this->output, array('start', 'flush'));70 $connectors = array(); 60 71 61 for each ($this->files as $file)72 for ($i = 0; $i < $this->options['processes']; ++$i) 62 73 { 63 // start the file explicitly in case the file contains syntax errors 64 $this->output->start($file); 65 $connector->connect($file); 74 $connectors[] = new LimeOutputPipe($this->output, array('focus', 'flush')); 66 75 } 76 77 do 78 { 79 $done = true; 80 81 foreach ($connectors as $connector) 82 { 83 if ($connector->done() && !is_null(key($this->files))) 84 { 85 // start the file explicitly in case the file contains syntax errors 86 $this->output->focus(current($this->files)); 87 $connector->connect(current($this->files)); 88 89 next($this->files); 90 } 91 else if (!$connector->done()) 92 { 93 $this->output->focus($connector->getConnectedFile()); 94 } 95 96 if (!$connector->done()) 97 { 98 $connector->proceed(); 99 $done = false; 100 } 101 } 102 } 103 while (!$done); 67 104 68 105 $this->output->flush(); tools/lime/branches/2.0-experimental/lib/output/LimeOutputArray.php
r20975 r21230 22 22 } 23 23 24 public function start($file) 24 public function supportsThreading() 25 { 26 return true; 27 } 28 29 public function focus($file) 25 30 { 26 31 $this->currentResults =& $this->getResults($file); 32 } 33 34 public function close() 35 { 27 36 } 28 37 tools/lime/branches/2.0-experimental/lib/output/LimeOutputConsoleDetailed.php
r20976 r21230 30 30 } 31 31 32 public function supportsThreading() 33 { 34 return false; 35 } 36 32 37 private function stripBaseDir($path) 33 38 { … … 35 40 } 36 41 37 public function start($file)42 public function focus($file) 38 43 { 39 44 $this->printer->printLine('# '.$this->stripBaseDir($file), LimePrinter::INFO); 45 } 46 47 public function close() 48 { 40 49 } 41 50 tools/lime/branches/2.0-experimental/lib/output/LimeOutputConsoleSummary.php
r20978 r21230 13 13 { 14 14 protected 15 $printer = null, 16 $options = array(), 17 $startTime = 0, 18 $file = null, 19 $actualFiles = 0, 20 $failedFiles = 0, 21 $actualTests = 0, 22 $failedTests = 0, 23 $expected = 0, 24 $passed = 0, 25 $failed = 0, 26 $errors = 0, 27 $warnings = 0; 15 $printer = null, 16 $options = array(), 17 $startTime = 0, 18 $file = null, 19 $actualFiles = 0, 20 $failedFiles = 0, 21 $actualTests = 0, 22 $failedTests = 0, 23 $expected = array(), 24 $passed = array(), 25 $failed = array(), 26 $errors = array(), 27 $warnings = array(), 28 $line = array(); 28 29 29 30 public function __construct(LimePrinter $printer, array $options = array()) … … 36 37 } 37 38 38 public function start($file) 39 { 40 $this->close(); 41 39 public function supportsThreading() 40 { 41 return true; 42 } 43 44 public function focus($file) 45 { 42 46 $this->file = $file; 43 $this->expected = 0; 44 $this->passed = 0; 45 $this->failed = 0; 46 $this->errors = 0; 47 $this->warnings = 0; 48 } 49 50 protected function close() 47 48 if (!array_key_exists($file, $this->line)) 49 { 50 $this->line[$file] = count($this->line); 51 $this->expected[$file] = 0; 52 $this->passed[$file] = 0; 53 $this->failed[$file] = 0; 54 $this->errors[$file] = 0; 55 $this->warnings[$file] = 0; 56 } 57 } 58 59 public function close() 51 60 { 52 61 if (!is_null($this->file)) 53 62 { 54 63 $this->actualFiles++; 55 $this->actualTests += $this->passed + $this->failed; 56 $this->failedTests += $this->failed; 57 58 $actual = $this->passed+$this->failed; 59 $incomplete = ($this->expected > 0 && $actual != $this->expected); 64 $this->actualTests += $this->getActual(); 65 $this->failedTests += $this->getFailed(); 60 66 61 67 $this->printer->printText(str_pad($this->getTruncatedFile(), 73, '.')); 62 68 63 if ($this->errors || $this->failed || $incomplete) 69 $incomplete = ($this->getExpected() > 0 && $this->getActual() != $this->getExpected()); 70 71 if ($this->getErrors() || $this->getFailed() || $incomplete) 64 72 { 65 73 $this->failedFiles++; 66 $this->printer->printLine( 'not ok', LimePrinter::NOT_OK);67 } 68 else if ($this-> warnings)69 { 70 $this->printer->printLine( 'warning', LimePrinter::WARNING);74 $this->printer->printLine("not ok", LimePrinter::NOT_OK); 75 } 76 else if ($this->getWarnings()) 77 { 78 $this->printer->printLine("warning", LimePrinter::WARNING); 71 79 } 72 80 else 73 81 { 74 $this->printer->printLine( 'ok', LimePrinter::OK);75 } 76 77 if ($this-> errors || $this->warnings || $this->failed)82 $this->printer->printLine("ok", LimePrinter::OK); 83 } 84 85 if ($this->getErrors() || $this->getWarnings() || $this->getFailed()) 78 86 { 79 87 $this->printer->printText(' '); 80 $this->printer->printText('Passed: '.$this-> passed);81 $this->printer->printText(str_repeat(' ', 6 - strlen($this-> passed)));82 $this->printer->printText('Failed: '.$this-> failed, $this->failed> 0 ? LimePrinter::NOT_OK : null);83 $this->printer->printText(str_repeat(' ', 6 - strlen($this-> failed)));84 $this->printer->printText('Warnings: '.$this-> warnings, $this->warnings> 0 ? LimePrinter::WARNING : null);85 $this->printer->printText(str_repeat(' ', 6 - strlen($this-> warnings)));86 $this->printer->printLine('Errors: '.$this-> errors, $this->errors> 0 ? LimePrinter::NOT_OK : null);87 } 88 89 if ($this-> errors || $this->warnings || $this->failed|| $incomplete)90 { 91 $messages = LimeOutputConsoleDetailed::getMessages($ actual,92 $this-> expected, $this->passed, $this->errors, $this->warnings);88 $this->printer->printText('Passed: '.$this->getPassed()); 89 $this->printer->printText(str_repeat(' ', 6 - strlen($this->getPassed()))); 90 $this->printer->printText('Failed: '.$this->getFailed(), $this->getFailed() > 0 ? LimePrinter::NOT_OK : null); 91 $this->printer->printText(str_repeat(' ', 6 - strlen($this->getFailed()))); 92 $this->printer->printText('Warnings: '.$this->getWarnings(), $this->getWarnings() > 0 ? LimePrinter::WARNING : null); 93 $this->printer->printText(str_repeat(' ', 6 - strlen($this->getWarnings()))); 94 $this->printer->printLine('Errors: '.$this->getErrors(), $this->getErrors() > 0 ? LimePrinter::NOT_OK : null); 95 } 96 97 if ($this->getErrors() || $this->getWarnings() || $this->getFailed() || $incomplete) 98 { 99 $messages = LimeOutputConsoleDetailed::getMessages($this->getActual(), 100 $this->getExpected(), $this->getPassed(), $this->getErrors(), $this->getWarnings()); 93 101 94 102 foreach ($messages as $message) … … 101 109 } 102 110 111 protected function getExpected() 112 { 113 return $this->expected[$this->file]; 114 } 115 116 protected function getActual() 117 { 118 return $this->getPassed() + $this->getFailed(); 119 } 120 121 protected function getPassed() 122 { 123 return $this->passed[$this->file]; 124 } 125 126 protected function getFailed() 127 { 128 return $this->failed[$this->file]; 129 } 130 131 protected function getErrors() 132 { 133 return $this->errors[$this->file]; 134 } 135 136 protected function getWarnings() 137 { 138 return $this->warnings[$this->file]; 139 } 140 141 protected function setCursor() 142 { 143 for ($i = count($this->line); $i > $this->line[$this->file]; --$i) 144 { 145 $this->printer->previousLine(); 146 } 147 } 148 149 protected function resetCursor() 150 { 151 for ($i = $this->line[$this->file]; $i < count($this->line); ++$i) 152 { 153 $this->printer->nextLine(); 154 } 155 } 156 103 157 public function plan($amount) 104 158 { 105 $this->expected = $amount;159 $this->expected[$this->file] = $amount; 106 160 } 107 161 108 162 public function pass($message, $file, $line) 109 163 { 110 $this->passed++; 111 112 $this->update(); 164 $this->passed[$this->file]++; 113 165 } 114 166 115 167 public function fail($message, $file, $line, $error = null) 116 168 { 117 $this->failed++; 118 119 $this->update(); 169 $this->failed[$this->file]++; 120 170 } 121 171 … … 128 178 public function warning($message, $file, $line) 129 179 { 130 $this->warnings ++;180 $this->warnings[$this->file]++; 131 181 } 132 182 133 183 public function error(Exception $exception) 134 184 { 135 $this->errors ++;185 $this->errors[$this->file]++; 136 186 } 137 187 … … 140 190 public function flush() 141 191 { 142 $this->close();143 144 192 if ($this->failedFiles > 0) 145 193 { … … 161 209 } 162 210 163 protected function update() 164 { 165 if ($this->errors || $this->failed) 166 { 167 $style = LimePrinter::NOT_OK; 168 } 169 else if ($this->warnings) 170 { 171 $style = LimePrinter::WARNING; 211 protected function getTruncatedFile() 212 { 213 if (!is_null($this->options)) 214 { 215 return str_replace($this->options['base_dir'], '', $this->file); 172 216 } 173 217 else 174 218 { 175 $style = LimePrinter::OK;176 }177 178 $tests = $this->passed + $this->failed;179 180 $this->printer->printText(str_pad($this->getTruncatedFile(), 73, '.'));181 $this->printer->printText($tests."\r", $style);182 }183 184 protected function getTruncatedFile()185 {186 if (!is_null($this->options))187 {188 return str_replace($this->options['base_dir'], '', $this->file);189 }190 else191 {192 219 return $this->file; 193 220 } tools/lime/branches/2.0-experimental/lib/output/LimeOutputCoverage.php
r20975 r21230 12 12 class LimeOutputCoverage implements LimeOutputInterface 13 13 { 14 public function start($file) 14 public function supportsThreading() 15 { 16 return false; 17 } 18 19 public function focus($file) 15 20 { 16 21 xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); … … 21 26 echo serialize(xdebug_get_code_coverage()); 22 27 } 28 29 public function close() {} 23 30 24 31 public function plan($amount) {} tools/lime/branches/2.0-experimental/lib/output/LimeOutputInterface.php
r20975 r21230 12 12 interface LimeOutputInterface 13 13 { 14 public function start($file); 14 public function supportsThreading(); 15 16 public function focus($file); 17 18 public function close(); 15 19 16 20 public function plan($amount); tools/lime/branches/2.0-experimental/lib/output/LimeOutputNone.php
r20975 r21230 12 12 class LimeOutputNone implements LimeOutputInterface 13 13 { 14 public function start($file) {} 14 public function supportsThreading() 15 { 16 return true; 17 } 18 19 public function focus($file) {} 20 21 public function close() {} 15 22 16 23 public function plan($amount) {} tools/lime/branches/2.0-experimental/lib/output/LimeOutputPipe.php
r20974 r21230 16 16 $error = false, 17 17 $buffer = '', 18 $output = null; 18 $output = null, 19 $shell = null, 20 $file = null, 21 $handle = null, 22 $done = true; 19 23 20 24 public function __construct(LimeOutputInterface $output, array $suppressedMethods = array()) … … 22 26 $this->output = $output; 23 27 $this->suppressedMethods = $suppressedMethods; 28 $this->shell = new LimeShell(); 29 } 30 31 public function getConnectedFile() 32 { 33 return $this->file; 24 34 } 25 35 … … 28 38 $arguments['output'] = 'raw'; 29 39 40 $this->file = $file; 30 41 $this->buffer = ''; 42 $this->done = false; 43 $this->handle = $this->shell->spawn($file, $arguments); 44 } 31 45 32 $shell = new LimeShell(); 33 $shell->executeCallback(array($this, 'unserializeLines'), $file, $arguments); 46 public function proceed() 47 { 48 $this->unserializeLines(fread($this->handle, 2048)); 34 49 35 if ( !empty($this->buffer))50 if (feof($this->handle)) 36 51 { 37 $this->output->warning("Could not parse test output. Make sure you don't echo any additional data.", $file, 1); 52 if (!empty($this->buffer)) 53 { 54 $this->output->warning("Could not parse test output. Make sure you don't echo any additional data.", $this->file, 1); 55 } 56 57 $this->done = true; 38 58 } 39 59 } 40 60 41 public function unserializeLines($lines) 61 public function done() 62 { 63 return $this->done; 64 } 65 66 protected function unserializeLines($lines) 42 67 { 43 68 $this->buffer .= $lines; tools/lime/branches/2.0-experimental/lib/output/LimeOutputRaw.php
r20975 r21230 25 25 } 26 26 27 public function s tart($file)27 public function supportsThreading() 28 28 { 29 $this->printCall('start', array($file)); 29 return true; 30 } 31 32 public function focus($file) 33 { 34 $this->printCall('focus', array($file)); 35 } 36 37 public function close() 38 { 39 $this->printCall('close', array()); 30 40 } 31 41 tools/lime/branches/2.0-experimental/lib/output/LimeOutputXml.php
r20975 r21230 20 20 } 21 21 22 public function s tart($file)22 public function supportsThreading() 23 23 { 24 return $this->output->start($file); 24 return $this->output->supportsThreading(); 25 } 26 27 public function focus($file) 28 { 29 return $this->output->focus($file); 30 } 31 32 public function close($file) 33 { 34 return $this->output->close($file); 25 35 } 26 36 tools/lime/branches/2.0-experimental/test/unit/LimePrinterTest.php
r20975 r21230 51 51 $result = ob_get_clean(); 52 52 // assertions 53 $t->todo('asdf', 3);54 53 $t->is($result, "<RED>My text</RED>\n", 'The result was colorized and printed'); 55 54 tools/lime/branches/2.0-experimental/test/unit/LimeShellTest.php
r20981 r21230 14 14 LimeAnnotationSupport::enable(); 15 15 16 $t = new LimeTest( 9);16 $t = new LimeTest(6); 17 17 18 18 … … 78 78 79 79 80 // @Test: PHP scripts can be executed with a callback being called on each output81 82 // fixtures83 $mock = LimeMock::create('Dummy', $t);84 $mock->callback("Hello World!");85 $mock->callback("Foo\nBar");86 $mock->callback('');87 $mock->replay();88 file_put_contents($file, <<<EOF89 <?php90 echo "Hello World!";91 sleep(1);92 echo "Foo\nBar";93 exit(1);94 EOF95 );96 // test97 list($returnValue, $output) = $shell->executeCallback(array($mock, 'callback'), $file);98 // assertions99 $mock->verify();tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputArrayTest.php
r20390 r21230 14 14 LimeAnnotationSupport::enable(); 15 15 16 $t = new LimeTest( 1);16 $t = new LimeTest(2); 17 17 18 18 // @Before … … 87 87 ); 88 88 // test 89 $output-> start('/test/file1');89 $output->focus('/test/file1'); 90 90 $output->plan(3); 91 91 $output->pass('Test message 1', '/test/file1', 11); 92 92 $output->fail('Test message 2', '/test/file1', 22); 93 $output-> start('/test/file2');93 $output->focus('/test/file2'); 94 94 $output->plan(2); 95 95 $output->fail('Test message 3', '/test/file2', 33, 'error message'); … … 98 98 // assertions 99 99 $t->is($output->toArray(), $expected, 'The array is correct'); 100 101 102 // @Test: The array is constructed correctly when switching focus 103 104 // fixtures 105 $expected = array( 106 array( 107 'file' => '/test/file1', 108 'tests' => array( 109 1 => array( 110 'line' => 11, 111 'file' => '/test/file1', 112 'message' => 'Test message 1', 113 'status' => true, 114 ), 115 2 => array( 116 'line' => 22, 117 'file' => '/test/file1', 118 'message' => 'Test message 2', 119 'status' => false, 120 ), 121 ), 122 'stats' => array( 123 'plan' => 3, 124 'total' => 2, 125 'failed' => array(2), 126 'passed' => array(1), 127 'skipped' => array(), 128 ), 129 ), 130 array( 131 'file' => '/test/file2', 132 'tests' => array( 133 1 => array( 134 'line' => 33, 135 'file' => '/test/file2', 136 'message' => 'Test message 3', 137 'status' => false, 138 'error' => 'error message', 139 ), 140 2 => array( 141 'line' => 44, 142 'file' => '/test/file2', 143 'message' => 'Test message 4', 144 'status' => true, 145 ), 146 3 => array( 147 'line' => 55, 148 'file' => '/test/file2', 149 'message' => 'Test message 5', 150 'status' => true, 151 ), 152 ), 153 'stats' => array( 154 'plan' => 2, 155 'total' => 3, 156 'failed' => array(1), 157 'passed' => array(2), 158 'skipped' => array(3), 159 ), 160 ), 161 ); 162 // test 163 $output->focus('/test/file1'); 164 $output->plan(3); 165 $output->pass('Test message 1', '/test/file1', 11); 166 $output->focus('/test/file2'); 167 $output->plan(2); 168 $output->fail('Test message 3', '/test/file2', 33, 'error message'); 169 $output->pass('Test message 4', '/test/file2', 44); 170 $output->focus('/test/file1'); 171 $output->fail('Test message 2', '/test/file1', 22); 172 $output->focus('/test/file2'); 173 $output->skip('Test message 5', '/test/file2', 55); 174 // assertions 175 $t->is($output->toArray(), $expected, 'The array is correct'); tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputConsoleDetailedTest.php
r20976 r21230 28 28 29 29 30 // @Test: start() prints the filename30 // @Test: focus() prints the filename 31 31 32 32 $printer->printLine('# /test/file', LimePrinter::INFO); 33 33 $printer->replay(); 34 34 // test 35 $output-> start('/test/file');35 $output->focus('/test/file'); 36 36 // assertions 37 37 $printer->verify(); … … 45 45 $printer->replay(); 46 46 // test 47 $output-> start('/test/file');47 $output->focus('/test/file'); 48 48 // assertions 49 49 $printer->verify(); tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputConsoleSummaryTest.php
r20978 r21230 14 14 LimeAnnotationSupport::enable(); 15 15 16 $t = new LimeTest( 79);16 $t = new LimeTest(37); 17 17 18 18 … … 29 29 30 30 31 // @Test: The number of tests is updated on every input 32 33 // fixtures 34 $printer->printText(str_pad('/test/script', 73, '.')); 35 $printer->printText("1\r", LimePrinter::OK); 36 $printer->printText(str_pad('/test/script', 73, '.')); 37 $printer->printText("2\r", LimePrinter::OK); 38 $printer->printText(str_pad('/test/script', 73, '.')); 39 $printer->printText("3\r", LimePrinter::OK); 40 $printer->replay(); 41 // test 42 $output->start('/test/script'); 43 $output->pass('A passed test', '/test/script', 11); 44 $output->pass('A passed test', '/test/script', 22); 45 $output->pass('A passed test', '/test/script', 33); 46 // assertions 47 $printer->verify(); 48 49 50 // @Test: Once any test has failed, the style of the number is LimePrinter::NOT_OK 51 52 // fixtures 53 $printer->printText(str_pad('/test/script', 73, '.')); 54 $printer->printText("1\r", LimePrinter::OK); 55 $printer->printText(str_pad('/test/script', 73, '.')); 56 $printer->printText("2\r", LimePrinter::NOT_OK); 57 $printer->printText(str_pad('/test/script', 73, '.')); 58 $printer->printText("3\r", LimePrinter::NOT_OK); 59 $printer->replay(); 60 // test 61 $output->start('/test/script'); 62 $output->pass('A passed test', '/test/script', 11); 63 $output->fail('A failed test', '/test/script', 22); 64 $output->pass('A passed test', '/test/script', 33); 65 // assertions 66 $printer->verify(); 67 68 69 // @Test: Once a warning has appeared, the style of the number is LimePrinter::WARNING 70 71 // fixtures 72 $printer->printText(str_pad('/test/script', 73, '.')); 73 $printer->printText("1\r", LimePrinter::OK); 74 $printer->printText(str_pad('/test/script', 73, '.')); 75 $printer->printText("2\r", LimePrinter::WARNING); 76 $printer->replay(); 77 // test 78 $output->start('/test/script'); 79 $output->pass('A passed test', '/test/script', 11); 80 $output->warning('A warning', '/test/script', 22); 81 $output->pass('A passed test', '/test/script', 33); 82 // assertions 83 $printer->verify(); 84 85 86 // @Test: Once an error has appeared, the style of the number is LimePrinter::NOT_OK 87 88 // fixtures 89 $printer->printText(str_pad('/test/script', 73, '.')); 90 $printer->printText("1\r", LimePrinter::OK); 91 $printer->printText(str_pad('/test/script', 73, '.')); 92 $printer->printText("2\r", LimePrinter::NOT_OK); 93 $printer->replay(); 94 // test 95 $output->start('/test/script'); 31 // @Test: When close() is called, the test summary is printed 32 33 // fixtures 34 $printer->printText(str_pad('/test/script', 73, '.')); 35 $printer->printLine("ok", LimePrinter::OK); 36 $printer->replay(); 37 // test 38 $output->focus('/test/script'); 39 $output->pass('A passed test', '/test/script', 11); 40 $output->close(); 41 // assertions 42 $printer->verify(); 43 44 45 // @Test: When close() is called and tests failed, the status is "not ok" 46 47 // fixtures 48 $printer->printText(str_pad('/test/script', 73, '.')); 49 $printer->printLine("not ok", LimePrinter::NOT_OK); 50 $printer->any('printText'); 51 $printer->any('printLine'); 52 $printer->replay(); 53 // test 54 $output->focus('/test/script'); 55 $output->fail('A failed test', '/test/script', 11); 56 $output->close(); 57 // assertions 58 $printer->verify(); 59 60 61 // @Test: When close() is called and warnings appeared in the test, the status is warning 62 63 // fixtures 64 $printer->printText(str_pad('/test/script', 73, '.')); 65 $printer->printLine("warning", LimePrinter::WARNING); 66 $printer->any('printText'); 67 $printer->any('printLine'); 68 $printer->replay(); 69 // test 70 $output->focus('/test/script'); 71 $output->pass('A passed test', '/test/script', 11); 72 $output->warning('A warning', '/test/script', 33); 73 $output->close(); 74 // assertions 75 $printer->verify(); 76 77 78 // @Test: When close() is called and errors appeared in the test, the status is "not ok" 79 80 // fixtures 81 $printer->printText(str_pad('/test/script', 73, '.')); 82 $printer->printLine("not ok", LimePrinter::NOT_OK); 83 $printer->any('printText'); 84 $printer->any('printLine'); 85 $printer->replay(); 86 // test 87 $output->focus('/test/script'); 96 88 $output->pass('A passed test', '/test/script', 11); 97 89 $output->error(new LimeError('An error', '/test/script', 22)); 98 $output->pass('A passed test', '/test/script', 33); 99 // assertions 100 $printer->verify(); 101 102 103 // @Test: If both a warning and an error appeared, the style is LimePrinter::NOT_OK 104 105 // fixtures 106 $printer->printText(str_pad('/test/script', 73, '.')); 107 $printer->printText("1\r", LimePrinter::OK); 108 $printer->printText(str_pad('/test/script', 73, '.')); 109 $printer->printText("2\r", LimePrinter::NOT_OK); 110 $printer->replay(); 111 // test 112 $output->start('/test/script'); 113 $output->pass('A passed test', '/test/script', 11); 114 $output->error(new LimeError('An error', '/test/script', 22)); 115 $output->warning('A warning', '/test/script', 33); 116 $output->pass('A passed test', '/test/script', 44); 117 // assertions 118 $printer->verify(); 119 120 121 // @Test: When start() is called again, a new line for the new test is started 122 123 // fixtures 124 $printer->printText(str_pad('/test/script', 73, '.')); 125 $printer->printText("1\r", LimePrinter::OK); 126 $printer->printText(str_pad('/test/script', 73, '.')); 127 $printer->printLine("ok", LimePrinter::OK); 128 $printer->replay(); 129 // test 130 $output->start('/test/script'); 131 $output->pass('A passed test', '/test/script', 11); 132 $output->start('/test/script2'); 133 // assertions 134 $printer->verify(); 135 136 137 // @Test: When start() is called again and tests failed, the status is "not ok" 138 139 // fixtures 140 $printer->printText(str_pad('/test/script', 73, '.')); 141 $printer->printText("1\r", LimePrinter::NOT_OK); 142 $printer->printText(str_pad('/test/script', 73, '.')); 143 $printer->printLine("not ok", LimePrinter::NOT_OK); 144 $printer->any('printText'); 145 $printer->any('printLine'); 146 $printer->replay(); 147 // test 148 $output->start('/test/script'); 149 $output->fail('A failed test', '/test/script', 11); 150 $output->start('/test/script2'); 151 // assertions 152 $printer->verify(); 153 154 155 // @Test: When start() is called again and warnings appeared in the test, the status is warning 156 157 // fixtures 158 $printer->printText(str_pad('/test/script', 73, '.')); 159 $printer->printText("1\r", LimePrinter::OK); 160 $printer->printText(str_pad('/test/script', 73, '.')); 161 $printer->printLine("warning", LimePrinter::WARNING); 162 $printer->any('printText'); 163 $printer->any('printLine'); 164 $printer->replay(); 165 // test 166 $output->start('/test/script'); 167 $output->pass('A passed test', '/test/script', 11); 168 $output->warning('A warning', '/test/script', 33); 169 $output->start('/test/script2'); 170 // assertions 171 $printer->verify(); 172 173 174 // @Test: When start() is called again and errors appeared in the test, the status is "not ok" 175 176 // fixtures 177 $printer->printText(str_pad('/test/script', 73, '.')); 178 $printer->printText("1\r", LimePrinter::OK); 179 $printer->printText(str_pad('/test/script', 73, '.')); 180 $printer->printLine("not ok", LimePrinter::NOT_OK); 181 $printer->any('printText'); 182 $printer->any('printLine'); 183 $printer->replay(); 184 // test 185 $output->start('/test/script'); 186 $output->pass('A passed test', '/test/script', 11); 187 $output->error(new LimeError('An error', '/test/script', 22)); 188 $output->start('/test/script2'); 189 // assertions 190 $printer->verify(); 191 192 193 // @Test: When start() is called again, the styles are reset 194 195 // fixtures 196 $printer->printText(str_pad('/test/script', 73, '.')); 197 $printer->printText("1\r", LimePrinter::OK); 198 $printer->printText(str_pad('/test/script', 73, '.')); 199 $printer->printLine("not ok", LimePrinter::NOT_OK); 200 $printer->any('printText'); 201 $printer->any('printLine'); 202 $printer->printText(str_pad('/test/script2', 73, '.')); 203 $printer->printText("1\r", LimePrinter::OK); 204 $printer->replay(); 205 // test 206 $output->start('/test/script'); 207 $output->pass('A passed test', '/test/script', 11); 208 $output->error(new LimeError('An error', '/test/script', 22)); 209 $output->start('/test/script2'); 210 $output->pass('A passed test', '/test/script2', 11); 211 // assertions 212 $printer->verify(); 213 214 215 // @Test: When start() is called again and the plan did not match, a message is printed 216 217 // fixtures 218 $printer->printText(str_pad('/test/script', 73, '.')); 219 $printer->printText("1\r", LimePrinter::OK); 90 $output->close(); 91 // assertions 92 $printer->verify(); 93 94 95 // @Test: When close() is called and the plan did not match, a message is printed 96 97 // fixtures 220 98 $printer->printText(str_pad('/test/script', 73, '.')); 221 99 $printer->printLine("not ok", LimePrinter::NOT_OK); … … 223 101 $printer->replay(); 224 102 // test 225 $output-> start('/test/script');103 $output->focus('/test/script'); 226 104 $output->plan(2); 227 105 $output->pass('A passed test', '/test/script', 11); 228 $output-> start('/test/script2');229 // assertions 230 $printer->verify(); 231 232 233 // @Test: When start() is called againand anything failed, detailed statistics are printed106 $output->close(); 107 // assertions 108 $printer->verify(); 109 110 111 // @Test: When close() is called and anything failed, detailed statistics are printed 234 112 235 113 // fixtures … … 247 125 $printer->replay(); 248 126 // test 249 $output-> start('/test/script');127 $output->focus('/test/script'); 250 128 $output->pass('A passed test', '/test/script', 11); 251 129 $output->fail('A failed test', '/test/script', 11); … … 254 132 $output->error(new LimeError('An error', '/test/script', 11)); 255 133 $output->error(new LimeError('An error', '/test/script', 11)); 256 $output-> start('/test/script2');134 $output->close(); 257 135 // assertions 258 136 $printer->verify(); … … 269 147 $output = new LimeOutputConsoleSummary($printer); 270 148 // test 271 $output->start('/test/script1'); 272 $output->pass('A passed test', '/test/script', 11); 273 $output->start('/test/script2'); 149 $output->focus('/test/script1'); 150 $output->pass('A passed test', '/test/script', 11); 151 $output->close(); 152 $output->focus('/test/script2'); 274 153 $output->pass('A passed test', '/test/script2', 11); 275 154 $output->warning('A warning', '/test/script2', 11); 276 $output->start('/test/script3'); 155 $output->close(); 156 $output->focus('/test/script3'); 277 157 $output->fail('A failed test', '/test/script3', 11); 278 $output->start('/test/script4'); 158 $output->close(); 159 $output->focus('/test/script4'); 279 160 $output->pass('A passed test', '/test/script', 11); 280 161 $output->error(new LimeError('An error', '/test/script', 11)); 281 $output->start('/test/script5'); 282 $output->pass('A passed test', '/test/script', 11); 162 $output->close(); 163 $output->focus('/test/script5'); 164 $output->pass('A passed test', '/test/script', 11); 165 $output->close(); 283 166 $output->flush(); 284 167 // assertions … … 297 180 $output = new LimeOutputConsoleSummary($printer); 298 181 // test 299 $output-> start('/test/script1');182 $output->focus('/test/script1'); 300 183 $output->pass('A passed test', '/test/script1', 11); 301 $output->start('/test/script2'); 184 $output->close(); 185 $output->focus('/test/script2'); 302 186 $output->pass('A passed test', '/test/script2', 11); 303 187 $output->pass('A passed test', '/test/script2', 11); 188 $output->close(); 304 189 $output->flush(); 305 190 // assertions … … 313 198 $printer->reset(); 314 199 $printer->printText(str_pad('/script', 73, '.')); 315 $printer->printText("1\r", LimePrinter::OK); 316 $printer->replay(); 317 // test 318 $output->start('/test/script'); 319 $output->pass('A passed test', '/test/script', 11); 320 // assertions 321 $printer->verify(); 200 $printer->printLine("ok", LimePrinter::OK); 201 $printer->replay(); 202 // test 203 $output->focus('/test/script'); 204 $output->pass('A passed test', '/test/script', 11); 205 $output->close(); 206 // assertions 207 $printer->verify(); tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputInspectableTest.php
r20975 r21230 79 79 // fixtures 80 80 $mock = LimeMock::create('LimeOutputInterface', $t); 81 $mock-> start('/test/file');81 $mock->focus('/test/file'); 82 82 $mock->pass('A passed test', '/test/script', 11); 83 83 $mock->fail('A failed test', '/test/script', 11, 'The error'); … … 91 91 $output = new LimeOutputInspectable($mock); 92 92 // test 93 $output-> start('/test/file');93 $output->focus('/test/file'); 94 94 $output->pass('A passed test', '/test/script', 11); 95 95 $output->fail('A failed test', '/test/script', 11, 'The error'); tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputPipeTest.php
r20974 r21230 43 43 // test 44 44 $connector->connect($file); 45 while (!$connector->done()) $connector->proceed(); 45 46 // assertions 46 47 $output->verify(); … … 59 60 // test 60 61 $connector->connect($file); 62 while (!$connector->done()) $connector->proceed(); 61 63 // assertions 62 64 $output->verify(); … … 78 80 // test 79 81 $connector->connect($file); 82 while (!$connector->done()) $connector->proceed(); 80 83 // assertions 81 84 $output->verify(); … … 94 97 // test 95 98 $connector->connect($file); 99 while (!$connector->done()) $connector->proceed(); 96 100 // assertions 97 101 $output->verify(); … … 111 115 // test 112 116 $connector->connect($file); 117 while (!$connector->done()) $connector->proceed(); 113 118 // assertions 114 119 $output->verify(); … … 129 134 // test 130 135 $connector->connect($file); 136 while (!$connector->done()) $connector->proceed(); 131 137 // assertions 132 138 $output->verify(); … … 148 154 // test 149 155 $connector->connect($file); 156 while (!$connector->done()) $connector->proceed(); 150 157 // assertions 151 158 $output->verify(); … … 163 170 // test 164 171 $connector->connect($file); 172 while (!$connector->done()) $connector->proceed(); 165 173 // assertions 166 174 $output->verify(); … … 175 183 // test 176 184 $connector->connect($file); 185 while (!$connector->done()) $connector->proceed(); 177 186 // assertions 178 187 $output->verify(); … … 189 198 // test 190 199 $connector->connect($file); 200 while (!$connector->done()) $connector->proceed(); 191 201 // assertions 192 202 $output->verify(); … … 202 212 // test 203 213 $connector->connect($file); 204 // assertions 205 $output->verify(); 214 while (!$connector->done()) $connector->proceed(); 215 // assertions 216 $output->verify(); tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputRawTest.php
r20975 r21230 14 14 LimeAnnotationSupport::enable(); 15 15 16 $t = new LimeTest(1 1);16 $t = new LimeTest(12); 17 17 18 18 … … 27 27 28 28 29 // @Test: start() prints the method call as serialized array29 // @Test: focus() prints the method call as serialized array 30 30 31 31 // test 32 32 ob_start(); 33 $output-> start('/test/file');33 $output->focus('/test/file'); 34 34 $result = ob_get_clean(); 35 35 // assertions 36 $t->is($result, serialize(array('start', array('/test/file')))."\n", 'The method call is serialized'); 36 $t->is($result, serialize(array('focus', array('/test/file')))."\n", 'The method call is serialized'); 37 38 39 // @Test: close() prints the method call as serialized array 40 41 // test 42 ob_start(); 43 $output->close(); 44 $result = ob_get_clean(); 45 // assertions 46 $t->is($result, serialize(array('close', array()))."\n", 'The method call is serialized'); 37 47 38 48