Skip to content

Commit 1955ca5

Browse files
committed
Add more tests for artifact API
1 parent 8cd4c1a commit 1955ca5

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/Api/Packages.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function editVcsPackage($packageName, $url, $credentialId = null, $type =
9393

9494
public function editArtifactPackage($packageName, array $artifactPackageFileIds)
9595
{
96-
return $this->put(sprintf('/packages/%s/', $packageName), ['artifactIds' => $artifactPackageFileIds, 'repoType' => 'artifact']);
96+
return $this->put(sprintf('/packages/%s/', $packageName), ['repoType' => 'artifact', 'artifactIds' => $artifactPackageFileIds]);
9797
}
9898

9999
/**

tests/Api/PackagesTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,23 @@ public function testCreateCustomPackage($customJson)
142142
$this->assertSame($expected, $api->createCustomPackage($customJson));
143143
}
144144

145+
public function testCreateArtifactPackage()
146+
{
147+
$expected = [
148+
'id' => 'job-id',
149+
'status' => 'queued',
150+
];
151+
152+
/** @var Packages&\PHPUnit_Framework_MockObject_MockObject $api */
153+
$api = $this->getApiMock();
154+
$api->expects($this->once())
155+
->method('post')
156+
->with($this->equalTo('/packages/'), $this->equalTo(['repoType' => 'artifact', 'artifactIds' => [42]]))
157+
->willReturn($expected);
158+
159+
$this->assertSame($expected, $api->createArtifactPackage([42]));
160+
}
161+
145162
public function customProvider()
146163
{
147164
return [
@@ -184,6 +201,23 @@ public function testEditCustomPackage()
184201
$this->assertSame($expected, $api->editCustomPackage('acme-website/package', '{}'));
185202
}
186203

204+
public function testEditArtifactPackage()
205+
{
206+
$expected = [
207+
'id' => 'job-id',
208+
'status' => 'queued',
209+
];
210+
211+
/** @var Packages&\PHPUnit_Framework_MockObject_MockObject $api */
212+
$api = $this->getApiMock();
213+
$api->expects($this->once())
214+
->method('put')
215+
->with($this->equalTo('/packages/acme-website/package/'), $this->equalTo(['repoType' => 'artifact', 'artifactIds' => [1, 3]]))
216+
->willReturn($expected);
217+
218+
$this->assertSame($expected, $api->editArtifactPackage('acme-website/package', [1, 3]));
219+
}
220+
187221
public function testRemove()
188222
{
189223
$expected = [];

0 commit comments

Comments
 (0)