コード例 #1
0
ファイル: SyntaxTest.php プロジェクト: Rmtram/XmlValidator
 /**
  * @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());
 }
コード例 #2
0
 /**
  * @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());
 }
コード例 #3
0
 /**
  * @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());
 }
コード例 #4
0
ファイル: RequiredTest.php プロジェクト: Rmtram/XmlValidator
 /**
  * @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());
 }