Skip to content

Commit 6a6de74

Browse files
committed
feat(internal-api-php-client): add ability to add artifacts in JobArtifacts
1 parent cb8cb58 commit 6a6de74

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

src/Result/JobArtifacts.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ public function setDownloaded(array $downloadedFiles): self
3535
return $this;
3636
}
3737

38+
/** @param Result[] $downloadedArtifacts */
39+
public function addDownloaded(array $downloadedArtifacts): void
40+
{
41+
$this->downloaded = array_merge($this->downloaded, $downloadedArtifacts);
42+
}
43+
44+
/** @param Result[] $uploadedArtifacts */
45+
public function addUploaded(array $uploadedArtifacts): void
46+
{
47+
$this->uploaded = array_merge($this->uploaded, $uploadedArtifacts);
48+
}
49+
3850
public function jsonSerialize(): array
3951
{
4052
return [

tests/Result/ArtifactsTest.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,78 @@ public function testSetDownloaded(): void
5151
],
5252
], $artifacts->jsonSerialize());
5353
}
54+
55+
public function testAddUploaded(): void
56+
{
57+
$artifacts = new JobArtifacts();
58+
$artifacts->setUploaded([
59+
new Result(100),
60+
]);
61+
62+
$artifacts->addUploaded([
63+
new Result(200),
64+
new Result(300),
65+
]);
66+
67+
self::assertSame([
68+
'uploaded' => [
69+
['storageFileId' => '100'],
70+
['storageFileId' => '200'],
71+
['storageFileId' => '300'],
72+
],
73+
'downloaded' => [],
74+
], $artifacts->jsonSerialize());
75+
}
76+
77+
public function testAddUploadedToEmpty(): void
78+
{
79+
$artifacts = new JobArtifacts();
80+
$artifacts->addUploaded([
81+
new Result(400),
82+
]);
83+
84+
self::assertSame([
85+
'uploaded' => [
86+
['storageFileId' => '400'],
87+
],
88+
'downloaded' => [],
89+
], $artifacts->jsonSerialize());
90+
}
91+
92+
public function testAddDownloaded(): void
93+
{
94+
$artifacts = new JobArtifacts();
95+
$artifacts->setDownloaded([
96+
new Result(500),
97+
]);
98+
99+
$artifacts->addDownloaded([
100+
new Result(600),
101+
new Result(700),
102+
]);
103+
104+
self::assertSame([
105+
'uploaded' => [],
106+
'downloaded' => [
107+
['storageFileId' => '500'],
108+
['storageFileId' => '600'],
109+
['storageFileId' => '700'],
110+
],
111+
], $artifacts->jsonSerialize());
112+
}
113+
114+
public function testAddDownloadedToEmpty(): void
115+
{
116+
$artifacts = new JobArtifacts();
117+
$artifacts->addDownloaded([
118+
new Result(800),
119+
]);
120+
121+
self::assertSame([
122+
'uploaded' => [],
123+
'downloaded' => [
124+
['storageFileId' => '800'],
125+
],
126+
], $artifacts->jsonSerialize());
127+
}
54128
}

0 commit comments

Comments
 (0)