1<?php
2require_once('stratatest.inc.php');
3
4/**
5 * Tests storage graphs.
6 *
7 * @group plugin_strata_storage
8 * @group plugin_strata
9 * @group plugins
10 */
11class storage_graphs_test extends Strata_UnitTestCase {
12
13	function testGraphs() {
14		$OK = $this->_triples->addTriple('Bob', 'knows', 'Alice', 'knowledgebase of bob');
15		$this->assertTrue($OK);
16		$OK = $this->_triples->addTriple('Alice', 'knows', 'Carol', 'knowledgebase of alice');
17		$this->assertTrue($OK);
18
19		$expected1 = array('subject' => 'Bob', 'predicate' => 'knows', 'object' => 'Alice', 'graph' => 'knowledgebase of bob');
20		$expected2 = array('subject' => 'Alice', 'predicate' => 'knows', 'object' => 'Carol', 'graph' => 'knowledgebase of alice');
21
22		// Retrieve the wiki graph
23		$data = $this->_triples->fetchTriples(null, null, null, 'wiki');
24		$this->assertEquals($data, array());
25
26		// Retrieve Bobs graph
27		$data = $this->_triples->fetchTriples(null, null, null, 'knowledgebase of bob');
28		$this->assertEquals($data, array($expected1));
29
30		// Retrieve Alices graph
31		$data = $this->_triples->fetchTriples(null, null, null, 'knowledgebase of alice');
32		$this->assertEquals($data, array($expected2));
33
34		// Retrieve all graphs
35		$data = $this->_triples->fetchTriples(null, null, null, null);
36		$this->assertEquals($data, array($expected1, $expected2));
37	}
38}
39
40