Exemple #1
0
 /**
  * Creates a suite and adds it to the current suite. The newly
  * created suite will become the new "current" suite
  *
  * @param $description
  * @param callable $fn
  */
 public function addSuite($description, callable $fn, $pending = null)
 {
     $suite = new Suite($description, $fn);
     if (!is_null($pending)) {
         $suite->setPending($pending);
     }
     $this->getCurrentSuite()->addTest($suite);
     array_unshift($this->suites, $suite);
     call_user_func($suite->getDefinition());
     array_shift($this->suites);
     return $suite;
 }
Exemple #2
0
     });
     $fn = function () {
     };
     $test1 = new Test("should have log", $fn);
     $test2 = new Test("should have log too", $fn);
     $suite->addTest($test1);
     $suite->addTest($test2);
     $result = new TestResult($this->eventEmitter);
     $suite->setEventEmitter($this->eventEmitter);
     $suite->run($result);
     assert('torntorn' == $test1->getScope()->log . $test2->getScope()->log, "tear down should have run for both tests");
 });
 it("should set pending status on tests if not null", function () {
     $suite = new Suite("Suite", function () {
     });
     $suite->setPending(true);
     $fn = function () {
     };
     $test1 = new Test("should have log", $fn);
     $suite->addTest($test1);
     $result = new TestResult($this->eventEmitter);
     $suite->setEventEmitter($this->eventEmitter);
     $suite->run($result);
     assert($test1->getPending(), "test should be pending");
 });
 it("should emit a suite.start event", function () {
     $suite = new Suite("Suite", function () {
     });
     $emitted = null;
     $this->eventEmitter->on('suite.start', function ($s) use(&$emitted) {
         $emitted = $s;
Exemple #3
0
 /**
  * Create a Suite based on the state of the Context.
  *
  * @param $description
  * @param callable $fn
  * @param $pending
  * @return Suite
  */
 private function createSuite($description, callable $fn, $pending)
 {
     $suite = new Suite($description, $fn);
     if ($pending !== null) {
         $suite->setPending($pending);
     }
     $suite->setFile($this->file);
     $suite->setEventEmitter($this->getEventEmitter());
     return $suite;
 }