|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * (c) Packagist Conductors UG (haftungsbeschränkt) <[email protected]> |
| 5 | + * |
| 6 | + * For the full copyright and license information, please view the LICENSE |
| 7 | + * file that was distributed with this source code. |
| 8 | + */ |
| 9 | + |
| 10 | +namespace PrivatePackagist\ApiClient\Api\Packages; |
| 11 | + |
| 12 | +use PrivatePackagist\ApiClient\Api\ApiTestCase; |
| 13 | + |
| 14 | +class ArtifactsTest extends ApiTestCase |
| 15 | +{ |
| 16 | + public function testCreate() |
| 17 | + { |
| 18 | + $expected = [ |
| 19 | + 'id' => 1, |
| 20 | + ]; |
| 21 | + $rawFileContent = 'foobar'; |
| 22 | + $headers = [ |
| 23 | + 'Content-Type' => 'application/zip', |
| 24 | + 'X-FILENAME' => 'file.zip' |
| 25 | + ]; |
| 26 | + |
| 27 | + /** @var Artifacts&\PHPUnit_Framework_MockObject_MockObject $api */ |
| 28 | + $api = $this->getApiMock(); |
| 29 | + $api->expects($this->once()) |
| 30 | + ->method('postFile') |
| 31 | + ->with($this->equalTo('/packages/artifacts/'), $rawFileContent, $headers) |
| 32 | + ->willReturn($expected); |
| 33 | + |
| 34 | + |
| 35 | + $this->assertSame($expected, $api->create($rawFileContent, $headers['Content-Type'], $headers['X-FILENAME'])); |
| 36 | + } |
| 37 | + |
| 38 | + public function testShow() |
| 39 | + { |
| 40 | + $expected = [ |
| 41 | + 'repoType' => 'artifact', |
| 42 | + 'artifactPackageFileIds' =>[1, 2], |
| 43 | + ]; |
| 44 | + |
| 45 | + /** @var Artifacts&\PHPUnit_Framework_MockObject_MockObject $api */ |
| 46 | + $api = $this->getApiMock(); |
| 47 | + $api->expects($this->once()) |
| 48 | + ->method('get') |
| 49 | + ->with($this->equalTo('/packages/artifacts/1/')) |
| 50 | + ->willReturn($expected); |
| 51 | + |
| 52 | + $this->assertSame($expected, $api->show('1')); |
| 53 | + } |
| 54 | + |
| 55 | + public function testShowPackageArtifacts() |
| 56 | + { |
| 57 | + $expected = [ |
| 58 | + 'name' => 'acme-website/package', |
| 59 | + 'repoType' => 'artifact', |
| 60 | + 'artifactFiles' => 'artifact', |
| 61 | + ]; |
| 62 | + |
| 63 | + /** @var Artifacts&\PHPUnit_Framework_MockObject_MockObject $api */ |
| 64 | + $api = $this->getApiMock(); |
| 65 | + $api->expects($this->once()) |
| 66 | + ->method('get') |
| 67 | + ->with($this->equalTo('/packages/acme-website/package/artifacts/')) |
| 68 | + ->willReturn($expected); |
| 69 | + |
| 70 | + $this->assertSame($expected, $api->showPackageArtifacts('acme-website/package')); |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * @return string |
| 75 | + */ |
| 76 | + protected function getApiClass() |
| 77 | + { |
| 78 | + return Artifacts::class; |
| 79 | + } |
| 80 | +} |
0 commit comments