Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use page result instead of rendering layout directly in controllers #8419

Merged
merged 2 commits into from
Feb 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/code/Magento/Backup/Controller/Adminhtml/Index/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
*/
namespace Magento\Backup\Controller\Adminhtml\Index;

use Magento\Framework\Controller\ResultFactory;

class Grid extends \Magento\Backup\Controller\Adminhtml\Index
{
/**
* Backup list action
*
* @return void
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$this->_view->loadLayout();
$this->_view->renderLayout();
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
}
}
7 changes: 4 additions & 3 deletions app/code/Magento/CatalogSearch/Controller/Advanced/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
*/
namespace Magento\CatalogSearch\Controller\Advanced;

use Magento\Framework\Controller\ResultFactory;

class Index extends \Magento\Framework\App\Action\Action
{
/**
* @return void
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$this->_view->loadLayout();
$this->_view->renderLayout();
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
}
}
7 changes: 4 additions & 3 deletions app/code/Magento/Contact/Controller/Index/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
*/
namespace Magento\Contact\Controller\Index;

use Magento\Framework\Controller\ResultFactory;

class Index extends \Magento\Contact\Controller\Index
{
/**
* Show Contact Us page
*
* @return void
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$this->_view->loadLayout();
$this->_view->renderLayout();
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
}
}
27 changes: 15 additions & 12 deletions app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace Magento\Contact\Test\Unit\Controller\Index;

use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Controller\ResultInterface;

class IndexTest extends \PHPUnit_Framework_TestCase
{
/**
Expand All @@ -25,7 +28,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase
* View mock
* @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $_view;
protected $resultFactory;

/**
* Url mock
Expand All @@ -43,7 +46,7 @@ protected function setUp()
);
$context = $this->getMock(
\Magento\Framework\App\Action\Context::class,
['getRequest', 'getResponse', 'getView', 'getUrl'],
['getRequest', 'getResponse', 'getResultFactory', 'getUrl'],
[],
'',
false
Expand All @@ -67,17 +70,17 @@ protected function setUp()
$this->getMockForAbstractClass(\Magento\Framework\App\ResponseInterface::class, [], '', false)
));

$this->_view = $this->getMock(
\Magento\Framework\App\ViewInterface::class,
$this->resultFactory = $this->getMock(
ResultFactory::class,
[],
[],
'',
false
);

$context->expects($this->once())
->method('getView')
->will($this->returnValue($this->_view));
->method('getResultFactory')
->will($this->returnValue($this->resultFactory));

$this->_controller = new \Magento\Contact\Controller\Index\Index(
$context,
Expand All @@ -90,12 +93,12 @@ protected function setUp()

public function testExecute()
{
$this->_view->expects($this->once())
->method('loadLayout');

$this->_view->expects($this->once())
->method('renderLayout');
$resultStub = $this->getMockForAbstractClass(ResultInterface::class);
$this->resultFactory->expects($this->once())
->method('create')
->with(ResultFactory::TYPE_PAGE)
->willReturn($resultStub);

$this->_controller->execute();
$this->assertSame($resultStub, $this->_controller->execute());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
*/
namespace Magento\User\Controller\Adminhtml\User\Role;

use Magento\Framework\Controller\ResultFactory;

class Editrolegrid extends \Magento\User\Controller\Adminhtml\User\Role
{
/**
* Action for ajax request from assigned users grid
*
* @return void
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$this->_view->loadLayout();
$this->_view->renderLayout();
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
}
}