1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 08:32:56 +00:00

Allow optional name and description fields for project type

This commit is contained in:
BoShurik 2021-03-16 15:33:49 +03:00
parent b6826f3523
commit cc55b56dd7
3 changed files with 40 additions and 4 deletions

View file

@ -41,18 +41,35 @@ class ComposerSchemaTest extends TestCase
{
$json = '{ }';
$result = $this->check($json);
$this->assertContains(array('property' => 'name', 'message' => 'The property name is required', 'constraint' => 'required'), $result);
$this->assertContains(array('property' => 'description', 'message' => 'The property description is required', 'constraint' => 'required'), $result);
$this->assertContains(array('property' => 'type', 'message' => 'The property type is required', 'constraint' => 'required'), $result);
$json = '{ "name": "vendor/package" }';
$this->assertEquals(array(
array('property' => 'type', 'message' => 'The property type is required', 'constraint' => 'required'),
array('property' => 'description', 'message' => 'The property description is required', 'constraint' => 'required'),
array('property' => '', 'message' => 'Failed to match exactly one schema', 'constraint' => 'oneOf'),
), $this->check($json));
$json = '{ "description": "generic description" }';
$this->assertEquals(array(
array('property' => 'type', 'message' => 'The property type is required', 'constraint' => 'required'),
array('property' => 'name', 'message' => 'The property name is required', 'constraint' => 'required'),
array('property' => '', 'message' => 'Failed to match exactly one schema', 'constraint' => 'oneOf'),
), $this->check($json));
$json = '{ "type": "library" }';
$this->assertEquals(array(
array('property' => 'type', 'message' => 'Does not have a value in the enumeration ["project"]', 'constraint' => 'enum', 'enum' => array('project')),
array('property' => 'name', 'message' => 'The property name is required', 'constraint' => 'required'),
array('property' => 'description', 'message' => 'The property description is required', 'constraint' => 'required'),
array('property' => '', 'message' => 'Failed to match exactly one schema', 'constraint' => 'oneOf'),
), $this->check($json));
$json = '{ "type": "project" }';
$this->assertTrue($this->check($json));
$json = '{ "name": "vendor/package", "description": "description" }';
$this->assertTrue($this->check($json));
}
public function testOptionalAbandonedProperty()