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


PHP Action\Context类代码示例

本文整理汇总了PHP中Magento\Framework\App\Action\Context的典型用法代码示例。如果您正苦于以下问题:PHP Context类的具体用法?PHP Context怎么用?PHP Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setUp

 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getMessageManager', 'getRedirect', 'getObjectManager', 'getSession', 'getActionFlag', 'getHelper', 'getResultRedirectFactory', 'getResultFactory'], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', ['create'], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess', 'addError'], [], '', false);
     $this->orderCollectionMock = $this->getMockBuilder('Magento\\Sales\\Model\\Resource\\Order\\Collection')->disableOriginalConstructor()->getMock();
     $this->sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlagMock = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get', 'set'], [], '', false);
     $this->helperMock = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->resultRedirectMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
     $redirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $resultFactoryMock->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($redirectMock);
     $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->once())->method('getSession')->willReturn($this->sessionMock);
     $this->contextMock->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlagMock);
     $this->contextMock->expects($this->once())->method('getHelper')->willReturn($this->helperMock);
     $this->contextMock->expects($this->once())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $this->massAction = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\MassCancel', ['context' => $this->contextMock]);
 }
开发者ID:nja78,项目名称:magento2,代码行数:29,代码来源:MassCancelTest.php

示例2: setUp

 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->contextMock = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $resultRedirectFactory = $this->getMock('Magento\\Backend\\Model\\View\\Result\\RedirectFactory', [], [], '', false);
     $this->responseMock = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->customerCollectionMock = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer\\Collection')->disableOriginalConstructor()->getMock();
     $this->customerCollectionFactoryMock = $this->getMockBuilder('Magento\\Customer\\Model\\ResourceModel\\Customer\\CollectionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $redirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $resultFactoryMock->expects($this->any())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($redirectMock);
     $this->subscriberMock = $this->getMock('Magento\\Newsletter\\Model\\Subscriber', [], [], '', false);
     $subscriberFactoryMock = $this->getMockBuilder('Magento\\Newsletter\\Model\\SubscriberFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $subscriberFactoryMock->expects($this->any())->method('create')->willReturn($this->subscriberMock);
     $this->resultRedirectMock = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
     $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
     $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
     $this->contextMock->expects($this->any())->method('getResultRedirectFactory')->willReturn($resultRedirectFactory);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($resultFactoryMock);
     $this->filterMock = $this->getMock('Magento\\Ui\\Component\\MassAction\\Filter', [], [], '', false);
     $this->filterMock->expects($this->once())->method('getCollection')->with($this->customerCollectionMock)->willReturnArgument(0);
     $this->customerCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->customerCollectionMock);
     $this->customerRepositoryMock = $this->getMockBuilder('Magento\\Customer\\Api\\CustomerRepositoryInterface')->getMockForAbstractClass();
     $this->massAction = $objectManagerHelper->getObject('Magento\\Customer\\Controller\\Adminhtml\\Index\\MassUnsubscribe', ['context' => $this->contextMock, 'filter' => $this->filterMock, 'collectionFactory' => $this->customerCollectionFactoryMock, 'customerRepository' => $this->customerRepositoryMock, 'subscriberFactory' => $subscriberFactoryMock]);
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:31,代码来源:MassUnsubscribeTest.php

示例3: __construct

 /**
  * @param \Magento\Framework\App\Action\Context $context
  * @param PhpCookieManager $cookieManager
  * @param CookieMetadataFactory $cookieMetadataFactory
  */
 public function __construct(\Magento\Framework\App\Action\Context $context, PhpCookieManager $cookieManager, CookieMetadataFactory $cookieMetadataFactory)
 {
     $this->cookieManager = $cookieManager;
     $this->cookieMetadataFacory = $cookieMetadataFactory;
     $this->_response = $context->getResponse();
     $this->request = $context->getRequest();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:CookieTester.php

示例4: setUp

 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface', [], [], '', false);
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', [], [], '', false);
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->session = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', [], [], '', false);
     $this->helper = $this->getMock('\\Magento\\Backend\\Helper\\Data', [], [], '', false);
     $this->resultRedirect = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultRedirectFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager);
     $this->context->expects($this->once())->method('getObjectManager')->willReturn($this->objectManager);
     $this->context->expects($this->once())->method('getSession')->willReturn($this->session);
     $this->context->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlag);
     $this->context->expects($this->once())->method('getRequest')->willReturn($this->request);
     $this->context->expects($this->once())->method('getResponse')->willReturn($this->response);
     $this->context->expects($this->once())->method('getHelper')->willReturn($this->helper);
     $this->context->expects($this->once())->method('getResultRedirectFactory')->willReturn($this->resultRedirectFactory);
     $this->resultForward = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Forward')->disableOriginalConstructor()->getMock();
     $this->resultForwardFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\ForwardFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->invoiceEmail = $objectManagerHelper->getObject('Magento\\Sales\\Controller\\Adminhtml\\Order\\Invoice\\Email', ['context' => $this->context, 'resultForwardFactory' => $this->resultForwardFactory]);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:25,代码来源:EmailTest.php

