/** * @covers Validator::validate * @covers Validator::errors * @covers BasicEvaluation::evaluate */ public function testError() { $xml = $this->loadXml('syntax-error'); $validator = new Validator(); $validator->addEvaluation(new SyntaxEvaluation()); $this->assertFalse($validator->validate($xml)); $this->assertArrayHasKey(0, $validator->errors()); }
/** * @covers Validator::validate * @covers Validator::errors * @covers MatchValueEvaluation::evaluate */ public function testSuccessInValues() { $xml = $this->loadXml('match-value'); $validator = new Validator(); $columns = ['value' => ['ok1', 'ok2', 'ok'], 'nest.value' => ['ok', 'ok2', 'ok3']]; $validator->addEvaluation(new MatchValueEvaluation($columns)); $this->assertTrue($validator->validate($xml)); $this->assertEmpty($validator->errors()); }
/** * @covers Validator::validate * @covers Validator::errors * @covers PropertyExistsEvaluation::evaluate */ public function testNestingNotExistsColumns() { $xml = $this->loadXml('property-exists'); $validator = new Validator(); $columns = ['nest.not']; $validator->addEvaluation(new PropertyExistsEvaluation($columns)); $this->assertFalse($validator->validate($xml)); $this->assertNotEmpty($validator->errors()); }
/** * @covers Validator::validate * @covers Validator::errors * @covers RequiredEvaluation::evaluate */ public function testNestingEmptyData() { $xml = $this->loadXml('required'); $validator = new Validator(); $columns = ['nest.required1', 'nest.required2', 'nest.required3', 'nest.required4', 'nest.required5']; $validator->addEvaluation(new RequiredEvaluation($columns)); $this->assertFalse($validator->validate($xml)); $this->assertNotEmpty($validator->errors()); }