Exemplo n.º 1
0
 /**
  * @magentoConfigFixture current_store persistent/options/enabled 1
  * @magentoConfigFixture current_store persistent/options/remember_enabled 1
  * @magentoConfigFixture current_store persistent/options/remember_default 1
  * @magentoAppArea frontend
  * @magentoConfigFixture current_store persistent/options/shopping_cart 1
  * @magentoConfigFixture current_store persistent/options/logout_clear 0
  */
 public function testEmulateQuote()
 {
     $requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->setMethods([])->getMock();
     $requestMock->expects($this->once())->method('getFullActionName')->will($this->returnValue('valid_action'));
     $event = new \Magento\Framework\Event(['request' => $requestMock]);
     $observer = new \Magento\Framework\Event\Observer();
     $observer->setEvent($event);
     $this->_customerSession->loginById(1);
     $customer = $this->customerRepository->getById($this->_persistentSessionHelper->getSession()->getCustomerId());
     $this->_checkoutSession->expects($this->once())->method('setCustomerData')->with($customer);
     $this->_customerSession->logout();
     $this->_observer->execute($observer);
 }
 public function testUpgradeCustomerPassword()
 {
     $customerId = '1';
     $password = '******';
     $passwordHash = 'hash:salt:999';
     $model = $this->getMockBuilder('Magento\\Customer\\Model\\Customer')->disableOriginalConstructor()->setMethods(['getId'])->getMock();
     $customer = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMockForAbstractClass();
     $customerSecure = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\CustomerSecure')->disableOriginalConstructor()->setMethods(['getPasswordHash', 'setPasswordHash'])->getMock();
     $model->expects($this->exactly(2))->method('getId')->willReturn($customerId);
     $this->customerRepository->expects($this->once())->method('getById')->with($customerId)->willReturn($customer);
     $this->customerRegistry->expects($this->once())->method('retrieveSecureData')->with($customerId)->willReturn($customerSecure);
     $customerSecure->expects($this->once())->method('getPasswordHash')->willReturn($passwordHash);
     $this->encryptorMock->expects($this->once())->method('validateHashVersion')->with($passwordHash)->willReturn(false);
     $this->encryptorMock->expects($this->once())->method('getHash')->with($password, true)->willReturn($passwordHash);
     $customerSecure->expects($this->once())->method('setPasswordHash')->with($passwordHash);
     $this->customerRepository->expects($this->once())->method('save')->with($customer);
     $event = new \Magento\Framework\DataObject();
     $event->setData(['password' => 'password', 'model' => $model]);
     $observerMock = new \Magento\Framework\Event\Observer();
     $observerMock->setEvent($event);
     $this->model->execute($observerMock);
 }