Skip to content

Commit

Permalink
[BUGFIX] Allow global options with prefix for defined tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
helhum committed Mar 31, 2016
1 parent 1a88e2a commit 705e965
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
42 changes: 42 additions & 0 deletions Tests/Unit/Domain/Service/TaskManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,46 @@ public function applicationOptionsOverrideDeploymentOptions()
$localOptions = array();
$this->taskManager->execute('MyVendor\\MyPackage\\Task\\TaskGroup\\MyTask', $this->node, $this->application, $this->deployment, 'test', $localOptions);
}

/**
* @test
*/
public function executeDoesNotPassPrefixedTaskOptionsOfBaseTaskToDefinedTask()
{
$globalOptions = array(
'MyVendor\\MyPackage\\Task\\TaskGroup\\MyTask[taskOption]' => 'Foo'
);
$this->deployment->setOptions($globalOptions);

$this->task->expects($this->atLeastOnce())->method('execute')->with(
$this->anything(),
$this->anything(),
$this->anything(),
$this->logicalNot($this->arrayHasKey('taskOption'))
);

$localOptions = array();
$this->taskManager->execute('MyVendor\\MyPackage\\Task\\TaskGroup\\MyTask', $this->node, $this->application, $this->deployment, 'test', $localOptions, 'MyVendor\\MyPackage\\DefinedTask\\TaskGroup\\MyTask');
}

/**
* @test
*/
public function executePassePrefixedDefinedTaskOptionsToDefinedTask()
{
$globalOptions = array(
'MyVendor\\MyPackage\\DefinedTask\\TaskGroup\\MyTask[taskOption]' => 'Foo'
);
$this->deployment->setOptions($globalOptions);

$this->task->expects($this->atLeastOnce())->method('execute')->with(
$this->anything(),
$this->anything(),
$this->anything(),
$this->arrayHasKey('taskOption')
);

$localOptions = array();
$this->taskManager->execute('MyVendor\\MyPackage\\Task\\TaskGroup\\MyTask', $this->node, $this->application, $this->deployment, 'test', $localOptions, 'MyVendor\\MyPackage\\DefinedTask\\TaskGroup\\MyTask');
}
}
2 changes: 1 addition & 1 deletion src/Domain/Service/TaskManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function execute($taskName, Node $node, Application $application, Deploym

$task = $this->createTaskInstance($taskName);

$globalOptions = $this->overrideOptions($taskName, $deployment, $node, $application, $options);
$globalOptions = $this->overrideOptions($definedTaskName, $deployment, $node, $application, $options);

if (!$deployment->isDryRun()) {
$task->execute($node, $application, $deployment, $globalOptions);
Expand Down

0 comments on commit 705e965

Please sign in to comment.