/** * @return void */ public function testSendNotificationEmailsIfRequired() { $storeId = 0; $email = '*****@*****.**'; $origEmail = '*****@*****.**'; $password = '******'; $origPassword = '******'; $username = '******'; $origUsername = '******'; $firstName = 'Foo'; $lastName = 'Bar'; $changes = __('email') . ', ' . __('password') . ', ' . __('username'); $this->model->setEmail($email); $this->model->setOrigData('email', $origEmail); $this->model->setPassword($password); $this->model->setOrigData('password', $origPassword); $this->model->setUsername($username); $this->model->setOrigData('username', $origUsername); $this->model->setFirstname($firstName); $this->model->setLastname($lastName); $this->configMock->expects($this->exactly(4))->method('getValue')->withConsecutive([\Magento\User\Model\User::XML_PATH_USER_NOTIFICATION_TEMPLATE], [\Magento\User\Model\User::XML_PATH_FORGOT_EMAIL_IDENTITY], [\Magento\User\Model\User::XML_PATH_USER_NOTIFICATION_TEMPLATE], [\Magento\User\Model\User::XML_PATH_FORGOT_EMAIL_IDENTITY])->willReturnOnConsecutiveCalls('templateId', 'sender', 'templateId', 'sender'); $this->transportBuilderMock->expects($this->exactly(2))->method('setTemplateModel')->with($this->equalTo('Magento\\Email\\Model\\BackendTemplate'))->willReturnSelf(); $this->transportBuilderMock->expects($this->exactly(2))->method('setTemplateOptions')->willReturnSelf(); $this->transportBuilderMock->expects($this->exactly(2))->method('setTemplateVars')->with(['user' => $this->model, 'store' => $this->storetMock, 'changes' => $changes])->willReturnSelf(); $this->transportBuilderMock->expects($this->exactly(2))->method('addTo')->withConsecutive($this->equalTo($email), $this->equalTo($firstName . ' ' . $lastName), $this->equalTo($origEmail), $this->equalTo($firstName . ' ' . $lastName))->willReturnSelf(); $this->transportBuilderMock->expects($this->exactly(2))->method('setFrom')->with('sender')->willReturnSelf(); $this->transportBuilderMock->expects($this->exactly(2))->method('setTemplateIdentifier')->with('templateId')->willReturnSelf(); $this->transportBuilderMock->expects($this->exactly(2))->method('getTransport')->willReturn($this->transportMock); $this->transportMock->expects($this->exactly(2))->method('sendMessage'); $this->storeManagerMock->expects($this->exactly(2))->method('getStore')->with($storeId)->willReturn($this->storetMock); $this->assertInstanceOf('\\Magento\\User\\Model\\User', $this->model->sendNotificationEmailsIfRequired()); }