• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Controller\ResultFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了ResultFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: getRedirect

 /**
  * Retrieve redirect
  *
  * @return ResultRedirect|ResultForward
  */
 public function getRedirect()
 {
     $this->updateLastCustomerId();
     $this->prepareRedirectUrl();
     /** @var ResultRedirect|ResultForward $result */
     if ($this->session->getBeforeRequestParams()) {
         $result = $this->resultFactory->create(ResultFactory::TYPE_FORWARD);
         $result->setParams($this->session->getBeforeRequestParams())->setModule($this->session->getBeforeModuleName())->setController($this->session->getBeforeControllerName())->forward($this->session->getBeforeAction());
     } else {
         $result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
         $result->setUrl($this->session->getBeforeAuthUrl(true));
     }
     return $result;
 }
开发者ID:Zash22,项目名称:magento,代码行数:19,代码来源:Redirect.php


示例17: _prepareMockObjects

 /**
  * Get mock objects for SetUp()
  */
 protected function _prepareMockObjects()
 {
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\Request\\Http')->disableOriginalConstructor()->getMock();
     $this->objectManagerMock = $this->getMock('Magento\\Framework\\ObjectManagerInterface');
     $this->storeManagerMock = $this->getMockForAbstractClass('Magento\\Store\\Model\\StoreManagerInterface');
     $this->storeModelMock = $this->getMock('Magento\\Store\\Model\\Store', ['__wakeup', 'getId'], [], '', false);
     $this->reviewMock = $this->getMock('Magento\\Review\\Model\\Review', ['__wakeup', 'create', 'save', 'getId', 'getResource', 'aggregate'], [], '', false);
     $this->reviewFactoryMock = $this->getMock('Magento\\Review\\Model\\ReviewFactory', ['create'], [], '', false);
     $this->ratingMock = $this->getMock('Magento\\Review\\Model\\Rating', ['__wakeup', 'setRatingId', 'setReviewId', 'addOptionVote'], [], '', false);
     $this->ratingFactoryMock = $this->getMock('Magento\\Review\\Model\\RatingFactory', ['create'], [], '', 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);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:17,代码来源:PostTest.php


示例18: setUp

    public function setUp()
    {
        $this->mediaGallery = [
            'image' => '/m/a/magento.png',
            'small_image' => '/m/a/magento.png',
            'thumbnail' => '/m/a/magento.png',
            'swatch_image' => '/m/a/magento.png',
        ];

        $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);

        $this->swatchHelperMock = $this->getMock('\Magento\Swatches\Helper\Data', [], [], '', false);
        $this->productModelFactoryMock = $this->getMock(
            '\Magento\Catalog\Model\ProductFactory',
            ['create'],
            [],
            '',
            false
        );
        $this->productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false);
        $this->attributeMock = $this->getMock('\Magento\Catalog\Model\ResourceModel\Eav\Attribute', [], [], '', false);
        $this->contextMock = $this->getMock('\Magento\Framework\App\Action\Context', [], [], '', false);

        $this->requestMock = $this->getMock('\Magento\Framework\App\Request', ['getParam'], [], '', false);
        $this->requestMock->expects($this->any())->method('getParam')->withConsecutive(
            ['product_id'],
            ['attributes'],
            ['additional']
        )->willReturnOnConsecutiveCalls(
            59,
            ['size' => 454],
            ['color' => 43]
        );
        $this->contextMock->method('getRequest')->willReturn($this->requestMock);
        $this->resultFactory = $this->getMock('\Magento\Framework\Controller\ResultFactory', ['create'], [], '', false);
        $this->contextMock->method('getResultFactory')->willReturn($this->resultFactory);

        $this->jsonMock = $this->getMock('\Magento\Framework\Controller\Result\Json', [], [], '', false);
        $this->resultFactory->expects($this->once())->method('create')->with('json')->willReturn($this->jsonMock);

        $this->controller = $this->objectManager->getObject(
            '\Magento\Swatches\Controller\Ajax\Media',
            [
                'context' => $this->contextMock,
                'swatchHelper' => $this->swatchHelperMock,
                'productModelFactory' => $this->productModelFactoryMock
            ]
        );
    }
