public function testRunEventWrongTarget() { $e = new RunEvent(); $this->setExpectedException('ZFTool\\Diagnostics\\Exception\\InvalidArgumentException'); $e->setTarget(new \stdClass()); }
public function testCatchErrors() { \PHPUnit_Framework_Error_Warning::$enabled = false; \PHPUnit_Framework_Error_Notice::$enabled = false; $e = new RunEvent(); $this->listener->setCatchErrorSeverity(E_WARNING); $test = new TriggerWarningTest(); $e->setTarget($test); $result = $this->em->trigger(RunEvent::EVENT_RUN, $e)->last(); $this->assertInstanceOf('ZFTool\\Diagnostics\\Result\\Failure', $result); $this->assertInstanceOf('ErrorException', $result->getData()); $e = new RunEvent(); $this->listener->setCatchErrorSeverity(E_WARNING | E_USER_ERROR); $test = new TriggerUserErrorTest('bar', E_USER_ERROR); $e->setTarget($test); $result = $this->em->trigger(RunEvent::EVENT_RUN, $e)->last(); $this->assertInstanceOf('ZFTool\\Diagnostics\\Result\\Failure', $result); $this->assertStringStartsWith('PHP USER_ERROR: bar', $result->getMessage()); $this->assertInstanceOf('ErrorException', $result->getData()); }