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

Add config option for update reference in path repository (#10488)

This commit is contained in:
Volodymyr Panivko 2022-02-07 14:54:17 +02:00 committed by GitHub
parent ac8fb8cc57
commit a0b0ddcd73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 88 additions and 6 deletions

View file

@ -154,4 +154,50 @@ class PathRepositoryTest extends TestCase
$relativeUrl = str_replace(DIRECTORY_SEPARATOR, '/', $relativeUrl);
$this->assertSame($relativeUrl, $package->getDistUrl());
}
public function testReferenceNone()
{
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
->getMock();
$config = new \Composer\Config();
$options = array(
'reference' => 'none',
);
$repositoryUrl = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'Fixtures', 'path', '*'));
$repository = new PathRepository(array('url' => $repositoryUrl, 'options' => $options), $ioInterface, $config);
$packages = $repository->getPackages();
$this->assertGreaterThanOrEqual(2, $repository->count());
foreach ($packages as $package) {
$this->assertEquals($package->getDistReference(), null);
}
}
public function testReferenceConfig()
{
$ioInterface = $this->getMockBuilder('Composer\IO\IOInterface')
->getMock();
$config = new \Composer\Config();
$options = array(
'reference' => 'config',
'relative' => true,
);
$repositoryUrl = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'Fixtures', 'path', '*'));
$repository = new PathRepository(array('url' => $repositoryUrl, 'options' => $options), $ioInterface, $config);
$packages = $repository->getPackages();
$this->assertGreaterThanOrEqual(2, $repository->count());
foreach ($packages as $package) {
$this->assertEquals(
$package->getDistReference(),
sha1(file_get_contents($package->getDistUrl() . '/composer.json') . serialize($options))
);
}
}
}