-
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 pull request #463 from magento-south/BUGS
[South] Code coverage
- Loading branch information
Showing
5 changed files
with
334 additions
and
2 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
...ento/Theme/Test/Unit/Controller/Adminhtml/System/Design/Wysiwyg/Files/DeleteFilesTest.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,104 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Theme\Test\Unit\Controller\Adminhtml\System\Design\Wysiwyg\Files; | ||
|
||
class DeleteFilesTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var \Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files */ | ||
protected $controller; | ||
|
||
/** @var \PHPUnit_Framework_MockObject_MockObject|\PHPUnit_Framework_MockObject_MockObject*/ | ||
protected $objectManager; | ||
|
||
/** @var \Magento\Theme\Helper\Storage|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $storage; | ||
|
||
/** @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $request; | ||
|
||
/** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $response; | ||
|
||
public function setUp() | ||
{ | ||
$this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); | ||
$this->storage = $this->getMock('Magento\Theme\Model\Wysiwyg\Storage', [], [], '', false); | ||
$this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); | ||
$this->request = $this->getMockForAbstractClass( | ||
'Magento\Framework\App\RequestInterface', | ||
[], | ||
'', | ||
false, | ||
false, | ||
true, | ||
['isPost', 'getParam'] | ||
); | ||
|
||
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$this->controller = $helper->getObject( | ||
'Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files\DeleteFiles', | ||
[ | ||
'objectManager' => $this->objectManager, | ||
'request' => $this->request, | ||
'response' => $this->response, | ||
] | ||
); | ||
} | ||
|
||
public function testExecuteWithWrongRequest() | ||
{ | ||
$this->request->expects($this->once()) | ||
->method('isPost') | ||
->willReturn(false); | ||
|
||
$jsonData = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false); | ||
$jsonData->expects($this->once()) | ||
->method('jsonEncode') | ||
->with(['error' => true, 'message' => 'Wrong request']) | ||
->willReturn('{"error":"true","message":"Wrong request"}'); | ||
|
||
$this->objectManager->expects($this->once()) | ||
->method('get') | ||
->with('Magento\Framework\Json\Helper\Data') | ||
->willReturn($jsonData); | ||
|
||
$this->response->expects($this->once()) | ||
->method('representJson') | ||
->with('{"error":"true","message":"Wrong request"}'); | ||
|
||
$this->controller->execute(); | ||
} | ||
|
||
public function testExecute() | ||
{ | ||
$this->request->expects($this->once()) | ||
->method('isPost') | ||
->willReturn(true); | ||
$this->request->expects($this->once()) | ||
->method('getParam') | ||
->with('files') | ||
->willReturn('{"files":"file"}'); | ||
|
||
$jsonData = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false); | ||
$jsonData->expects($this->once()) | ||
->method('jsonDecode') | ||
->with('{"files":"file"}') | ||
->willReturn(['files' => 'file']); | ||
$this->objectManager->expects($this->at(0)) | ||
->method('get') | ||
->with('Magento\Framework\Json\Helper\Data') | ||
->willReturn($jsonData); | ||
$this->objectManager->expects($this->at(1)) | ||
->method('get') | ||
->with('Magento\Theme\Model\Wysiwyg\Storage') | ||
->willReturn($this->storage); | ||
$this->storage->expects($this->once()) | ||
->method('deleteFile') | ||
->with('file'); | ||
|
||
$this->controller->execute(); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...nto/Theme/Test/Unit/Controller/Adminhtml/System/Design/Wysiwyg/Files/DeleteFolderTest.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,71 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Theme\Test\Unit\Controller\Adminhtml\System\Design\Wysiwyg\Files; | ||
|
||
class DeleteFolderTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var \Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files */ | ||
protected $controller; | ||
|
||
/** @var \PHPUnit_Framework_MockObject_MockObject|\PHPUnit_Framework_MockObject_MockObject*/ | ||
protected $objectManager; | ||
|
||
/** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $response; | ||
|
||
/** @var \Magento\Theme\Helper\Storage|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $storage; | ||
|
||
/** @var \Magento\Theme\Helper\Storage|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $storageHelper; | ||
|
||
public function setUp() | ||
{ | ||
$this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); | ||
$this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); | ||
$this->storage = $this->getMock('Magento\Theme\Model\Wysiwyg\Storage', [], [], '', false); | ||
$this->storageHelper = $this->getMock('Magento\Theme\Helper\Storage', [], [], '', false); | ||
|
||
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$this->controller = $helper->getObject( | ||
'Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files\DeleteFolder', | ||
[ | ||
'objectManager' => $this->objectManager, | ||
'response' => $this->response, | ||
'storage' => $this->storageHelper | ||
] | ||
); | ||
} | ||
|
||
public function testExecute() | ||
{ | ||
$this->storageHelper->expects($this->once()) | ||
->method('getCurrentPath') | ||
->willReturn('/current/path/'); | ||
|
||
$this->objectManager->expects($this->at(0)) | ||
->method('get') | ||
->with('Magento\Theme\Model\Wysiwyg\Storage') | ||
->willReturn($this->storage); | ||
$this->storage->expects($this->once()) | ||
->method('deleteDirectory') | ||
->with('/current/path/') | ||
->willThrowException(new \Exception('Message')); | ||
|
||
$jsonData = $this->getMock('Magento\Framework\Json\Helper\Data', [], [], '', false); | ||
$jsonData->expects($this->once()) | ||
->method('jsonEncode') | ||
->with(['error' => true, 'message' => 'Message']) | ||
->willReturn('{"error":"true","message":"Message"}'); | ||
|
||
$this->objectManager->expects($this->at(1)) | ||
->method('get') | ||
->with('Magento\Framework\Json\Helper\Data') | ||
->willReturn($jsonData); | ||
|
||
$this->controller->execute(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...de/Magento/Theme/Test/Unit/Controller/Adminhtml/System/Design/Wysiwyg/Files/IndexTest.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,39 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Theme\Test\Unit\Controller\Adminhtml\System\Design\Wysiwyg\Files; | ||
|
||
class IndexTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var \Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files */ | ||
protected $controller; | ||
|
||
/** @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $view; | ||
|
||
public function setUp() | ||
{ | ||
$this->view = $this->getMock('\Magento\Framework\App\ViewInterface', [], [], '', false); | ||
|
||
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$this->controller = $helper->getObject( | ||
'Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files\Index', | ||
[ | ||
'view' => $this->view, | ||
] | ||
); | ||
} | ||
|
||
public function testExecute() | ||
{ | ||
$this->view ->expects($this->once()) | ||
->method('loadLayout') | ||
->with('overlay_popup'); | ||
$this->view ->expects($this->once()) | ||
->method('renderLayout'); | ||
|
||
$this->controller->execute(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...Magento/Theme/Test/Unit/Controller/Adminhtml/System/Design/Wysiwyg/Files/OnInsertTest.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,59 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Theme\Test\Unit\Controller\Adminhtml\System\Design\Wysiwyg\Files; | ||
|
||
class OnInsertTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var \Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files */ | ||
protected $controller; | ||
|
||
/** @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $view; | ||
|
||
/** @var \PHPUnit_Framework_MockObject_MockObject|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $objectManager; | ||
|
||
/** @var \Magento\Theme\Helper\Storage|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $storageHelper; | ||
|
||
/** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $response; | ||
|
||
public function setUp() | ||
{ | ||
$this->objectManager = $this->getMock('Magento\Framework\ObjectManagerInterface'); | ||
$this->view = $this->getMock('\Magento\Framework\App\ViewInterface', [], [], '', false); | ||
$this->storageHelper = $this->getMock('Magento\Theme\Helper\Storage', [], [], '', false); | ||
$this->response = $this->getMock('Magento\Framework\App\Response\Http', ['setBody'], [], '', false); | ||
|
||
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$this->controller = $helper->getObject( | ||
'Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files\OnInsert', | ||
[ | ||
'objectManager' => $this->objectManager, | ||
'view' => $this->view, | ||
'response' => $this->response | ||
] | ||
); | ||
} | ||
|
||
public function testExecute() | ||
{ | ||
$this->objectManager->expects($this->once()) | ||
->method('get') | ||
->with('Magento\Theme\Helper\Storage') | ||
->willReturn($this->storageHelper); | ||
$this->storageHelper | ||
->expects($this->once()) | ||
->method('getRelativeUrl') | ||
->willReturn('http://relative.url/'); | ||
$this->response->expects($this->once()) | ||
->method('setBody') | ||
->with('http://relative.url/'); | ||
|
||
$this->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