1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the sweetrdf/InMemoryStoreSqlite package and licensed under |
5
|
|
|
* the terms of the GPL-2 license. |
6
|
|
|
* |
7
|
|
|
* (c) Konrad Abicht <[email protected]> |
8
|
|
|
* (c) Benjamin Nowack |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Tests\Integration\Store\InMemoryStoreSqlite\SPARQL11; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Runs tests which are based on W3C tests from https://www.w3.org/2009/sparql/docs/tests/. |
18
|
|
|
* |
19
|
|
|
* Version: 2012-10-23 20:52 (sparql11-test-suite-20121023.tar.gz) |
20
|
|
|
* |
21
|
|
|
* Tests are located in the w3c-tests folder. |
22
|
|
|
*/ |
23
|
|
|
class DropTest extends ComplianceTestCase |
24
|
|
|
{ |
25
|
|
|
protected function setUp(): void |
26
|
|
|
{ |
27
|
|
|
parent::setUp(); |
28
|
|
|
|
29
|
|
|
$this->w3cTestsFolderPath = __DIR__.'/w3c-tests/drop'; |
30
|
|
|
$this->testPref = 'http://www.w3.org/2009/sparql/docs/tests/data-sparql11/drop/manifest#'; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Helper function to get test query for a given test. |
35
|
|
|
* |
36
|
|
|
* @param string $testUri |
37
|
|
|
* |
38
|
|
|
* @return string query to test |
39
|
|
|
*/ |
40
|
|
|
protected function getTestQuery($testUri) |
41
|
|
|
{ |
42
|
|
|
/* |
43
|
|
|
example: |
44
|
|
|
|
45
|
|
|
:group1 mf:action [ |
46
|
|
|
qt:query <group01.rq> |
47
|
|
|
] |
48
|
|
|
*/ |
49
|
|
|
$query = $this->store->query(' |
50
|
|
|
PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> . |
51
|
|
|
PREFIX ut: <http://www.w3.org/2009/sparql/tests/test-update#> . |
52
|
|
|
SELECT * FROM <'.$this->manifestGraphUri.'> WHERE { |
53
|
|
|
<'.$testUri.'> mf:action [ ut:request ?queryFile ] . |
54
|
|
|
} |
55
|
|
|
'); |
56
|
|
|
|
57
|
|
|
return $query['result']['rows'][0]['queryFile']; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/* |
61
|
|
|
* tests |
62
|
|
|
*/ |
63
|
|
|
|
64
|
|
|
// this test is not part of the W3C test collection |
65
|
|
|
// it tests DELETE FROM <...> command which is the store equivalent to DROP GRAPH <...> |
66
|
|
|
public function testDeleteGraph() |
67
|
|
|
{ |
68
|
|
|
$graphUri = 'http://example.org/g1'; |
69
|
|
|
|
70
|
|
|
$this->store->query('INSERT INTO <'.$graphUri.'> { |
71
|
|
|
<http://example.org/g1> <http://example.org/name> "G1" ; |
72
|
|
|
<http://example.org/description> "Graph 1" . |
73
|
|
|
}'); |
74
|
|
|
|
75
|
|
|
// check if graph really contains data |
76
|
|
|
$res = $this->store->query('SELECT * WHERE {?s ?p ?o.}'); |
77
|
|
|
$this->assertTrue(0 < \count($res['result']['rows']), 'No test data in graph found.'); |
78
|
|
|
|
79
|
|
|
// run test query |
80
|
|
|
$res = $this->store->query('DELETE FROM <'.$graphUri.'>'); |
|
|
|
|
81
|
|
|
|
82
|
|
|
// check if test data are still available |
83
|
|
|
$res = $this->store->query('SELECT * FROM <'.$graphUri.'> WHERE {?s ?p ?o.}'); |
84
|
|
|
$this->assertTrue(0 == \count($res['result']['rows'])); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|