/**
  * Test if the validation for a XML throws an exception if expected.
  *
  * @return void
  *
  * @expectedException AppserverIo\Configuration\ConfigurationException
  */
 public function testValidateFileWithException()
 {
     $this->configurationUtils->validateFile(__DIR__ . '/_files/META-INF/appserver-03-ds.xml', __DIR__ . '/_files/META-INF/appserver.xsd', true);
 }
Esempio n. 2
0
 /**
  * Will validate a DOM document against a schema file.
  * Will return true if validation passes, false otherwise.
  * A specific schema file to use might be passed as well, if none is given the tester tries to choose the right one
  *
  * @param \DOMDocument $domDocument  DOM document to validate
  * @param string|null  $schemaFile   The specific schema file to validate against (optional)
  * @param boolean      $failOnErrors If the validation should fail on error (optional)
  *
  * @return boolean
  *
  * @throws \AppserverIo\Appserver\Core\Api\InvalidConfigurationException If $failOnErrors is set to true an exception will be thrown on errors
  */
 public function validateXml(\DOMDocument $domDocument, $schemaFile = null, $failOnErrors = false)
 {
     // if we got a specific schema file we will use it, otherwise we will use the one we got globally
     $schemaFileName = $this->schemaFile;
     if (!is_null($schemaFile)) {
         $schemaFileName = $schemaFile;
     }
     // validate the passed DOM document
     ConfigurationUtils::singleton()->validateXml($domDocument, $schemaFileName, $failOnErrors);
     // return TRUE if validation has been successfull
     return true;
 }