1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 16:42:57 +00:00

Test case to verify relative paths remain relative

This commit is contained in:
Dennis Birkholz 2015-09-23 18:15:43 +02:00
parent 9febf55f76
commit 3febbc2cbf

View file

@ -81,4 +81,29 @@ class PathRepositoryTest extends TestCase
$package = $packages[1];
$this->assertEquals('test/path-unversioned', $package->getName());
}
/**
* Verify relative repository URLs remain relative, see #4439
*/
public function testUrlRemainsRelative()
{
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
->getMock();
$config = new \Composer\Config();
$loader = new ArrayLoader(new VersionParser());
$versionGuesser = null;
$repositoryUrl = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'Fixtures', 'path', 'with-version'));
$relativeUrl = ltrim(substr($repositoryUrl, strlen(getcwd())), DIRECTORY_SEPARATOR);
$repository = new PathRepository(array('url' => $relativeUrl), $ioInterface, $config, $loader);
$packages = $repository->getPackages();
$this->assertEquals(1, $repository->count());
$package = $packages[0];
$this->assertEquals('test/path-versioned', $package->getName());
$this->assertEquals(rtrim($relativeUrl, DIRECTORY_SEPARATOR), rtrim($package->getDistUrl(), DIRECTORY_SEPARATOR));
}
}