Ejemplo n.º 1
1
 /**
  * {@inheritdoc}
  */
 public function authenticate($username, $password)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'authenticate');
     if (!$pluginInfo) {
         return parent::authenticate($username, $password);
     } else {
         return $this->___callPlugins('authenticate', func_get_args(), $pluginInfo);
     }
 }
 /**
  * @return void
  */
 public function testAuthenticate()
 {
     $username = '******';
     $password = '******';
     $customerData = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $customerModel = $this->getMockBuilder('Magento\\Customer\\Model\\Customer')->disableOriginalConstructor()->getMock();
     $customerModel->expects($this->once())->method('updateData')->willReturn($customerModel);
     $this->customerRepository->expects($this->once())->method('get')->with($username)->willReturn($customerData);
     $this->accountManagementHelper->expects($this->once())->method('checkIfLocked')->with($customerData);
     $this->accountManagementHelper->expects($this->once())->method('validatePasswordAndLockStatus')->with($customerData, $password);
     $this->customerFactory->expects($this->once())->method('create')->willReturn($customerModel);
     $this->manager->expects($this->exactly(2))->method('dispatch')->withConsecutive(['customer_customer_authenticated', ['model' => $customerModel, 'password' => $password]], ['customer_data_object_login', ['customer' => $customerData]]);
     $this->assertEquals($customerData, $this->accountManagement->authenticate($username, $password));
 }
 /**
  * @return void
  */
 public function testAuthenticate()
 {
     $username = '******';
     $password = '******';
     $passwordHash = '1a2b3f4c';
     $customerData = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $customerModel = $this->getMockBuilder('Magento\\Customer\\Model\\Customer')->disableOriginalConstructor()->getMock();
     $customerModel->expects($this->once())->method('updateData')->willReturn($customerModel);
     $this->customerRepository->expects($this->once())->method('get')->with($username)->willReturn($customerData);
     $this->authenticationMock->expects($this->once())->method('authenticate');
     $customerSecure = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\CustomerSecure')->setMethods(['getPasswordHash'])->disableOriginalConstructor()->getMock();
     $customerSecure->expects($this->any())->method('getPasswordHash')->willReturn($passwordHash);
     $this->customerRegistry->expects($this->any())->method('retrieveSecureData')->willReturn($customerSecure);
     $this->customerFactory->expects($this->once())->method('create')->willReturn($customerModel);
     $this->manager->expects($this->exactly(2))->method('dispatch')->withConsecutive(['customer_customer_authenticated', ['model' => $customerModel, 'password' => $password]], ['customer_data_object_login', ['customer' => $customerData]]);
     $this->assertEquals($customerData, $this->accountManagement->authenticate($username, $password));
 }