예제 #1
0
 public function testRenewCookieWhenCannotProcessPersistentData()
 {
     $this->helperMock->expects($this->once())->method('canProcess')->with($this->observerMock)->will($this->returnValue(false));
     $this->helperMock->expects($this->never())->method('isEnabled');
     $this->observerMock->expects($this->never())->method('getEvent');
     $this->model->renewCookie($this->observerMock);
 }
예제 #2
0
 /**
  * @covers \Magento\Persistent\Model\Observer\Session::synchronizePersistentOnLogin
  */
 public function testSynchronizePersistentOnLogin()
 {
     $event = new \Magento\Framework\Event();
     $observer = new \Magento\Framework\Event\Observer(['event' => $event]);
     /** @var \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository */
     $customerRepository = $this->_objectManager->create('Magento\\Customer\\Api\\CustomerRepositoryInterface');
     /** @var $customer \Magento\Customer\Api\Data\CustomerInterface */
     $customer = $customerRepository->getById(1);
     $event->setData('customer', $customer);
     $this->_persistentSession->setRememberMeChecked(true);
     $this->_model->synchronizePersistentOnLogin($observer);
     // check that persistent session has been stored for Customer
     /** @var \Magento\Persistent\Model\Session $sessionModel */
     $sessionModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Persistent\\Model\\Session');
     $sessionModel->loadByCustomerId(1);
     $this->assertEquals(1, $sessionModel->getCustomerId());
 }
예제 #3
0
 /**
  * @covers \Magento\Persistent\Model\Observer\Session::synchronizePersistentOnLogin
  */
 public function testSynchronizePersistentOnLogin()
 {
     $event = new \Magento\Framework\Event();
     $observer = new \Magento\Framework\Event\Observer(array('event' => $event));
     /** @var \Magento\Customer\Service\V1\CustomerAccountServiceInterface $customerAccountService */
     $customerAccountService = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Customer\\Service\\V1\\CustomerAccountServiceInterface');
     /** @var $customer \Magento\Customer\Service\V1\Data\Customer */
     $customer = $customerAccountService->getCustomer(1);
     $event->setData('customer', $customer);
     $this->_persistentSession->setRememberMeChecked(true);
     $this->_cookieMock->expects($this->once())->method('set')->with(\Magento\Persistent\Model\Session::COOKIE_NAME, $this->anything(), $this->anything(), $this->_customerSession->getCookiePath());
     $this->_model->synchronizePersistentOnLogin($observer);
     // check that persistent session has been stored for Customer
     /** @var \Magento\Persistent\Model\Session $sessionModel */
     $sessionModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Persistent\\Model\\Session');
     $sessionModel->loadByCustomerId(1);
     $this->assertEquals(1, $sessionModel->getCustomerId());
 }