Ejemplo n.º 1
0
 /**
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testSendPasswordResetConfirmationEmail()
 {
     $storeId = 1;
     $storeIds = array(1);
     $email = '*****@*****.**';
     $firstName = 'Foo';
     $lastName = 'Bar';
     $this->_model->setStoreId(0);
     $this->_model->setWebsiteId(1);
     $this->_model->setEmail($email);
     $this->_model->setFirstname($firstName);
     $this->_model->setLastname($lastName);
     $this->_config->expects($this->any())->method('getAttribute')->will($this->returnValue($this->_attribute));
     $this->_attribute->expects($this->any())->method('isVisible')->will($this->returnValue(false));
     $this->_storeManager->expects($this->once())->method('getWebsite')->with($this->equalTo(1))->will($this->returnValue($this->_website));
     $this->_storeManager->expects($this->once())->method('getStore')->with(0)->will($this->returnValue($this->_storetMock));
     $this->_website->expects($this->once())->method('getStoreIds')->will($this->returnValue($storeIds));
     $this->_scopeConfigMock->expects($this->at(0))->method('getValue')->with(\Magento\Customer\Model\Customer::XML_PATH_RESET_PASSWORD_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)->will($this->returnValue('templateId'));
     $this->_scopeConfigMock->expects($this->at(1))->method('getValue')->with(\Magento\Customer\Model\Customer::XML_PATH_FORGOT_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)->will($this->returnValue('sender'));
     $this->_transportBuilderMock->expects($this->once())->method('setTemplateOptions')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('setTemplateVars')->with(array('customer' => $this->_model, 'store' => $this->_storetMock))->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('addTo')->with($this->equalTo($email), $this->equalTo($firstName . ' ' . $lastName))->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('setFrom')->with('sender')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('setTemplateIdentifier')->with('templateId')->will($this->returnSelf());
     $this->_transportBuilderMock->expects($this->once())->method('getTransport')->will($this->returnValue($this->_transportMock));
     $this->_transportMock->expects($this->once())->method('sendMessage');
     $this->_model->sendPasswordResetNotificationEmail();
 }
Ejemplo n.º 2
0
    /**
     * @return void
     */
    public function testSendPasswordResetConfirmationEmail()
    {
        $storeId = 0;
        $email = '*****@*****.**';
        $firstName = 'Foo';
        $lastName = 'Bar';

        $this->model->setEmail($email);
        $this->model->setFirstname($firstName);
        $this->model->setLastname($lastName);

        $this->configMock->expects($this->at(0))
            ->method('getValue')
            ->with(\Magento\User\Model\User::XML_PATH_FORGOT_EMAIL_TEMPLATE)
            ->willReturn('templateId');
        $this->configMock->expects($this->at(1))
            ->method('getValue')
            ->with(\Magento\User\Model\User::XML_PATH_FORGOT_EMAIL_IDENTITY)
            ->willReturn('sender');
        $this->transportBuilderMock->expects($this->once())
            ->method('setTemplateModel')
            ->with($this->equalTo('Magento\Email\Model\BackendTemplate'))
            ->willReturnSelf();
        $this->transportBuilderMock->expects($this->once())
            ->method('setTemplateOptions')
            ->willReturnSelf();
        $this->transportBuilderMock->expects($this->once())
            ->method('setTemplateVars')
            ->with(['user' => $this->model, 'store' => $this->storetMock])
            ->willReturnSelf();
        $this->transportBuilderMock->expects($this->once())
            ->method('addTo')
            ->with($this->equalTo($email), $this->equalTo($firstName . ' ' . $lastName))
            ->willReturnSelf();
        $this->transportBuilderMock->expects($this->once())
            ->method('setFrom')
            ->with('sender')
            ->willReturnSelf();
        $this->transportBuilderMock->expects($this->once())
            ->method('setTemplateIdentifier')
            ->with('templateId')
            ->willReturnSelf();
        $this->transportBuilderMock->expects($this->once())
            ->method('getTransport')
            ->willReturn($this->transportMock);
        $this->transportMock->expects($this->once())->method('sendMessage');

        $this->storeManagerMock->expects($this->once())
            ->method('getStore')
            ->with($storeId)
            ->willReturn($this->storetMock);

        $this->assertInstanceOf('\Magento\User\Model\User', $this->model->sendPasswordResetConfirmationEmail());
    }