Skip to content

Commit 7ba5139

Browse files
committed
test: removed obsolete DropTest::createGraph; added exploit for #114
1 parent 2187ee9 commit 7ba5139

File tree

2 files changed

+21
-48
lines changed

2 files changed

+21
-48
lines changed

tests/db_adapter_depended/sparql_1_1_tests/DropTest.php

-48
Original file line numberDiff line numberDiff line change
@@ -19,51 +19,6 @@ public function setUp()
1919
$this->testPref = 'http://www.w3.org/2009/sparql/docs/tests/data-sparql11/drop/manifest#';
2020
}
2121

22-
/**
23-
* @param string $graphUri
24-
* @todo Check that $graphUri is a valid URI
25-
* @todo port this functionality to ARC2_Store->query
26-
*/
27-
protected function createGraph($graphUri)
28-
{
29-
// g2t table
30-
if (isset($this->dbConfig['db_table_prefix'])) {
31-
$g2t = $this->dbConfig['db_table_prefix'] . '_';
32-
} else {
33-
$g2t = '';
34-
}
35-
if (isset($this->dbConfig['store_name'])) {
36-
$g2t .= $this->dbConfig['store_name'] . '_';
37-
}
38-
$g2t .= 'g2t';
39-
40-
// id2val table
41-
if (isset($this->dbConfig['db_table_prefix'])) {
42-
$id2val = $this->dbConfig['db_table_prefix'] . '_';
43-
} else {
44-
$id2val = '';
45-
}
46-
if (isset($this->dbConfig['store_name'])) {
47-
$id2val .= $this->dbConfig['store_name'] . '_';
48-
}
49-
$id2val .= 'id2val';
50-
51-
/*
52-
* for id2val table
53-
*/
54-
$query = 'INSERT INTO '. $id2val .' (val) VALUES("'. $graphUri .'")';
55-
$this->store->getDBObject()->simpleQuery($query);
56-
$usedId = $this->store->getDBObject()->getLastInsertId();
57-
58-
/*
59-
* for g2t table
60-
*/
61-
$newIdg2t = 1 + $this->getRowCount($g2t);
62-
$query = 'INSERT INTO '. $g2t .' (t, g) VALUES('. $newIdg2t .', '. $usedId .')';
63-
$this->store->getDBObject()->simpleQuery($query);
64-
$usedId = $this->store->getDBObject()->getLastInsertId();
65-
}
66-
6722
/**
6823
* Helper function to get test query for a given test.
6924
*
@@ -100,9 +55,6 @@ public function test_delete_graph()
10055
{
10156
$graphUri = 'http://example.org/g1';
10257

103-
// create graph
104-
$this->createGraph($graphUri);
105-
10658
$this->store->query('INSERT INTO <'.$graphUri.'> {
10759
<http://example.org/g1> <http://example.org/name> "G1" ;
10860
<http://example.org/description> "Graph 1" .

tests/db_adapter_depended/store/ARC2_StoreTest.php

+21
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,27 @@ public function testInsertSaftRegressionTest3()
557557
$this->assertEquals(1, count($res['result']['rows']));
558558
}
559559

560+
public function testMultipleInsertQuerysInDifferentGraphs()
561+
{
562+
$this->fixture->query('INSERT INTO <http://graph1/> {<http://foo/1> <http://foo/2> <http://foo/3> . }');
563+
$this->fixture->query('INSERT INTO <http://graph2/> {<http://foo/4> <http://foo/5> <http://foo/6> . }');
564+
$this->fixture->query('INSERT INTO <http://graph2/> {<http://foo/1> <http://foo/2> <http://foo/3> . }');
565+
566+
$res = $this->fixture->query('SELECT * FROM <http://graph1/> WHERE {?s ?p ?o.}');
567+
$this->assertEquals(1, count($res['result']['rows']));
568+
569+
$res = $this->fixture->query('SELECT * FROM <http://graph2/> WHERE {?s ?p ?o.}');
570+
$this->assertEquals(1, count($res['result']['rows']));
571+
572+
$res = $this->fixture->query('SELECT * WHERE {?s ?p ?o.}');
573+
$this->assertEquals(3, count($res['result']['rows']));
574+
575+
$this->markTestSkipped(
576+
'Adding the same triple into two graphs does not work.'
577+
. PHP_EOL . 'Bug report: https://github.com/semsol/arc2/issues/114'
578+
);
579+
}
580+
560581
/*
561582
* Tests for logQuery
562583
*/

0 commit comments

Comments
 (0)