Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class CacheCleanCommand extends AbstractCacheTypeManageCommand
{
/**
* {@inheritdoc}
* @inheritdoc
*/
protected function configure()
{
Expand All @@ -32,12 +32,15 @@ protected function configure()
*/
protected function performAction(array $cacheTypes)
{
$this->eventManager->dispatch('adminhtml_cache_flush_system');
if ($cacheTypes === [] || in_array('full_page', $cacheTypes)) {
$this->eventManager->dispatch('adminhtml_cache_flush_system');
}

$this->cacheManager->clean($cacheTypes);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
protected function getDisplayMessage()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class CacheFlushCommand extends AbstractCacheTypeManageCommand
{
/**
* {@inheritdoc}
* @inheritdoc
*/
protected function configure()
{
Expand All @@ -32,12 +32,15 @@ protected function configure()
*/
protected function performAction(array $cacheTypes)
{
$this->eventManager->dispatch('adminhtml_cache_flush_all');
if ($cacheTypes === [] || in_array('full_page', $cacheTypes)) {
$this->eventManager->dispatch('adminhtml_cache_flush_all');
}

$this->cacheManager->flush($cacheTypes);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
protected function getDisplayMessage()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,22 @@ public function executeDataProvider()
return [
'implicit all' => [
[],
['A', 'B', 'C'],
$this->getExpectedExecutionOutput(['A', 'B', 'C']),
['A', 'B', 'C', 'full_page'],
true,
$this->getExpectedExecutionOutput(['A', 'B', 'C', 'full_page']),
],
'specified types' => [
['types' => ['A', 'B']],
['A', 'B'],
false,
$this->getExpectedExecutionOutput(['A', 'B']),
],
'fpc_only' => [
['types' => ['full_page']],
['full_page'],
true,
$this->getExpectedExecutionOutput(['full_page']),
],
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@ protected function setUp(): void
/**
* @param array $param
* @param array $types
* @param bool $shouldDispatch
* @param string $output
* @dataProvider executeDataProvider
*/
public function testExecute($param, $types, $output)
public function testExecute($param, $types, $shouldDispatch, $output)
{
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn([
'A', 'B', 'C', 'full_page'
]);
$this->cacheManagerMock->expects($this->once())->method('clean')->with($types);
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);

if ($shouldDispatch) {
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
} else {
$this->eventManagerMock->expects($this->never())->method('dispatch');
}

$commandTester = new CommandTester($this->command);
$commandTester->execute($param);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@ protected function setUp(): void
/**
* @param array $param
* @param array $types
* @param bool $shouldDispatch
* @param string $output
* @dataProvider executeDataProvider
*/
public function testExecute($param, $types, $output)
public function testExecute($param, $types, $shouldDispatch, $output)
{
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']);
$this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn([
'A', 'B', 'C', 'full_page'
]);
$this->cacheManagerMock->expects($this->once())->method('flush')->with($types);
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);

if ($shouldDispatch) {
$this->eventManagerMock->expects($this->once())->method('dispatch')->with($this->cacheEventName);
} else {
$this->eventManagerMock->expects($this->never())->method('dispatch');
}

$commandTester = new CommandTester($this->command);
$commandTester->execute($param);
Expand Down