本文整理汇总了PHP中Magento\Quote\Model\Quote::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Quote::expects方法的具体用法?PHP Quote::expects怎么用?PHP Quote::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Quote\Model\Quote
的用法示例。
在下文中一共展示了Quote::expects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$this->markTestIncomplete();
$this->messageManager = $this->getMockForAbstractClass('Magento\\Framework\\Message\\ManagerInterface');
$this->config = $this->getMock('Magento\\Paypal\\Model\\Config', [], [], '', false);
$this->request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
$this->quote = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
$this->quote->expects($this->any())->method('hasItems')->will($this->returnValue(true));
$this->redirect = $this->getMockForAbstractClass('Magento\\Framework\\App\\Response\\RedirectInterface');
$this->response = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false);
$this->customerData = $this->getMock('Magento\\Customer\\Api\\Data\\CustomerInterface', [], [], '', false);
$this->checkout = $this->getMock('Magento\\Paypal\\Model\\Express\\Checkout', [], [], '', false);
$this->customerSession = $this->getMock('Magento\\Customer\\Model\\Session', [], [], '', false);
$this->customerSession->expects($this->any())->method('getCustomerDataObject')->will($this->returnValue($this->customerData));
$this->checkoutSession = $this->getMock('Magento\\Checkout\\Model\\Session', [], [], '', false);
$this->checkoutFactory = $this->getMock('Magento\\Paypal\\Model\\Express\\Checkout\\Factory', [], [], '', false);
$this->checkoutFactory->expects($this->any())->method('create')->will($this->returnValue($this->checkout));
$this->checkoutSession->expects($this->any())->method('getQuote')->will($this->returnValue($this->quote));
$this->session = $this->getMock('Magento\\Framework\\Session\\Generic', [], [], '', false);
$objectManager = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
$this->objectManagerCallback = function ($className) {
if ($className == 'Magento\\Paypal\\Model\\Config') {
return $this->config;
}
return $this->getMock($className, [], [], '', false);
};
$objectManager->expects($this->any())->method('get')->will($this->returnCallback(function ($className) {
return call_user_func($this->objectManagerCallback, $className);
}));
$objectManager->expects($this->any())->method('create')->will($this->returnCallback(function ($className) {
return call_user_func($this->objectManagerCallback, $className);
}));
$helper = new ObjectManagerHelper($this);
$this->model = $helper->getObject('\\Magento\\\\Paypal\\Controller\\Express\\' . $this->name, ['messageManager' => $this->messageManager, 'response' => $this->response, 'redirect' => $this->redirect, 'request' => $this->request, 'customerSession' => $this->customerSession, 'checkoutSession' => $this->checkoutSession, 'checkoutFactory' => $this->checkoutFactory, 'paypalSession' => $this->session, 'objectManager' => $objectManager]);
}
示例2: testCollect
public function testCollect()
{
$this->shippingAssignment->expects($this->exactly(3))->method('getShipping')->willReturn($this->shipping);
$this->shipping->expects($this->exactly(2))->method('getAddress')->willReturn($this->address);
$this->shipping->expects($this->once())->method('getMethod')->willReturn('flatrate');
$this->shippingAssignment->expects($this->atLeastOnce())->method('getItems')->willReturn([$this->cartItem]);
$this->freeShipping->expects($this->once())->method('isFreeShipping')->with($this->quote, [$this->cartItem])->willReturn(true);
$this->address->expects($this->once())->method('setFreeShipping')->with(true);
$this->total->expects($this->atLeastOnce())->method('setTotalAmount');
$this->total->expects($this->atLeastOnce())->method('setBaseTotalAmount');
$this->cartItem->expects($this->atLeastOnce())->method('getProduct')->willReturnSelf();
$this->cartItem->expects($this->atLeastOnce())->method('isVirtual')->willReturn(false);
$this->cartItem->expects($this->once())->method('getParentItem')->willReturn(false);
$this->cartItem->expects($this->once())->method('getHasChildren')->willReturn(false);
$this->cartItem->expects($this->once())->method('getWeight')->willReturn(2);
$this->cartItem->expects($this->atLeastOnce())->method('getQty')->willReturn(2);
$this->address->expects($this->once())->method('getFreeShipping')->willReturn(true);
$this->cartItem->expects($this->once())->method('setRowWeight')->with(0);
$this->address->expects($this->once())->method('setItemQty')->with(2);
$this->address->expects($this->atLeastOnce())->method('setWeight');
$this->address->expects($this->atLeastOnce())->method('setFreeMethodWeight');
$this->address->expects($this->once())->method('collectShippingRates');
$this->address->expects($this->once())->method('getAllShippingRates')->willReturn([$this->rate]);
$this->rate->expects($this->once())->method('getCode')->willReturn('flatrate');
$this->quote->expects($this->once())->method('getStore')->willReturn($this->store);
$this->rate->expects($this->atLeastOnce())->method('getPrice')->willReturn(5);
$this->priceCurrency->expects($this->once())->method('convert')->with(5, $this->store)->willReturn(5);
$this->total->expects($this->once())->method('setShippingAmount')->with(5);
$this->rate->expects($this->once())->method('getCarrierTitle')->willReturn('Carrier title');
$this->rate->expects($this->once())->method('getMethodTitle')->willReturn('Method title');
$this->address->expects($this->once())->method('setShippingDescription')->with('Carrier title - Method title');
$this->address->expects($this->once())->method('getShippingDescription')->willReturn('Carrier title - Method title');
$this->total->expects($this->once())->method('setShippingDescription')->with('Carrier title - Method title');
$this->shippingModel->collect($this->quote, $this->shippingAssignment, $this->total);
}
示例3: prepare
public function prepare()
{
$this->contextMock = $this->getMock('Magento\\Framework\\View\\Element\\Template\\Context', [], [], '', false);
$this->checkoutSessionMock = $this->getMock('Magento\\Checkout\\Model\\Session', [], [], '', false);
$this->orderFactoryMock = $this->getMock('Magento\\Sales\\Model\\OrderFactory', ['getQuote'], [], '', false);
$this->hssHelperMock = $this->getMock('Magento\\Paypal\\Helper\\Hss', [], [], '', false);
$this->paymentDataMock = $this->getMock('Magento\\Payment\\Helper\\Data', [], [], '', false);
$this->quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', ['getPayment', '__wakeup'], [], '', false);
$this->paymentMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Payment', [], [], '', false);
$this->checkoutSessionMock->expects($this->any())->method('getQuote')->will($this->returnValue($this->quoteMock));
$this->quoteMock->expects($this->any())->method('getPayment')->will($this->returnValue($this->paymentMock));
$this->hssHelperMock->expects($this->any())->method('getHssMethods')->will($this->returnValue([]));
}
示例4: testGetTotals
/**
* @dataProvider totalsDataProvider
*/
public function testGetTotals($isVirtual)
{
$expected = 'expected';
$this->quoteMock->expects($this->at(0))->method('setTotalsCollectedFlag')->with(false);
$this->quoteMock->expects($this->at(1))->method('collectTotals');
$this->quoteMock->expects($this->once())->method('isVirtual')->willreturn($isVirtual);
if ($isVirtual) {
$this->billingAddressMock->expects($this->once())->method('getTotals')->willReturn($expected);
} else {
$this->shippingAddressMock->expects($this->once())->method('getTotals')->willReturn($expected);
}
$this->assertEquals($expected, $this->totals->getTotals());
}
示例5: setUp
protected function setUp()
{
$this->loggerMock = $this->getMock('Psr\\Log\\LoggerInterface');
$this->quoteMock = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
$this->orderMock = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false);
$this->paymentMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Payment', [], [], '', false);
$this->orderSenderMock = $this->getMock('Magento\\Sales\\Model\\Order\\Email\\Sender\\OrderSender', [], [], '', false);
$eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getQuote', 'getOrder'])->getMock();
$this->observerMock = $this->getMock('Magento\\Framework\\Event\\Observer', ['getEvent'], [], '', false);
$this->observerMock->expects($this->any())->method('getEvent')->willReturn($eventMock);
$eventMock->expects($this->once())->method('getQuote')->willReturn($this->quoteMock);
$eventMock->expects($this->once())->method('getOrder')->willReturn($this->orderMock);
$this->quoteMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock);
$this->model = new \Magento\Quote\Observer\Webapi\SubmitObserver($this->loggerMock, $this->orderSenderMock);
}
示例6: setUp
public function setUp()
{
$objectManager = new ObjectManager($this);
$this->taxConfig = $this->getMockBuilder('\\Magento\\Tax\\Model\\Config')->disableOriginalConstructor()->setMethods(['getShippingTaxClass', 'shippingPriceIncludesTax'])->getMock();
$this->store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['__wakeup'])->getMock();
$this->quote = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods(['__wakeup', 'getStore'])->getMock();
$this->quote->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
$this->address = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote\\Address')->disableOriginalConstructor()->setMethods(['__wakeup', 'getQuote', 'getShippingDiscountAmount', 'getBaseShippingDiscountAmount'])->getMock();
$this->address->expects($this->any())->method('getQuote')->will($this->returnValue($this->quote));
$methods = ['setType', 'setCode', 'setQuantity', 'setUnitPrice', 'setDiscountAmount', 'setTaxClassKey', 'setTaxIncluded', 'create'];
$this->quoteDetailsItemBuilderMock = $this->getMock('Magento\\Tax\\Api\\Data\\QuoteDetailsItemDataBuilder', $methods, [], '', false);
$classMethods = ['setType', 'setValue', 'create'];
$this->taxClassKeyBuilderMock = $this->getMock('Magento\\Tax\\Api\\Data\\TaxClassKeyDataBuilder', $classMethods, [], '', false);
$this->commonTaxCollector = $objectManager->getObject('Magento\\Tax\\Model\\Sales\\Total\\Quote\\CommonTaxCollector', ['taxConfig' => $this->taxConfig, 'quoteDetailsItemBuilder' => $this->quoteDetailsItemBuilderMock, 'taxClassKeyBuilder' => $this->taxClassKeyBuilderMock]);
}
示例7: testDelete
public function testDelete()
{
$this->quoteMock->expects($this->once())->method('delete');
$this->quoteMock->expects($this->exactly(1))->method('getId')->willReturn(1);
$this->quoteMock->expects($this->exactly(1))->method('getCustomerId')->willReturn(2);
$this->model->delete($this->quoteMock);
}
示例8: testExecuteWithSuccessOrderSave
/**
* Test for execute method
*
* @return void
*/
public function testExecuteWithSuccessOrderSave()
{
$testData = $this->getExecuteWithSuccessOrderSaveTestData();
$redirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
$paymentMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Payment')->disableOriginalConstructor()->getMock();
$checkoutMock = $this->getMockBuilder('Magento\\Checkout\\Model\\Session')->disableOriginalConstructor()->setMethods(['getRedirectUrl'])->getMock();
$resultJsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
$redirectMock->expects($this->never())->method('setPath')->with('*/*/')->willReturn('redirect');
$this->formKeyValidatorMock->expects($this->once())->method('validate')->with($this->requestMock)->willReturn(true);
$this->resultRedirectFactoryMock->expects($this->never())->method('create')->willReturn($redirectMock);
$this->objectManagerMock->expects($this->atLeastOnce())->method('get')->willReturnMap($testData['objectManager.get']);
// call _expireAjax method
$this->expireAjaxFlowHasItemsFalse();
$this->requestMock->expects($this->atLeastOnce())->method('getPost')->willReturnMap($testData['request.getPost']);
$this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($testData['agreementsValidator.isValid'])->willReturn(true);
$this->quoteMock->expects($this->atLeastOnce())->method('getPayment')->willReturn($paymentMock);
$paymentMock->expects($this->once())->method('setQuote')->with($this->quoteMock);
$paymentMock->expects($this->once())->method('importData')->with($testData['payment.importData']);
$this->onepageMock->expects($this->once())->method('saveOrder');
$this->onepageMock->expects($this->once())->method('getCheckout')->willReturn($checkoutMock);
$checkoutMock->expects($this->once())->method('getRedirectUrl')->willReturn(null);
$this->eventManagerMock->expects($this->once())->method('dispatch')->withConsecutive($this->equalTo('checkout_controller_onepage_saveOrder'), $this->countOf(2));
$this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($resultJsonMock);
$resultJsonMock->expects($this->once())->method('setData')->with($testData['resultJson.setData'])->willReturnSelf();
$this->assertEquals($resultJsonMock, $this->controller->execute());
}
示例9: testExecuteFailedPlaceOrder
/**
* @param $paymentMethod
* @param $controller
* @param $quoteId
* @param $result
* @dataProvider textExecuteFailedPlaceOrderDataProvider
*/
public function testExecuteFailedPlaceOrder($paymentMethod, $controller, $quoteId, $result)
{
$this->requestMock->expects($this->at(0))->method('getParam')->with('payment')->will($this->returnValue($paymentMethod));
$this->requestMock->expects($this->at(1))->method('getParam')->with('controller')->will($this->returnValue($controller));
$this->quoteMock->expects($this->any())->method('getId')->will($this->returnValue($quoteId));
$this->cartManagementMock->expects($this->once())->method('placeOrder')->willThrowException(new \Exception());
$this->jsonHelperMock->expects($this->any())->method('jsonEncode')->with($result);
$this->placeOrderController->execute();
}
示例10: setUp
public function setUp()
{
$objectManager = new ObjectManager($this);
$this->taxConfig = $this->getMockBuilder('\\Magento\\Tax\\Model\\Config')->disableOriginalConstructor()->setMethods(['getShippingTaxClass', 'shippingPriceIncludesTax'])->getMock();
$this->store = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['__wakeup'])->getMock();
$this->quote = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods(['__wakeup', 'getStore'])->getMock();
$this->quote->expects($this->any())->method('getStore')->will($this->returnValue($this->store));
$this->address = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote\\Address')->disableOriginalConstructor()->getMock();
$this->address->expects($this->any())->method('getQuote')->will($this->returnValue($this->quote));
$methods = ['create'];
$this->quoteDetailsItemDataObject = $objectManager->getObject('Magento\\Tax\\Model\\Sales\\Quote\\ItemDetails');
$this->taxClassKeyDataObject = $objectManager->getObject('Magento\\Tax\\Model\\TaxClass\\Key');
$this->quoteDetailsItemDataObjectFactoryMock = $this->getMock('Magento\\Tax\\Api\\Data\\QuoteDetailsItemInterfaceFactory', $methods, [], '', false);
$this->quoteDetailsItemDataObjectFactoryMock->expects($this->any())->method('create')->willReturn($this->quoteDetailsItemDataObject);
$this->taxClassKeyDataObjectFactoryMock = $this->getMock('Magento\\Tax\\Api\\Data\\TaxClassKeyInterfaceFactory', $methods, [], '', false);
$this->taxClassKeyDataObjectFactoryMock->expects($this->any())->method('create')->willReturn($this->taxClassKeyDataObject);
$this->commonTaxCollector = $objectManager->getObject('Magento\\Tax\\Model\\Sales\\Total\\Quote\\CommonTaxCollector', ['taxConfig' => $this->taxConfig, 'quoteDetailsItemDataObjectFactory' => $this->quoteDetailsItemDataObjectFactoryMock, 'taxClassKeyDataObjectFactory' => $this->taxClassKeyDataObjectFactoryMock]);
}
示例11: testCalculate
/**
* @covers \Magento\SalesRule\Model\Rule\Action\Discount\CartFixed::calculate
*/
public function testCalculate()
{
$this->rule->setData(['id' => 1, 'discount_amount' => 10.0]);
$this->address->expects($this->any())->method('getCartFixedRules')->will($this->returnValue([]));
$store = $this->getMock('Magento\\Store\\Model\\Store', [], [], '', false);
$this->priceCurrency->expects($this->atLeastOnce())->method('convert')->will($this->returnArgument(0));
$this->priceCurrency->expects($this->atLeastOnce())->method('round')->will($this->returnArgument(0));
$this->quote->expects($this->any())->method('getStore')->will($this->returnValue($store));
/** validators data */
$this->validator->expects($this->once())->method('getItemPrice')->with($this->item)->will($this->returnValue(100));
$this->validator->expects($this->once())->method('getItemBasePrice')->with($this->item)->will($this->returnValue(100));
$this->validator->expects($this->once())->method('getItemOriginalPrice')->with($this->item)->will($this->returnValue(100));
$this->validator->expects($this->once())->method('getItemBaseOriginalPrice')->with($this->item)->will($this->returnValue(100));
$this->address->expects($this->once())->method('setCartFixedRules')->with([1 => 0.0]);
$this->model->calculate($this->rule, $this->item, 1);
$this->assertEquals($this->data->getAmount(), 10);
$this->assertEquals($this->data->getBaseAmount(), 10);
$this->assertEquals($this->data->getOriginalAmount(), 10);
$this->assertEquals($this->data->getBaseOriginalAmount(), 100);
}
示例12: testGetWithExceptionByIsActive
/**
* @expectedExcpetion \Magento\Framework\Exception\NoSuchEntityException
* @expectedExceptionMessage No such entity with cartId = 15
*/
public function testGetWithExceptionByIsActive()
{
$cartId = 15;
$this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($this->quoteMock);
$this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($this->storeMock);
$this->storeMock->expects($this->once())->method('getId')->willReturn($this->storeMock);
$this->quoteMock->expects($this->never())->method('setSharedStoreIds');
$this->quoteMock->expects($this->once())->method('load')->with($cartId)->willReturn($this->storeMock);
$this->quoteMock->expects($this->once())->method('getId')->willReturn($cartId);
$this->quoteMock->expects($this->once())->method('getIsActive')->willReturn(0);
$this->model->get($cartId);
}
示例13: 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);
}
示例14: testProcessRelation
/**
* Test for processRelation
*/
public function testProcessRelation()
{
$addressCollectionMock = $this->getMock('Magento\\Eav\\Model\\Entity\\Collection\\AbstractCollection', [], [], '', false);
$this->quoteMock->expects($this->once())->method('addressCollectionWasSet')->willReturn(true);
$this->quoteMock->expects($this->once())->method('getAddressesCollection')->willReturn($addressCollectionMock);
$addressCollectionMock->expects($this->once())->method('save');
$itemsCollectionMock = $this->getMock('Magento\\Eav\\Model\\Entity\\Collection\\AbstractCollection', [], [], '', false);
$this->quoteMock->expects($this->once())->method('itemsCollectionWasSet')->willReturn(true);
$this->quoteMock->expects($this->once())->method('getItemsCollection')->willReturn($itemsCollectionMock);
$itemsCollectionMock->expects($this->once())->method('save');
$paymentCollectionMock = $this->getMock('Magento\\Eav\\Model\\Entity\\Collection\\AbstractCollection', [], [], '', false);
$this->quoteMock->expects($this->once())->method('paymentsCollectionWasSet')->willReturn(true);
$this->quoteMock->expects($this->once())->method('getPaymentsCollection')->willReturn($paymentCollectionMock);
$paymentCollectionMock->expects($this->once())->method('save');
$paymentMock = $this->getMock('Magento\\Quote\\Model\\Quote\\Payment', [], [], '', false);
$this->quoteMock->expects($this->once())->method('currentPaymentWasSet')->willReturn(true);
$this->quoteMock->expects($this->once())->method('getPayment')->willReturn($paymentMock);
$paymentMock->expects($this->once())->method('save');
$this->model->processRelation($this->quoteMock);
}
示例15: testPopulateCustomerInfo
public function testPopulateCustomerInfo()
{
$this->quoteMock->expects($this->once())->method('getCustomer')->willReturn($this->customerMock);
$this->customerMock->expects($this->atLeastOnce())->method('getId')->willReturn(null);
$this->customerMock->expects($this->atLeastOnce())->method('getDefaultBilling')->willReturn(100500);
$this->quoteMock->expects($this->atLeastOnce())->method('getBillingAddress')->willReturn($this->quoteAddressMock);
$this->quoteMock->expects($this->atLeastOnce())->method('getShippingAddress')->willReturn($this->quoteAddressMock);
$this->quoteMock->expects($this->atLeastOnce())->method('setCustomer')->with($this->customerMock)->willReturnSelf();
$this->quoteMock->expects($this->once())->method('getPasswordHash')->willReturn('password hash');
$this->quoteAddressMock->expects($this->atLeastOnce())->method('getId')->willReturn(null);
$this->customerAddressRepositoryMock->expects($this->atLeastOnce())->method('getById')->with(100500)->willReturn($this->customerAddressMock);
$this->quoteAddressMock->expects($this->atLeastOnce())->method('importCustomerAddressData')->willReturnSelf();
$this->accountManagementMock->expects($this->once())->method('createAccountWithPasswordHash')->with($this->customerMock, 'password hash')->willReturn($this->customerMock);
$this->customerManagement->populateCustomerInfo($this->quoteMock);
}