-
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.
MAGETWO-40553: [GITHUB] Update Console Tool Usage for Cache and Index…
… Operations #1440 Merge commit 'refs/pull/1440/head' of https://github.com/magento/magento2 into MAGETWO-39841-pull-request-1440
- Loading branch information
Showing
24 changed files
with
291 additions
and
296 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
36 changes: 36 additions & 0 deletions
36
app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheCommandTest.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,36 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Backend\Test\Unit\Console\Command; | ||
|
||
use Magento\Backend\Console\Command\AbstractCacheManageCommand; | ||
|
||
abstract class AbstractCacheCommandTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Magento\Framework\App\Cache\Manager|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $cacheManager; | ||
|
||
/** | ||
* @var AbstractCacheManageCommand | ||
*/ | ||
protected $command; | ||
|
||
public function setUp() | ||
{ | ||
$this->cacheManager = $this->getMock('Magento\Framework\App\Cache\Manager', [], [], '', false); | ||
} | ||
|
||
/** | ||
* Formats expected output for testExecute data providers | ||
* | ||
* @param array $types | ||
* @return string | ||
*/ | ||
abstract function getExpectedExecutionOutput(array $types); | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheManageCommandTest.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\Backend\Test\Unit\Console\Command; | ||
|
||
use Symfony\Component\Console\Tester\CommandTester; | ||
|
||
abstract class AbstractCacheManageCommandTest extends AbstractCacheCommandTest | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function testExecuteDataProvider() | ||
{ | ||
return [ | ||
'implicit all' => [ | ||
[], | ||
['A', 'B', 'C'], | ||
$this->getExpectedExecutionOutput(['A', 'B', 'C']), | ||
], | ||
'specified types' => [ | ||
['types' => ['A', 'B']], | ||
['A', 'B'], | ||
$this->getExpectedExecutionOutput(['A', 'B']), | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
* @expectedExceptionMessage The following requested cache types are not supported: | ||
*/ | ||
public function testExecuteInvalidCacheType() | ||
{ | ||
$this->cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']); | ||
$param = ['types' => ['A', 'D']]; | ||
$commandTester = new CommandTester($this->command); | ||
$commandTester->execute($param); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
app/code/Magento/Backend/Test/Unit/Console/Command/AbstractCacheSetCommandTest.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,57 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Backend\Test\Unit\Console\Command; | ||
|
||
abstract class AbstractCacheSetCommandTest extends AbstractCacheManageCommandTest | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function testExecuteDataProvider() | ||
{ | ||
return [ | ||
'implicit all' => [ | ||
[], | ||
['A', 'B', 'C'], | ||
['A', 'B', 'C'], | ||
$this->getExpectedExecutionOutput(['A', 'B', 'C']), | ||
], | ||
'specified types' => [ | ||
['types' => ['A', 'B']], | ||
['A', 'B'], | ||
['A', 'B'], | ||
$this->getExpectedExecutionOutput(['A', 'B']), | ||
], | ||
'no changes' => [ | ||
['types' => ['A', 'B']], | ||
['A', 'B'], | ||
[], | ||
$this->getExpectedExecutionOutput([]), | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* Formats expected output of cache status change | ||
* | ||
* @param array $changes | ||
* @param bool $enabled | ||
* @return string | ||
*/ | ||
public function getExpectedChangeOutput(array $changes, $enabled) | ||
{ | ||
if ($changes) { | ||
$output = 'Changed cache status:' . PHP_EOL; | ||
foreach ($changes as $type) { | ||
$output .= sprintf('%30s: %d -> %d', $type, $enabled === false, $enabled === true) . PHP_EOL; | ||
} | ||
} else { | ||
$output = 'There is nothing to change in cache status' . PHP_EOL; | ||
} | ||
return $output; | ||
} | ||
} |
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.