示例#1
0
 public function testAfterRunStopTesting()
 {
     $eventFired = false;
     $eventFired2 = false;
     $self = $this;
     $test1 = new AlwaysSuccessTest();
     $test2 = new ReturnThisTest(new Failure());
     $this->runner->addTest($test1);
     $this->runner->addTest($test2);
     $this->runner->getEventManager()->attach(RunEvent::EVENT_AFTER_RUN, function (RunEvent $e) use(&$self, &$test1, &$eventFired) {
         $eventFired = true;
         $self->assertInstanceOf('ZFTool\\Diagnostics\\Test\\TestInterface', $e->getTarget());
         // stop testing after first test
         if ($e->getTarget() === $test1) {
             return false;
         }
     });
     $this->runner->getEventManager()->attach(RunEvent::EVENT_STOP, function (RunEvent $e) use(&$self, &$test1, &$eventFired2) {
         $eventFired2 = true;
         $self->assertInstanceOf('ZFTool\\Diagnostics\\Result\\Collection', $e->getResults());
         $self->assertInstanceOf('ZFTool\\Diagnostics\\Result\\Success', $e->getLastResult());
         $self->assertSame($test1, $e->getTarget());
     });
     $results = $this->runner->run();
     $this->assertTrue($eventFired);
     $this->assertTrue($eventFired2);
     $this->assertNotNull($results[$test1]);
     $this->assertNotContains($test2, $results);
 }
示例#2
0
 public function testDummyReporterStopped()
 {
     $reporter = new DummyReporter();
     $runner = new Runner();
     $runner->addReporter($reporter);
     $test = new AlwaysSuccessTest();
     $runner->addTest($test);
     $runner->getEventManager()->attach(RunEvent::EVENT_AFTER_RUN, function () {
         return false;
     });
     $runner->run();
 }