Skip to content

Commit

Permalink
[TASK] Add option to flush cache for files only
Browse files Browse the repository at this point in the history
  • Loading branch information
sabbelasichon committed May 10, 2020
1 parent e5eb783 commit 4849bfb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Task/TYPO3/CMS/FlushCachesTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* file that was distributed with this source code.
*/

use Symfony\Component\OptionsResolver\OptionsResolver;
use TYPO3\Surf\Application\TYPO3\CMS;
use TYPO3\Surf\Domain\Model\Application;
use TYPO3\Surf\Domain\Model\Deployment;
Expand Down Expand Up @@ -46,9 +47,18 @@ protected function getSuitableCliArguments(Node $node, CMS $application, Deploym
{
switch ($this->getAvailableCliPackage($node, $application, $deployment, $options)) {
case 'typo3_console':
if ($options['filesOnly']) {
return [$this->getConsoleScriptFileName($node, $application, $deployment, $options), 'cache:flush', '--files-only'];
}
return [$this->getConsoleScriptFileName($node, $application, $deployment, $options), 'cache:flush'];
default:
return [];
}
}

protected function resolveOptions(OptionsResolver $resolver)
{
$resolver->setDefault('filesOnly', false);
$resolver->setAllowedTypes('filesOnly', ['boolean']);
}
}
11 changes: 11 additions & 0 deletions tests/Unit/Task/TYPO3/CMS/FlushCachesTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ public function executeFlushCacheCommandSuccessfully(): void
$this->assertCommandExecuted('/php \'typo3cms\' \'cache:flush\'$/');
}

/**
* @test
*/
public function executeFlushCacheWithFilesOnlyCommandSuccessfully(): void
{
$application = new CMS();
$options = ['scriptFileName' => 'typo3cms', 'filesOnly' => true];
$this->task->execute($this->node, $application, $this->deployment, $options);
$this->assertCommandExecuted('/php \'typo3cms\' \'cache:flush\' \'--files-only\'$/');
}

protected function createTask()
{
return new FlushCachesTask();
Expand Down

0 comments on commit 4849bfb

Please sign in to comment.