Skip to content

Commit

Permalink
MAGETWO-67634: Product Wizard: Use result type Layout instead of page…
Browse files Browse the repository at this point in the history
… layout #9129
  • Loading branch information
Oleksii Korshenko authored Apr 21, 2017
2 parents c2af247 + 1fe6b0b commit e9e96c3
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ public function execute()
$this->productBuilder->build($this->getRequest());

/** @var \Magento\Framework\View\Result\Layout $resultLayout */
$resultLayout = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultLayout->getLayout()->getUpdate()->removeHandle('default');

$resultLayout = $this->resultFactory->create(ResultFactory::TYPE_LAYOUT);
return $resultLayout;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\ConfigurableProduct\Test\Unit\Controller\Adminhtml\Product;

use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;

class WizardTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $resultFactory;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $productBuilder;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $request;

/**
* @var \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Wizard
*/
private $model;

protected function setUp()
{
$this->resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class)
->disableOriginalConstructor()
->getMock();
$this->productBuilder = $this->getMockBuilder(\Magento\Catalog\Controller\Adminhtml\Product\Builder::class)
->disableOriginalConstructor()
->setMethods(['build'])
->getMock();
$this->request = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
->disableOriginalConstructor()
->getMock();
$context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class)
->disableOriginalConstructor()
->getMock();

$context->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactory);
$context->expects($this->any())->method('getRequest')->willReturn($this->request);

$objectManagerHelper = new ObjectManagerHelper($this);
$this->model = $objectManagerHelper->getObject(
\Magento\ConfigurableProduct\Controller\Adminhtml\Product\Wizard::class,
[
'context' => $context,
'productBuilder' => $this->productBuilder
]
);
}

public function testExecute()
{
$this->productBuilder->expects($this->once())->method('build')->with($this->request);
$this->resultFactory->expects($this->once())->method('create')->with(ResultFactory::TYPE_LAYOUT);

$this->model->execute();
}
}

0 comments on commit e9e96c3

Please sign in to comment.