Skip to content

Commit c26d8ff

Browse files
Added name and description to UploadTransferables task
Signed-off-by: Bastian Schwarz <bastian@codename-php.de>
1 parent 17478df commit c26d8ff

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/task/deploy/updateCode/UploadTransferables.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919

2020
use de\codenamephp\deployer\base\functions\All;
2121
use de\codenamephp\deployer\base\functions\iUpload;
22-
use de\codenamephp\deployer\base\task\iTask;
22+
use de\codenamephp\deployer\base\task\iTaskWithDescription;
23+
use de\codenamephp\deployer\base\task\iTaskWithName;
2324
use de\codenamephp\deployer\base\transferable\iTransferable;
2425

2526
/**
2627
* Uses a collection of transferables and the deployer upload function to update the code on remote.
2728
*/
28-
final class UploadTransferables implements iTask {
29+
final class UploadTransferables implements iTaskWithName, iTaskWithDescription {
30+
31+
public const NAME = 'deploy:update_code';
2932

3033
public iUpload $deployerFunctions;
3134

@@ -51,9 +54,17 @@ public function setTransferables(iTransferable ...$transferables) : UploadTransf
5154
return $this;
5255
}
5356

57+
public function getDescription() : string {
58+
return 'Updates the code on the remote machine.';
59+
}
60+
5461
public function __invoke() : void {
5562
foreach($this->transferables as $transferable) {
5663
$this->deployerFunctions->upload($transferable->getLocalPath(), $transferable->getRemotePath(), $transferable->getConfig());
5764
}
5865
}
66+
67+
public function getName() : string {
68+
return self::NAME;
69+
}
5970
}

test/task/deploy/updateCode/UploadTransferablesTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,12 @@ public function test__construct_withTransferrables() : void {
7979
self::assertInstanceOf(All::class, $this->sut->deployerFunctions);
8080
self::assertEquals([$transferable1, $transferable2, $transferable3], $this->sut->getTransferables());
8181
}
82+
83+
public function testGetName() : void {
84+
self::assertEquals(UploadTransferables::NAME, $this->sut->getName());
85+
}
86+
87+
public function testGetDescription() : void {
88+
self::assertEquals('Updates the code on the remote machine.', $this->sut->getDescription());
89+
}
8290
}

0 commit comments

Comments
 (0)