예제 #1
0
파일: Adapter.php 프로젝트: reliv/rcm-user
 /**
  * createService
  *
  * @param ServiceLocatorInterface $serviceLocator serviceLocator
  *
  * @return mixed|UserAdapter
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $userDataService = $serviceLocator->get('RcmUser\\User\\Service\\UserDataService');
     $encrypt = $serviceLocator->get('RcmUser\\User\\Encryptor');
     $adapter = new UserAdapter();
     $adapter->setUserDataService($userDataService);
     $adapter->setEncryptor($encrypt);
     return $adapter;
 }
예제 #2
0
 /**
  * testBuildUserAdapter
  *
  * @return UserAdapter
  */
 public function testBuildUserAdapter()
 {
     $this->userDataService = $this->getMockBuilder('\\RcmUser\\User\\Service\\UserDataService')->disableOriginalConstructor()->getMock();
     $this->userDataService->expects($this->any())->method('readUser')->will($this->returnCallback([$this, 'userResultCallback']));
     $encValueMap = [['goodpass', '#hash#', true], ['badpass', '#hash#', false]];
     $this->encryptor = $this->getMockBuilder('\\Zend\\Crypt\\Password\\PasswordInterface')->disableOriginalConstructor()->getMock();
     $this->encryptor->expects($this->any())->method('create')->will($this->returnValue('#hash#'));
     $this->encryptor->expects($this->any())->method('verify')->will($this->returnValueMap($encValueMap));
     $userAdapter = new UserAdapter();
     $userAdapter->setEncryptor($this->encryptor);
     $this->assertEquals($this->encryptor, $userAdapter->getEncryptor());
     $userAdapter->setUserDataService($this->userDataService);
     $this->assertEquals($this->userDataService, $userAdapter->getUserDataService());
     return $userAdapter;
 }