public function testonAfterClientReplyTicket_Exception() { $eventMock = $this->getMockBuilder('\\Box_Event')->disableOriginalConstructor()->getMock(); $supportServiceMock = $this->getMockBuilder('\\Box\\Mod\\Support\\Service')->getMock(); $supportServiceMock->expects($this->atLeastOnce())->method('getTicketById')->will($this->returnValue(new \Model_SupportTicket())); $supportServiceMock->expects($this->atLeastOnce())->method('toApiArray')->will($this->returnValue(array())); $emailServiceMock = $this->getMockBuilder('\\Box\\Mod\\Email\\Service')->getMock(); $emailServiceMock->expects($this->atLeastOnce())->method('sendTemplate')->willThrowException(new \Exception('PHPunit controlled Exception')); $eventMock->expects($this->atLeastOnce())->method('getparameters'); $service = new \Box\Mod\Staff\Service(); $di = new \Box_Di(); $di['mod_service'] = $di->protect(function ($name) use($supportServiceMock, $emailServiceMock) { if ($name == 'support') { return $supportServiceMock; } if ($name == 'email') { return $emailServiceMock; } }); $eventMock->expects($this->atLeastOnce())->method('getDi')->will($this->returnValue($di)); $service->setDi($di); $service->onAfterClientReplyTicket($eventMock); }