Fix schema minimum-stability pattern

main
Guilliam Xavier 3 years ago committed by Jordi Boggiano
parent 251b852fd2
commit 8d8842eb8c
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC

@ -41,7 +41,7 @@ To achieve this, you need to acquire the Composer source code:
2. Download the [`composer.phar`](https://getcomposer.org/composer.phar) executable
3. Run Composer to get the dependencies: `cd composer && php ../composer.phar install`
You can run the test suite by executing `vendor/bin/phpunit` when inside the
You can run the test suite by executing `vendor/bin/simple-phpunit` when inside the
composer directory, and run Composer by executing the `bin/composer`. To test
your modified Composer code against another project, run `php
/path/to/composer/bin/composer` inside that project's directory.

@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft-04/schema#",
"name": "Package",
"title": "Package",
"type": "object",
"additionalProperties": false,
"required": [ "name", "description" ],
@ -42,7 +42,7 @@
"version": {
"type": "string",
"description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.",
"pattern": "^v?\\d+(((\\.\\d+)?\\.\\d+)?\\.\\d+)?|^dev-"
"pattern": "^v?\\d+(\\.\\d+){0,3}|^dev-"
},
"time": {
"type": "string",
@ -397,7 +397,7 @@
"minimum-stability": {
"type": ["string"],
"description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
"pattern": "^dev|alpha|beta|rc|RC|stable$"
"enum": ["dev", "alpha", "beta", "rc", "RC", "stable"]
},
"prefer-stable": {
"type": ["boolean"],

@ -71,25 +71,23 @@ class ComposerSchemaTest extends TestCase
public function testMinimumStabilityValues()
{
$json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "" }';
$this->assertEquals(array(
$expectedError = array(
array(
'property' => 'minimum-stability',
'message' => 'Does not match the regex pattern ^dev|alpha|beta|rc|RC|stable$',
'constraint' => 'pattern',
'pattern' => '^dev|alpha|beta|rc|RC|stable$',
'message' => 'Does not have a value in the enumeration ["dev","alpha","beta","rc","RC","stable"]',
'constraint' => 'enum',
'enum' => array('dev', 'alpha', 'beta', 'rc', 'RC', 'stable'),
),
), $this->check($json), 'empty string');
);
$json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "" }';
$this->assertEquals($expectedError, $this->check($json), 'empty string');
$json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "dummy" }';
$this->assertEquals(array(
array(
'property' => 'minimum-stability',
'message' => 'Does not match the regex pattern ^dev|alpha|beta|rc|RC|stable$',
'constraint' => 'pattern',
'pattern' => '^dev|alpha|beta|rc|RC|stable$',
),
), $this->check($json), 'dummy');
$this->assertEquals($expectedError, $this->check($json), 'dummy');
$json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "devz" }';
$this->assertEquals($expectedError, $this->check($json), 'devz');
$json = '{ "name": "vendor/package", "description": "generic description", "minimum-stability": "dev" }';
$this->assertTrue($this->check($json), 'dev');

Loading…
Cancel
Save