Skip to content

Commit 65238a4

Browse files
authored
Merge pull request #142 from ailintom/patch-1
Fixed store/ARC2_StoreEndpoint.php: $this has no property named $store
2 parents 13279b2 + 7709770 commit 65238a4

3 files changed

Lines changed: 71 additions & 4 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ before_script:
158158
# Install composer packages, will also trigger dump-autoload
159159
- travis_retry composer install --no-interaction --prefer-dist
160160
# Install coveralls.phar
161-
- wget -c -nc --retry-connrefused --tries=0 https://github.com/satooshi/php-coveralls/releases/download/v1.1.0/coveralls.phar
161+
- travis_retry wget -c -nc --retry-connrefused --tries=0 https://github.com/satooshi/php-coveralls/releases/download/v1.1.0/coveralls.phar
162162
- chmod +x coveralls.phar
163163
- php coveralls.phar --version
164164

store/ARC2_StoreEndpoint.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,13 @@ public function getSPARQLJSONSelectResultDoc($r)
429429
$r .= ' "'.$var.'": {';
430430
if ('uri' == $row[$var.' type']) {
431431
$r .= $nl.' "type": "uri",';
432-
$r .= $nl.' "value": "'.$this->store->a['db_object']->escape($row[$var]).'"';
432+
$r .= $nl.' "value": "'.$this->a['db_object']->escape($row[$var]).'"';
433433
} elseif ('bnode' == $row[$var.' type']) {
434434
$r .= $nl.' "type": "bnode",';
435435
$r .= $nl.' "value": "'.substr($row[$var], 2).'"';
436436
} else {
437-
$dt = isset($row[$var.' datatype']) ? ','.$nl.' "datatype": "'.$this->store->a['db_object']->escape($row[$var.' datatype']).'"' : '';
438-
$lang = isset($row[$var.' lang']) ? ','.$nl.' "xml:lang": "'.$this->store->a['db_object']->escape($row[$var.' lang']).'"' : '';
437+
$dt = isset($row[$var.' datatype']) ? ','.$nl.' "datatype": "'.$this->a['db_object']->escape($row[$var.' datatype']).'"' : '';
438+
$lang = isset($row[$var.' lang']) ? ','.$nl.' "xml:lang": "'.$this->a['db_object']->escape($row[$var.' lang']).'"' : '';
439439
$type = $dt ? 'typed-literal' : 'literal';
440440
$r .= $nl.' "type": "'.$type.'",';
441441
$r .= $nl.' "value": "'.$this->jsonEscape($row[$var]).'"';
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace Tests\unit\store;
4+
5+
use Tests\ARC2_TestCase;
6+
7+
8+
//Tests ARC2_StoreEndpoint functions
9+
class ARC2_StoreEndpointTest extends ARC2_TestCase
10+
{
11+
12+
public function setUp(): void
13+
{
14+
parent::setUp();
15+
$this->endpoint = \ARC2::getStoreEndpoint($this->dbConfig);
16+
$this->endpoint->createDBCon();
17+
}
18+
public function testJSON()
19+
{
20+
21+
$data = array(
22+
'result' => array(
23+
'variables' => array(
24+
'a',
25+
'b',
26+
'c'
27+
),
28+
'rows' => array(
29+
array(
30+
'a' => 'http://de.dbpedia.org/resource/Johann_von_Pont',
31+
'a type' => 'uri',
32+
'b' => 'http://dbpedia.org/ontology/deathPlace',
33+
'b type' => 'uri',
34+
'c' => 'http://de.dbpedia.org/resource/Aachen',
35+
'c type' => 'uri'
36+
),
37+
array(
38+
'a' => 'http://de.dbpedia.org/resource/Aachen',
39+
'a type' => 'uri',
40+
'b' => 'http://dbpedia.org/ontology/elevation',
41+
'b type' => 'uri',
42+
'c' => '173.0',
43+
'c type' => 'literal',
44+
'c datatype' => 'http://www.w3.org/2001/XMLSchema#double'
45+
),
46+
array(
47+
'a' => 'http://de.dbpedia.org/resource/Aachen',
48+
'a type' => 'uri',
49+
'b' => 'http://dbpedia.org/ontology/leaderTitle',
50+
'b type' => 'uri',
51+
'c' => 'Oberbürgermeister',
52+
'c type' => 'literal',
53+
'c lang' => 'de'
54+
)
55+
)
56+
),
57+
'query_time' => 1
58+
);
59+
$res = json_decode($this->endpoint->getSPARQLJSONSelectResultDoc($data), true);
60+
$this->assertArrayHasKey('head', $res);
61+
$this->assertArrayHasKey('results', $res);
62+
$this->assertEquals($res['head']['vars'][0], 'a');
63+
$this->assertEquals($res['results']['bindings'][0]['a']['value'], 'http://de.dbpedia.org/resource/Johann_von_Pont');
64+
$this->assertEquals($res['results']['bindings'][1]['c']['type'], 'typed-literal');
65+
$this->assertEquals($res['results']['bindings'][2]['c']['type'], 'literal');
66+
}
67+
}

0 commit comments

Comments
 (0)