當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Address::expects方法代碼示例

本文整理匯總了PHP中Magento\Customer\Helper\Address::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP Address::expects方法的具體用法?PHP Address::expects怎麽用?PHP Address::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Customer\Helper\Address的用法示例。


在下文中一共展示了Address::expects方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testExecute

 /**
  * @param string|null $configAddressType
  * @dataProvider restoreCustomerGroupIdDataProvider
  */
 public function testExecute($configAddressType)
 {
     $quoteAddress = $this->getMock('Magento\\Quote\\Model\\Quote\\Address', ['getQuote', 'setCustomerGroupId', 'getPrevQuoteCustomerGroupId', 'unsPrevQuoteCustomerGroupId', 'hasPrevQuoteCustomerGroupId'], [], '', false);
     $observer = $this->getMock('Magento\\Framework\\Event\\Observer', ['getQuoteAddress'], [], '', false);
     $observer->expects($this->once())->method('getQuoteAddress')->will($this->returnValue($quoteAddress));
     $this->customerAddressHelperMock->expects($this->once())->method('getTaxCalculationAddressType')->will($this->returnValue($configAddressType));
     $quoteAddress->expects($this->once())->method('hasPrevQuoteCustomerGroupId');
     $id = $quoteAddress->expects($this->any())->method('getPrevQuoteCustomerGroupId');
     $quoteAddress->expects($this->any())->method('setCustomerGroupId')->with($id);
     $quoteAddress->expects($this->any())->method('getQuote');
     $quoteAddress->expects($this->any())->method('unsPrevQuoteCustomerGroupId');
     $this->assertNull($this->quote->execute($observer));
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:17,代碼來源:RestoreCustomerGroupIdTest.php

示例2: testAddVatRequestParamsOrderComment

 /**
  * @param string $configAddressType
  * @param string|int $vatRequestId
  * @param string|int $vatRequestDate
  * @param string $orderHistoryComment
  * @dataProvider addVatRequestParamsOrderCommentDataProvider
  */
 public function testAddVatRequestParamsOrderComment($configAddressType, $vatRequestId, $vatRequestDate, $orderHistoryComment)
 {
     $this->customerAddressHelperMock->expects($this->once())->method('getTaxCalculationAddressType')->will($this->returnValue($configAddressType));
     $orderAddressMock = $this->getMock('Magento\\Sales\\Model\\Order\\Address', ['getVatRequestId', 'getVatRequestDate', '__wakeup'], [], '', false);
     $orderAddressMock->expects($this->any())->method('getVatRequestId')->will($this->returnValue($vatRequestId));
     $orderAddressMock->expects($this->any())->method('getVatRequestDate')->will($this->returnValue($vatRequestDate));
     $orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['getShippingAddress', '__wakeup', 'addStatusHistoryComment', 'getBillingAddress'])->getMock();
     $orderMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($orderAddressMock));
     if ($orderHistoryComment === null) {
         $orderMock->expects($this->never())->method('addStatusHistoryComment');
     } else {
         $orderMock->expects($this->once())->method('addStatusHistoryComment')->with($orderHistoryComment, false);
     }
     $observer = $this->getMock('Magento\\Framework\\Event\\Observer', ['getOrder'], [], '', false);
     $observer->expects($this->once())->method('getOrder')->will($this->returnValue($orderMock));
     $this->assertNull($this->observer->execute($observer));
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:24,代碼來源:AddVatRequestParamsOrderCommentTest.php

