Changeset 65 for php/trunk/unittest/rdftestcases/unittest.php
- Timestamp:
- Aug 7, 2011, 5:22:38 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
php/trunk/unittest/rdftestcases/unittest.php
r64 r65 32 32 // rune once initializer 33 33 public static function setUpBeforeClass() { 34 35 // create manifest data object 34 36 self::$manifest = new RDFTestCasesManifest; 37 35 38 } 36 39 … … 57 60 // helper: write input and output data to new output 58 61 // directory for manual examination 59 private function _writeErrorData( $testcase, 60 $source, $sourceuri, 61 $result, $resulturi) { 62 if (!is_dir( $testcase)) 63 mkdir( $testcase, NULL, true); 64 65 $orgsource = file_get_contents( $sourceuri); 66 file_put_contents ( "$testcase/org_source.txt" , $orgsource); 67 68 $orgresult = file_get_contents( $resulturi); 69 file_put_contents ( "$testcase/org_result.txt" , $orgresult); 70 71 file_put_contents ( "$testcase/parsed_source.txt" , $source); 72 file_put_contents ( "$testcase/parsed_result.txt" , $result); 62 private function _writeErrorData( $testcase, $source, $result) { 63 if (!is_dir( $testcase->name)) 64 mkdir( $testcase->name, NULL, true); 65 66 $orgsource = file_get_contents( $testcase->input); 67 file_put_contents ( $testcase->name."/org_source.txt" , $orgsource); 68 69 $orgresult = file_get_contents( $testcase->output); 70 file_put_contents ( $testcase->name."/org_result.txt" , $orgresult); 71 72 file_put_contents ( $testcase->name."/parsed_source.txt" , $source); 73 file_put_contents ( $testcase->name."/parsed_result.txt" , $result); 73 74 } 74 75 … … 85 86 } // private function _getSerializedData 86 87 88 // -------------------------------------------------------- 89 90 public function _executePositiveParserTest( $testcase) { 91 92 // read source data 93 $source = $this->_getSerializedData( $testcase->input); 94 $this->assertEquals( ($source !== false), true); 95 96 // read target data 97 $result = $this->_getSerializedData( $testcase->output); 98 $this->assertEquals( ($result !== false), true); 99 100 // resolve problems with blnak node identifiers 101 // and different sorting of triples 102 $source = $this->_refineResult( $source); 103 $result = $this->_refineResult( $result); 104 105 // check if results are equal 106 $success = ($source == $result); 107 108 // in case of error, write serialized data to subdirectory 109 if (!$success) 110 $this->_writeErrorData( $testcase, 111 $source, 112 $result); 113 114 // compare source and target data 115 $this->assertEquals( $success, true); 116 117 } // public function test_parse_sparql() 118 87 119 88 120 // -------------------------------------------------------- … … 90 122 public function test() { 91 123 92 $ type= trim( getenv( 'CATEGORY'));93 if ($ type== '')94 $ types = self::$manifest->getCategories();124 $category = trim( getenv( 'CATEGORY')); 125 if ($category == '') 126 $categories = self::$manifest->getCategories(); 95 127 else 96 $ types = array( $type);97 98 foreach ($types as $type) {99 echo "\nExecuting RDF Test Cases of category: $type\n\n";100 101 $testcases = self::$manifest->getParserTests( $type);102 128 $categories = array( $type); 129 130 // run test 131 // NOTE: all assertions are made in the specific test routine 132 foreach ($categories as $category) { 133 echo "\nExecuting RDF Test Cases of category: $category\n\n"; 134 $testcases = self::$manifest->getParserTests( $category); 103 135 foreach ($testcases as $testcase) { 104 echo " Executing: " . $testcase->name . "\n"; 105 $this->assertEquals( 0, 0); 136 137 echo " Executing: " . $testcase->name . "\n"; 138 switch ($category) { 139 case 'PositiveParserTest': 140 $result = $this->_executePositiveParserTest( $testcase); 141 break; 142 } // switch ($category) 106 143 } 107 144 } … … 156 193 echo 'Input: ' . $testcase->input . "\n"; 157 194 echo 'Output: ' . $testcase->output . "\n"; 158 echo 'Conclu ision: ' . $testcase->conclusion . "\n";195 echo 'Conclusion: ' . $testcase->conclusion . "\n"; 159 196 } 160 197 }
Note:
See TracChangeset
for help on using the changeset viewer.