Fix tests
parent
deaec7c0ac
commit
032db5bc01
|
@ -37,21 +37,22 @@ class ValidatingArrayLoader implements LoaderInterface
|
|||
private $warnings;
|
||||
/** @var mixed[] */
|
||||
private $config;
|
||||
/** @var bool */
|
||||
private $strictName;
|
||||
/** @var int One or more of self::CHECK_* constants */
|
||||
private $flags;
|
||||
|
||||
/**
|
||||
* @param bool $strictName
|
||||
* @param true $strictName
|
||||
* @param int $flags
|
||||
*/
|
||||
public function __construct(LoaderInterface $loader, $strictName = true, VersionParser $parser = null, $flags = 0)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
$this->versionParser = $parser ?: new VersionParser();
|
||||
$this->strictName = $strictName;
|
||||
$this->flags = $flags;
|
||||
|
||||
if ($strictName !== true) {
|
||||
trigger_error('$strictName must be set to true in ValidatingArrayLoader\'s constructor as of 2.2, and it will be removed in 3.0', E_USER_DEPRECATED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,14 +64,9 @@ class ValidatingArrayLoader implements LoaderInterface
|
|||
$this->warnings = array();
|
||||
$this->config = $config;
|
||||
|
||||
if ($err = self::hasPackageNamingError($config['name'])) {
|
||||
$this->errors[] = 'Your package name '.$err;
|
||||
}
|
||||
|
||||
if ($this->strictName) {
|
||||
$this->validateRegex('name', '[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*', true);
|
||||
} else {
|
||||
$this->validateString('name', true);
|
||||
if ($err = self::hasPackageNamingError($config['name'])) {
|
||||
$this->errors[] = 'name : '.$err;
|
||||
}
|
||||
|
||||
if (!empty($this->config['version'])) {
|
||||
|
|
|
@ -48,7 +48,7 @@ class PackageRepository extends ArrayRepository
|
|||
{
|
||||
parent::initialize();
|
||||
|
||||
$loader = new ValidatingArrayLoader(new ArrayLoader(null, true), false);
|
||||
$loader = new ValidatingArrayLoader(new ArrayLoader(null, true), true);
|
||||
foreach ($this->config as $package) {
|
||||
try {
|
||||
$package = $loader->load($package);
|
||||
|
|
|
@ -9,9 +9,6 @@ Test the error output of solver problems.
|
|||
{ "name": "package/found", "version": "2.0.0", "require": {
|
||||
"unstable/package2": "2.*"
|
||||
} },
|
||||
{ "name": "package/found2", "version": "2.0.0", "require": {
|
||||
"invalid/💩package": "*"
|
||||
} },
|
||||
{ "name": "package/found3", "version": "2.0.0", "require": {
|
||||
"unstable/package2": "2.*"
|
||||
} },
|
||||
|
@ -54,7 +51,6 @@ Test the error output of solver problems.
|
|||
],
|
||||
"require": {
|
||||
"package/found": "2.*",
|
||||
"package/found2": "2.*",
|
||||
"package/found3": "2.*",
|
||||
"package/found4": "2.*",
|
||||
"package/found5": "2.*",
|
||||
|
@ -130,24 +126,21 @@ Your requirements could not be resolved to an installable set of packages.
|
|||
- Root composer.json requires package/found 2.* -> satisfiable by package/found[2.0.0].
|
||||
- package/found 2.0.0 requires unstable/package2 2.* -> found unstable/package2[2.0.0-alpha] but it does not match your minimum-stability.
|
||||
Problem 10
|
||||
- Root composer.json requires package/found2 2.* -> satisfiable by package/found2[2.0.0].
|
||||
- package/found2 2.0.0 requires invalid/💩package * -> could not be found, it looks like its name is invalid, "💩" is not allowed in package names.
|
||||
Problem 11
|
||||
- Root composer.json requires package/found3 2.* -> satisfiable by package/found3[2.0.0].
|
||||
- package/found3 2.0.0 requires unstable/package2 2.* -> found unstable/package2[2.0.0-alpha] but it does not match your minimum-stability.
|
||||
Problem 12
|
||||
Problem 11
|
||||
- Root composer.json requires package/found4 2.* -> satisfiable by package/found4[2.0.0].
|
||||
- package/found4 2.0.0 requires non-existent/pkg2 1.* -> could not be found in any version, there may be a typo in the package name.
|
||||
Problem 13
|
||||
Problem 12
|
||||
- Root composer.json requires package/found6 2.* -> satisfiable by package/found6[2.0.0].
|
||||
- package/found6 2.0.0 requires stable-requiree-excluded/pkg2 1.0.1 -> found stable-requiree-excluded/pkg2[1.0.0] but it does not match the constraint.
|
||||
Problem 14
|
||||
Problem 13
|
||||
- Root composer.json requires package/found7 2.* -> satisfiable by package/found7[2.0.0].
|
||||
- package/found7 2.0.0 requires php-64bit 1.0.1 -> your php-64bit version (%s) does not satisfy that requirement.
|
||||
Problem 15
|
||||
Problem 14
|
||||
- Root composer.json requires requirer/pkg 1.* -> satisfiable by requirer/pkg[1.0.0].
|
||||
- requirer/pkg 1.0.0 requires dependency/pkg 1.0.0 -> found dependency/pkg[1.0.0] but it conflicts with your root composer.json require (2.*).
|
||||
Problem 16
|
||||
Problem 15
|
||||
- requirer/pkg 1.0.0 requires dependency/pkg 1.0.0 -> found dependency/pkg[1.0.0] but it conflicts with your root composer.json require (2.*).
|
||||
- package/found5 2.0.0 requires requirer/pkg 1.* -> satisfiable by requirer/pkg[1.0.0].
|
||||
- Root composer.json requires package/found5 2.* -> satisfiable by package/found5[2.0.0].
|
||||
|
|
|
@ -87,26 +87,26 @@ class ValidatingArrayLoaderTest extends TestCase
|
|||
'require' => array(
|
||||
'a/b' => '1.*',
|
||||
'b/c' => '~2',
|
||||
'example' => '>2.0-dev,<2.4-dev',
|
||||
'example/pkg' => '>2.0-dev,<2.4-dev',
|
||||
'composer-runtime-api' => '*',
|
||||
),
|
||||
'require-dev' => array(
|
||||
'a/b' => '1.*',
|
||||
'b/c' => '*',
|
||||
'example' => '>2.0-dev,<2.4-dev',
|
||||
'example/pkg' => '>2.0-dev,<2.4-dev',
|
||||
),
|
||||
'conflict' => array(
|
||||
'a/b' => '1.*',
|
||||
'b/c' => '>2.7',
|
||||
'example' => '>2.0-dev,<2.4-dev',
|
||||
'a/bx' => '1.*',
|
||||
'b/cx' => '>2.7',
|
||||
'example/pkgx' => '>2.0-dev,<2.4-dev',
|
||||
),
|
||||
'replace' => array(
|
||||
'a/b' => '1.*',
|
||||
'example' => '>2.0-dev,<2.4-dev',
|
||||
'example/pkg' => '>2.0-dev,<2.4-dev',
|
||||
),
|
||||
'provide' => array(
|
||||
'a/b' => '1.*',
|
||||
'example' => '>2.0-dev,<2.4-dev',
|
||||
'example/pkg' => '>2.0-dev,<2.4-dev',
|
||||
),
|
||||
'suggest' => array(
|
||||
'foo/bar' => 'Foo bar is very useful',
|
||||
|
@ -284,11 +284,29 @@ class ValidatingArrayLoaderTest extends TestCase
|
|||
'name' => $invalidName,
|
||||
),
|
||||
array(
|
||||
"name : invalid value ($invalidName), must match [A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*",
|
||||
"name : $invalidName is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match \"^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$\".",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$invalidNames = array(
|
||||
'fo--oo/bar',
|
||||
'fo-oo/bar__baz',
|
||||
'fo-oo/bar_.baz',
|
||||
'foo/bar---baz',
|
||||
);
|
||||
foreach ($invalidNames as $invalidName) {
|
||||
$invalidNaming[] = array(
|
||||
array(
|
||||
'name' => $invalidName,
|
||||
),
|
||||
array(
|
||||
"name : $invalidName is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match \"^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$\".",
|
||||
),
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
return array_merge($invalidNaming, array(
|
||||
array(
|
||||
array(
|
||||
|
@ -310,6 +328,42 @@ class ValidatingArrayLoaderTest extends TestCase
|
|||
'support.source : invalid value, must be a string',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'foo/bar.json',
|
||||
),
|
||||
array(
|
||||
'name : foo/bar.json is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'com1/foo',
|
||||
),
|
||||
array(
|
||||
'name : com1/foo is reserved, package and vendor names can not match any of: nul, con, prn, aux, com1, com2, com3, com4, com5, com6, com7, com8, com9, lpt1, lpt2, lpt3, lpt4, lpt5, lpt6, lpt7, lpt8, lpt9.',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'Foo/Bar',
|
||||
),
|
||||
array(
|
||||
'name : Foo/Bar is invalid, it should not contain uppercase characters. We suggest using foo/bar instead.',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'foo/bar',
|
||||
'require' => array(
|
||||
'Foo/Baz' => '^1.0',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'require.Foo/Baz is invalid, it should not contain uppercase characters. Please use foo/baz instead.',
|
||||
),
|
||||
false,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'foo/bar',
|
||||
|
@ -368,26 +422,7 @@ class ValidatingArrayLoaderTest extends TestCase
|
|||
|
||||
public function warningProvider()
|
||||
{
|
||||
$invalidNames = array(
|
||||
'fo--oo/bar',
|
||||
'fo-oo/bar__baz',
|
||||
'fo-oo/bar_.baz',
|
||||
'foo/bar---baz',
|
||||
);
|
||||
$invalidNaming = array();
|
||||
foreach ($invalidNames as $invalidName) {
|
||||
$invalidNaming[] = array(
|
||||
array(
|
||||
'name' => $invalidName,
|
||||
),
|
||||
array(
|
||||
"Deprecation warning: Your package name $invalidName is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match \"^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$\". Make sure you fix this as Composer 2.0 will error.",
|
||||
),
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
return array_merge($invalidNaming, array(
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'name' => 'foo/bar',
|
||||
|
@ -397,30 +432,6 @@ class ValidatingArrayLoaderTest extends TestCase
|
|||
'homepage : invalid value (foo:bar), must be an http/https URL',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'foo/bar.json',
|
||||
),
|
||||
array(
|
||||
'Deprecation warning: Your package name foo/bar.json is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead. Make sure you fix this as Composer 2.0 will error.',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'com1/foo',
|
||||
),
|
||||
array(
|
||||
'Deprecation warning: Your package name com1/foo is reserved, package and vendor names can not match any of: nul, con, prn, aux, com1, com2, com3, com4, com5, com6, com7, com8, com9, lpt1, lpt2, lpt3, lpt4, lpt5, lpt6, lpt7, lpt8, lpt9. Make sure you fix this as Composer 2.0 will error.',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'Foo/Bar',
|
||||
),
|
||||
array(
|
||||
'Deprecation warning: Your package name Foo/Bar is invalid, it should not contain uppercase characters. We suggest using foo/bar instead. Make sure you fix this as Composer 2.0 will error.',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'foo/bar',
|
||||
|
@ -458,18 +469,6 @@ class ValidatingArrayLoaderTest extends TestCase
|
|||
),
|
||||
false,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'foo/bar',
|
||||
'require' => array(
|
||||
'Foo/Baz' => '^1.0',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'Deprecation warning: require.Foo/Baz is invalid, it should not contain uppercase characters. Please use foo/baz instead. Make sure you fix this as Composer 2.0 will error.',
|
||||
),
|
||||
false,
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'name' => 'foo/bar',
|
||||
|
@ -510,6 +509,6 @@ class ValidatingArrayLoaderTest extends TestCase
|
|||
),
|
||||
false,
|
||||
),
|
||||
));
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue