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


PHP QuoteRepository::expects方法代码示例

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


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

示例1: testSaveAddresses

 public function testSaveAddresses()
 {
     $cartId = 100;
     $additionalData = $this->getMock('\\Magento\\Quote\\Api\\Data\\AddressAdditionalDataInterface');
     $billingAddressMock = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Address', [], [], '', false);
     $shippingAddressMock = $this->getMock('\\Magento\\Quote\\Model\\Quote\\Address', [], [], '', false);
     $this->billingAddressManagement->expects($this->once())->method('assign')->with($cartId, $billingAddressMock)->willReturn(1);
     $billingAddressMock->expects($this->once())->method('format')->with('html');
     $this->billingAddressManagement->expects($this->once())->method('get')->with($cartId)->willReturn($billingAddressMock);
     $this->shippingAddressManagement->expects($this->once())->method('assign')->with($cartId, $shippingAddressMock)->willReturn(1);
     $shippingAddressMock->expects($this->once())->method('format')->with('html');
     $this->shippingAddressManagement->expects($this->once())->method('get')->with($cartId)->willReturn($shippingAddressMock);
     $shippingMethodMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\ShippingMethodInterface');
     $this->shippingMethodManagement->expects($this->once())->method('getList')->with($cartId)->willReturn([$shippingMethodMock]);
     $paymentMethodMock = $this->getMock('\\Magento\\Quote\\Api\\Data\\PaymentMethodInterface');
     $this->paymentMethodManagement->expects($this->once())->method('getList')->with($cartId)->willReturn([$paymentMethodMock]);
     $addressDetailsMock = $this->getMock('\\Magento\\Quote\\Model\\AddressDetails', [], [], '', false);
     $this->addressDetailsFactory->expects($this->once())->method('create')->willReturn($addressDetailsMock);
     $addressDetailsMock->expects($this->once())->method('setShippingMethods')->with([$shippingMethodMock])->willReturnSelf();
     $addressDetailsMock->expects($this->once())->method('setPaymentMethods')->with([$paymentMethodMock])->willReturnSelf();
     $this->dataProcessor->expects($this->once())->method('process')->with($additionalData);
     $quote = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $quote->expects($this->once())->method('setCheckoutMethod')->willReturnSelf();
     $this->quoteRepository->expects($this->once())->method('getActive')->willReturn($quote);
     $this->model->saveAddresses($cartId, $billingAddressMock, $shippingAddressMock, $additionalData, 'register');
 }
开发者ID:kid17,项目名称:magento2,代码行数:26,代码来源:AddressDetailsManagementTest.php

示例2: testSavePaymentInQuote

 public function testSavePaymentInQuote()
 {
     $quoteId = 1;
     $response = new DataObject();
     $payment = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Payment')->disableOriginalConstructor()->getMock();
     $payment->expects($this->once())->method('setAdditionalInformation')->with('pnref');
     $this->errorHandlerMock->expects($this->once())->method('handle')->with($payment, $response);
     $quote = $this->getMock('Magento\\Quote\\Api\\Data\\CartInterface', [], [], '', false);
     $quote->expects($this->exactly(2))->method('getId')->willReturn($quoteId);
     $this->sessionTransparent->expects($this->once())->method('getQuoteId')->willReturn($quoteId);
     $this->quoteRepository->expects($this->once())->method('get')->willReturn($quote);
     $this->paymentMethodManagementInterface->expects($this->once())->method('get')->willReturn($payment);
     $this->paymentMethodManagementInterface->expects($this->once())->method('set');
     $this->model->savePaymentInQuote($response);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:15,代码来源:TransactionTest.php

示例3: testGetCartForCustomer

 public function testGetCartForCustomer()
 {
     $customerId = 100;
     $cartMock = $this->getMock('\\Magento\\Quote\\Model\\Quote', [], [], '', false);
     $this->quoteRepositoryMock->expects($this->once())->method('getActiveForCustomer')->with($customerId)->willReturn($cartMock);
     $this->assertEquals($cartMock, $this->model->getCartForCustomer($customerId));
 }
开发者ID:nja78,项目名称:magento2,代码行数:7,代码来源:QuoteManagementTest.php

示例4: testSaveBilling

 /**
  * @dataProvider saveBillingDataProvider
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function testSaveBilling($data, $customerAddressId, $quoteCustomerId, $addressCustomerId, $isAddress, $validateDataResult, $validateResult, $checkoutMethod, $customerPassword, $confirmPassword, $validationResultMessages, $isEmailAvailable, $isVirtual, $getStepDataResult, $expected)
 {
     $useForShipping = (int) $data['use_for_shipping'];
     $passwordHash = 'password hash';
     $this->requestMock->expects($this->any())->method('isAjax')->will($this->returnValue(false));
     $customerValidationResultMock = $this->getMock('Magento\\Customer\\Api\\Data\\ValidationResultsInterface', [], [], '', false);
     $customerValidationResultMock->expects($this->any())->method('isValid')->will($this->returnValue(empty($validationResultMessages)));
     $customerValidationResultMock->expects($this->any())->method('getMessages')->will($this->returnValue($validationResultMessages));
     $this->accountManagementMock->expects($this->any())->method('getPasswordHash')->with($customerPassword)->will($this->returnValue($passwordHash));
     $this->accountManagementMock->expects($this->any())->method('validate')->will($this->returnValue($customerValidationResultMock));
     $this->accountManagementMock->expects($this->any())->method('isEmailAvailable')->will($this->returnValue($isEmailAvailable));
     /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quoteMock */
     $quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', ['getData', 'getCustomerId', '__wakeup', 'getBillingAddress', 'setPasswordHash', 'getCheckoutMethod', 'isVirtual', 'getShippingAddress', 'getCustomerData', 'collectTotals', 'save', 'getCustomer'], [], '', false);
     $customerMock = $this->getMockForAbstractClass('Magento\\Framework\\Api\\AbstractExtensibleObject', [], '', false, true, true, ['__toArray']);
     $shippingAddressMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Address', ['setSameAsBilling', 'save', 'collectTotals', 'addData', 'setShippingMethod', 'setCollectShippingRates', '__wakeup'], [], '', false);
     $quoteMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($shippingAddressMock));
     $shippingAddressMock->expects($useForShipping ? $this->any() : $this->once())->method('setSameAsBilling')->with($useForShipping)->will($this->returnSelf());
     $expects = !$useForShipping || $checkoutMethod != Onepage::METHOD_REGISTER ? $this->once() : $this->never();
     $shippingAddressMock->expects($expects)->method('save');
     $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never())->method('addData')->will($this->returnSelf());
     $shippingAddressMock->expects($this->any())->method('setSaveInAddressBook')->will($this->returnSelf());
     $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never())->method('setShippingMethod')->will($this->returnSelf());
     $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never())->method('setCollectShippingRates')->will($this->returnSelf());
     $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never())->method('collectTotals');
     $quoteMock->expects($this->any())->method('setPasswordHash')->with($passwordHash);
     $quoteMock->expects($this->any())->method('getCheckoutMethod')->will($this->returnValue($checkoutMethod));
     $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue($isVirtual));
     $addressMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Address', ['setSaveInAddressBook', 'getData', 'setEmail', '__wakeup', 'importCustomerAddressData', 'validate', 'save'], [], '', false);
     $addressMock->expects($this->any())->method('importCustomerAddressData')->will($this->returnSelf());
     $addressMock->expects($this->atLeastOnce())->method('validate')->will($this->returnValue($validateResult));
     $addressMock->expects($this->any())->method('getData')->will($this->returnValue([]));
     $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($addressMock));
     $quoteMock->expects($this->any())->method('getCustomerId')->will($this->returnValue($quoteCustomerId));
     $this->quoteRepositoryMock->expects($checkoutMethod === Onepage::METHOD_REGISTER ? $this->once() : $this->never())->method('save')->with($quoteMock);
     $addressMock->expects($checkoutMethod === Onepage::METHOD_REGISTER ? $this->never() : $this->once())->method('save');
     $quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock));
     $data1 = [];
     $extensibleDataObjectConverterMock = $this->getMock('Magento\\Framework\\Api\\ExtensibleDataObjectConverter', ['toFlatArray'], [], '', false);
     $extensibleDataObjectConverterMock->expects($this->any())->method('toFlatArray')->with($customerMock)->will($this->returnValue($data1));
     $formMock = $this->getMock('Magento\\Customer\\Model\\Metadata\\Form', [], [], '', false);
     $formMock->expects($this->atLeastOnce())->method('validateData')->will($this->returnValue($validateDataResult));
     $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($formMock));
     $formMock->expects($this->any())->method('prepareRequest')->will($this->returnValue($this->requestMock));
     $formMock->expects($this->any())->method('extractData')->with($this->requestMock)->will($this->returnValue([]));
     $formMock->expects($this->any())->method('validateData')->with([])->will($this->returnValue(false));
     $customerDataMock = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
     $this->customerDataFactoryMock->expects($this->any())->method('create')->will($this->returnValue($customerDataMock));
     $this->checkoutSessionMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
     $this->checkoutSessionMock->expects($this->any())->method('getStepData')->will($this->returnValue($useForShipping ? true : $getStepDataResult));
     $this->checkoutSessionMock->expects($this->any())->method('setStepData')->will($this->returnSelf());
     $customerAddressMock = $this->getMockForAbstractClass('Magento\\Customer\\Api\\Data\\AddressInterface', [], '', false);
     $customerAddressMock->expects($this->any())->method('getCustomerId')->will($this->returnValue($addressCustomerId));
     $this->addressRepositoryMock->expects($this->any())->method('getById')->will($isAddress ? $this->returnValue($customerAddressMock) : $this->throwException(new \Exception()));
     $websiteMock = $this->getMock('Magento\\Store\\Model\\Website', [], [], '', false);
     $this->storeManagerMock->expects($this->any())->method('getWebsite')->will($this->returnValue($websiteMock));
     $this->assertEquals($expected, $this->onepage->saveBilling($data, $customerAddressId));
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:65,代码来源:OnepageTest.php

