forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request magento#328 from magento-south/BUGS
[SOUTH] Bugs
- Loading branch information
Showing
75 changed files
with
3,154 additions
and
717 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ShowUpdateResultTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product; | ||
|
||
use Magento\Catalog\Controller\Adminhtml\Product\ShowUpdateResult; | ||
|
||
class ShowUpdateResultTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $context; | ||
|
||
/** @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $layout; | ||
|
||
/** @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $session; | ||
|
||
/** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $request; | ||
|
||
/** | ||
* Init session object | ||
* | ||
* @return \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected function getSession() | ||
{ | ||
$session = $this->getMock( | ||
'Magento\Backend\Model\Session', | ||
['hasCompositeProductResult', 'getCompositeProductResult', 'unsCompositeProductResult'], | ||
[], | ||
'', | ||
false | ||
); | ||
$session->expects($this->once()) | ||
->method('hasCompositeProductResult') | ||
->willReturn(true); | ||
$session->expects($this->once()) | ||
->method('unsCompositeProductResult'); | ||
$session->expects($this->atLeastOnce()) | ||
->method('getCompositeProductResult') | ||
->willReturn(new \Magento\Framework\Object()); | ||
|
||
return $session; | ||
} | ||
|
||
/** | ||
* Init context object | ||
* | ||
* @return \PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected function getContext() | ||
{ | ||
$productActionMock = $this->getMock('Magento\Catalog\Model\Product\Action', [], [], '', false); | ||
$objectManagerMock = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); | ||
$objectManagerMock->expects($this->any()) | ||
->method('get') | ||
->willreturn($productActionMock); | ||
|
||
$eventManager = $this->getMockForAbstractClass('Magento\Framework\Event\Manager', ['dispatch'], '', false); | ||
|
||
$eventManager->expects($this->any()) | ||
->method('dispatch') | ||
->willReturnSelf(); | ||
|
||
$this->request = $this->getMock( | ||
'Magento\Framework\App\Request\Http', | ||
['getParam', 'getPost', 'getFullActionName', 'getPostValue'], | ||
[], | ||
'', | ||
false | ||
); | ||
|
||
$responseInterfaceMock = $this->getMock( | ||
'Magento\Framework\App\ResponseInterface', | ||
['setRedirect', 'sendResponse'], | ||
[], | ||
'', | ||
false | ||
); | ||
|
||
$managerInterfaceMock = $this->getMock('Magento\Framework\Message\ManagerInterface'); | ||
$this->session = $this->getSession(); | ||
$actionFlagMock = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false); | ||
$helperDataMock = $this->getMock('Magento\Backend\Helper\Data', [], [], '', false); | ||
$this->context = $this->getMock( | ||
'Magento\Backend\App\Action\Context', | ||
[ | ||
'getRequest', | ||
'getResponse', | ||
'getObjectManager', | ||
'getEventManager', | ||
'getMessageManager', | ||
'getSession', | ||
'getActionFlag', | ||
'getHelper', | ||
'getTitle', | ||
'getView', | ||
'getResultRedirectFactory' | ||
], | ||
[], | ||
'', | ||
false | ||
); | ||
|
||
$this->context->expects($this->any()) | ||
->method('getEventManager') | ||
->willReturn($eventManager); | ||
$this->context->expects($this->any()) | ||
->method('getRequest') | ||
->willReturn($this->request); | ||
$this->context->expects($this->any()) | ||
->method('getResponse') | ||
->willReturn($responseInterfaceMock); | ||
$this->context->expects($this->any()) | ||
->method('getObjectManager') | ||
->willReturn($objectManagerMock); | ||
|
||
$this->context->expects($this->any()) | ||
->method('getMessageManager') | ||
->willReturn($managerInterfaceMock); | ||
$this->context->expects($this->any()) | ||
->method('getSession') | ||
->willReturn($this->session); | ||
$this->context->expects($this->any()) | ||
->method('getActionFlag') | ||
->willReturn($actionFlagMock); | ||
$this->context->expects($this->any()) | ||
->method('getHelper') | ||
->willReturn($helperDataMock); | ||
|
||
return $this->context; | ||
} | ||
|
||
public function testExecute() | ||
{ | ||
$productCompositeHelper = $this->getMock('Magento\Catalog\Helper\Product\Composite', [], [], '', false); | ||
$productCompositeHelper->expects($this->once()) | ||
->method('renderUpdateResult'); | ||
|
||
$productBuilder = $this->getMock('Magento\Catalog\Controller\Adminhtml\Product\Builder', [], [], '', false); | ||
$context = $this->getContext(); | ||
|
||
/** @var \Magento\Catalog\Controller\Adminhtml\Product\ShowUpdateResult $controller */ | ||
$controller = new ShowUpdateResult($context, $productBuilder, $productCompositeHelper); | ||
$controller->execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.