-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into MAGETWO-41755
- Loading branch information
Showing
21 changed files
with
932 additions
and
38 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
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
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
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
68 changes: 68 additions & 0 deletions
68
app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/AbstractMassActionTest.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,68 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Cms\Test\Unit\Controller\Adminhtml; | ||
|
||
use Magento\Framework\Controller\ResultFactory; | ||
|
||
abstract class AbstractMassActionTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager | ||
*/ | ||
protected $objectManager; | ||
|
||
/** | ||
* @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $contextMock; | ||
|
||
/** | ||
* @var \Magento\Framework\Controller\ResultFactory|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $resultFactoryMock; | ||
|
||
/** | ||
* @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $resultRedirectMock; | ||
|
||
/** | ||
* @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $messageManagerMock; | ||
|
||
/** | ||
* @var \Magento\Ui\Component\MassAction\Filter|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $filterMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
|
||
$this->messageManagerMock = $this->getMock('Magento\Framework\Message\ManagerInterface', [], [], '', false); | ||
|
||
$this->resultFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\ResultFactory') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->resultRedirectMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$this->resultFactoryMock->expects($this->any()) | ||
->method('create') | ||
->with(ResultFactory::TYPE_REDIRECT, []) | ||
->willReturn($this->resultRedirectMock); | ||
|
||
$this->contextMock = $this->getMock('\Magento\Backend\App\Action\Context', [], [], '', false); | ||
|
||
$this->filterMock = $this->getMockBuilder('Magento\Ui\Component\MassAction\Filter') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock); | ||
$this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactoryMock); | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/MassDeleteTest.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,97 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Cms\Test\Unit\Controller\Adminhtml\Block; | ||
|
||
use Magento\Cms\Test\Unit\Controller\Adminhtml\AbstractMassActionTest; | ||
|
||
class MassDeleteTest extends AbstractMassActionTest | ||
{ | ||
/** | ||
* @var \Magento\Cms\Controller\Adminhtml\Block\MassDelete | ||
*/ | ||
protected $massDeleteController; | ||
|
||
/** | ||
* @var \Magento\Cms\Model\Resource\Block\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $collectionFactoryMock; | ||
|
||
/** | ||
* @var \Magento\Cms\Model\Resource\Block\Collection|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $blockCollectionMock; | ||
|
||
protected function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->collectionFactoryMock = $this->getMock( | ||
'Magento\Cms\Model\Resource\Block\CollectionFactory', | ||
['create'], | ||
[], | ||
'', | ||
false | ||
); | ||
|
||
$this->blockCollectionMock = $this->getMock('Magento\Cms\Model\Resource\Block\Collection', [], [], '', false); | ||
|
||
$this->massDeleteController = $this->objectManager->getObject( | ||
'Magento\Cms\Controller\Adminhtml\Block\MassDelete', | ||
[ | ||
'context' => $this->contextMock, | ||
'filter' => $this->filterMock, | ||
'collectionFactory' => $this->collectionFactoryMock | ||
] | ||
); | ||
} | ||
|
||
public function testMassDeleteAction() | ||
{ | ||
$deletedBlocksCount = 2; | ||
|
||
$collection = [ | ||
$this->getBlockMock(), | ||
$this->getBlockMock() | ||
]; | ||
|
||
$this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($this->blockCollectionMock); | ||
|
||
$this->filterMock->expects($this->once()) | ||
->method('getCollection') | ||
->with($this->blockCollectionMock) | ||
->willReturn($this->blockCollectionMock); | ||
|
||
$this->blockCollectionMock->expects($this->once())->method('getSize')->willReturn($deletedBlocksCount); | ||
$this->blockCollectionMock->expects($this->once()) | ||
->method('getIterator') | ||
->willReturn(new \ArrayIterator($collection)); | ||
|
||
$this->messageManagerMock->expects($this->once()) | ||
->method('addSuccess') | ||
->with(__('A total of %1 record(s) have been deleted.', $deletedBlocksCount)); | ||
$this->messageManagerMock->expects($this->never())->method('addError'); | ||
|
||
$this->resultRedirectMock->expects($this->once()) | ||
->method('setPath') | ||
->with('*/*/') | ||
->willReturnSelf(); | ||
|
||
$this->assertSame($this->resultRedirectMock, $this->massDeleteController->execute()); | ||
} | ||
|
||
/** | ||
* Create Cms Block Collection Mock | ||
* | ||
* @return \Magento\Cms\Model\Resource\Block\Collection|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected function getBlockMock() | ||
{ | ||
$blockMock = $this->getMock('Magento\Cms\Model\Resource\Block\Collection', ['delete'], [], '', false); | ||
$blockMock->expects($this->once())->method('delete')->willReturn(true); | ||
|
||
return $blockMock; | ||
} | ||
} |
Oops, something went wrong.