示例5: testInitializeQuoteForReview

 /**
  * @dataProvider initializeQuoteForReviewDataProvider
  */
 public function testInitializeQuoteForReview($paymentMethodNonce, $details, $expectedShipping, $expectedBilling, $expectedPaymentAdditionalInfo)
 {
     $this->verifyIgnoreAddressValidation();
     $this->quoteMock->expects($this->any())->method('getIsVirtual')->willReturn(false);
     $paymentMock = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote\\Payment')->disableOriginalConstructor()->getMock();
     $paymentMock->expects($this->once())->method('setMethod')->with(PayPal::METHOD_CODE);
     $this->quoteMock->expects($this->any())->method('getPayment')->willReturn($paymentMock);
     foreach ($expectedShipping as $methodName => $value) {
         $this->shippingAddressMock->expects($this->once())->method($methodName)->with($value)->willReturnSelf();
     }
     foreach ($expectedBilling as $methodName => $value) {
         $this->billingAddressMock->expects($this->once())->method($methodName)->with($value)->willReturnSelf();
     }
     $index = 1;
     foreach ($expectedPaymentAdditionalInfo as $key => $value) {
         $paymentMock->expects($this->at($index))->method('setAdditionalInformation')->with($key, $value);
         $index++;
     }
     $this->quoteMock->expects($this->once())->method('collectTotals');
     $this->quoteRepositoryMock->expects($this->once())->method('save')->with($this->quoteMock);
     $this->model->initializeQuoteForReview($paymentMethodNonce, $details);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:25,代码来源:CheckoutTest.php

示例6: testEstimateByExtendedAddress

 /**
  * @covers \Magento\Quote\Model\ShippingMethodManagement::estimateByExtendedAddress
  */
 public function testEstimateByExtendedAddress()
 {
     $cartId = 1;
     $addressData = ['region' => 'California', 'region_id' => 23, 'country_id' => 1, 'postcode' => 90200];
     $currencyCode = 'UAH';
     $address = $this->getMockBuilder(Address::class)->disableOriginalConstructor()->setMethods(['getData'])->getMock();
     $this->quoteRepository->expects(static::once())->method('getActive')->with($cartId)->willReturn($this->quote);
     $this->quote->expects(static::once())->method('isVirtual')->willReturn(false);
     $this->quote->expects(static::once())->method('getItemsCount')->willReturn(1);
     $address->expects(static::once())->method('getData')->willReturn($addressData);
     $this->quote->expects(static::once())->method('getShippingAddress')->willReturn($this->shippingAddress);
     $this->shippingAddress->expects(static::once())->method('addData')->with($addressData)->willReturnSelf();
     $this->shippingAddress->expects(static::once())->method('setCollectShippingRates')->with(true)->willReturnSelf();
     $this->totalsCollector->expects(static::once())->method('collectAddressTotals')->with($this->quote, $this->shippingAddress)->willReturnSelf();
     $rate = $this->getMockBuilder(Rate::class)->disableOriginalConstructor()->setMethods([])->getMock();
     $methodObject = $this->getMockForAbstractClass(ShippingMethodInterface::class);
     $expectedRates = [$methodObject];
     $this->shippingAddress->expects(static::once())->method('getGroupedAllShippingRates')->willReturn([[$rate]]);
     $this->quote->expects(static::once())->method('getQuoteCurrencyCode')->willReturn($currencyCode);
     $this->converter->expects(static::once())->method('modelToDataObject')->with($rate, $currencyCode)->willReturn($methodObject);
     $carriersRates = $this->model->estimateByExtendedAddress($cartId, $address);
     static::assertEquals($expectedRates, $carriersRates);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:26,代码来源:ShippingMethodManagementTest.php


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