1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Merge pull request #2188 from Danack/GetRootComposerJson

Find root composer.json in zip artifact more reliably.
This commit is contained in:
Jordi Boggiano 2014-02-21 11:33:01 +01:00
commit eb3384445b
5 changed files with 86 additions and 1 deletions

View file

@ -26,6 +26,10 @@ class ArtifactRepositoryTest extends TestCase
'composer/composer-1.0.0-alpha6',
'vendor1/package2-4.3.2',
'vendor3/package1-5.4.3',
'test/jsonInRoot-1.0.0',
'test/jsonInFirstLevel-1.0.0',
//The files not-an-artifact.zip and jsonSecondLevel are not valid
//artifacts and do not get detected.
);
$coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts');
@ -41,3 +45,42 @@ class ArtifactRepositoryTest extends TestCase
$this->assertSame($expectedPackages, $foundPackages);
}
}
//Files jsonInFirstLevel.zip, jsonInRoot.zip and jsonInSecondLevel.zip were generated with:
//
//$archivesToCreate = array(
// 'jsonInRoot' => array(
// "extra.txt" => "Testing testing testing",
// "composer.json" => '{ "name": "test/jsonInRoot", "version": "1.0.0" }',
// "subdir/extra.txt" => "Testing testing testing",
// "subdir/extra2.txt" => "Testing testing testing",
// ),
//
// 'jsonInFirstLevel' => array(
// "extra.txt" => "Testing testing testing",
// "subdir/composer.json" => '{ "name": "test/jsonInFirstLevel", "version": "1.0.0" }',
// "subdir/extra.txt" => "Testing testing testing",
// "subdir/extra2.txt" => "Testing testing testing",
// ),
//
// 'jsonInSecondLevel' => array(
// "extra.txt" => "Testing testing testing",
// "subdir/extra1.txt" => "Testing testing testing",
// "subdir/foo/composer.json" => '{ "name": "test/jsonInSecondLevel", "version": "1.0.0" }',
// "subdir/foo/extra1.txt" => "Testing testing testing",
// "subdir/extra2.txt" => "Testing testing testing",
// "subdir/extra3.txt" => "Testing testing testing",
// ),
//);
//
//foreach($archivesToCreate as $archiveName => $fileDetails) {
// $zipFile = new ZipArchive();
// $zipFile->open("$archiveName.zip", ZIPARCHIVE::CREATE);
//
// foreach ($fileDetails as $filename => $fileContents) {
// $zipFile->addFromString($filename, $fileContents);
// }
//
// $zipFile->close();
//}