Override to run the test and assert its state.
mixed
protected function runTest() {
if ($this->name === NULL) {
throw new PHPUnit_Framework_Exception('PHPUnit_Framework_TestCase::$name must not be NULL.');
}
try {
$class = new ReflectionClass($this);
$method = $class
->getMethod($this->name);
} catch (ReflectionException $e) {
$this
->fail($e
->getMessage());
}
try {
$testResult = $method
->invokeArgs($this, array_merge($this->data, $this->dependencyInput));
} catch (Exception $e) {
$checkException = FALSE;
if (is_string($this->expectedException)) {
$checkException = TRUE;
if ($e instanceof PHPUnit_Framework_Exception) {
$checkException = FALSE;
}
$reflector = new ReflectionClass($this->expectedException);
if ($this->expectedException == 'PHPUnit_Framework_Exception' || $reflector
->isSubclassOf('PHPUnit_Framework_Exception')) {
$checkException = TRUE;
}
}
if ($checkException) {
$this
->assertThat($e, new PHPUnit_Framework_Constraint_Exception($this->expectedException));
if (is_string($this->expectedExceptionMessage) && !empty($this->expectedExceptionMessage)) {
$this
->assertThat($e, new PHPUnit_Framework_Constraint_ExceptionMessage($this->expectedExceptionMessage));
}
if ($this->expectedExceptionCode !== NULL) {
$this
->assertThat($e, new PHPUnit_Framework_Constraint_ExceptionCode($this->expectedExceptionCode));
}
return;
}
else {
throw $e;
}
}
if ($this->expectedException !== NULL) {
$this
->assertThat(NULL, new PHPUnit_Framework_Constraint_Exception($this->expectedException));
}
return $testResult;
}