Example #1
0
 /**
  * Transforms the annotations in the script file and executes the resulting
  * script.
  */
 public function execute()
 {
     if (file_exists($this->path)) {
         unlink($this->path);
     }
     $this->lexer = new LimeLexerTransformAnnotations($this->path);
     $callbacks = $this->lexer->parse($this->originalPath);
     $this->includeTestFile();
     $testRunner = new LimeTestRunner($this->test ? $this->test->getOutput() : null);
     if ($this->test instanceof LimeTest) {
         $testRunner->addBefore(array($this->test, 'beginTest'));
     }
     foreach ($callbacks as $annotation => $callbacks) {
         $addMethod = 'add' . $annotation;
         foreach ($callbacks as $list) {
             list($callback, $comment, $file, $line) = $list;
             $testRunner->{$addMethod}($callback, $comment, $file, $line);
         }
     }
     if ($this->test instanceof LimeTest) {
         $testRunner->addExceptionHandler(array($this->test, 'handleException'));
         $testRunner->addAfter(array($this->test, 'endTest'));
     }
     $testRunner->run();
 }
Example #2
0
/*
 * This file is part of the Lime framework.
 *
 * (c) Fabien Potencier <*****@*****.**>
 * (c) Bernhard Schussek <*****@*****.**>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */
$t = new LimeTest();
$t->diag('The before callbacks are called before each test method');
// fixtures
$mock = $t->mock('Mock', array('strict' => true));
$r = new LimeTestRunner();
$r->addBefore(array($mock, 'setUp'));
$r->addTest(array($mock, 'testDoSomething'), 'Do something', '/test/file', 11);
$r->addTest(array($mock, 'testDoSomethingElse'), 'Do something else', '/test/file', 22);
$mock->setUp('Do something', '/test/file', 11);
$mock->testDoSomething();
$mock->setUp('Do something else', '/test/file', 22);
$mock->testDoSomethingElse();
$mock->replay();
// test
$r->run();
$t->diag('The after callbacks are called before each test method');
// fixtures
$mock = $t->mock('Mock', array('strict' => true));
$r = new LimeTestRunner();
$r->addAfter(array($mock, 'tearDown'));
$r->addTest(array($mock, 'testDoSomething'), '', '', 0);