|
| 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