function test_number_of_resources_remains_constant_after_skolemise_bnodes() { $graph = new SimpleGraph(file_get_contents(dirname(__FILE__) . '/documents/ckan-ds.ttl')); $index = $graph->get_index(); $before = count($graph->get_subjects()); $graph->skolemise_bnodes('http://example.com/test/'); $after = count($graph->get_subjects()); $this->assertEquals($before, $after, "skolemise_bnodes shouldn't reduce the number of resources"); }
function test_get_subjects() { $g = new SimpleGraph(); $g->add_resource_triple('http://example.org/subj1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://example.org/type_1'); $g->add_resource_triple('http://example.org/subj2', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://example.org/type_2'); $g->add_resource_triple('http://example.org/subj3', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://example.org/type_1'); $g->add_literal_triple('http://example.org/subj4', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://example.org/type_1'); $subjects = $g->get_subjects(); $this->assertEquals(4, count($subjects), 'The returned subjects should be exactly 4'); $this->assertContains('http://example.org/subj1', $subjects, 'subj1 matches and should be returned'); $this->assertContains('http://example.org/subj2', $subjects, 'subj2 matches and should be returned'); $this->assertContains('http://example.org/subj3', $subjects, 'subj3 matches and should be returned'); $this->assertContains('http://example.org/subj4', $subjects, 'subj4 matches and should be returned'); }