本文整理汇总了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));
}
示例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));
}
示例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);
}
示例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();
}
示例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();
}