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

PHP Result\Redirect类代码示例

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

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



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

示例1: testTryToSaveInvalidDataShouldFailWithErrors

 public function testTryToSaveInvalidDataShouldFailWithErrors()
 {
     $validatorClass = 'Magento\\MediaStorage\\Model\\File\\Validator\\AvailablePath';
     $helperClass = 'Magento\\Sitemap\\Helper\\Data';
     $validPaths = [];
     $messages = ['message1', 'message2'];
     $sessionClass = 'Magento\\Backend\\Model\\Session';
     $data = ['sitemap_filename' => 'sitemap_filename', 'sitemap_path' => '/sitemap_path'];
     $siteMapId = 1;
     $this->requestMock->expects($this->once())->method('getPostValue')->willReturn($data);
     $this->requestMock->expects($this->once())->method('getParam')->with('sitemap_id')->willReturn($siteMapId);
     $validator = $this->getMock($validatorClass, [], [], '', false);
     $validator->expects($this->once())->method('setPaths')->with($validPaths)->willReturnSelf();
     $validator->expects($this->once())->method('isValid')->with('/sitemap_path/sitemap_filename')->willReturn(false);
     $validator->expects($this->once())->method('getMessages')->willReturn($messages);
     $helper = $this->getMock($helperClass, [], [], '', false);
     $helper->expects($this->once())->method('getValidPaths')->willReturn($validPaths);
     $session = $this->getMock($sessionClass, ['setFormData'], [], '', false);
     $session->expects($this->once())->method('setFormData')->with($data)->willReturnSelf();
     $this->objectManagerMock->expects($this->once())->method('create')->with($validatorClass)->willReturn($validator);
     $this->objectManagerMock->expects($this->any())->method('get')->willReturnMap([[$helperClass, $helper], [$sessionClass, $session]]);
     $this->messageManagerMock->expects($this->at(0))->method('addError')->withConsecutive([$messages[0]], [$messages[1]])->willReturnSelf();
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('adminhtml/*/edit', ['sitemap_id' => $siteMapId])->willReturnSelf();
     $this->assertSame($this->resultRedirectMock, $this->saveController->execute());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:SaveTest.php


示例2: testExecuteNotPost

 public function testExecuteNotPost()
 {
     $this->validatorMock->expects($this->once())->method('validate')->willReturn(false);
     $this->request->expects($this->once())->method('isPost')->willReturn(false);
     $this->messageManager->expects($this->once())->method('addError')->with('You have not canceled the item.');
     $this->resultRedirect->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf();
     $this->assertEquals($this->resultRedirect, $this->controller->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:8,代码来源:CancelTest.php


示例3: testDeleteActionNoId

 public function testDeleteActionNoId()
 {
     $this->requestMock->expects($this->once())->method('getParam')->willReturn(null);
     $this->messageManagerMock->expects($this->once())->method('addError')->with(__('We can\'t find a synonym group to delete.'));
     $this->messageManagerMock->expects($this->never())->method('addSuccess');
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('*/*/')->willReturnSelf();
     $this->assertSame($this->resultRedirectMock, $this->deleteController->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:8,代码来源:DeleteTest.php


示例4: testExecute

 public function testExecute()
 {
     $path = '*/*';
     $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
     $this->messageManager->expects($this->once())->method('addSuccess')->with(__('We updated lifetime statistic.'));
     $this->objectManager->expects($this->any())->method('create')->with('Magento\\Sales\\Model\\Resource\\Report\\Order')->willReturn($this->order);
     $this->resultRedirect->expects($this->once())->method('setPath')->with($path)->willReturnSelf();
     $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Redirect', $this->refreshStatisticsController->execute());
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:9,代码来源:RefreshStatisticsTest.php


示例5: testExecuteSetsProductDataToSessionAndRedirectsToNewActionOnError

 /**
  * @param string $exceptionType
  * @return void
  * @dataProvider exceptionTypeDataProvider
  */
 public function testExecuteSetsProductDataToSessionAndRedirectsToNewActionOnError($exceptionType)
 {
     $productData = ['product' => ['name' => 'test-name']];
     $this->request->expects($this->any())->method('getPostValue')->willReturn($productData);
     $this->initializationHelper->expects($this->any())->method('initialize')->willReturn($this->product);
     $this->product->expects($this->any())->method('getSku')->willThrowException(new $exceptionType(__('message')));
     $this->resultRedirect->expects($this->once())->method('setPath')->with('catalog/*/new');
     $this->action->execute();
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:14,代码来源:SaveTest.php


示例6: testExecuteEmptyQuery

 public function testExecuteEmptyQuery()
 {
     $url = 'some url';
     $searchString = '';
     $this->request->expects($this->once())->method('getParam')->with('q')->will($this->returnValue($searchString));
     $this->url->expects($this->once())->method('getBaseUrl')->willReturn($url);
     $this->resultRedirectMock->expects($this->once())->method('setUrl')->with($url)->willReturnSelf();
     $this->assertSame($this->resultRedirectMock, $this->controller->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:9,代码来源:SuggestTest.php


示例7: testExecute

 public function testExecute()
 {
     $ids = [1, 2];
     $this->request->expects($this->once())->method('getParam')->with('search')->will($this->returnValue($ids));
     $this->createQuery(0, 1);
     $this->createQuery(1, 2);
     $this->messageManager->expects($this->once())->method('addSuccess')->will($this->returnSelf());
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('search/*/')->willReturnSelf();
     $this->assertSame($this->resultRedirectMock, $this->controller->execute());
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:MassDeleteTest.php


示例8: testEditActionBlockNoExists

 public function testEditActionBlockNoExists()
 {
     $blockId = 1;
     $this->requestMock->expects($this->once())->method('getParam')->with('block_id')->willReturn($blockId);
     $this->blockMock->expects($this->once())->method('load')->with($blockId);
     $this->blockMock->expects($this->once())->method('getId')->willReturn(null);
     $this->messageManagerMock->expects($this->once())->method('addError')->with(__('This block no longer exists.'));
     $this->resultRedirectFactoryMock->expects($this->atLeastOnce())->method('create')->willReturn($this->resultRedirectMock);
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('*/*/')->willReturnSelf();
     $this->assertSame($this->resultRedirectMock, $this->editController->execute());
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:EditTest.php


示例9: testDelete

 public function testDelete()
 {
     $categoryId = 5;
     $parentId = 7;
     $this->request->expects($this->any())->method('getParam')->with('id')->willReturn($categoryId);
     $category = $this->getMock('Magento\\Catalog\\Model\\Category', ['getParentId', 'getPath'], [], '', false);
     $category->expects($this->once())->method('getParentId')->willReturn($parentId);
     $category->expects($this->once())->method('getPath')->willReturn('category-path');
     $this->categoryRepository->expects($this->once())->method('get')->with($categoryId)->willReturn($category);
     $this->authStorage->expects($this->once())->method('setDeletedPath')->with('category-path');
     $this->resultRedirect->expects($this->once())->method('setPath')->with('catalog/*/', ['_current' => true, 'id' => $parentId]);
     $this->unit->execute();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:DeleteTest.php


示例10: testDeleteActionThrowsException

 public function testDeleteActionThrowsException()
 {
     $errorMsg = 'Can\'t delete the page';
     $this->requestMock->expects($this->once())->method('getParam')->willReturn($this->pageId);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Cms\\Model\\Page')->willReturn($this->pageMock);
     $this->pageMock->expects($this->once())->method('load')->with($this->pageId);
     $this->pageMock->expects($this->once())->method('getTitle')->willReturn($this->title);
     $this->pageMock->expects($this->once())->method('delete')->willThrowException(new \Exception(__($errorMsg)));
     $this->eventManagerMock->expects($this->once())->method('dispatch')->with('adminhtml_cmspage_on_delete', ['title' => $this->title, 'status' => 'fail']);
     $this->messageManagerMock->expects($this->once())->method('addError')->with($errorMsg);
     $this->messageManagerMock->expects($this->never())->method('addSuccess');
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('*/*/edit', ['page_id' => $this->pageId])->willReturnSelf();
     $this->assertSame($this->resultRedirectMock, $this->deleteController->execute());
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:14,代码来源:DeleteTest.php


示例11: testExecute

    /**
     * @return void
     */
    public function testExecute()
    {
        $creditmemoId = '111';

        $this->requestMock->expects($this->once())
            ->method('getParam')
            ->with('creditmemo_id')
            ->willReturn($creditmemoId);
        $this->objectManagerMock->expects($this->once())
            ->method('create')
            ->with('Magento\Sales\Api\CreditmemoManagementInterface')
            ->willReturn($this->creditmemoManagementMock);
        $this->creditmemoManagementMock->expects($this->once())
            ->method('cancel')
            ->with($creditmemoId);
        $this->messageManagerMock->expects($this->once())
            ->method('addSuccess')
            ->with('The credit memo has been canceled.');
        $this->resultRedirectFactoryMock->expects($this->once())
            ->method('create')
            ->willReturn($this->resultRedirectMock);
        $this->resultRedirectMock->expects($this->once())
            ->method('setPath')
            ->with('sales/*/view', ['creditmemo_id' => $creditmemoId])
            ->willReturnSelf();

        $this->assertInstanceOf(
            'Magento\Backend\Model\View\Result\Redirect',
            $this->controller->executeInternal()
        );
    }
开发者ID:nblair,项目名称:magescotch,代码行数:34,代码来源:CancelTest.php


示例12: testEmailNoOrderId

    public function testEmailNoOrderId()
    {
        $this->request->expects($this->once())
            ->method('getParam')
            ->with('order_id')
            ->will($this->returnValue(null));
        $this->orderRepositoryMock->expects($this->once())
            ->method('get')
            ->with(null)
            ->willThrowException(
                new \Magento\Framework\Exception\NoSuchEntityException(__('Requested entity doesn\'t exist'))
            );
        $this->messageManager->expects($this->once())
            ->method('addError')
            ->with('This order no longer exists.');

        $this->actionFlag->expects($this->once())
            ->method('set')
            ->with('', 'no-dispatch', true)
            ->will($this->returnValue(true));
        $this->resultRedirect->expects($this->once())
            ->method('setPath')
            ->with('sales/*/')
            ->willReturnSelf();

        $this->assertInstanceOf(
            'Magento\Backend\Model\View\Result\Redirect',
            $this->orderEmail->executeInternal()
        );
    }
开发者ID:nblair,项目名称:magescotch,代码行数:30,代码来源:EmailTest.php


示例13: testExecuteUpdateAction

 public function testExecuteUpdateAction()
 {
     $orderId = 30;
     $action = 'update';
     $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->willReturn($orderId);
     $this->requestMock->expects($this->at(1))->method('getParam')->with('action')->willReturn($action);
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRedirectMock);
     $this->orderRepositoryMock->expects($this->once())->method('get')->with($orderId)->willReturn($this->orderMock);
     $this->orderMock->expects($this->any())->method('getEntityId')->willReturn($orderId);
     $this->orderMock->expects($this->any())->method('getPayment')->willReturn($this->paymentMock);
     $this->orderRepositoryMock->expects($this->once())->method('save')->with($this->orderMock)->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('update');
     $this->paymentMock->expects($this->any())->method('getIsTransactionApproved')->willReturn(true);
     $this->messageManagerMock->expects($this->once())->method('addSuccess');
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/order/view')->willReturnSelf();
     $result = $this->reviewPayment->execute();
     $this->assertEquals($this->resultRedirectMock, $result);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:ReviewPaymentTest.php


示例14: testExecute

 /**
  * @return void
  */
 public function testExecute()
 {
     $customerId = 1;
     $this->requestMock->expects($this->once())->method('getParam')->with($this->equalTo('customer_id'))->will($this->returnValue($customerId));
     $this->authenticationMock->expects($this->once())->method('unlock')->with($customerId);
     $this->messageManagerMock->expects($this->once())->method('addSuccess');
     $this->redirectMock->expects($this->once())->method('setPath')->with($this->equalTo('customer/index/edit'))->willReturnSelf();
     $this->assertInstanceOf('\\Magento\\Backend\\Model\\View\\Result\\Redirect', $this->controller->execute());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:UnlockTest.php


示例15: testExecute

 public function testExecute()
 {
     $customersIds = [10, 11, 12];
     $this->customerCollectionMock->expects($this->any())->method('getAllIds')->willReturn($customersIds);
     $this->customerRepositoryMock->expects($this->any())->method('deleteById')->willReturnMap([[10, true], [11, true], [12, true]]);
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with(__('A total of %1 record(s) were deleted.', count($customersIds)));
     $this->resultRedirectMock->expects($this->any())->method('setPath')->with('customer/*/index')->willReturnSelf();
     $this->massAction->execute();
 }
开发者ID:tingyeeh,项目名称:magento2,代码行数:9,代码来源:MassDeleteTest.php


示例16: testExecuteUpdateAction

 public function testExecuteUpdateAction()
 {
     $orderId = 30;
     $action = 'update';
     $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->willReturn($orderId);
     $this->requestMock->expects($this->at(1))->method('getParam')->with('action')->willReturn($action);
     $this->resultRedirectFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRedirectMock);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Sales\\Model\\Order')->willReturn($this->orderMock);
     $this->orderMock->expects($this->once())->method('load')->with($orderId)->willReturn($this->orderMock);
     $this->orderMock->expects($this->any())->method('getId')->willReturn($orderId);
     $this->orderMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock);
     $this->orderMock->expects($this->once())->method('save')->willReturnSelf();
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with('The payment update has been made.');
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('sales/*/')->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('update');
     $result = $this->reviewPayment->execute();
     $this->assertEquals($this->resultRedirectMock, $result);
 }
开发者ID:niranjanssiet,项目名称:magento2,代码行数:18,代码来源:ReviewPaymentTest.php


示例17: testDeleteActionThrowsException

 public function testDeleteActionThrowsException()
 {
     $errorMsg = 'Can\'t create the block';
     $this->requestMock->expects($this->once())->method('getParam')->willReturn($this->blockId);
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Cms\\Model\\Block')->willThrowException(new \Exception(__($errorMsg)));
     $this->messageManagerMock->expects($this->once())->method('addError')->with($errorMsg);
     $this->messageManagerMock->expects($this->never())->method('addSuccess');
     $this->resultRedirectMock->expects($this->once())->method('setPath')->with('*/*/edit', ['block_id' => $this->blockId])->willReturnSelf();
     $this->assertSame($this->resultRedirectMock, $this->deleteController->execute());
 }
开发者ID:kid17,项目名称:magento2,代码行数:10,代码来源:DeleteTest.php


示例18: prepareRedirect

 /**
  * @param int $cmId
  */
 protected function prepareRedirect($cmId)
 {
     $this->resultRedirectFactoryMock->expects($this->once())
         ->method('create')
         ->willReturn($this->resultRedirectMock);
     $this->resultRedirectMock->expects($this->once())
         ->method('setPath')
         ->with('sales/order_creditmemo/view', ['creditmemo_id' => $cmId])
         ->willReturnSelf();
 }
开发者ID:nblair,项目名称:magescotch,代码行数:13,代码来源:EmailTest.php


示例19: testExecute

 public function testExecute()
 {
     $customersIds = [10, 11, 12];
     $customerMock = $this->getMockBuilder('Magento\\Customer\\Api\\Data\\CustomerInterface')->getMockForAbstractClass();
     $this->customerCollectionMock->expects($this->any())->method('getAllIds')->willReturn($customersIds);
     $this->customerRepositoryMock->expects($this->any())->method('getById')->willReturnMap([[10, $customerMock], [11, $customerMock], [12, $customerMock]]);
     $this->messageManagerMock->expects($this->once())->method('addSuccess')->with(__('A total of %1 record(s) were updated.', count($customersIds)));
     $this->resultRedirectMock->expects($this->any())->method('setPath')->with('customer/*/index')->willReturnSelf();
     $this->massAction->execute();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:MassAssignGroupTest.php


示例20: testEmail

    public function testEmail()
    {
        $invoiceId = 10000031;
        $orderId = 100000030;
        $invoiceClassName = 'Magento\Sales\Model\Order\Invoice';
        $cmNotifierClassName = 'Magento\Sales\Api\InvoiceManagementInterface';
        $invoice = $this->getMock($invoiceClassName, [], [], '', false);
        $invoice->expects($this->once())
            ->method('getEntityId')
            ->willReturn($invoiceId);
        $order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false);
        $order->expects($this->once())
            ->method('getId')
            ->willReturn($orderId);

        $this->request->expects($this->once())
            ->method('getParam')
            ->with('invoice_id')
            ->willReturn($invoiceId);
        $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface')
            ->disableOriginalConstructor()
            ->getMock();
        $invoiceRepository->expects($this->any())
            ->method('get')
            ->willReturn($invoice);
        $this->objectManager->expects($this->at(0))
            ->method('create')
            ->with('Magento\Sales\Api\InvoiceRepositoryInterface')
            ->willReturn($invoiceRepository);

        $invoice->expects($this->once())
            ->method('getOrder')
            ->willReturn($order);
        $this->objectManager->expects($this->at(1))
            ->method('create')
            ->with($cmNotifierClassName)
            ->willReturn($this->invoiceManagement);

        $this->invoiceManagement->expects($this->once())
            ->method('notify')
            ->with($invoiceId)
            ->willReturn(true);
        $this->messageManager->expects($this->once())
            ->method('addSuccess')
            ->with('You sent the message.');

        $this->resultRedirectFactory->expects($this->atLeastOnce())
            ->method('create')
            ->willReturn($this->resultRedirect);
        $this->resultRedirect->expects($this->once())
            ->method('setPath')
            ->with('sales/invoice/view', ['order_id' => $orderId, 'invoice_id' => $invoiceId])
            ->willReturnSelf();
        $this->assertInstanceOf('Magento\Backend\Model\View\Result\Redirect', $this->invoiceEmail->executeInternal());
    }
开发者ID:nblair,项目名称:magescotch,代码行数:55,代码来源:EmailTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Result\RedirectFactory类代码示例发布时间:2022-05-23
下一篇:
PHP Result\ForwardFactory类代码示例发布时间: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