/** * @covers ZfcUser\Authentication\Adapter\Db::getMapper */ public function testGetMapperWithNoMapperSet() { $serviceMapper = $this->getMock('Zend\\ServiceManager\\ServiceManager'); $serviceMapper->expects($this->once())->method('get')->with('zfcuser_user_mapper')->will($this->returnValue($this->mapper)); $this->db->setServiceManager($serviceMapper); $mapper = $this->db->getMapper(); $this->assertInstanceOf('ZfcUser\\Mapper\\UserInterface', $mapper); $this->assertSame($this->mapper, $mapper); }
protected function setUp() { $this->options = $this->getMock('ZfcUser\\Options\\ModuleOptions'); $this->mapper = $this->getMockForAbstractClass('ZfcUser\\Mapper\\UserInterface'); $this->user = $this->getMockForAbstractClass('ZfcUser\\Entity\\UserInterface'); $this->storage = $this->getMockForAbstractClass('Zend\\Authentication\\Storage\\StorageInterface'); $this->authEvent = $this->getMock('ZfcUser\\Authentication\\Adapter\\AdapterChainEvent'); $this->bcrypt = $this->getMock('Zend\\Crypt\\Password\\Bcrypt'); $this->hydrator = $this->getMockForAbstractClass('ZfcUser\\Mapper\\HydratorInterface'); $this->hydrator->expects($this->any())->method('getCryptoService')->will($this->returnValue($this->bcrypt)); $this->services = $this->getMock('Zend\\ServiceManager\\ServiceManager'); $this->services->expects($this->any())->method('get')->will($this->returnValueMap(array(array('zfcuser_module_options', true, $this->options), array('zfcuser_user_mapper', true, $this->mapper), array('zfcuser_user_hydrator', true, $this->hydrator)))); $this->db = new Db(); $this->db->setServiceManager($this->services); $this->db->setStorage($this->storage); $sessionManager = $this->getMock('Zend\\Session\\SessionManager'); \Zend\Session\AbstractContainer::setDefaultManager($sessionManager); }