1
0
Fork 0

Add more tests

pull/9912/head
Guilliam Xavier 2021-05-24 14:42:23 +02:00
parent 2d21dd675a
commit 393c9a5946
1 changed files with 28 additions and 0 deletions

View File

@ -176,6 +176,34 @@ class JsonFileTest extends TestCase
}
$this->assertTrue($json->validateSchema(JsonFile::LAX_SCHEMA));
file_put_contents($file, '{ "type": "library" }');
try {
$json->validateSchema();
$this->fail('Expected exception to be thrown (strict)');
} catch (JsonValidationException $e) {
$this->assertEquals($expectedMessage, $e->getMessage());
$errors = $e->getErrors();
$this->assertContains('name : The property name is required', $errors);
$this->assertContains('description : The property description is required', $errors);
}
$this->assertTrue($json->validateSchema(JsonFile::LAX_SCHEMA));
file_put_contents($file, '{ "type": "project" }');
try {
$json->validateSchema();
$this->fail('Expected exception to be thrown (strict)');
} catch (JsonValidationException $e) {
$this->assertEquals($expectedMessage, $e->getMessage());
$errors = $e->getErrors();
$this->assertContains('name : The property name is required', $errors);
$this->assertContains('description : The property description is required', $errors);
}
$this->assertTrue($json->validateSchema(JsonFile::LAX_SCHEMA));
file_put_contents($file, '{ "name": "vendor/package", "description": "generic description" }');
$this->assertTrue($json->validateSchema());
$this->assertTrue($json->validateSchema(JsonFile::LAX_SCHEMA));
unlink($file);
}