Skip to content

Commit b2faa16

Browse files
Setting default for deployer function in WithDeployerFunctions runner
Signed-off-by: Bastian Schwarz <bastian@codename-php.de>
1 parent b66c77b commit b2faa16

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/runner/WithDeployerFunctions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace de\codenamephp\deployer\command\runner;
1919

20+
use de\codenamephp\deployer\base\functions\All;
2021
use de\codenamephp\deployer\base\functions\iRun;
2122
use de\codenamephp\deployer\command\iCommand;
2223

@@ -25,7 +26,7 @@
2526
*/
2627
final class WithDeployerFunctions implements iRunner {
2728

28-
public function __construct(public iRun $deployerFunction) {}
29+
public function __construct(public iRun $deployerFunction = new All()) {}
2930

3031
public function run(iCommand $command) : string {
3132
return $this->deployerFunction->run($command->__toString(), $command->getRunConfiguration()->getOptions());

test/runner/WithDeployerFunctionsTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace de\codenamephp\deployer\command\test\runner;
1919

20+
use de\codenamephp\deployer\base\functions\All;
2021
use de\codenamephp\deployer\base\functions\iRun;
2122
use de\codenamephp\deployer\command\iCommand;
2223
use de\codenamephp\deployer\command\runConfiguration\iRunConfiguration;
@@ -43,6 +44,12 @@ public function test__construct() : void {
4344
self::assertSame($deployerFunction, $this->sut->deployerFunction);
4445
}
4546

47+
public function test__construct_withoutArguments() : void {
48+
$this->sut = new WithDeployerFunctions();
49+
50+
self::assertInstanceOf(All::class, $this->sut->deployerFunction);
51+
}
52+
4653
public function testRun() : void {
4754
$runConfiguration = $this->createMock(iRunConfiguration::class);
4855
$runConfiguration->expects(self::once())->method('getOptions')->willReturn(['some' => 'options']);

0 commit comments

Comments
 (0)