當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Controller\ResultFactory類代碼示例

本文整理匯總了PHP中Magento\Framework\Controller\ResultFactory的典型用法代碼示例。如果您正苦於以下問題:PHP ResultFactory類的具體用法?PHP ResultFactory怎麽用?PHP ResultFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ResultFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

示例2: setUp

    protected function setUp()
    {
        $this->context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false);
        $this->wishlistProvider = $this->getMock('Magento\Wishlist\Controller\WishlistProvider', [], [], '', false);
        $this->itemCarrier = $this->getMock('Magento\Wishlist\Model\ItemCarrier', [], [], '', false);
        $this->formKeyValidator = $this->getMock('Magento\Framework\Data\Form\FormKey\Validator', [], [], '', false);
        $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false);
        $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false);
        $this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultRedirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultForwardMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Forward')
            ->disableOriginalConstructor()
            ->getMock();

        $this->resultFactoryMock->expects($this->any())
            ->method('create')
            ->willReturnMap(
                [
                    [ResultFactory::TYPE_REDIRECT, [], $this->resultRedirectMock],
                    [ResultFactory::TYPE_FORWARD, [], $this->resultForwardMock]
                ]
            );
    }
開發者ID:nblair,項目名稱:magescotch,代碼行數:27,代碼來源:AllcartTest.php

示例3: setUp

    protected function setUp()
    {
        $this->context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false);
        $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false);
        $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false);
        $this->wishlistProvider = $this->getMock('Magento\Wishlist\Controller\WishlistProvider', [], [], '', false);
        $this->redirect = $this->getMock('\Magento\Store\App\Response\Redirect', [], [], '', false);
        $this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page')
            ->disableOriginalConstructor()
            ->getMock();
        $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout')
            ->disableOriginalConstructor()
            ->getMock();

        $this->resultFactoryMock->expects($this->any())
            ->method('create')
            ->with(ResultFactory::TYPE_PAGE, [])
            ->willReturn($this->resultPageMock);
        $this->resultPageMock->expects($this->any())
            ->method('getLayout')
            ->willReturn($this->layoutMock);
    }
開發者ID:nblair,項目名稱:magescotch,代碼行數:25,代碼來源:IndexTest.php