示例3: testExecute

 /**
  * @param string|null $configAddressType
  * @dataProvider restoreCustomerGroupIdDataProvider
  */
 public function testExecute($configAddressType)
 {
     $eventMock = $this->getMock('\\Magento\\Framework\\Event', ['getShippingAssignment', 'getQuote'], [], '', false);
     $observer = $this->getMock('Magento\\Framework\\Event\\Observer', ['getEvent'], [], '', false);
     $observer->expects($this->exactly(2))->method('getEvent')->willReturn($eventMock);
     $shippingAssignmentMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\ShippingAssignmentInterface');
     $quoteMock = $this->getMock('\\Magento\\Quote\\Model\\Quote', [], [], '', false);
     $eventMock->expects($this->once())->method('getShippingAssignment')->willReturn($shippingAssignmentMock);
     $eventMock->expects($this->once())->method('getQuote')->willReturn($quoteMock);
     $shippingMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\ShippingInterface');
     $shippingAssignmentMock->expects($this->once())->method('getShipping')->willReturn($shippingMock);
     $quoteAddress = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Address', ['getPrevQuoteCustomerGroupId', 'unsPrevQuoteCustomerGroupId', 'hasPrevQuoteCustomerGroupId'], [], '', false);
     $shippingMock->expects($this->once())->method('getAddress')->willReturn($quoteAddress);
     $this->customerAddressHelperMock->expects($this->once())->method('getTaxCalculationAddressType')->will($this->returnValue($configAddressType));
     $quoteAddress->expects($this->once())->method('hasPrevQuoteCustomerGroupId');
     $id = $quoteAddress->expects($this->any())->method('getPrevQuoteCustomerGroupId');
     $quoteAddress->expects($this->any())->method('setCustomerGroupId')->with($id);
     $quoteAddress->expects($this->any())->method('getQuote');
     $quoteAddress->expects($this->any())->method('unsPrevQuoteCustomerGroupId');
     $this->quote->execute($observer);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:25,代碼來源:RestoreCustomerGroupIdTest.php

示例4: testSuccessMessage

 /**
  * @param $customerId
  * @param $key
  * @param $vatValidationEnabled
  * @param $addressType
  * @param $successMessage
  *
  * @dataProvider getSuccessMessageDataProvider
  */
 public function testSuccessMessage($customerId, $key, $vatValidationEnabled, $addressType, $successMessage)
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['id', false, $customerId], ['key', false, $key]]);
     $this->customerRepositoryMock->expects($this->any())->method('getById')->with($customerId)->will($this->returnValue($this->customerDataMock));
     $email = 'test@example.com';
     $this->customerDataMock->expects($this->once())->method('getEmail')->will($this->returnValue($email));
     $this->customerAccountManagementMock->expects($this->once())->method('activate')->with($this->equalTo($email), $this->equalTo($key))->will($this->returnValue($this->customerDataMock));
     $this->customerSessionMock->expects($this->any())->method('setCustomerDataAsLoggedIn')->with($this->equalTo($this->customerDataMock))->willReturnSelf();
     $this->messageManagerMock->expects($this->any())->method('addSuccess')->with($this->stringContains($successMessage))->willReturnSelf();
     $this->addressHelperMock->expects($this->once())->method('isVatValidationEnabled')->will($this->returnValue($vatValidationEnabled));
     $this->addressHelperMock->expects($this->any())->method('getTaxCalculationAddressType')->will($this->returnValue($addressType));
     $this->storeMock->expects($this->any())->method('getFrontendName')->will($this->returnValue('frontend'));
     $this->storeManagerMock->expects($this->any())->method('getStore')->will($this->returnValue($this->storeMock));
     $this->model->execute();
 }
開發者ID:kid17,項目名稱:magento2,代碼行數:25,代碼來源:ConfirmTest.php

示例5: testSuccessMessage

 /**
  * @param $customerId
  * @param $customerEmail
  * @param $password
  * @param $confirmationStatus
  * @param $vatValidationEnabled
  * @param $addressType
  * @param $successMessage
  *
  * @dataProvider getSuccessMessageDataProvider
  */
 public function testSuccessMessage($customerId, $customerEmail, $password, $confirmationStatus, $vatValidationEnabled, $addressType, $successMessage)
 {
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->will($this->returnValue(false));
     $this->registration->expects($this->once())->method('isAllowed')->will($this->returnValue(true));
     $this->customerUrl->expects($this->once())->method('getEmailConfirmationUrl')->will($this->returnValue($customerEmail));
     $this->customerSessionMock->expects($this->once())->method('regenerateId');
     $this->customerMock->expects($this->any())->method('getId')->will($this->returnValue($customerId));
     $this->customerMock->expects($this->any())->method('getEmail')->will($this->returnValue($customerEmail));
     $this->customerExtractorMock->expects($this->any())->method('extract')->with($this->equalTo('customer_account_create'), $this->equalTo($this->requestMock))->will($this->returnValue($this->customerMock));
     $this->requestMock->expects($this->once())->method('isPost')->will($this->returnValue(true));
     $this->requestMock->expects($this->any())->method('getPost')->will($this->returnValue(false));
     $this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['password', null, $password], ['password_confirmation', null, $password], ['is_subscribed', false, true]]);
     $this->customerMock->expects($this->once())->method('setAddresses')->with($this->equalTo([]))->will($this->returnSelf());
     $this->accountManagement->expects($this->once())->method('createAccount')->with($this->equalTo($this->customerDetailsMock), $this->equalTo($password), '')->will($this->returnValue($this->customerMock));
     $this->accountManagement->expects($this->once())->method('getConfirmationStatus')->with($this->equalTo($customerId))->will($this->returnValue($confirmationStatus));
     $this->subscriberMock->expects($this->once())->method('subscribeCustomerById')->with($this->equalTo($customerId));
     $this->messageManagerMock->expects($this->any())->method('addSuccess')->with($this->stringContains($successMessage))->will($this->returnSelf());
     $this->addressHelperMock->expects($this->any())->method('isVatValidationEnabled')->will($this->returnValue($vatValidationEnabled));
     $this->addressHelperMock->expects($this->any())->method('getTaxCalculationAddressType')->will($this->returnValue($addressType));
     $this->model->execute();
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:32,代碼來源:CreatePostTest.php


注:本文中的Magento\Customer\Helper\Address::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。