예제 #1
0
 public function testEvents()
 {
     $service = new \Box\Mod\Client\Service();
     $service->setDi($this->di);
     $params = array('id' => 1, 'password' => 'qwerty123');
     $event = new Box_Event(null, 'name', $params, $this->api_admin, $this->api_guest);
     $event->setDi($this->di);
     $bool = $service->onAfterClientSignUp($event);
     $this->assertTrue($bool);
 }
예제 #2
0
 public function testExceptiononAfterClientSignUp()
 {
     $eventParams = array('password' => 'testPassword', 'id' => 1);
     $eventMock = $this->getMockBuilder('\\Box_Event')->disableOriginalConstructor()->getMock();
     $eventMock->expects($this->atLeastOnce())->method('getParameters')->will($this->returnValue($eventParams));
     $service = $this->getMockBuilder('\\Box\\Mod\\Email\\Service')->getMock();
     $service->expects($this->atLeastOnce())->method('sendTemplate')->will($this->throwException(new \Exception('exception created in unit test')));
     $di = new \Box_Di();
     $di['mod_service'] = $di->protect(function () use($service) {
         return $service;
     });
     $di['mod_config'] = $di->protect(function ($name) use($di) {
         array('require_email_confirmation' => false);
     });
     $eventMock->expects($this->atLeastOnce())->method('getDi')->will($this->returnValue($di));
     $clientService = new \Box\Mod\Client\Service();
     $clientService->setDi($di);
     $result = $clientService->onAfterClientSignUp($eventMock);
     $this->assertTrue($result);
 }