mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Add composer platform package with exact Composer version (#10313)
Co-authored-by: Lars Strojny <lars.strojny@internations.org> Co-authored-by: Nils Adermann <naderman@naderman.de>
This commit is contained in:
parent
7a3d2b8157
commit
ace8a1776c
3 changed files with 143 additions and 1 deletions
|
@ -12,6 +12,7 @@
|
|||
|
||||
namespace Composer\Test\Repository;
|
||||
|
||||
use Composer\Composer;
|
||||
use Composer\Package\Link;
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\PlatformRepository;
|
||||
|
@ -1213,6 +1214,64 @@ Linked Version => 1.2.11',
|
|||
self::assertTrue($link->getConstraint()->matches($this->getVersionConstraint('=', $sourcePackage->getVersion())));
|
||||
}
|
||||
}
|
||||
|
||||
public function testComposerPlatformVersion()
|
||||
{
|
||||
$runtime = $this->getMockBuilder('Composer\Platform\Runtime')->getMock();
|
||||
$runtime
|
||||
->method('getExtensions')
|
||||
->willReturn(array());
|
||||
$runtime
|
||||
->method('getConstant')
|
||||
->willReturnMap(
|
||||
array(
|
||||
array('PHP_VERSION', null, '7.0.0'),
|
||||
array('PHP_DEBUG', null, false),
|
||||
)
|
||||
);
|
||||
|
||||
$platformRepository = new PlatformRepository(array(), array(), $runtime);
|
||||
|
||||
$package = $platformRepository->findPackage('composer', '='.Composer::getVersion());
|
||||
self::assertNotNull($package, 'Composer package exists');
|
||||
}
|
||||
|
||||
public static function providePlatformPackages()
|
||||
{
|
||||
return array(
|
||||
array('php', true),
|
||||
array('php-debug', true),
|
||||
array('php-ipv6', true),
|
||||
array('php-64bit', true),
|
||||
array('php-zts', true),
|
||||
array('hhvm', true),
|
||||
array('hhvm-foo', false),
|
||||
array('ext-foo', true),
|
||||
array('ext-123', true),
|
||||
array('extfoo', false),
|
||||
array('ext', false),
|
||||
array('lib-foo', true),
|
||||
array('lib-123', true),
|
||||
array('libfoo', false),
|
||||
array('lib', false),
|
||||
array('composer', true),
|
||||
array('composer-foo', false),
|
||||
array('composer-plugin-api', true),
|
||||
array('composer-plugin', false),
|
||||
array('composer-runtime-api', true),
|
||||
array('composer-runtime', false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @param bool $expectation
|
||||
* @dataProvider providePlatformPackages
|
||||
*/
|
||||
public function testValidPlatformPackages($packageName, $expectation)
|
||||
{
|
||||
self::assertSame($expectation, PlatformRepository::isPlatformPackage($packageName));
|
||||
}
|
||||
}
|
||||
|
||||
class ResourceBundleStub
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue