当前位置: 首页>>代码示例>>PHP>>正文


PHP View::expects方法代码示例

本文整理汇总了PHP中Magento\Customer\Helper\View::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP View::expects方法的具体用法?PHP View::expects怎么用?PHP View::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Customer\Helper\View的用法示例。


在下文中一共展示了View::expects方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetUserName

 public function testGetUserName()
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(true);
     $customerDataObject = $this->getMockBuilder('\\Magento\\Customer\\Model\\Data\\Customer')->disableOriginalConstructor()->getMock();
     $this->customerSessionMock->expects($this->once())->method('getCustomerDataObject')->willReturn($customerDataObject);
     $this->customerViewHelperMock->expects($this->once())->method('getCustomerName')->willReturn(' customer name ');
     $this->assertEquals('customer name', $this->helper->getUserName());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:8,代码来源:DataTest.php

示例2: testGetUserName

 public function testGetUserName()
 {
     $this->_customerSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true));
     $objectBuilder = $this->getMockForAbstractClass('\\Magento\\Framework\\Service\\Data\\AbstractSimpleObjectBuilder', ['getData'], '', false);
     $customerDataObject = new \Magento\Customer\Service\V1\Data\Customer($objectBuilder);
     $this->_customerSession->expects($this->once())->method('getCustomerDataObject')->will($this->returnValue($customerDataObject));
     $this->_customerViewHelper->expects($this->once())->method('getCustomerName')->will($this->returnValue(' customer name '));
     $this->assertEquals('customer name', $this->_helper->getUserName());
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:9,代码来源:DataTest.php

示例3: testNewAccount

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testNewAccount()
 {
     $customerId = 1;
     $customerStoreId = 2;
     $customerEmail = 'email@email.com';
     $customerData = ['key' => 'value'];
     $customerName = 'Customer Name';
     $templateIdentifier = 'Template Identifier';
     $sender = 'Sender';
     $customer = $this->getMock(\Magento\Customer\Api\Data\CustomerInterface::class, [], [], '', false);
     $customer->expects($this->any())->method('getStoreId')->willReturn($customerStoreId);
     $customer->expects($this->any())->method('getId')->willReturn($customerId);
     $customer->expects($this->any())->method('getEmail')->willReturn($customerEmail);
     $this->storeMock->expects($this->any())->method('getId')->willReturn($customerStoreId);
     $this->storeManagerMock->expects($this->once())->method('getStore')->with($customerStoreId)->willReturn($this->storeMock);
     $this->customerRegistryMock->expects($this->once())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecureMock);
     $this->dataProcessorMock->expects($this->once())->method('buildOutputDataArray')->with($customer, \Magento\Customer\Api\Data\CustomerInterface::class)->willReturn($customerData);
     $this->customerViewHelperMock->expects($this->any())->method('getCustomerName')->with($customer)->willReturn($customerName);
     $this->customerSecureMock->expects($this->once())->method('addData')->with($customerData)->willReturnSelf();
     $this->customerSecureMock->expects($this->once())->method('setData')->with('name', $customerName)->willReturnSelf();
     $this->scopeConfigMock->expects($this->at(0))->method('getValue')->with(EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($templateIdentifier);
     $this->scopeConfigMock->expects($this->at(1))->method('getValue')->with(EmailNotification::XML_PATH_REGISTER_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($sender);
     $transport = $this->getMock(\Magento\Framework\Mail\TransportInterface::class, [], [], '', false);
     $this->transportBuilderMock->expects($this->once())->method('setTemplateIdentifier')->with($templateIdentifier)->willReturnSelf();
     $this->transportBuilderMock->expects($this->once())->method('setTemplateOptions')->with(['area' => Area::AREA_FRONTEND, 'store' => $customerStoreId])->willReturnSelf();
     $this->transportBuilderMock->expects($this->once())->method('setTemplateVars')->with(['customer' => $this->customerSecureMock, 'back_url' => '', 'store' => $this->storeMock])->willReturnSelf();
     $this->transportBuilderMock->expects($this->once())->method('setFrom')->with($sender)->willReturnSelf();
     $this->transportBuilderMock->expects($this->once())->method('addTo')->with($customerEmail, $customerName)->willReturnSelf();
     $this->transportBuilderMock->expects($this->once())->method('getTransport')->willReturn($transport);
     $transport->expects($this->once())->method('sendMessage');
     $this->model->newAccount($customer, EmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED, '', $customerStoreId);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:35,代码来源:EmailNotificationTest.php

示例4: prepareInitiatePasswordReset

 /**
  * @param string $email
  * @param string $templateIdentifier
  * @param string $sender
  * @param int $storeId
  * @param int $customerId
  * @param string $hash
  */
 protected function prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash)
 {
     $websiteId = 1;
     $dateTime = date(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT);
     $customerData = ['key' => 'value'];
     $customerName = 'Customer Name';
     $this->store->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
     $this->store->expects($this->any())->method('getId')->willReturn($storeId);
     $this->storeManager->expects($this->any())->method('getStore')->willReturn($this->store);
     $customer = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $customer->expects($this->any())->method('getEmail')->willReturn($email);
     $customer->expects($this->any())->method('getId')->willReturn($customerId);
     $customer->expects($this->any())->method('getStoreId')->willReturn($storeId);
     $this->customerRepository->expects($this->once())->method('get')->with($email, $websiteId)->willReturn($customer);
     $this->customerRepository->expects($this->once())->method('save')->with($customer)->willReturnSelf();
     $this->random->expects($this->once())->method('getUniqueHash')->willReturn($hash);
     $this->customerViewHelper->expects($this->any())->method('getCustomerName')->with($customer)->willReturn($customerName);
     $this->customerSecure->expects($this->any())->method('setRpToken')->with($hash)->willReturnSelf();
     $this->customerSecure->expects($this->any())->method('setRpTokenCreatedAt')->with($dateTime)->willReturnSelf();
     $this->customerSecure->expects($this->any())->method('addData')->with($customerData)->willReturnSelf();
     $this->customerSecure->expects($this->any())->method('setData')->with('name', $customerName)->willReturnSelf();
     $this->customerRegistry->expects($this->any())->method('retrieveSecureData')->with($customerId)->willReturn($this->customerSecure);
     $this->dataObjectProcessor->expects($this->any())->method('buildOutputDataArray')->with($customer, '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturn($customerData);
     $this->prepareEmailSend($email, $templateIdentifier, $sender, $storeId, $customerName);
 }
开发者ID:nja78,项目名称:magento2,代码行数:33,代码来源:AccountManagementTest.php

示例5: testSendNotificationEmailsIfRequired

 /**
  * @param int $testNumber
  * @param string $oldEmail
  * @param string $newEmail
  * @param bool $isPasswordChanged
  *
  * @dataProvider sendNotificationEmailsDataProvider
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testSendNotificationEmailsIfRequired($testNumber, $oldEmail, $newEmail, $isPasswordChanged)
 {
     $customerId = 1;
     $customerStoreId = 2;
     $customerWebsiteId = 1;
     $customerData = ['key' => 'value'];
     $customerName = 'Customer Name';
     $templateIdentifier = 'Template Identifier';
     $sender = 'Sender';
     switch ($testNumber) {
         case 1:
             $xmlPathTemplate = EmailNotification::XML_PATH_RESET_PASSWORD_TEMPLATE;
             $expects = $this->once();
             break;
         case 2:
             $xmlPathTemplate = EmailNotification::XML_PATH_CHANGE_EMAIL_TEMPLATE;
             $expects = $this->exactly(2);
             break;
         case 3:
             $xmlPathTemplate = EmailNotification::XML_PATH_CHANGE_EMAIL_AND_PASSWORD_TEMPLATE;
             $expects = $this->exactly(2);
             break;
     }
     $origCustomer = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $origCustomer->expects($this->any())->method('getStoreId')->willReturn(0);
     $origCustomer->expects($this->any())->method('getId')->willReturn($customerId);
     $origCustomer->expects($this->any())->method('getWebsiteId')->willReturn($customerWebsiteId);
     $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $storeMock->expects($this->any())->method('getId')->willReturn($customerStoreId);
     $this->storeManagerMock->expects(clone $expects)->method('getStore')->willReturn($storeMock);
     $websiteMock = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->setMethods(['getStoreIds'])->getMock();
     $websiteMock->expects($this->any())->method('getStoreIds')->willReturn([$customerStoreId]);
     $this->storeManagerMock->expects(clone $expects)->method('getWebsite')->with($customerWebsiteId)->willReturn($websiteMock);
     $customerSecureMock = $this->getMockBuilder('Magento\\Customer\\Model\\Data\\CustomerSecure')->disableOriginalConstructor()->getMock();
     $this->customerRegistryMock->expects(clone $expects)->method('retrieveSecureData')->with($customerId)->willReturn($customerSecureMock);
     $this->dataProcessorMock->expects(clone $expects)->method('buildOutputDataArray')->with($origCustomer, '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturn($customerData);
     $this->customerViewHelperMock->expects($this->any())->method('getCustomerName')->with($origCustomer)->willReturn($customerName);
     $customerSecureMock->expects(clone $expects)->method('addData')->with($customerData)->willReturnSelf();
     $customerSecureMock->expects(clone $expects)->method('setData')->with('name', $customerName)->willReturnSelf();
     $savedCustomer = clone $origCustomer;
     $origCustomer->expects($this->any())->method('getEmail')->willReturn($oldEmail);
     $savedCustomer->expects($this->any())->method('getEmail')->willReturn($newEmail);
     $this->scopeConfigMock->expects($this->any())->method('getValue')->withConsecutive([$xmlPathTemplate, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId], [\Magento\Customer\Helper\EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId], [$xmlPathTemplate, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId], [\Magento\Customer\Helper\EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId])->willReturnOnConsecutiveCalls($templateIdentifier, $sender, $templateIdentifier, $sender);
     $this->transportBuilderMock->expects(clone $expects)->method('setTemplateIdentifier')->with($templateIdentifier)->willReturnSelf();
     $this->transportBuilderMock->expects(clone $expects)->method('setTemplateOptions')->with(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $customerStoreId])->willReturnSelf();
     $this->transportBuilderMock->expects(clone $expects)->method('setTemplateVars')->with(['customer' => $customerSecureMock, 'store' => $storeMock])->willReturnSelf();
     $this->transportBuilderMock->expects(clone $expects)->method('setFrom')->with($sender)->willReturnSelf();
     $this->transportBuilderMock->expects(clone $expects)->method('addTo')->withConsecutive([$oldEmail, $customerName], [$newEmail, $customerName])->willReturnSelf();
     $transport = $this->getMockBuilder('Magento\\Framework\\Mail\\TransportInterface')->getMock();
     $this->transportBuilderMock->expects(clone $expects)->method('getTransport')->willReturn($transport);
     $transport->expects(clone $expects)->method('sendMessage');
     $this->assertEquals($this->helper, $this->helper->sendNotificationEmailsIfRequired($origCustomer, $savedCustomer, $isPasswordChanged));
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:62,代码来源:EmailNotificationTest.php

示例6: testSendPasswordReminderEmail

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testSendPasswordReminderEmail()
 {
     $customerId = 1;
     $customerStoreId = 2;
     $customerEmail = 'email@email.com';
     $passwordToken = 'token';
     $isFrontendSecure = true;
     $resetUrl = 'reset url';
     $customerData = ['key' => 'value'];
     $customerName = 'Customer Name';
     $templateIdentifier = 'Template Identifier';
     $sender = 'Sender';
     $customer = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMock();
     $customer->expects($this->any())->method('getStoreId')->willReturn($customerStoreId);
     $customer->expects($this->any())->method('getId')->willReturn($customerId);
     $customer->expects($this->any())->method('getEmail')->willReturn($customerEmail);
     $store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
     $this->storeManager->expects($this->any())->method('getStore')->with($customerStoreId)->willReturn($store);
     $store->expects($this->any())->method('isFrontUrlSecure')->willReturn($isFrontendSecure);
     $this->url->expects($this->once())->method('getUrl')->with('customer/account/createPassword', ['_query' => ['id' => $customerId, 'token' => $passwordToken], '_store' => $customerStoreId, '_secure' => $isFrontendSecure])->willReturn($resetUrl);
     $customerSecure = $this->getMockBuilder('\\Magento\\Customer\\Model\\Data\\CustomerSecure')->disableOriginalConstructor()->setMethods(['addData', 'setData', 'setResetPasswordUrl'])->getMock();
     $this->customerRegistry->expects($this->once())->method('retrieveSecureData')->with($customerId)->willReturn($customerSecure);
     $this->dataObjectProcessor->expects($this->once())->method('buildOutputDataArray')->with($customer, '\\Magento\\Customer\\Api\\Data\\CustomerInterface')->willReturn($customerData);
     $this->customerViewHelper->expects($this->any())->method('getCustomerName')->with($customer)->willReturn($customerName);
     $customerSecure->expects($this->once())->method('addData')->with($customerData)->willReturnSelf();
     $customerSecure->expects($this->once())->method('setData')->with('name', $customerName)->willReturnSelf();
     $customerSecure->expects($this->once())->method('setResetPasswordUrl')->with($resetUrl);
     $this->scopeConfig->expects($this->at(0))->method('getValue')->with(AccountManagement::XML_PATH_REMIND_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($templateIdentifier);
     $this->scopeConfig->expects($this->at(1))->method('getValue')->with(AccountManagement::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId)->willReturn($sender);
     $transport = $this->getMockBuilder('Magento\\Framework\\Mail\\TransportInterface')->getMock();
     $this->transportBuilder->expects($this->once())->method('setTemplateIdentifier')->with($templateIdentifier)->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('setTemplateOptions')->with(['area' => Area::AREA_FRONTEND, 'store' => $customerStoreId])->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('setTemplateVars')->with(['customer' => $customerSecure, 'store' => $store])->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('setFrom')->with($sender)->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('addTo')->with($customerEmail, $customerName)->willReturnSelf();
     $this->transportBuilder->expects($this->once())->method('getTransport')->willReturn($transport);
     $transport->expects($this->once())->method('sendMessage');
     $this->assertEquals($this->accountManagement, $this->accountManagement->sendPasswordReminderEmail($customer, $passwordToken));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:42,代码来源:AccountManagementTest.php


注:本文中的Magento\Customer\Helper\View::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。