示例4: testExecute

 public function testExecute()
 {
     $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()->setMethods(['_wakeup', 'getId'])->getMock();
     $this->productBuilder->expects($this->once())->method('build')->with($this->request)->willReturn($product);
     $resultLayout = $this->getMock(\Magento\Framework\View\Result\Layout::class, [], [], '', false);
     $this->resultFactory->expects($this->once())->method('create')->with(ResultFactory::TYPE_LAYOUT)->willReturn($resultLayout);
     $this->assertInstanceOf(\Magento\Framework\View\Result\Layout::class, $this->controller->execute());
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:8,代碼來源:AddAttributeTest.php

示例5: testExecute

 public function testExecute()
 {
     $_FILES['test_key'] = [];
     $result = ['file' => '', 'url' => ''];
     $resultJson = '{"file": "", "url": ""}';
     $this->imageProcessor->expects($this->once())->method('saveToTmp')->with('test_key')->willReturn($result);
     $this->resultFactory->expects($this->once())->method('create')->with(ResultFactory::TYPE_JSON)->willReturn($this->resultPage);
     $this->resultPage->expects($this->once())->method('setData')->with($result)->willReturn($resultJson);
     $this->assertEquals($resultJson, $this->controller->execute());
 }
開發者ID:BlackIkeEagle,項目名稱:magento2-continuousphp,代碼行數:10,代碼來源:SaveTest.php

示例6: execute

 /**
  * @return \Magento\Backend\Model\View\Result\Page
  */
 public function execute()
 {
     if ($this->initModel()) {
         /* @var \Magento\Backend\Model\View\Result\Page $resultPage */
         $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
         return $resultPage;
     } else {
         $this->_forward('no_route');
     }
 }
開發者ID:mirasvit,項目名稱:module-blog,代碼行數:13,代碼來源:View.php

示例7: setUp

 public function setUp()
 {
     $this->context = $this->getMock('Magento\\Framework\\App\\Action\\Context', [], [], '', false);
     $this->wishlistProvider = $this->getMock('Magento\\Wishlist\\Controller\\WishlistProvider', ['getWishlist'], [], '', false);
     $this->customerSession = $this->getMock('Magento\\Customer\\Model\\Session', ['getBeforeWishlistRequest', 'unsBeforeWishlistRequest', 'getBeforeWishlistUrl', 'setAddActionReferer', 'setBeforeWishlistUrl'], [], '', false);
     $this->productRepository = $this->getMock('\\Magento\\Catalog\\Model\\ProductRepository', [], [], '', false);
     $this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultFactoryMock->expects($this->any())->method('create')->with(ResultFactory::TYPE_REDIRECT, [])->willReturn($this->resultRedirectMock);
 }
開發者ID:opexsw,項目名稱:magento2,代碼行數:10,代碼來源:AddTest.php

示例8: setUp

    protected function setUp()
    {
        $this->autocomplete = $this->getMockBuilder('Magento\Search\Model\AutocompleteInterface')
            ->disableOriginalConstructor()
            ->setMethods(['getItems'])
            ->getMockForAbstractClass();
        $this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface')
            ->disableOriginalConstructor()
            ->setMethods([])
            ->getMockForAbstractClass();
        $this->url = $this->getMockBuilder('Magento\Framework\UrlInterface')
            ->disableOriginalConstructor()
            ->setMethods(['getBaseUrl'])
            ->getMockForAbstractClass();
        $this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
            ->disableOriginalConstructor()
            ->getMock();

        $this->context = $this->getMockBuilder('Magento\Framework\App\Action\Context')
            ->disableOriginalConstructor()
            ->getMock();
        $this->context->expects($this->atLeastOnce())
            ->method('getRequest')
            ->will($this->returnValue($this->request));
        $this->context->expects($this->any())
            ->method('getUrl')
            ->will($this->returnValue($this->url));
        $this->context->expects($this->any())
            ->method('getResultFactory')
            ->willReturn($this->resultFactoryMock);
        $this->resultFactoryMock->expects($this->any())
            ->method('create')
            ->willReturnMap(
                [
                    [ResultFactory::TYPE_REDIRECT, [], $this->resultRedirectMock],
                    [ResultFactory::TYPE_JSON, [], $this->resultJsonMock]
                ]
            );

        $this->objectManagerHelper = new ObjectManagerHelper($this);
        $this->controller = $this->objectManagerHelper->getObject(
            'Magento\Search\Controller\Ajax\Suggest',
            [
                'context' => $this->context,
                'autocomplete' => $this->autocomplete
            ]
        );
    }
開發者ID:nblair,項目名稱:magescotch,代碼行數:54,代碼來源:SuggestTest.php

示例9: setUp

 protected function setUp()
 {
     $this->request = $this->getMock('Magento\\Framework\\App\\RequestInterface', [], [], '', false);
     $this->factory = $this->getMock('Magento\\Catalog\\Model\\ProductFactory', ['create'], [], '', false);
     $this->registry = $this->getMock('Magento\\Framework\\Registry', [], [], '', false);
     $this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $this->resultLayoutMock = $this->getMockBuilder('Magento\\Framework\\View\\Result\\Layout')->disableOriginalConstructor()->getMock();
     $this->resultFactoryMock->expects($this->any())->method('create')->with(ResultFactory::TYPE_LAYOUT, [])->willReturn($this->resultLayoutMock);
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->context = $this->objectManager->getObject('Magento\\Backend\\App\\Action\\Context', ['request' => $this->request, 'resultFactory' => $this->resultFactoryMock]);
     $this->action = $this->objectManager->getObject('Magento\\GroupedProduct\\Controller\\Adminhtml\\Edit\\Popup', ['context' => $this->context, 'factory' => $this->factory, 'registry' => $this->registry]);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:12,代碼來源:PopupTest.php

示例10: setUp

 protected function setUp()
 {
     $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->messageManagerMock = $this->getMock('Magento\\Framework\\Message\\ManagerInterface', [], [], '', false);
     $this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultFactoryMock->expects($this->any())->method('create')->with(ResultFactory::TYPE_REDIRECT, [])->willReturn($this->resultRedirectMock);
     $this->contextMock = $this->getMock('\\Magento\\Backend\\App\\Action\\Context', [], [], '', false);
     $this->filterMock = $this->getMockBuilder('Magento\\Ui\\Component\\MassAction\\Filter')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock);
     $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactoryMock);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:12,代碼來源:AbstractMassActionTest.php

示例11: setUp

 protected function setUp()
 {
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getPostValue'])->getMockForAbstractClass();
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Backend\\Model\\View\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMockBuilder('Magento\\Framework\\ObjectManagerInterface')->getMock();
     $this->messageManagerMock = $this->getMockBuilder('Magento\\Framework\\Message\\ManagerInterface')->getMock();
     $this->resultFactoryMock->expects($this->once())->method('create')->with(ResultFactory::TYPE_REDIRECT)->willReturn($this->resultRedirectMock);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->context = $this->objectManagerHelper->getObject('Magento\\Backend\\App\\Action\\Context', ['resultFactory' => $this->resultFactoryMock, 'request' => $this->requestMock, 'messageManager' => $this->messageManagerMock, 'objectManager' => $this->objectManagerMock]);
     $this->saveController = $this->objectManagerHelper->getObject('Magento\\Sitemap\\Controller\\Adminhtml\\Sitemap\\Save', ['context' => $this->context]);
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:12,代碼來源:SaveTest.php

示例12: setUp

    protected function setUp()
    {
        $this->request = $this->getMockBuilder('\Magento\Framework\App\RequestInterface')
            ->disableOriginalConstructor()
            ->setMethods([])
            ->getMockForAbstractClass();
        $this->objectManager = $this->getMockBuilder('\Magento\Framework\ObjectManagerInterface')
            ->disableOriginalConstructor()
            ->setMethods(['create'])
            ->getMockForAbstractClass();
        $this->messageManager = $this->getMockBuilder('\Magento\Framework\Message\ManagerInterface')
            ->disableOriginalConstructor()
            ->setMethods(['addSuccess', 'addError'])
            ->getMockForAbstractClass();
        $this->pageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory')
            ->setMethods([])
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory')
            ->disableOriginalConstructor()
            ->getMock();
        $this->resultFactoryMock->expects($this->any())
            ->method('create')
            ->with(ResultFactory::TYPE_REDIRECT, [])
            ->willReturn($this->resultRedirectMock);
        $this->context = $this->getMockBuilder('Magento\Backend\App\Action\Context')
            ->disableOriginalConstructor()
            ->getMock();
        $this->context->expects($this->atLeastOnce())
            ->method('getRequest')
            ->willReturn($this->request);
        $this->context->expects($this->any())
            ->method('getObjectManager')
            ->willReturn($this->objectManager);
        $this->context->expects($this->any())
            ->method('getMessageManager')
            ->willReturn($this->messageManager);
        $this->context->expects($this->any())
            ->method('getResultFactory')
            ->willReturn($this->resultFactoryMock);

        $this->objectManagerHelper = new ObjectManagerHelper($this);
        $this->controller = $this->objectManagerHelper->getObject(
            'Magento\Search\Controller\Adminhtml\Term\MassDelete',
            [
                'context' => $this->context,
                'resultPageFactory' => $this->pageFactory,
            ]
        );
    }
開發者ID:nblair,項目名稱:magescotch,代碼行數:53,代碼來源:MassDeleteTest.php

示例13: setUp

 /**
  * Set up
  */
 protected function setUp()
 {
     $this->resultPage = $this->getMock('Magento\\Backend\\Model\\View\\Result\\Page', ['setActiveMenu', 'getConfig', 'getTitle', 'prepend', 'addBreadcrumb'], [], '', false);
     $this->resultPage->expects($this->any())->method('getConfig')->willReturnSelf();
     $this->resultPage->expects($this->any())->method('getTitle')->willReturnSelf();
     $this->resultFactory = $this->getMock('Magento\\Framework\\Controller\\ResultFactory', ['create'], [], '', false);
     $this->resultFactory->expects($this->any())->method('create')->willReturn($this->resultPage);
     $this->context = $this->getMock('Magento\\Backend\\App\\Action\\Context', ['getResultFactory'], [], '', false);
     $this->context->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactory);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->indexController = $this->objectManagerHelper->getObject('Magento\\ImportExport\\Controller\\Adminhtml\\History\\Index', ['context' => $this->context]);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:15,代碼來源:IndexTest.php

示例14: setUp

 protected function setUp()
 {
     $this->context = $this->getMock('Magento\\Framework\\App\\Action\\Context', [], [], '', false);
     $this->request = $this->getMock('Magento\\Framework\\App\\Request\\Http', [], [], '', false);
     $this->wishlistProvider = $this->getMock('Magento\\Wishlist\\Controller\\WishlistProvider', [], [], '', false);
     $this->redirect = $this->getMock('\\Magento\\Store\\App\\Response\\Redirect', [], [], '', false);
     $this->om = $this->getMock('Magento\\Framework\\App\\ObjectManager', [], [], '', false);
     $this->messageManager = $this->getMock('Magento\\Framework\\Message\\Manager', [], [], '', false);
     $this->url = $this->getMock('Magento\\Framework\\Url', [], [], '', false);
     $this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultFactoryMock->expects($this->any())->method('create')->with(ResultFactory::TYPE_REDIRECT, [])->willReturn($this->resultRedirectMock);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:13,代碼來源:RemoveTest.php

示例15: setUp

 protected function setUp()
 {
     $this->wishlistProviderMock = $this->getMockBuilder('Magento\\Wishlist\\Controller\\Shared\\WishlistProvider')->disableOriginalConstructor()->getMock();
     $this->itemCarrierMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\ItemCarrier')->disableOriginalConstructor()->getMock();
     $this->wishlistMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Wishlist')->disableOriginalConstructor()->getMock();
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultForwardMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Forward')->disableOriginalConstructor()->getMock();
     $this->resultFactoryMock->expects($this->any())->method('create')->willReturnMap([[ResultFactory::TYPE_REDIRECT, [], $this->resultRedirectMock], [ResultFactory::TYPE_FORWARD, [], $this->resultForwardMock]]);
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->context = $this->objectManagerHelper->getObject('Magento\\Framework\\App\\Action\\Context', ['request' => $this->requestMock, 'resultFactory' => $this->resultFactoryMock]);
     $this->allcartController = $this->objectManagerHelper->getObject('Magento\\Wishlist\\Controller\\Shared\\Allcart', ['context' => $this->context, 'wishlistProvider' => $this->wishlistProviderMock, 'itemCarrier' => $this->itemCarrierMock]);
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:14,代碼來源:AllcartTest.php


注:本文中的Magento\Framework\Controller\ResultFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。