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


PHP Session::expects方法代码示例

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


在下文中一共展示了Session::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]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:35,代码来源:ExpressTest.php

示例2: testAddBillingAgreementToSession

 /**
  * @param bool $isValid
  * @dataProvider addBillingAgreementToSessionDataProvider
  */
 public function testAddBillingAgreementToSession($isValid)
 {
     $agreement = $this->getMock('Magento\\Paypal\\Model\\Billing\\Agreement', [], [], '', false);
     $agreement->expects($this->once())->method('isValid')->will($this->returnValue($isValid));
     $comment = $this->getMockForAbstractClass('Magento\\Framework\\Model\\AbstractModel', [], '', false, true, true, ['__wakeup']);
     $order = $this->getMock('Magento\\Sales\\Model\\Order', [], [], '', false);
     $order->expects($this->once())->method('addStatusHistoryComment')->with($isValid ? __('Created billing agreement #%1.', 'agreement reference id') : __('We can\'t create a billing agreement for this order.'))->will($this->returnValue($comment));
     if ($isValid) {
         $agreement->expects($this->any())->method('__call')->with('getReferenceId')->will($this->returnValue('agreement reference id'));
         $agreement->expects($this->once())->method('addOrderRelation')->with($order);
         $order->expects(new MethodInvokedAtIndex(0))->method('addRelatedObject')->with($agreement);
         $this->_checkoutSession->expects($this->once())->method('__call')->with('setLastBillingAgreementReferenceId', ['agreement reference id']);
     } else {
         $this->_checkoutSession->expects($this->once())->method('__call')->with('unsLastBillingAgreementReferenceId');
         $agreement->expects($this->never())->method('__call');
     }
     $order->expects(new MethodInvokedAtIndex($isValid ? 1 : 0))->method('addRelatedObject')->with($comment);
     $payment = $this->getMock('Magento\\Sales\\Model\\Order\\Payment', [], [], '', false);
     $payment->expects($this->once())->method('__call')->with('getBillingAgreementData')->will($this->returnValue('not empty'));
     $payment->expects($this->once())->method('getOrder')->will($this->returnValue($order));
     $agreement->expects($this->once())->method('importOrderPayment')->with($payment)->will($this->returnValue($agreement));
     $this->_event->setPayment($payment);
     $this->_agreementFactory->expects($this->once())->method('create')->will($this->returnValue($agreement));
     $this->_model->execute($this->_observer);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:29,代码来源:AddBillingAgreementToSessionObserverTest.php

示例3: testAfterGenerateXmlNoDepersonalize

 public function testAfterGenerateXmlNoDepersonalize()
 {
     $expectedResult = $this->getMock('Magento\\Framework\\View\\Layout', [], [], '', false);
     $this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false);
     $this->checkoutSessionMock->expects($this->never())->method('clearStorage')->will($this->returnValue($expectedResult));
     $actualResult = $this->plugin->afterGenerateXml($this->layoutMock, $expectedResult);
     $this->assertEquals($expectedResult, $actualResult);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:DepersonalizePluginTest.php

示例4: testExecuteException

 /**
  * Run test for execute method (exception)
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Wrong type of request.
  */
 public function testExecuteException()
 {
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects(static::once())->method('getRequest')->willReturn($this->getRequestMock(false));
     $this->checkoutSessionMock = $this->getMockBuilder('Magento\\Checkout\\Model\\Session')->disableOriginalConstructor()->getMock();
     $this->checkoutSessionMock->expects(static::never())->method('getQuote');
     $getButtonData = new GetButtonData($this->contextMock, $this->checkoutSessionMock);
     $getButtonData->execute();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:15,代码来源:GetButtonDataTest.php

示例5: setupCart

 protected function setupCart()
 {
     $quoteMock = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods(['hasItems', 'getHasError', 'getPayment'])->getMock();
     $quoteMock->expects($this->any())->method('hasItems')->willReturn(true);
     $quoteMock->expects($this->any())->method('getHasError')->willReturn(false);
     $this->checkoutSessionMock->expects($this->any())->method('getQuote')->willReturn($quoteMock);
     $this->checkoutFactoryMock->expects($this->any())->method('create')->willReturn($this->checkoutMock);
     return $quoteMock;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:SaveShippingMethodTest.php

示例6: setUp

 protected function setUp()
 {
     $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->checkoutSession = $this->getMock('Magento\\Checkout\\Model\\Session', [], [], '', false);
     $this->checkoutHelper = $this->getMock('Magento\\Checkout\\Helper\\Data', [], [], '', false);
     $this->itemPriceRenderer = $this->getMock('Magento\\Tax\\Block\\Item\\Price\\Renderer', [], [], '', false);
     $this->checkoutCart = $this->getMock('Magento\\Checkout\\CustomerData\\Cart', [], [], '', false);
     $this->quote = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $this->checkoutSession->expects($this->any())->method('getQuote')->willReturn($this->quote);
     $this->cart = $helper->getObject('Magento\\Tax\\Plugin\\Checkout\\CustomerData\\Cart', ['checkoutSession' => $this->checkoutSession, 'checkoutHelper' => $this->checkoutHelper, 'itemPriceRenderer' => $this->itemPriceRenderer]);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:CartTest.php

示例7: 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([]));
 }
开发者ID:nja78,项目名称:magento2,代码行数:13,代码来源:IframeTest.php

示例8: testCancelCurrentOrder

 /**
  * @param bool $hasOrderId
  * @param bool $isOrderCancelled
  * @param bool $expectedResult
  * @dataProvider cancelCurrentOrderDataProvider
  */
 public function testCancelCurrentOrder($hasOrderId, $isOrderCancelled, $expectedResult)
 {
     $comment = 'Some test comment';
     $order = $this->_getOrderMock($hasOrderId, ['registerCancellation', 'save']);
     $order->setData('state', $isOrderCancelled ? \Magento\Sales\Model\Order::STATE_CANCELED : 'some another state');
     if ($expectedResult) {
         $order->expects($this->once())->method('registerCancellation')->with($this->equalTo($comment))->will($this->returnSelf());
         $order->expects($this->once())->method('save');
     } else {
         $order->expects($this->never())->method('registerCancellation');
         $order->expects($this->never())->method('save');
     }
     $this->_session->expects($this->any())->method('getLastRealOrder')->will($this->returnValue($order));
     $this->assertEquals($expectedResult, $this->_checkout->cancelCurrentOrder($comment));
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:21,代码来源:CheckoutTest.php

示例9: testSkipShortcutForGuest

 /**
  * @param bool $isLoggedIn
  * @param bool $isAllowedGuestCheckout
  * @dataProvider skipShortcutForGuestDataProvider
  */
 public function testSkipShortcutForGuest($isLoggedIn, $isAllowedGuestCheckout, $expected)
 {
     $this->customerSessionMock->expects($this->any())->method('isLoggedIn')->willReturn($isLoggedIn);
     $quoteMock = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
     $this->checkoutSessionMock->expects($this->any())->method('getQuote')->willReturn($quoteMock);
     $this->checkoutDataMock->expects($this->any())->method('isAllowedGuestCheckout')->willReturn($isAllowedGuestCheckout);
     $this->assertEquals($expected, $this->block->skipShortcutForGuest());
 }
开发者ID:nja78,项目名称:magento2,代码行数:13,代码来源:ShortcutTest.php

示例10: testIsQuoteSummaryValidTrue

 public function testIsQuoteSummaryValidTrue()
 {
     $isInCatalog = false;
     $quote = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods(['getGrandTotal', 'validateMinimumAmount', '__wakeup'])->getMock();
     $this->sessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quote));
     $quote->expects($this->once())->method('validateMinimumAmount')->will($this->returnValue(true));
     $quote->expects($this->once())->method('getGrandTotal')->will($this->returnValue(1));
     $this->assertTrue($this->checkoutValidator->isQuoteSummaryValid($isInCatalog));
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:9,代码来源:CheckoutValidatorTest.php

示例11: testGetLastOrderId

 public function testGetLastOrderId()
 {
     $orderIncrementId = 100001;
     $orderId = 1;
     $this->checkoutSessionMock->expects($this->once())->method('getLastOrderId')->will($this->returnValue($orderId));
     $orderMock = $this->getMock('Magento\\Sales\\Model\\Order', ['load', 'getIncrementId', '__wakeup'], [], '', false);
     $orderMock->expects($this->once())->method('load')->with($orderId)->will($this->returnSelf());
     $orderMock->expects($this->once())->method('getIncrementId')->will($this->returnValue($orderIncrementId));
     $this->orderFactoryMock->expects($this->once())->method('create')->will($this->returnValue($orderMock));
     $this->assertEquals($orderIncrementId, $this->onepage->getLastOrderId());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:11,代码来源:OnepageTest.php

示例12: testExecute

 public function testExecute()
 {
     $quoteId = 123;
     $orderId = 'orderId';
     $orderIncrementId = 125;
     $quoteMock = $this->setupCart();
     $this->checkoutMock->expects($this->once())->method('place')->with(null);
     $this->checkoutSessionMock->expects($this->once())->method('clearHelperData');
     $quoteMock->expects($this->once())->method('getId')->willReturn($quoteId);
     $this->checkoutSessionMock->expects($this->once())->method('setLastQuoteId')->with($quoteId)->willReturnSelf();
     $this->checkoutSessionMock->expects($this->once())->method('setLastSuccessQuoteId')->with($quoteId)->willReturnSelf();
     $orderMock = $this->getMockBuilder('\\Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
     $orderMock->expects($this->once())->method('getId')->willReturn($orderId);
     $orderMock->expects($this->once())->method('getIncrementId')->willReturn($orderIncrementId);
     $this->checkoutMock->expects($this->once())->method('getOrder')->willReturn($orderMock);
     $this->checkoutSessionMock->expects($this->once())->method('setLastOrderId')->with($orderId)->willReturnSelf();
     $this->checkoutSessionMock->expects($this->once())->method('setLastRealOrderId')->with($orderIncrementId)->willReturnSelf();
     $resultRedirect = $this->getMockBuilder('\\Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultRedirect->expects($this->once())->method('setPath')->with('checkout/onepage/success')->willReturnSelf();
     $this->resultFactoryMock->expects($this->once())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($resultRedirect);
     $this->assertEquals($resultRedirect, $this->controller->execute());
 }
开发者ID:nja78,项目名称:magento2,代码行数:22,代码来源:PlaceOrderTest.php

示例13: testExecuteException

 public function testExecuteException()
 {
     $redirectPath = 'path/to/redirect';
     $quoteMock = $this->getQuoteMock();
     $quoteMock->expects(self::once())->method('getItemsCount')->willReturn(0);
     $this->requestMock->expects(self::exactly(1))->method('getParam')->willReturnMap([['isAjax', null, true]]);
     $this->checkoutSessionMock->expects(self::once())->method('getQuote')->willReturn($quoteMock);
     $this->shippingMethodUpdaterMock->expects(self::never())->method('execute');
     $this->messageManagerMock->expects(self::once())->method('addExceptionMessage')->with(self::isInstanceOf('\\InvalidArgumentException'), 'We can\'t initialize checkout.');
     $this->urlMock->expects(self::once())->method('getUrl')->with('*/*/review', ['_secure' => true])->willReturn($redirectPath);
     $this->responseMock->expects(self::once())->method('setBody')->with(sprintf('<script>window.location.href = "%s";</script>', $redirectPath));
     $this->saveShippingMethod->execute();
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:13,代码来源:SaveShippingMethodTest.php

示例14: testExecuteException

 public function testExecuteException()
 {
     $agreement = ['test-data'];
     $quote = $this->getQuoteMock();
     $quote->expects(self::once())->method('getItemsCount')->willReturn(0);
     $resultMock = $this->getResultMock();
     $resultMock->expects(self::once())->method('setPath')->with('checkout/cart')->willReturnSelf();
     $this->resultFactoryMock->expects(self::once())->method('create')->with(ResultFactory::TYPE_REDIRECT)->willReturn($resultMock);
     $this->requestMock->expects(self::once())->method('getPostValue')->with('agreement', [])->willReturn($agreement);
     $this->checkoutSessionMock->expects(self::once())->method('getQuote')->willReturn($quote);
     $this->orderPlaceMock->expects(self::never())->method('execute');
     $this->messageManagerMock->expects(self::once())->method('addExceptionMessage')->with(self::isInstanceOf('\\InvalidArgumentException'), 'We can\'t initialize checkout.');
     self::assertEquals($this->placeOrder->execute(), $resultMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:PlaceOrderTest.php

示例15: testExecuteException

 public function testExecuteException()
 {
     $result = '{}';
     $quoteMock = $this->getQuoteMock();
     $resultRedirectMock = $this->getResultRedirectMock();
     $quoteMock->expects(self::once())->method('getItemsCount')->willReturn(1);
     $this->requestMock->expects(self::once())->method('getPostValue')->with('result', '{}')->willReturn($result);
     $this->checkoutSessionMock->expects(self::once())->method('getQuote')->willReturn($quoteMock);
     $this->quoteUpdaterMock->expects(self::never())->method('execute');
     $this->messageManagerMock->expects(self::once())->method('addExceptionMessage')->with(self::isInstanceOf('\\InvalidArgumentException'), 'Data of request cannot be empty.');
     $this->resultFactoryMock->expects(self::once())->method('create')->with(ResultFactory::TYPE_REDIRECT)->willReturn($resultRedirectMock);
     $resultRedirectMock->expects(self::once())->method('setPath')->with('checkout/cart')->willReturnSelf();
     self::assertEquals($this->review->execute(), $resultRedirectMock);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:14,代码来源:ReviewTest.php


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