<?PHP

/* RDFInt.php - RDF Interfaces for PHP
 * Copyright 2011 netlabs.org
 * Author: Christian Langanke, Adrian Gschwend
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// load unittest setup
require_once( '../unittest_config.php');

class UnitTest extends PHPUnit_Framework_TestCase {

  static protected $baseuri;
  private $testcase;
  const BASEURI = 'http://www.w3.org/2000/10/rdf-tests/rdfcore';

  // --------------------------------------------------------

  public static function setUpBeforeClass() {
    $testcase = trim( getenv( 'TESTCASE'));
    echo "Executing RDF testcase: $testcase\n\n";
  }

  // --------------------------------------------------------

  protected function setUp() {
  }

  // --------------------------------------------------------

  private function _getSerializedData( $uri) {

    $rdfaData = new \rdfa\Data();
    $this->assertInstanceOf( '\rdfa\Data', $rdfaData);
    $rdfaData->parse( $uri);
    return  $rdfaData->serialize( 'n3');

  } // private function _getSerializedData

  // --------------------------------------------------------

  public function test() {

    // get testcase name again in object context
    $testcase = trim( getenv( 'TESTCASE'));
    $this->assertGreaterThan( 0, strlen( $testcase));

    // read source data
    $source = $this->_getSerializedData( self::BASEURI."/$testcase.rdf");
    $this->assertEquals( ($source !== false), true);

    // read target data
    $result = $this->_getSerializedData( self::BASEURI."/$testcase.nt");
    $this->assertEquals( ($result !== false), true);

    // compare source and target data
    $this->assertEquals( ($source == $result), true);


  } // public function test_parse_sparql()

} // class UnitTest


