123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace Composer\Repository;
- use Composer\TestCase;
- use Composer\IO\NullIO;
- use Composer\Config;
- use Composer\Package\BasePackage;
- class ArtifactRepositoryTest extends TestCase
- {
- public function setUp()
- {
- parent::setUp();
- if (!extension_loaded('zip')) {
- $this->markTestSkipped('You need the zip extension to run this test.');
- }
- }
- public function testExtractsConfigsFromZipArchives()
- {
- $expectedPackages = array(
- 'vendor0/package0-0.0.1',
- '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',
-
-
- );
- $coordinates = array('type' => 'artifact', 'url' => __DIR__ . '/Fixtures/artifacts');
- $repo = new ArtifactRepository($coordinates, new NullIO(), new Config());
- $foundPackages = array_map(function (BasePackage $package) {
- return "{$package->getPrettyName()}-{$package->getPrettyVersion()}";
- }, $repo->getPackages());
- sort($expectedPackages);
- sort($foundPackages);
- $this->assertSame($expectedPackages, $foundPackages);
- }
- public function testAbsoluteRepoUrlCreatesAbsoluteUrlPackages()
- {
- $absolutePath = __DIR__ . '/Fixtures/artifacts';
- $coordinates = array('type' => 'artifact', 'url' => $absolutePath);
- $repo = new ArtifactRepository($coordinates, new NullIO(), new Config());
- foreach ($repo->getPackages() as $package) {
- $this->assertTrue(strpos($package->getDistUrl(), strtr($absolutePath, '\\', '/')) === 0);
- }
- }
- public function testRelativeRepoUrlCreatesRelativeUrlPackages()
- {
- $relativePath = 'tests/Composer/Test/Repository/Fixtures/artifacts';
- $coordinates = array('type' => 'artifact', 'url' => $relativePath);
- $repo = new ArtifactRepository($coordinates, new NullIO(), new Config());
- foreach ($repo->getPackages() as $package) {
- $this->assertTrue(strpos($package->getDistUrl(), $relativePath) === 0);
- }
- }
- }
|