开发者ID:nblair,项目名称:magescotch,代码行数:49,代码来源:MediaTest.php


示例19: setUp

 /**
  * SetUp method
  *
  * @return void
  */
 protected function setUp()
 {
     $this->productRepository = $this->getMock('Magento\\Catalog\\Model\\ProductRepository', [], [], '', false);
     $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->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->customerSession = $this->getMock('Magento\\Customer\\Model\\Session', [], [], '', false);
     $this->eventManager = $this->getMock('Magento\\Framework\\Event\\Manager', [], [], '', 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);
     $this->formKeyValidator = $this->getMockBuilder('Magento\\Framework\\Data\\Form\\FormKey\\Validator')->disableOriginalConstructor()->getMock();
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:21,代码来源:UpdateItemOptionsTest.php


示例20: setUp

 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->wishlistProviderMock = $this->getMockBuilder('Magento\\Wishlist\\Controller\\WishlistProviderInterface')->disableOriginalConstructor()->setMethods(['getWishlist'])->getMockForAbstractClass();
     $this->quantityProcessorMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\LocaleQuantityProcessor')->disableOriginalConstructor()->getMock();
     $this->itemFactoryMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\ItemFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->checkoutCartMock = $this->getMockBuilder('Magento\\Checkout\\Model\\Cart')->disableOriginalConstructor()->setMethods(['save', 'getQuote', 'getShouldRedirectToCart', 'getCartUrl'])->getMock();
     $this->optionFactoryMock = $this->getMockBuilder('Magento\\Wishlist\\Model\\Item\\OptionFactory')->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->productHelperMock = $this->getMockBuilder('Magento\\Catalog\\Helper\\Product')->disableOriginalConstructor()->getMock();
     $this->escaperMock = $this->getMockBuilder('Magento\\Framework\\Escaper')->disableOriginalConstructor()->getMock();
     $this->helperMock = $this->getMockBuilder('Magento\\Wishlist\\Helper\\Data')->disableOriginalConstructor()->getMock();
     $this->requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getParams', 'getParam', 'isAjax'])->getMockForAbstractClass();
     $this->redirectMock = $this->getMockBuilder('Magento\\Framework\\App\\Response\\RedirectInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->objectManagerMock = $this->getMockBuilder('Magento\\Framework\\ObjectManagerInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->messageManagerMock = $this->getMockBuilder('Magento\\Framework\\Message\\ManagerInterface')->disableOriginalConstructor()->setMethods(['addSuccess'])->getMockForAbstractClass();
     $this->urlMock = $this->getMockBuilder('Magento\\Framework\\UrlInterface')->disableOriginalConstructor()->setMethods(['getUrl'])->getMockForAbstractClass();
     $this->cartHelperMock = $this->getMockBuilder('Magento\\Checkout\\Helper\\Cart')->disableOriginalConstructor()->getMock();
     $this->resultFactoryMock = $this->getMockBuilder('Magento\\Framework\\Controller\\ResultFactory')->disableOriginalConstructor()->getMock();
     $this->resultRedirectMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock();
     $this->resultJsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $this->contextMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\Context')->disableOriginalConstructor()->getMock();
     $this->contextMock->expects($this->any())->method('getRequest')->will($this->returnValue($this->requestMock));
     $this->contextMock->expects($this->any())->method('getRedirect')->will($this->returnValue($this->redirectMock));
     $this->contextMock->expects($this->any())->method('getObjectManager')->will($this->returnValue($this->objectManagerMock));
     $this->contextMock->expects($this->any())->method('getMessageManager')->will($this->returnValue($this->messageManagerMock));
     $this->contextMock->expects($this->any())->method('getUrl')->willReturn($this->urlMock);
     $this->contextMock->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->model = new Cart($this->contextMock, $this->wishlistProviderMock, $this->quantityProcessorMock, $this->itemFactoryMock, $this->checkoutCartMock, $this->optionFactoryMock, $this->productHelperMock, $this->escaperMock, $this->helperMock, $this->cartHelperMock);
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:32,代码来源:CartTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Result\JsonFactory类代码示例发布时间:2022-05-23
下一篇:
PHP Reader\Filesystem类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap