Example #1
0
 public function testAddTripodArrayWhenAddingViews()
 {
     // view contains 4 subgraphs
     $view = json_decode(file_get_contents(dirname(__FILE__) . "/data/view.json"), true);
     $g = new \Tripod\Mongo\MongoGraph();
     $g->add_tripod_array($view);
     // graph should contain 4 subgraphs
     $this->assertEquals(4, count($g->get_subjects()));
     // assert each subgraph
     $this->assertHasLiteralTriple($g, 'http://example.com/resources/1', $g->qname_to_uri("dct:date"), "2003");
     $this->assertHasLiteralTriple($g, 'http://example.com/resources/1', $g->qname_to_uri("dct:title"), "Material cultures: why some things matter");
     $this->assertHasLiteralTriple($g, 'http://example.com/resources/1', $g->qname_to_uri("bibo:isbn10"), "1857286863");
     $this->assertHasLiteralTriple($g, 'http://example.com/resources/1', $g->qname_to_uri("bibo:volume"), "Consumption and space");
     $this->assertHasResourceTriple($g, 'http://example.com/resources/1', $g->qname_to_uri("dct:publisher"), "http://example.com/organisations/1");
     $this->assertHasResourceTriple($g, 'http://example.com/resources/1', $g->qname_to_uri("dct:source"), "http://example.com/catalog/542114");
     $this->assertHasResourceTriple($g, 'http://example.com/resources/1', $g->qname_to_uri("bibo:authorList"), "http://example.com/resources/1/authors");
     $this->assertHasResourceTriple($g, 'http://example.com/resources/1', $g->qname_to_uri("rdf:type"), "http://purl.org/ontology/bibo/Book");
     $this->assertHasLiteralTriple($g, 'http://example.com/people/1', $g->qname_to_uri("foaf:name"), "Miller, Daniel");
     $this->assertHasResourceTriple($g, 'http://example.com/people/1', $g->qname_to_uri("rdf:type"), "http://xmlns.com/foaf/0.1/Person");
     $this->assertHasLiteralTriple($g, 'http://example.com/organisations/1', $g->qname_to_uri("foaf:name"), "Routledge");
     $this->assertHasResourceTriple($g, 'http://example.com/organisations/1', $g->qname_to_uri("rdf:type"), "http://xmlns.com/foaf/0.1/Organization");
     $this->assertHasResourceTriple($g, 'http://example.com/resources/1/authors', $g->qname_to_uri("rdf:_1"), "http://example.com/people/1");
     $this->assertHasResourceTriple($g, 'http://example.com/resources/1/authors', $g->qname_to_uri("rdf:type"), "http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq");
 }