Passed
Branch extract-store (f24e42)
by Konrad
04:37
created

SyntaxUpdate1Test::testTest47()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the sweetrdf/InMemoryStoreSqlite package and licensed under
5
 * the terms of the GPL-3 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 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 SyntaxUpdate1Test extends ComplianceTest
24
{
25
    protected function setUp(): void
26
    {
27
        parent::setUp();
28
29
        $this->w3cTestsFolderPath = __DIR__.'/w3c-tests/syntax-update-1';
30
        $this->testPref = 'http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-update-1/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
            :test_1 rdf:type   mf:PositiveUpdateSyntaxTest11 ;
46
               dawgt:approval dawgt:Approved ;
47
               dawgt:approvedBy <http://www.w3.org/2009/sparql/meeting/2011-04-05#resolution_2> ;
48
               mf:name    "syntax-update-01.ru" ;
49
               mf:action  <syntax-update-01.ru> ;.
50
         */
51
        $query = $this->store->query('
52
            PREFIX mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
53
            SELECT * FROM <'.$this->manifestGraphUri.'> WHERE {
54
                <'.$testUri.'> mf:action ?queryFile .
55
            }
56
        ');
57
58
        return file_get_contents($query['result']['rows'][0]['queryFile']);
59
    }
60
61
    /*
62
     * tests
63
     */
64
65
    /*
66
     * Ignore test_1 because we don't support LOAD <...>
67
     */
68
69
    /*
70
     * Ignore test_2 because we don't support LOAD <...>
71
     */
72
73
    public function testTest41()
74
    {
75
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
76
        $query = $this->getTestQuery($this->testPref.'test_41');
77
78
        // fire query
79
        $result = $this->store->query($query);
80
81
        // check result
82
        $this->assertEquals(0, $result);
83
    }
84
85
    public function testTest42()
86
    {
87
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
88
        $query = $this->getTestQuery($this->testPref.'test_42');
89
90
        // fire query
91
        $result = $this->store->query($query);
92
93
        // check result
94
        $this->assertEquals(0, $result);
95
    }
96
97
    public function testTest43()
98
    {
99
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
100
        $query = $this->getTestQuery($this->testPref.'test_43');
101
102
        // fire query
103
        $result = $this->store->query($query);
104
105
        // check result
106
        $this->assertEquals(0, $result);
107
    }
108
109
    public function testTest44()
110
    {
111
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
112
        $query = $this->getTestQuery($this->testPref.'test_44');
113
114
        // fire query
115
        $result = $this->store->query($query);
116
117
        // check result
118
        $this->assertEquals(0, $result);
119
    }
120
121
    public function testTest45()
122
    {
123
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
124
        $query = $this->getTestQuery($this->testPref.'test_45');
125
126
        // fire query
127
        $result = $this->store->query($query);
128
129
        // check result
130
        $this->assertEquals(0, $result);
131
    }
132
133
    public function testTest46()
134
    {
135
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
136
        $query = $this->getTestQuery($this->testPref.'test_46');
137
138
        // fire query
139
        $result = $this->store->query($query);
140
141
        // check result
142
        $this->assertEquals(0, $result);
143
    }
144
145
    public function testTest47()
146
    {
147
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
148
        $query = $this->getTestQuery($this->testPref.'test_47');
149
150
        // fire query
151
        $result = $this->store->query($query);
152
153
        // check result
154
        $this->assertEquals(0, $result);
155
    }
156
157
    public function testTest48()
158
    {
159
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
160
        $query = $this->getTestQuery($this->testPref.'test_48');
161
162
        // fire query
163
        $result = $this->store->query($query);
164
165
        // check result
166
        $this->assertEquals(0, $result);
167
    }
168
169
    public function testTest49()
170
    {
171
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
172
        $query = $this->getTestQuery($this->testPref.'test_49');
173
174
        // fire query
175
        $result = $this->store->query($query);
176
177
        // check result
178
        $this->assertEquals(0, $result);
179
    }
180
181
    public function testTest50()
182
    {
183
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
184
        $query = $this->getTestQuery($this->testPref.'test_50');
185
186
        // fire query
187
        $result = $this->store->query($query);
188
189
        // check result
190
        $this->assertEquals(0, $result);
191
    }
192
193
    public function testTest51()
194
    {
195
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
196
        $query = $this->getTestQuery($this->testPref.'test_51');
197
198
        // fire query
199
        $result = $this->store->query($query);
200
201
        // check current reaction of the store, for compatibility reasons
202
        $this->assertTrue(\is_array($result));
203
204
        // check result
205
        $this->markTestSkipped(
206
            'Query has to fail, but store returns an array as if query is considered valid. Query: '
207
            .\PHP_EOL
208
            .$this->makeQueryA1Liner($query)
209
        );
210
    }
211
212
    public function testTest52()
213
    {
214
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
215
        $query = $this->getTestQuery($this->testPref.'test_52');
216
217
        // fire query
218
        $result = $this->store->query($query);
219
220
        // check result
221
        $this->assertEquals(0, $result);
222
    }
223
224
    public function testTest54()
225
    {
226
        $this->loadManifestFileIntoStore($this->w3cTestsFolderPath);
227
        $query = $this->getTestQuery($this->testPref.'test_54');
228
229
        // fire query
230
        $result = $this->store->query($query);
231
232
        // check result
233
        $this->assertEquals(0, $result);
234
    }
235
}
236