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


PHP Result\Redirect类代码示例

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


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


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