Development

Changeset 20335

You must first sign up to be able to contribute.

Changeset 20335

Show
Ignore:
Timestamp:
07/19/09 22:06:29 (4 years ago)
Author:
bschussek
Message:

Fixed failing tests for LimeTest?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/lime/branches/2.0-experimental/lib/LimeTest.php

    r20332 r20335  
    4343 
    4444    $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    } 
    4650 
    4751    $this->options['base_dir'] = realpath($this->options['base_dir']); 
     
    262266  public function unlike($exp, $regex, $message = '') 
    263267  { 
    264     $error = sprintf("              '%s'\nmatches '%s'", $exp, $regex); 
     268    $error = sprintf("         '%s'\nmatches '%s'", $exp, $regex); 
    265269 
    266270    return $this->test(!preg_match($regex, $exp), $message, $error); 
     
    303307      if (!method_exists($object, $method)) 
    304308      { 
    305         $failedMessages[] = sprintf("      method '%s' does not exist", $method); 
     309        $failedMessages[] = sprintf("method '%s' does not exist", $method); 
    306310        $result = false; 
    307311      } 
     
    323327  { 
    324328    $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); 
    326330 
    327331    return $this->test($type == $class, $message, $error); 
     
    407411  public function todo($message = '') 
    408412  { 
    409     $this->skip('TODO: '.$message); 
     413    $this->skip(trim('TODO '.$message)); 
    410414  } 
    411415 
  • tools/lime/branches/2.0-experimental/lib/output/LimeOutputConsoleDetailed.php

    r20324 r20335  
    1313{ 
    1414  protected 
     15    $expected = null, 
    1516    $passed = 0, 
    16     $expected = 0, 
    1717    $actual = 0, 
    1818    $printer = null; 
     
    2626  { 
    2727    $this->expected = $amount; 
    28  
    2928    $this->printer->printLine('1..'.$amount); 
    3029  } 
     
    3534    $this->passed++; 
    3635 
    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    } 
    3945  } 
    4046 
     
    4349    $this->actual++; 
    4450 
    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 
    4761    $this->printer->printLine(sprintf('#     Failed test (%s at line %s)', $file, $line), LimePrinter::COMMENT); 
    4862 
     
    5973  { 
    6074    $this->actual++; 
     75    $this->passed++; 
    6176 
    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    } 
    6486  } 
    6587 
     
    81103  public function flush() 
    82104  { 
     105    if (is_null($this->expected)) 
     106    { 
     107      $this->plan($this->actual, null); 
     108    } 
     109 
    83110    if ($this->passed == $this->expected) 
    84111    { 
     
    87114    else if ($this->passed != $this->actual) 
    88115    { 
    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); 
    90117    } 
    91118 
    92119    if ($this->actual > $this->expected) 
    93120    { 
    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); 
    95122    } 
    96123    else if ($this->actual < $this->expected) 
     
    98125      $this->printer->printBox(sprintf(' Looks like you planned %s tests but only ran %s.', $this->expected, $this->actual), LimePrinter::ERROR); 
    99126    } 
    100     else 
    101     { 
    102     } 
    103127  } 
    104128} 
  • tools/lime/branches/2.0-experimental/test/unit/LimeTest/skip.phpt

    r19496 r20335  
    77?> 
    88--EXPECT-- 
    9 ok 1 # SKIP 
     9skip 1 
    10101..1 
    1111 Looks like everything went fine. 
  • tools/lime/branches/2.0-experimental/test/unit/LimeTest/skip_name.phpt

    r19496 r20335  
    77?> 
    88--EXPECT-- 
    9 ok 1 # SKIP test name 
    10 ok 2 # SKIP test name 
     9skip 1 - test name 
     10skip 2 - test name 
    11111..2 
    1212 Looks like everything went fine. 
  • tools/lime/branches/2.0-experimental/test/unit/LimeTest/todo.phpt

    r19496 r20335  
    77?> 
    88--EXPECT-- 
    9 ok 1 # TODO 
     9skip 1 - TODO 
    10101..1 
    1111 Looks like everything went fine. 
  • tools/lime/branches/2.0-experimental/test/unit/LimeTest/todo_name.phpt

    r19496 r20335  
    77?> 
    88--EXPECT-- 
    9 ok 1 # TODO test name 
     9skip 1 - TODO test name 
    10101..1 
    1111 Looks like everything went fine. 
  • tools/lime/branches/2.0-experimental/test/unit/output/LimeOutputConsoleDetailedTest.php

    r20324 r20335  
    1414LimeAnnotationSupport::enable(); 
    1515 
    16 $t = new LimeTest(26); 
     16$t = new LimeTest(33); 
    1717 
    1818// @Before 
     
    5050  $output->pass('A passed test', '/test/file', 11); 
    5151  $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); 
    5263  // assertions 
    5364  $printer->verify(); 
     
    7384 
    7485 
     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 
    7598// @Test: skip() prints and counts skipped tests 
    7699 
     
    88111 
    89112 
     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 
    90124// @Test: warning() prints a warning 
    91125 
     
    166200 
    167201  // fixtures 
    168   $output->plan(2, '/test/file'); 
     202  $output->plan(3, '/test/file'); 
    169203  $output->pass('First test', '/test/file', 11); 
    170204  $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); 
    173208  $printer->replay(); 
    174209  // test 
     
    191226  // assertions 
    192227  $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();