Skip to content

Commit a44395a

Browse files
author
Yurii Torbyk
committed
MAGETWO-33064: Implement obsolete test for refactored controllers
1 parent 18e1715 commit a44395a

File tree

3 files changed

+24
-6
lines changed
  • app/code/Magento
  • dev/tests/static/testsuite/Magento/Test/Legacy/_files/response/blacklist

3 files changed

+24
-6
lines changed

app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteStore.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public function execute()
1616
$itemId = $this->getRequest()->getParam('item_id', null);
1717
if (!($model = $this->_objectManager->create('Magento\Store\Model\Store')->load($itemId))) {
1818
$this->messageManager->addError(__('Unable to proceed. Please, try again.'));
19-
$this->_redirect('adminhtml/*/');
2019
/** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */
2120
$redirectResult = $this->resultRedirectFactory->create();
2221
return $redirectResult->setPath('adminhtml/*/');

app/code/Magento/Catalog/Controller/Category/View.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ class View extends \Magento\Framework\App\Action\Action
5252
*/
5353
protected $resultPageFactory;
5454

55+
/**
56+
* @var \Magento\Framework\Controller\Result\ForwardFactory
57+
*/
58+
protected $resultForwardFactory;
59+
60+
/**
61+
* @var \Magento\Framework\Controller\Result\RedirectFactory
62+
*/
63+
protected $resultRedirectFactory;
64+
5565
/**
5666
* Catalog Layer Resolver
5767
*
@@ -73,8 +83,10 @@ class View extends \Magento\Framework\App\Action\Action
7383
* @param \Magento\Framework\Registry $coreRegistry
7484
* @param \Magento\Framework\Store\StoreManagerInterface $storeManager
7585
* @param \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator
76-
* @param Resolver $layerResolver
7786
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
87+
* @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory
88+
* @param \Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory
89+
* @param Resolver $layerResolver
7890
* @param CategoryRepositoryInterface $categoryRepository
7991
*/
8092
public function __construct(
@@ -85,6 +97,8 @@ public function __construct(
8597
\Magento\Framework\Store\StoreManagerInterface $storeManager,
8698
\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator,
8799
PageFactory $resultPageFactory,
100+
\Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory,
101+
\Magento\Framework\Controller\Result\RedirectFactory $resultRedirectFactory,
88102
Resolver $layerResolver,
89103
CategoryRepositoryInterface $categoryRepository
90104
) {
@@ -95,6 +109,8 @@ public function __construct(
95109
$this->_coreRegistry = $coreRegistry;
96110
$this->categoryUrlPathGenerator = $categoryUrlPathGenerator;
97111
$this->resultPageFactory = $resultPageFactory;
112+
$this->resultForwardFactory = $resultForwardFactory;
113+
$this->resultRedirectFactory = $resultRedirectFactory;
98114
$this->layerResolver = $layerResolver;
99115
$this->categoryRepository = $categoryRepository;
100116
}
@@ -137,15 +153,14 @@ protected function _initCategory()
137153
/**
138154
* Category view action
139155
*
140-
* @return \Magento\Framework\View\Result\Page
156+
* @return \Magento\Framework\Controller\ResultInterface
141157
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
142158
* @SuppressWarnings(PHPMD.NPathComplexity)
143159
*/
144160
public function execute()
145161
{
146162
if ($this->_request->getParam(\Magento\Framework\App\Action\Action::PARAM_NAME_URL_ENCODED)) {
147-
$this->getResponse()->setRedirect($this->_redirect->getRedirectUrl());
148-
return;
163+
return $this->resultRedirectFactory->create()->setUrl($this->_redirect->getRedirectUrl());
149164
}
150165
$category = $this->_initCategory();
151166
if ($category) {
@@ -192,7 +207,7 @@ public function execute()
192207
$page->getLayout()->initMessages();
193208
return $page;
194209
} elseif (!$this->getResponse()->isRedirect()) {
195-
$this->_forward('noroute');
210+
return $this->resultForwardFactory->create()->forward('noroute');
196211
}
197212
}
198213
}

dev/tests/static/testsuite/Magento/Test/Legacy/_files/response/blacklist/files_list.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
*/
1212
return [
1313
'/app/code/Magento/Backend/Model/View.php',
14+
'/app/code/Magento/Backend/App/AbstractAction.php',
15+
'/app/code/Magento/Backend/App/Response/Http/FileFactory.php',
16+
'/app/code/Magento/Backend/Block/Widget.php',
17+
'/app/code/Magento/Backend/Block/System/Config/Dwstree.php',
1418
];

0 commit comments

Comments
 (0)