34 $this->customerRepository = $this->getMockBuilder(\
Magento\Customer\Api\CustomerRepositoryInterface::class)
35 ->getMockForAbstractClass();
36 $this->customerRegistry = $this->getMockBuilder(\
Magento\Customer\Model\CustomerRegistry::class)
37 ->disableOriginalConstructor()
39 $this->encryptorMock = $this->getMockBuilder(\
Magento\Framework\Encryption\Encryptor::class)
40 ->disableOriginalConstructor()
45 $this->customerRegistry,
46 $this->customerRepository
53 $password =
'password';
54 $passwordHash =
'hash:salt:999';
55 $model = $this->getMockBuilder(\
Magento\Customer\Model\Customer::class)
56 ->disableOriginalConstructor()
57 ->setMethods([
'getId'])
59 $customer = $this->getMockBuilder(\
Magento\Customer\Api\Data\CustomerInterface::class)
60 ->getMockForAbstractClass();
61 $customerSecure = $this->getMockBuilder(\
Magento\Customer\Model\Data\CustomerSecure::class)
62 ->disableOriginalConstructor()
63 ->setMethods([
'getPasswordHash',
'setPasswordHash'])
65 $model->expects($this->exactly(2))
68 $this->customerRepository->expects($this->once())
72 $this->customerRegistry->expects($this->once())
73 ->method(
'retrieveSecureData')
75 ->willReturn($customerSecure);
76 $customerSecure->expects($this->once())
77 ->method(
'getPasswordHash')
78 ->willReturn($passwordHash);
79 $this->encryptorMock->expects($this->once())
80 ->method(
'validateHashVersion')
83 $this->encryptorMock->expects($this->once())
85 ->with($password,
true)
86 ->willReturn($passwordHash);
87 $customerSecure->expects($this->once())
88 ->method(
'setPasswordHash')
89 ->with($passwordHash);
90 $this->customerRepository->expects($this->once())
93 $event = new \Magento\Framework\DataObject();
94 $event->setData([
'password' =>
'password',
'model' =>
$model]);
95 $observerMock = new \Magento\Framework\Event\Observer();
96 $observerMock->setEvent($event);
97 $this->model->execute($observerMock);
testUpgradeCustomerPassword()