public function test2()
 {
     print 'Testing all XML/XSD files for well-formedness ' . PHP_EOL;
     foreach ($this->standardExtractionContents->directoryContents->file as $file) {
         $xmlValidationTestProperty = new XMLWellFormedTestProperty(Constants::TEST_XMLTEST_VALIDATION_WELLFORMED);
         $xmlTestWellFormed = new XMLTestWellFormed(Constants::TEST_XMLTEST_VALIDATION_WELLFORMED, $this->directory, $file->filename, $xmlValidationTestProperty);
         $xmlTestWellFormed->runTest();
         $this->testResultsHandler->addResult($xmlValidationTestProperty, Constants::TEST_TYPE_A1);
         print $xmlValidationTestProperty . PHP_EOL;
         $xmlTestWellFormed = null;
     }
     print 'Testing all XML files for validity ' . PHP_EOL;
     foreach ($this->standardExtractionContents->filesToValidate->file as $file) {
         $testProperty = new XMLValidationTestProperty(Constants::TEST_XMLTEST_VALIDATION_VALID);
         $xmlTestValidation = new XMLTestValidation(Constants::TEST_XMLTEST_VALIDATION_VALID, $this->directory, $file->filename, $file->validatedBy, $testProperty);
         $xmlTestValidation->runTest();
         $this->testResultsHandler->addResult($testProperty, Constants::TEST_TYPE_A1);
         print $testProperty . PHP_EOL;
         $xmlTestValidation = null;
     }
 }
} else {
    $filepathDebugLog = $arrRunParameter['log_dir'] . '/' . $filenameDebugLog;
}
// Log debug log filepath
$strDescription = '-- debug log filepath "' . $filepathDebugLog . '"' . PHP_EOL;
$strLine = '';
logLog(0, $strDescription, $strLine, 2);
### Test well-formed
if ($bArrCustom[1]) {
    $thisTestNameWellFormed = 'Well formed test';
    $thisDirectory = $strDatasetDir;
    $thisFilename = $filenameXmlReaderIn;
    $thisXMLWellFormedTestProperty = new XMLWellFormedTestProperty(Constants::TEST_XMLTEST_VALIDATION_WELLFORMED);
    $strTemp = implode('/', array($thisDirectory, $thisFilename));
    print $strTemp . PHP_EOL;
    $thisXMLTestWellFormed = new XMLTestWellFormed($thisTestNameWellFormed, $thisDirectory, $thisFilename, $thisXMLWellFormedTestProperty);
    $thisXMLTestWellFormed->runTest();
    // Log XML Reader in description report
    $strDescription = $thisXMLWellFormedTestProperty->getDescriptionReport() . PHP_EOL;
    $strLine = '';
    logLog(0, $strDescription, $strLine, 2);
    // Log XML Reader in description
    $strDescription = $thisXMLWellFormedTestProperty->getDescription() . PHP_EOL;
    $strLine = '';
    logLog(0, $strDescription, $strLine, 2);
    ## well-formed errors? ##
    $nXmlWellFormedError = count(libxml_get_errors());
    if (0 < $nXmlWellFormedError) {
        // Error: XML not well-formed
        $strDescription = PHP_EOL . '## error: xml file is NOT well-formed, error count = ' . $nXmlWellFormedError . ' ##' . PHP_EOL;
        $strLine = $thisDirectory . '/' . $thisFilename;
Esempio n. 3
0
 public function testA1()
 {
     $this->logger->info('START test A1 : XML files are wellformed and valid');
     try {
         $this->logger->info('  Testing all XML/XSD files for well-formedness');
         foreach ($this->standardExtractionContents->directoryContents->file as $file) {
             $xmlValidationTestProperty = new XMLWellFormedTestProperty(Constants::TEST_XMLTEST_VALIDATION_WELLFORMED);
             $xmlTestWellFormed = new XMLTestWellFormed(Constants::TEST_XMLTEST_VALIDATION_WELLFORMED, $this->directory, $file->filename, $xmlValidationTestProperty);
             $xmlTestWellFormed->runTest();
             if ($xmlValidationTestProperty->getTestResult() == false) {
                 $this->testProperty->setTestResult(false);
             }
             $this->testResultsHandler->addResult($xmlValidationTestProperty, Constants::TEST_TYPE_A1);
             $xmlTestWellFormed = null;
         }
         $this->logger->info('  Testing all XML files for validity');
         foreach ($this->standardExtractionContents->filesToValidate->file as $file) {
             $testProperty = new XMLValidationTestProperty(Constants::TEST_XMLTEST_VALIDATION_VALID);
             $xmlTestValidation = new XMLTestValidation(Constants::TEST_XMLTEST_VALIDATION_VALID, $this->directory, $file->filename, $file->validatedBy, $testProperty);
             $xmlTestValidation->runTest();
             if ($testProperty->getTestResult() == false) {
                 $this->testProperty->setTestResult(false);
             }
             $this->testResultsHandler->addResult($testProperty, Constants::TEST_TYPE_A1);
             $xmlTestValidation = null;
         }
     } catch (Exception $e) {
         $this->logger->error("Error when attempting test A1. The following exception occured " . $e);
     }
     $this->logger->info('END test A1');
     $this->logger->info('');
 }