public function validate(array $data)
{
$loader = new YamlLoader();
$schemaContent = $loader->loadFromFile(__DIR__ . '/../definitionSchema.yml');
$schema = new MetaYaml($schemaContent);
try {
$schema->validate($data);
} catch (\Exception $e) {
throw new \LogicException($e->getMessage(), $e->getCode(), $e);
}
}
public function testValidate() { $fileContent = file_get_contents(__DIR__ . '/../crud.yml'); $validDefinition = Yaml::parse($fileContent); $validator = new EntityDefinitionValidator(); $validator->validate($validDefinition); try { $validator->validate(['foo' => 'bar']); $this->fail(); } catch (\LogicException $e) { // Expected } catch (\Exception $e) { $this->fail(); } }