Skip to content

Commit a1002e9

Browse files
committed
Add API for showing artifact files for a package
1 parent 8a2cca8 commit a1002e9

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

src/Api/PackageArtifacts.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ class PackageArtifacts extends AbstractApi
1313
{
1414
public function create($file, $contentType, $fileName)
1515
{
16-
return $this->postFile('/packages/artifact/', $file, array_filter([
16+
return $this->postFile('/packages/artifacts/', $file, array_filter([
1717
'Content-Type' => $contentType,
1818
'X-FILENAME' => $fileName
1919
]));
2020
}
2121

2222
public function show($artifactId)
2323
{
24-
return $this->get(sprintf('/packages/artifact/%s/', $artifactId));
24+
return $this->get(sprintf('/packages/artifacts/%s/', $artifactId));
2525
}
2626
}

src/Api/Packages.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public function show($packageName)
5454
return $this->get(sprintf('/packages/%s/', $packageName));
5555
}
5656

57+
public function showArtifacts($packageName)
58+
{
59+
return $this->get(sprintf('/packages/%s/artifacts/', $packageName));
60+
}
61+
5762
public function createVcsPackage($url, $credentialId = null, $type = 'vcs')
5863
{
5964
return $this->post('/packages/', ['repoType' => $type, 'repoUrl' => $url, 'credentials' => $credentialId]);

tests/Api/PackagArtifactsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testCreate()
2626
$api = $this->getApiMock();
2727
$api->expects($this->once())
2828
->method('postFile')
29-
->with($this->equalTo('/packages/artifact/'), $rawFileContent, $headers)
29+
->with($this->equalTo('/packages/artifacts/'), $rawFileContent, $headers)
3030
->willReturn($expected);
3131

3232

@@ -44,7 +44,7 @@ public function testShow()
4444
$api = $this->getApiMock();
4545
$api->expects($this->once())
4646
->method('get')
47-
->with($this->equalTo('/packages/artifact/1/'))
47+
->with($this->equalTo('/packages/artifacts/1/'))
4848
->willReturn($expected);
4949

5050
$this->assertSame($expected, $api->show('1'));

tests/Api/PackagesTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@ public function testShow()
8787
$this->assertSame($expected, $api->show('acme-website/package'));
8888
}
8989

90+
public function testShowArtifacts()
91+
{
92+
$expected = [
93+
'name' => 'acme-website/package',
94+
'repoType' => 'artifact',
95+
'artifactFiles' => 'artifact',
96+
];
97+
98+
/** @var Packages&\PHPUnit_Framework_MockObject_MockObject $api */
99+
$api = $this->getApiMock();
100+
$api->expects($this->once())
101+
->method('get')
102+
->with($this->equalTo('/packages/acme-website/package/artifacts'))
103+
->willReturn($expected);
104+
105+
$this->assertSame($expected, $api->showArtifacts('acme-website/package'));
106+
}
107+
90108
public function testCreateVcsPackage()
91109
{
92110
$expected = [

0 commit comments

Comments
 (0)