示例5: setUp

 public function setUp()
 {
     $objectManagerHelper = new ObjectManagerHelper($this);
     $this->shipmentLoader = $this->getMock('Magento\\Shipping\\Controller\\Adminhtml\\Order\\ShipmentLoader', ['setOrderId', 'setShipmentId', 'setShipment', 'setTracking', 'load'], [], '', false);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getRequest', 'getResponse', 'getMessageManager', 'getRedirect', 'getObjectManager', 'getSession', 'getActionFlag', 'getHelper', 'getResultFactory'], [], '', false);
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse'], [], '', false);
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->setMethods(['isPost', 'getModuleName', 'setModuleName', 'getActionName', 'setActionName', 'getParam', 'getCookie'])->getMockForAbstractClass();
     $this->objectManager = $this->getMock('Magento\\Framework\\ObjectManager\\ObjectManager', ['create'], [], '', false);
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', ['addSuccess', 'addError'], [], '', false);
     $this->session = $this->getMock('Magento\\Backend\\Model\\Session', ['setIsUrlNotice'], [], '', false);
     $this->actionFlag = $this->getMock('Magento\\Framework\\App\\ActionFlag', ['get'], [], '', false);
     $this->helper = $this->getMock('\\Magento\\Backend\\Helper\\Data', ['getUrl'], [], '', false);
     $this->resultRedirect = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Redirect', [], [], '', false);
     $this->resultFactory = $this->getMock('Magento\\Framework\\Controller\\ResultFactory', ['create'], [], '', false);
     $this->resultFactory->expects($this->once())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($this->resultRedirect);
     $this->context->expects($this->once())->method('getMessageManager')->willReturn($this->messageManager);
     $this->context->expects($this->once())->method('getRequest')->willReturn($this->request);
     $this->context->expects($this->once())->method('getResponse')->willReturn($this->response);
     $this->context->expects($this->once())->method('getObjectManager')->willReturn($this->objectManager);
     $this->context->expects($this->once())->method('getSession')->willReturn($this->session);
     $this->context->expects($this->once())->method('getActionFlag')->willReturn($this->actionFlag);
     $this->context->expects($this->once())->method('getHelper')->willReturn($this->helper);
     $this->context->expects($this->once())->method('getResultFactory')->willReturn($this->resultFactory);
     $this->shipmentEmail = $objectManagerHelper->getObject('Magento\\Shipping\\Controller\\Adminhtml\\Order\\Shipment\\Email', ['context' => $this->context, 'shipmentLoader' => $this->shipmentLoader, 'request' => $this->request, 'response' => $this->response]);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:25,代码来源:EmailTest.php

示例6: __construct

 /**
  * @param \Magento\Framework\App\Action\Context $context
  */
 public function __construct(\Magento\Framework\App\Action\Context $context)
 {
     $this->_request = $context->getRequest();
     $this->_response = $context->getResponse();
     $this->resultRedirectFactory = $context->getResultRedirectFactory();
     $this->resultFactory = $context->getResultFactory();
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:10,代码来源:AbstractAction.php

示例7: __construct

 /**
  * @param Context $context
  */
 public function __construct(Context $context)
 {
     $this->_request = $context->getRequest();
     $this->_response = $context->getResponse();
     $this->resultRedirectFactory = $context->getResultRedirectFactory();
     $this->resultFactory = $context->getResultFactory();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:AbstractAction.php

示例8: __construct

 /**
  * @param AuthorFactory $authorFactory
  * @param Registry      $registry
  * @param Context       $context
  */
 public function __construct(AuthorFactory $authorFactory, Registry $registry, Context $context)
 {
     $this->authorFactory = $authorFactory;
     $this->registry = $registry;
     $this->resultFactory = $context->getResultFactory();
     parent::__construct($context);
 }
开发者ID:mirasvit,项目名称:module-blog,代码行数:12,代码来源:View.php

示例9: __construct

 /**
  * @param Context $context
  * @param Registry $coreRegistry
  * @param DataFactory $dataFactory
  * @param CartManagementInterface $cartManagement
  * @param Onepage $onepageCheckout
  * @param JsonHelper $jsonHelper
  */
 public function __construct(Context $context, Registry $coreRegistry, DataFactory $dataFactory, CartManagementInterface $cartManagement, Onepage $onepageCheckout, JsonHelper $jsonHelper)
 {
     $this->eventManager = $context->getEventManager();
     $this->cartManagement = $cartManagement;
     $this->onepageCheckout = $onepageCheckout;
     $this->jsonHelper = $jsonHelper;
     parent::__construct($context, $coreRegistry, $dataFactory);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:Place.php

示例10: setUp

 protected function setUp()
 {
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', ['setRedirect', 'sendResponse']);
     $this->redirect = $this->getMock('\\Magento\\Framework\\App\\Response\\RedirectInterface');
     $this->context = $this->getMock('Magento\\Framework\\App\\Action\\Context', [], [], '', false);
     $this->context->expects($this->any())->method('getResponse')->will($this->returnValue($this->response));
     $this->context->expects($this->any())->method('getRedirect')->will($this->returnValue($this->redirect));
     $this->unit = (new ObjectManager($this))->getObject('Magento\\Store\\Controller\\Store\\SwitchAction', ['context' => $this->context]);
 }
开发者ID:nja78,项目名称:magento2,代码行数:9,代码来源:SwitchActionTest.php

示例11: __construct

 /**
  * AjaxPlugin constructor.
  * @param Context $context
  * @param \Boxalino\Intelligence\Helper\Data $bxHelperData
  * @param \Boxalino\Intelligence\Helper\P13n\Adapter $p13nHelper
  * @param AutocompleteInterface $autocomplete
  * @param \Boxalino\Intelligence\Helper\Autocomplete $autocompleteHelper
  */
 public function __construct(Context $context, \Boxalino\Intelligence\Helper\Data $bxHelperData, \Boxalino\Intelligence\Helper\P13n\Adapter $p13nHelper, \Boxalino\Intelligence\Helper\Autocomplete $autocompleteHelper)
 {
     $this->autocompleteHelper = $autocompleteHelper;
     $this->url = $context->getUrl();
     $this->request = $context->getRequest();
     $this->p13nHelper = $p13nHelper;
     $this->resultFactory = $context->getResultFactory();
     $this->bxHelperData = $bxHelperData;
 }
开发者ID:boxalino,项目名称:plugin-magento2,代码行数:17,代码来源:AjaxPlugin.php

示例12: 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

示例13: __construct

 /**
  * @param \Magento\Framework\App\Action\Context $context
  * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder
  * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  */
 public function __construct(\Magento\Framework\App\Action\Context $context, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Escaper $escaper)
 {
     $this->_transportBuilder = $transportBuilder;
     $this->inlineTranslation = $inlineTranslation;
     $this->scopeConfig = $scopeConfig;
     $this->storeManager = $storeManager;
     $this->_escaper = $escaper;
     $this->messageManager = $context->getMessageManager();
 }
开发者ID:alinmiron,项目名称:alin-cadou,代码行数:16,代码来源:Mailer.php

示例14: __construct

 /**
  * @param PaymentHelper $paymentHelper
  */
 public function __construct(\Magento\Framework\App\Action\Context $context, PaymentHelper $paymentHelper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\View\Asset\Repository $assetRepo)
 {
     $this->_request = $context->getRequest();
     $this->methodInstance = $paymentHelper->getMethodInstance($this->methodCode);
     $this->_scopeConfig = $scopeConfig;
     $this->_checkoutSession = $checkoutSession;
     $this->_storeManager = $storeManager;
     $this->_assetRepo = $assetRepo;
     $this->_context = $context;
 }
开发者ID:SummaSolutions,项目名称:cart-magento2,代码行数:13,代码来源:CustomConfigProvider.php

示例15: setUp

 public function setUp()
 {
     $this->request = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->getMock();
     $this->response = $this->getMock('Magento\\Framework\\App\\ResponseInterface', [], [], '', false);
     $this->redirect = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->setMethods(['setRefererOrBaseUrl'])->disableOriginalConstructor()->getMock();
     $this->redirectFactory = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\RedirectFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->redirectFactory->expects($this->any())->method('create')->willReturn($this->redirect);
     $this->context = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getResultRedirectFactory')->willReturn($this->redirectFactory);
     $this->action = $this->getMockForAbstractClass('Magento\\Framework\\App\\Action\\AbstractAction', [$this->context]);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:11,代码来源:AbstractActionTest.php


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