Skip to content

Commit

Permalink
Merge branch 'master' into issue-396-force-option-in-flushcachestask
Browse files Browse the repository at this point in the history
  • Loading branch information
t3easy committed Jun 29, 2020
2 parents 334c37d + 3a153a2 commit f4dbdc9
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
22 changes: 14 additions & 8 deletions src/Task/Neos/Flow/FlushCacheListTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,20 @@ public function simulate(Node $node, Application $application, Deployment $deplo

protected function resolveOptions(OptionsResolver $resolver)
{
$resolver->setRequired('flushCacheList');
$resolver->setAllowedValues('flushCacheList', static function ($value) {
return trim($value) !== '';
});

$resolver->setNormalizer('flushCacheList', static function (Options $options, $value) {
return is_array($value) ? $value : explode(',', $value);
});
$resolver->setRequired('flushCacheList')
->setAllowedTypes('flushCacheList', ['array', 'string'])
->setNormalizer('flushCacheList', static function (Options $options, $value) {
return is_array($value) ? $value : explode(',', $value);
})
->setAllowedValues('flushCacheList', static function ($value) {
if (is_array($value)) {
return !empty($value);
}
if (is_string($value)) {
return trim($value) !== '';
}
return false;
});

$resolver->setDefault('phpBinaryPathAndFilename', 'php')
->setAllowedTypes('phpBinaryPathAndFilename', 'string');
Expand Down
24 changes: 22 additions & 2 deletions tests/Unit/Task/Neos/Flow/FlushCacheListTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,23 @@ public function noFlowApplicationGivenThrowsException()
/**
* @test
*/
public function requiredOptionFlushCacheListNotGivenThrowsException()
public function requiredOptionFlushCacheListWithEmptyStringThrowsException()
{
$this->expectException(InvalidConfigurationException::class);
$this->application = new Flow();
$this->task->execute($this->node, $this->application, $this->deployment, ['flushCacheList' => '']);
}

/**
* @test
*/
public function requiredOptionFlushCacheListWithEmptyArrayThrowsException()
{
$this->expectException(InvalidConfigurationException::class);
$this->application = new Flow();
$this->task->execute($this->node, $this->application, $this->deployment, ['flushCacheList' => []]);
}

/**
* @test
*/
Expand All @@ -51,13 +61,23 @@ public function tooLowFlowVersionThrowsException()
/**
* @test
*/
public function executeSuccessfully()
public function executeSuccessfullyWithString()
{
$this->application = new Flow();
$this->task->execute($this->node, $this->application, $this->deployment, ['flushCacheList' => 'list']);
$this->assertCommandExecuted(sprintf('cd /releases/%s && FLOW_CONTEXT=Production php ./flow neos.flow:cache:flushone \'--identifier\' \'list\'', $this->deployment->getReleaseIdentifier()));
}

/**
* @test
*/
public function executeSuccessfullyWithArray()
{
$this->application = new Flow();
$this->task->execute($this->node, $this->application, $this->deployment, ['flushCacheList' => ['list']]);
$this->assertCommandExecuted(sprintf('cd /releases/%s && FLOW_CONTEXT=Production php ./flow neos.flow:cache:flushone \'--identifier\' \'list\'', $this->deployment->getReleaseIdentifier()));
}

/**
* @return FlushCacheListTask
*/
Expand Down

0 comments on commit f4dbdc9

Please sign in to comment.