示例#1
0
 /**
  * @covers ZfcUser\Authentication\Adapter\Db::Authenticate
  */
 public function testAuthenticationAuthenticates()
 {
     $this->setAuthenticationCredentials();
     $this->setAuthenticationUser();
     $this->options->expects($this->once())->method('getEnableUserState')->will($this->returnValue(true));
     $this->options->expects($this->once())->method('getAllowedLoginStates')->will($this->returnValue(array(1, 2, 3)));
     $this->bcrypt->expects($this->once())->method('verify')->will($this->returnValue(true));
     $this->bcrypt->expects($this->any())->method('getCost')->will($this->returnValue(static::PASSWORD_COST_04));
     $this->user->expects($this->exactly(2))->method('getPassword')->will($this->returnValue('$2a$04$5kq1mnYWbww8X.rIj7eOVOHXtvGw/peefjIcm0lDGxRTEjm9LnOae'));
     $this->user->expects($this->once())->method('getId')->will($this->returnValue(1));
     $this->user->expects($this->once())->method('getState')->will($this->returnValue(1));
     $this->storage->expects($this->any())->method('getNameSpace')->will($this->returnValue('test'));
     $this->authEvent->expects($this->once())->method('setIdentity')->with(1)->will($this->returnValue($this->authEvent));
     $this->authEvent->expects($this->once())->method('setCode')->with(\Zend\Authentication\Result::SUCCESS)->will($this->returnValue($this->authEvent));
     $this->authEvent->expects($this->once())->method('setMessages')->with(array('Authentication successful.'))->will($this->returnValue($this->authEvent));
     $result = $this->db->authenticate($this->authEvent);
 }