/**
  * Loop trough the jena infmodel tests
  */
 function testInfModelFModel()
 {
     $testURI = 'http://www.hpl.hp.com/semweb/2003/query_tester#';
     $testmodel = new MemModel($testURI);
     $testmodel->load(RDFS_INF_TESTFILES . 'rdfs/manifest-standard.rdf');
     $i = 1;
     do {
         $inf = new InfModelF();
         $res1 = $testmodel->find(new Resource(RDFS_INF_TESTFILES . 'rdfs/test' . $i++), null, null);
         if ($res1->isEmpty()) {
             break;
         }
         $findTBOX = $res1->find(null, new Resource($testURI . 'tbox'), null);
         $inf->load(RDFS_INF_TESTFILES . $findTBOX->triples[0]->getLabelObject());
         $findDATA = $res1->find(null, new Resource($testURI . 'data'), null);
         $inf->load(RDFS_INF_TESTFILES . $findDATA->triples[0]->getLabelObject());
         $findQUERY = $res1->find(null, new Resource($testURI . 'query'), null);
         $query = $this->_doFindFromFile(RDFS_INF_TESTFILES . $findQUERY->triples[0]->getLabelObject(), $inf);
         $result = new MemModel();
         $findRESULT = $res1->find(null, new Resource($testURI . 'result'), null);
         $result->load(RDFS_INF_TESTFILES . $findRESULT->triples[0]->getLabelObject());
         $isEqual = $result->equals($query);
         $findDATA = $res1->find(null, new Resource($testURI . 'description'), null);
         echo '<b>' . $findDATA->triples[0]->getLabelObject() . ' (InfModelF)</b><BR>';
         $this->assertTrue($isEqual);
     } while (true);
 }
 /**
  * generates a test model containing given number of statements
  * and given indextype.
  *
  * @return Object MemModel $model
  * @param  int $num 
  * @param  int $des
  * @param  int $ind
  * @param  Object MemModel $needle
  */
 function _generateModel($num, $des, $ind, $needle)
 {
     $model = new InfModelF();
     // generate Subjects
     for ($i = 0; $i < $num; $i++) {
         $subs[$i] = new Resource('http://www.example.org/Subject' . $i % 6);
     }
     // generate Predicates
     for ($i = 0; $i < $num; $i++) {
         $preds[$i] = new Resource('http://www.example.org/Predicate' . $i % 7);
     }
     // generate Objects
     for ($i = 0; $i < $num; $i++) {
         $objs[$i] = new Resource('http://www.example.org/Object' . $i % 5);
     }
     for ($i = 0; $i < $num; $i++) {
         $model->add(new Statement($subs[$i], $preds[$i], $objs[$i]));
     }
     $model->index($ind);
     return $model;
 }
 function _generateModelLiteral($stats, $ind)
 {
     $model = new InfModelF();
     $model->index($ind);
     for ($i = 0; $i < $stats; $i++) {
         $subs[$i] = new Resource('http://www.example.org/sub' . $i % 3);
         $preds[$i] = new Resource('http://www.example.org/pred' . $i % 5);
         $objs[$i] = new Literal('http://www.example.org/obj' . $i % 9);
         $objs[$i]->setDatatype('test');
     }
     for ($i = 0; $i < $stats; $i++) {
         $model->add(new Statement($subs[$i], $preds[$i], $objs[$i]));
     }
     return $model;
 }
    /**
     * 
     */
    function test1()
    {
        $inf = new InfModelF('http://myInfModelF.com');
        $result = new MemModel();
        $parser = new N3Parser();
        $inf->addModel($parser->parse2model('
		<http://example.org/baz1> <http://example.org/bat> <http://example.org/baz2> .
		<http://example.org/bat> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://example.org/bas> .
		'));
        $result->addModel($parser->parse2model('
		@prefix ns0: <http://example.org/> .
		@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
		ns0:baz1 ns0:bas ns0:baz2 ; ns0:bat ns0:baz2 .
		ns0:bat rdfs:subPropertyOf ns0:bas .
		'));
        $this->assertTrue($inf->equals($result));
        //next test
        $inf->add(new Statement(new Resource('http://example.org/bat'), new Resource('http://www.w3.org/2000/01/rdf-schema#domain'), new Resource('http://example.org/Domain1')));
        $inf->add(new Statement(new Resource('http://example.org/bat'), new Resource('http://www.w3.org/2000/01/rdf-schema#range'), new Resource('http://example.org/Range1')));
        $result = new MemModel();
        $result->addModel($parser->parse2model('
			@prefix ns0: <http://example.org/> .
			@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
			@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
			ns0:baz1 ns0:bas ns0:baz2 ; ns0:bat ns0:baz2 ; a ns0:Domain1 .
			ns0:bat rdfs:domain ns0:Domain1 ; rdfs:range ns0:Range1 ; rdfs:subPropertyOf ns0:bas .
			ns0:baz2 a ns0:Range1 .
		'));
        $this->assertTrue($inf->equals($result));
        // next test
        $inf->add(new Statement(new Resource('http://example.org/bas'), new Resource('http://www.w3.org/2000/01/rdf-schema#domain'), new Resource('http://example.org/Domain2')));
        $inf->add(new Statement(new Resource('http://example.org/bas'), new Resource('http://www.w3.org/2000/01/rdf-schema#range'), new Resource('http://example.org/Range2')));
        $result = new MemModel();
        $result->addModel($parser->parse2model('
		@prefix ns0: <http://example.org/> .
		@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
		@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
		ns0:baz1 ns0:bas ns0:baz2 ; ns0:bat ns0:baz2 ; a ns0:Domain1 ,  ns0:Domain2 .
		ns0:bat rdfs:domain ns0:Domain1 ; rdfs:range ns0:Range1 ; rdfs:subPropertyOf ns0:bas .
		ns0:bas rdfs:domain ns0:Domain2 ; rdfs:range ns0:Range2 .
		ns0:baz2 a ns0:Range1 ,  ns0:Range2 .
		'));
        $this->assertTrue($inf->equals($result));
        //next test
        $inf->add(new Statement(new Resource('http://example.org/Domain2'), new Resource('http://www.w3.org/2000/01/rdf-schema#subClassOf'), new Resource('http://example.org/Domain3')));
        $inf->add(new Statement(new Resource('http://example.org/Domain3'), new Resource('http://www.w3.org/2000/01/rdf-schema#subClassOf'), new Resource('http://example.org/Domain2')));
        $result = new MemModel();
        $result->addModel($parser->parse2model('
		@prefix ns0: <http://example.org/> .
		@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
		@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
		ns0:baz1 ns0:bas ns0:baz2 ; ns0:bat ns0:baz2 ; a ns0:Domain1 ,  ns0:Domain2 ,  ns0:Domain3 .
		ns0:bat rdfs:domain ns0:Domain1 ; rdfs:range ns0:Range1 ; rdfs:subPropertyOf ns0:bas .
		ns0:bas rdfs:domain ns0:Domain2 ; rdfs:range ns0:Range2 .
		ns0:baz2 a ns0:Range1 ,  ns0:Range2 .
		ns0:Domain3 rdfs:subClassOf ns0:Domain2 .
		ns0:Domain2 rdfs:subClassOf ns0:Domain3 .
		'));
        $this->assertTrue($inf->equals($result));
        //next test
        $inf->add(new Statement(new Resource('http://example.org/Range3'), new Resource('http://www.w3.org/2002/07/owl#sameAs'), new Resource('http://example.org/Range2')));
        $result = new MemModel();
        $result->addModel($parser->parse2model('
		@prefix ns0: <http://example.org/> .
		@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
		@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
		@prefix owl: <http://www.w3.org/2002/07/owl#> .
		ns0:baz1 ns0:bas ns0:baz2 ; ns0:bat ns0:baz2 ; a ns0:Domain1 ,  ns0:Domain2 ,  ns0:Domain3 .
		ns0:baz2 a ns0:Range1 ,  ns0:Range2 ,  ns0:Range3 .
		ns0:bat rdfs:domain ns0:Domain1 ; rdfs:range ns0:Range1 ; rdfs:subPropertyOf ns0:bas .
		ns0:bas rdfs:domain ns0:Domain2 ; rdfs:range ns0:Range2 .
		ns0:Range3 owl:sameAs ns0:Range2 .
		ns0:Domain3 rdfs:subClassOf ns0:Domain2 .
		ns0:Domain2 rdfs:subClassOf ns0:Domain3 .
		'));
        $this->assertTrue($inf->equals($result));
        //next test
        $findResult = $inf->find(new Resource('http://example.org/baz2'), null, null);
        $result = new MemModel();
        $result->addModel($parser->parse2model('
		@prefix ns0: <http://example.org/> .
		@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
		ns0:baz2 a ns0:Range1 ,  ns0:Range2 ,  ns0:Range3 .
		'));
        $this->assertTrue($findResult->equals($result));
        //text test
        $inf->remove(new Statement(new Resource('http://example.org/bat'), new Resource('http://www.w3.org/2000/01/rdf-schema#subPropertyOf'), new Resource('http://example.org/bas')));
        $result = new MemModel();
        $result->addModel($parser->parse2model('
		@prefix ns0: <http://example.org/> .
		@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
		@prefix owl: <http://www.w3.org/2002/07/owl#> .
		@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
		ns0:baz1 ns0:bat ns0:baz2 ; a ns0:Domain1 .
		ns0:bas rdfs:domain ns0:Domain2 ; rdfs:range ns0:Range2 .
		ns0:bat rdfs:domain ns0:Domain1 ; rdfs:range ns0:Range1 .
		ns0:baz2 a ns0:Range1 .
		ns0:Range3 owl:sameAs ns0:Range2 .
		ns0:Domain2 rdfs:subClassOf ns0:Domain3 .
		ns0:Domain3 rdfs:subClassOf ns0:Domain2 .
		'));
        $this->assertTrue($inf->equals($result));
    }