1 | <?PHP
|
---|
2 |
|
---|
3 | /* RDFInt.php - RDF Interfaces for PHP
|
---|
4 | * Copyright 2011 netlabs.org
|
---|
5 | * Author: Christian Langanke, Adrian Gschwend
|
---|
6 | *
|
---|
7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
8 | * you may not use this file except in compliance with the License.
|
---|
9 | * You may obtain a copy of the License at
|
---|
10 | *
|
---|
11 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
12 | *
|
---|
13 | * Unless required by applicable law or agreed to in writing, software
|
---|
14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
16 | * See the License for the specific language governing permissions and
|
---|
17 | * limitations under the License.
|
---|
18 | */
|
---|
19 |
|
---|
20 | // load library setup
|
---|
21 | define( 'RDFINT', getenv( 'PHP_LIBROOT_RDFINT'));
|
---|
22 | require_once( RDFINT.'/rdfa.php');
|
---|
23 |
|
---|
24 | class UnitTest extends PHPUnit_Framework_TestCase {
|
---|
25 |
|
---|
26 | static protected $baseuri;
|
---|
27 | private $testcase;
|
---|
28 | const BASEURI = 'http://www.w3.org/2000/10/rdf-tests/rdfcore';
|
---|
29 |
|
---|
30 | // --------------------------------------------------------
|
---|
31 |
|
---|
32 | public static function setUpBeforeClass() {
|
---|
33 | $testcase = trim( getenv( 'TESTCASE'));
|
---|
34 | echo "Executing RDF testcase: $testcase\n\n";
|
---|
35 | }
|
---|
36 |
|
---|
37 | // --------------------------------------------------------
|
---|
38 |
|
---|
39 | protected function setUp() {
|
---|
40 | }
|
---|
41 |
|
---|
42 | // --------------------------------------------------------
|
---|
43 |
|
---|
44 | private function _getSerializedData( $uri) {
|
---|
45 |
|
---|
46 | $rdfaData = new \rdfa\Data();
|
---|
47 | $this->assertInstanceOf( '\rdfa\Data', $rdfaData);
|
---|
48 | $rdfaData->parse( $uri);
|
---|
49 | return $rdfaData->_serialize( 'n3');
|
---|
50 |
|
---|
51 | } // private function _getSerializedData
|
---|
52 |
|
---|
53 | // --------------------------------------------------------
|
---|
54 |
|
---|
55 | public function test() {
|
---|
56 |
|
---|
57 | // get testcase name again in object context
|
---|
58 | $testcase = trim( getenv( 'TESTCASE'));
|
---|
59 | $this->assertGreaterThan( 0, strlen( $testcase));
|
---|
60 |
|
---|
61 | // read source data
|
---|
62 | $source = $this->_getSerializedData( self::BASEURI."/$testcase.rdf");
|
---|
63 | $this->assertEquals( ($source !== false), true);
|
---|
64 |
|
---|
65 | // read target data
|
---|
66 | $result = $this->_getSerializedData( self::BASEURI."/$testcase.nt");
|
---|
67 | $this->assertEquals( ($result !== false), true);
|
---|
68 |
|
---|
69 | // compare source and target data
|
---|
70 | $this->assertEquals( ($source == $result), true);
|
---|
71 |
|
---|
72 |
|
---|
73 | } // public function test_parse_sparql()
|
---|
74 |
|
---|
75 | } // class UnitTest
|
---|
76 |
|
---|
77 |
|
---|