-
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 #95 from magento-troll/troll_s30
[Troll] Varnish updates and Unit Tests Coverage
- Loading branch information
Showing
27 changed files
with
2,264 additions
and
11 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
26 changes: 26 additions & 0 deletions
26
dev/tests/unit/testsuite/Magento/Indexer/Block/Backend/ContainerTest.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,26 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Indexer\Block\Backend; | ||
|
||
class ContainerTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testPseudoConstruct() | ||
{ | ||
$headerText = __('Indexer Management'); | ||
$buttonList = $this->getMock('\Magento\Backend\Block\Widget\Button\ButtonList', ['remove', 'add'], [], '', false); | ||
$buttonList->expects($this->once())->method('add'); | ||
$buttonList->expects($this->once())->method('remove')->with('add'); | ||
$urlBuilderMock = $this->getMock('\Magento\Framework\UrlInterface', [], [], '', false); | ||
$contextMock = $this->getMock('\Magento\Backend\Block\Widget\Context', ['getUrlBuilder', 'getButtonList'], [], '', false); | ||
|
||
$contextMock->expects($this->once())->method('getUrlBuilder')->will($this->returnValue($urlBuilderMock)); | ||
$contextMock->expects($this->once())->method('getButtonList')->will($this->returnValue($buttonList)); | ||
|
||
$block = new Container($contextMock); | ||
|
||
$this->assertEquals($block->getHeaderText(), $headerText); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...tests/unit/testsuite/Magento/Indexer/Block/Backend/Grid/Column/Renderer/ScheduledTest.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,43 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Indexer\Block\Backend\Grid\Column\Renderer; | ||
|
||
class ScheduledTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @param bool $rowValue | ||
* @param string $class | ||
* @param string $text | ||
* @dataProvider typeProvider | ||
*/ | ||
public function testRender($rowValue, $class, $text) | ||
{ | ||
$html = '<span class="' . $class . '"><span>' . $text . '</span></span>'; | ||
$row = new \Magento\Framework\Object(); | ||
$column = new \Magento\Framework\Object(); | ||
$context = $this->getMockBuilder('\Magento\Backend\Block\Context') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$model = new Scheduled($context); | ||
$column->setGetter('getValue'); | ||
$row->setValue($rowValue); | ||
$model->setColumn($column); | ||
|
||
$result = $model->render($row); | ||
$this->assertEquals($result, $html); | ||
} | ||
|
||
public function typeProvider() | ||
{ | ||
return [ | ||
[true, 'grid-severity-notice', __('Update by Schedule')], | ||
[false, 'grid-severity-major', __('Update on Save')], | ||
['', 'grid-severity-major', __('Update on Save')], | ||
]; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
dev/tests/unit/testsuite/Magento/Indexer/Block/Backend/Grid/Column/Renderer/StatusTest.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,51 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Indexer\Block\Backend\Grid\Column\Renderer; | ||
|
||
class StatusTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @param array $indexValues | ||
* @param string $expectedResult | ||
* @dataProvider renderDataProvider | ||
*/ | ||
public function testRender($indexValues, $expectedResult) | ||
{ | ||
$context = $this->getMockBuilder('\Magento\Backend\Block\Context') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$model = new Status($context); | ||
$obj = new \Magento\Framework\Object(); | ||
$obj->setGetter(null); | ||
$obj->setDefault(''); | ||
$obj->setValue(''); | ||
$obj->setIndex($indexValues[0]); | ||
$obj->setData($indexValues[0], $indexValues[0]); | ||
$model->setColumn($obj); | ||
$model->setIndex($indexValues[0]); | ||
$result = $model->render($obj); | ||
$this->assertEquals($result, '<span class="' . $expectedResult['class'] . '"><span>' . $expectedResult['text'] . '</span></span>'); | ||
} | ||
|
||
public function renderDataProvider() | ||
{ | ||
return [ | ||
'set1' => [ | ||
[\Magento\Indexer\Model\Indexer\State::STATUS_INVALID], | ||
['class' => 'grid-severity-critical', 'text' => 'Reindex required'] | ||
], | ||
'set2' => [ | ||
[\Magento\Indexer\Model\Indexer\State::STATUS_VALID], | ||
['class' => 'grid-severity-notice', 'text' => 'Ready'] | ||
], | ||
'set3' => [ | ||
[\Magento\Indexer\Model\Indexer\State::STATUS_WORKING], | ||
['class' => 'grid-severity-major', 'text' => 'Processing'] | ||
] | ||
]; | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
dev/tests/unit/testsuite/Magento/Indexer/Block/Backend/Grid/Column/Renderer/UpdatedTest.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,37 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Indexer\Block\Backend\Grid\Column\Renderer; | ||
|
||
class UpdatedTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @param string $defaultValue | ||
* @param string $assert | ||
* @dataProvider renderProvider | ||
*/ | ||
public function testRender($defaultValue, $assert) | ||
{ | ||
$context = $this->getMockBuilder('\Magento\Backend\Block\Context') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$model = new Updated($context); | ||
$obj = new \Magento\Framework\Object(); | ||
$obj->setGetter('getValue'); | ||
$obj->setDefault($defaultValue); | ||
$obj->setValue(''); | ||
$model->setColumn($obj); | ||
$result = $model->render($obj); | ||
$this->assertEquals($result, $assert); | ||
} | ||
|
||
public function renderProvider() | ||
{ | ||
return [ | ||
['true', 'true'], | ||
['', __('Never')] | ||
]; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
dev/tests/unit/testsuite/Magento/Indexer/Block/Backend/Grid/ItemsUpdaterTest.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,38 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Indexer\Block\Backend\Grid; | ||
|
||
class ItemsUpdaterTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @param bool $argument | ||
* @dataProvider updateDataProvider | ||
*/ | ||
public function testUpdate($argument) | ||
{ | ||
$params = ['change_mode_onthefly' => 1, 'change_mode_changelog' => 2]; | ||
|
||
$auth = $this->getMockBuilder('Magento\Framework\AuthorizationInterface') | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
$auth->expects($this->once())->method('isAllowed')->with('Magento_Indexer::changeMode')->will($this->returnValue($argument)); | ||
|
||
$model = new ItemsUpdater($auth); | ||
$params = $model->update($params); | ||
$this->assertEquals($argument, (isset($params['change_mode_onthefly']) && isset($params['change_mode_changelog']))); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function updateDataProvider() | ||
{ | ||
return [ | ||
[true], | ||
[false] | ||
]; | ||
} | ||
} |
Oops, something went wrong.