ArtifactRepositoryTest.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Repository;
  12. use Composer\Test\TestCase;
  13. use Composer\IO\NullIO;
  14. use Composer\Config;
  15. use Composer\Package\BasePackage;
  16. class ArtifactRepositoryTest extends TestCase
  17. {
  18. public function testExtractsConfigsFromZipArchives()
  19. {
  20. $expectedPackages = array(
  21. 'vendor0/package0-0.0.1',
  22. 'composer/composer-1.0.0-alpha6',
  23. 'vendor1/package2-4.3.2',
  24. 'vendor3/package1-5.4.3',
  25. 'test/jsonInRoot-1.0.0',
  26. 'test/jsonInFirstLevel-1.0.0',
  27. //The files not-an-artifact.zip and jsonSecondLevel are not valid
  28. //artifacts and do not get detected.
  29. );
  30. $coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts');
  31. $repo = new ArtifactRepository($coordinates, new NullIO(), new Config());
  32. $foundPackages = array_map(function(BasePackage $package) {
  33. return "{$package->getPrettyName()}-{$package->getPrettyVersion()}";
  34. }, $repo->getPackages());
  35. sort($expectedPackages);
  36. sort($foundPackages);
  37. $this->assertSame($expectedPackages, $foundPackages);
  38. }
  39. }
  40. //$archivesToCreate = array(
  41. // 'jsonInRoot' => array(
  42. // "extra.txt" => "Testing testing testing",
  43. // "composer.json" => '{ "name": "test/jsonInRoot", "version": "1.0.0" }',
  44. // "subdir/extra.txt" => "Testing testing testing",
  45. // "subdir/extra2.txt" => "Testing testing testing",
  46. // ),
  47. //
  48. // 'jsonInFirstLevel' => array(
  49. // "extra.txt" => "Testing testing testing",
  50. // "subdir/composer.json" => '{ "name": "test/jsonInFirstLevel", "version": "1.0.0" }',
  51. // "subdir/extra.txt" => "Testing testing testing",
  52. // "subdir/extra2.txt" => "Testing testing testing",
  53. // ),
  54. //
  55. // 'jsonInSecondLevel' => array(
  56. // "extra.txt" => "Testing testing testing",
  57. // "subdir/extra1.txt" => "Testing testing testing",
  58. // "subdir/foo/composer.json" => '{ "name": "test/jsonInSecondLevel", "version": "1.0.0" }',
  59. // "subdir/foo/extra1.txt" => "Testing testing testing",
  60. // "subdir/extra2.txt" => "Testing testing testing",
  61. // "subdir/extra3.txt" => "Testing testing testing",
  62. // ),
  63. //);
  64. //
  65. //foreach($archivesToCreate as $archiveName => $fileDetails) {
  66. // $zipFile = new ZipArchive();
  67. // $zipFile->open("$archiveName.zip", ZIPARCHIVE::CREATE);
  68. //
  69. // foreach ($fileDetails as $filename => $fileContents) {
  70. // $zipFile->addFromString($filename, $fileContents);
  71. // }
  72. //
  73. // $zipFile->close();
  74. //}