Changeset 56 for php/trunk/unittest


Ignore:
Timestamp:
Jul 17, 2011, 7:54:35 PM (14 years ago)
Author:
cla
Message:

rdfint

  • added export or original and parsed data of failing unittests related to W3C 'RDF Test Cases'

(Finding: failing 'positive parser tests' cannot be properly compared by current unittest code:
blank nodes have different identifiers, so the string compare will always fail.
Except for 'xml-canon/test001', all other test cases do not fail with ARC2!)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • php/trunk/unittest/rdftestcases/unittest.php

    r27 r56  
    4242  // --------------------------------------------------------
    4343
     44  private function _writeErrorData( $testcase,
     45                                    $source, $sourceuri,
     46                                    $result, $resulturi) {
     47    if (!is_dir( $testcase))
     48      mkdir( $testcase, NULL, true);
     49
     50    $orgsource = file_get_contents( $sourceuri);
     51    file_put_contents ( "$testcase/org_source.txt" , $orgsource);
     52
     53    $orgresult = file_get_contents( $resulturi);
     54    file_put_contents ( "$testcase/org_result.txt" , $orgresult);
     55
     56    file_put_contents ( "$testcase/parsed_source.txt" , $source);
     57    file_put_contents ( "$testcase/parsed_result.txt" , $result);
     58  }
     59
     60  // --------------------------------------------------------
     61
    4462  private function _getSerializedData( $uri) {
    4563
     
    6078
    6179    // read source data
    62     $source = $this->_getSerializedData( self::BASEURI."/$testcase.rdf");
     80    $sourceuri = self::BASEURI."/$testcase.rdf";
     81    $source = $this->_getSerializedData( $sourceuri);
    6382    $this->assertEquals( ($source !== false), true);
    6483
    6584    // read target data
    66     $result = $this->_getSerializedData( self::BASEURI."/$testcase.nt");
     85    $resulturi = self::BASEURI."/$testcase.nt";
     86    $result = $this->_getSerializedData( $resulturi);
    6787    $this->assertEquals( ($result !== false), true);
    6888
     89    // check if results are equal
     90    $success = ($source == $result);
     91
     92    // in case of error, write serialized data to subdirectory
     93    if (!$success)
     94      $this->_writeErrorData( $testcase,
     95                              $source, $sourceuri,
     96                              $result, $resulturi);
     97
    6998    // compare source and target data
    70     $this->assertEquals( ($source == $result), true);
     99    $this->assertEquals( $success, true);
    71100
    72101
Note: See TracChangeset for help on using the changeset viewer.