/** * Add test result node, if it does not yet exist. * * @param unittest.TestCase case * @return xml.Node */ protected function testNode(TestCase $case) { $class = $case->getClass(); if (!$this->classes->containsKey($class)) { $this->classes[$class] = $this->tree->addChild(new \xml\Node('testsuite', null, ['name' => $class->getName(), 'file' => $this->uriFor($class), 'tests' => 0, 'failures' => 0, 'errors' => 0, 'skipped' => 0, 'time' => 0])); } return $this->classes[$class]; }
/** * After test: Update field * * @param unittest.TestCase $t */ public function afterTest(TestCase $t) { $f = $t->getClass()->getField($this->field); $f->set($t, array_merge($f->get($t), ['after'])); }
/** * Run a single test * * @param unittest.TestCase test * @return unittest.TestResult * @throws lang.IllegalArgumentException in case given argument is not a testcase * @throws lang.MethodNotImplementedException in case given argument is not a valid testcase */ public function runTest(TestCase $test) { $class = $test->getClass(); if (!$class->hasMethod($test->name)) { throw new MethodNotImplementedException('Test method does not exist', $test->name); } $this->notifyListeners('testRunStarted', [$this]); // Run the single test $result = new TestResult(); try { $this->beforeClass($class); $this->runInternal($test, $result); $this->afterClass($class); $this->notifyListeners('testRunFinished', [$this, $result, null]); } catch (PrerequisitesNotMetError $e) { $this->notifyListeners('testSkipped', [$result->setSkipped($test, $e, 0.0)]); } catch (StopTests $stop) { $this->notifyListeners('testRunFinished', [$this, $result, $stop]); } return $result; }
/** * After test: Update field * * @param unittest.TestCase $t */ public function afterTest(\unittest\TestCase $t) { $f = $t->getClass()->getField($this->field); $f->set($t, array_merge($f->get($t), array('after'))); }