diff --git a/tests/Functional/Controller/RepoControllerTest.php b/tests/Functional/Controller/RepoControllerTest.php index fc803fb6..5989a57e 100644 --- a/tests/Functional/Controller/RepoControllerTest.php +++ b/tests/Functional/Controller/RepoControllerTest.php @@ -150,6 +150,37 @@ public function testOrganizationPackageDistDownload(): void self::assertTrue($this->client->getResponse()->isNotFound()); } + public function testOrganizationArtifactPackageDistDownload(): void + { + $this->fixtures->prepareRepoFiles(); + $this->fixtures->createToken( + $this->fixtures->createOrganization('buddy', $this->fixtures->createUser()), + 'secret-org-token' + ); + + $this->contentFromStream(function (): void { + $this->client->request('GET', '/dists/buddy-works/artifact/1.0.0.0/zip', [], [], [ + 'HTTP_HOST' => 'buddy.repo.repman.wip', + 'PHP_AUTH_USER' => 'token', + 'PHP_AUTH_PW' => 'secret-org-token', + ]); + }); + + $response = $this->client->getResponse(); + self::assertTrue($response->isOk(), 'Response code was not 200, it was instead '.$response->getStatusCode()); + self::assertInstanceOf(StreamedResponse::class, $response); + + $this->contentFromStream(function (): void { + $this->client->request('GET', '/dists/vendor/artifact/1.0.0.0/zip', [], [], [ + 'HTTP_HOST' => 'buddy.repo.repman.wip', + 'PHP_AUTH_USER' => 'token', + 'PHP_AUTH_PW' => 'secret-org-token', + ]); + }); + + self::assertTrue($this->client->getResponse()->isNotFound()); + } + public function testOrganizationTrackDownloads(): void { $this->fixtures->createPackage('c75b535f-5817-41a2-9424-e05476e7958f', 'buddy'); diff --git a/tests/Resources/buddy/dist/buddy-works/artifact/1.0.0.0.zip b/tests/Resources/buddy/dist/buddy-works/artifact/1.0.0.0.zip new file mode 100644 index 00000000..1e868021 Binary files /dev/null and b/tests/Resources/buddy/dist/buddy-works/artifact/1.0.0.0.zip differ diff --git a/tests/Unit/Service/Dist/StorageTest.php b/tests/Unit/Service/Dist/StorageTest.php new file mode 100644 index 00000000..a8e289ed --- /dev/null +++ b/tests/Unit/Service/Dist/StorageTest.php @@ -0,0 +1,38 @@ +storage = new Storage( + new FakeDownloader(), + new Filesystem(new MemoryAdapter()) + ); + } + + public function testFilename(): void + { + $dist = new Dist('repo', 'package', '1.1.0', '123456', 'zip'); + + self::assertEquals('repo/dist/package/1.1.0_123456.zip', $this->storage->filename($dist)); + } + + public function testArtifactFilename(): void + { + $dist = new Dist('repo', 'package', '1.1.0', '', 'zip'); + self::assertEquals('repo/dist/package/1.1.0.zip', $this->storage->filename($dist)); + } +} diff --git a/tests/Unit/Service/PackageSynchronizer/ComposerPackageSynchronizerTest.php b/tests/Unit/Service/PackageSynchronizer/ComposerPackageSynchronizerTest.php index b3b854d7..aad6fdfd 100644 --- a/tests/Unit/Service/PackageSynchronizer/ComposerPackageSynchronizerTest.php +++ b/tests/Unit/Service/PackageSynchronizer/ComposerPackageSynchronizerTest.php @@ -109,6 +109,11 @@ public function testSynchronizePackageFromArtifacts(): void self::assertContains('replaces-buddy-works/replace-^1.0', $linkStrings); self::assertContains('conflicts-buddy-works/conflict-^1.0', $linkStrings); self::assertContains('suggests-buddy-works/suggests-You really should', $linkStrings); + + $referencestrings = array_map(function (Version $version): string { + return $version->reference(); + }, $package->versions()->toArray()); + self::assertEquals(['', '', '', ''], $referencestrings); } public function testWithMostRecentUnstable(): void