Exemplo n.º 1
0
 public function testauthorizeAdmin()
 {
     $email = '*****@*****.**';
     $password = '******';
     $model = new \Model_Admin();
     $model->loadBean(new \RedBeanPHP\OODBBean());
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('findOne')->with('Admin', 'email = ? AND status = ?')->willReturn($model);
     $authMock = $this->getMockBuilder('\\Box_Authorization')->disableOriginalConstructor()->getMock();
     $authMock->expects($this->atLeastOnce())->method('authorizeUser')->with($model, $password)->willReturn($model);
     $di = new \Box_Di();
     $di['db'] = $dbMock;
     $di['auth'] = $authMock;
     $service = new \Box\Mod\Staff\Service();
     $service->setDi($di);
     $result = $service->authorizeAdmin($email, $password);
     $this->assertInstanceOf('\\Model_Admin', $result);
 }