Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
written more test to cover Store related code
* SELECT queries: * LIMIT and OFFSET * AVG aggregate function (still buggy, but to catch current behavior) * DESCRIBE queries: * DESCRIBE <..> * DESCRIBE ?s WHERE ... * DESCRIBE * WHERE ... * LOAD queries: * LOAD <...> * LOAD <...> INTO <...>
- Loading branch information
Showing
5 changed files
with
329 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
|
||
namespace Tests\integration\store\query; | ||
|
||
use Tests\ARC2_TestCase; | ||
|
||
/** | ||
* Tests for query method - focus on DESCRIBE queries | ||
*/ | ||
class DescribeQueryTest extends ARC2_TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->fixture = \ARC2::getStore($this->dbConfig); | ||
$this->fixture->drop(); | ||
$this->fixture->setup(); | ||
} | ||
|
||
public function testDescribeDefaultGraph() | ||
{ | ||
// test data | ||
$this->fixture->query('INSERT INTO <http://example.com/> { | ||
<http://s> <http://p1> "baz" . | ||
}'); | ||
|
||
$res = $this->fixture->query('DESCRIBE <http://s>'); | ||
$this->assertEquals( | ||
[ | ||
'query_type' => 'describe', | ||
'result' => [ | ||
'http://s' => [ | ||
'http://p1' => [ | ||
[ | ||
'value' => 'baz', | ||
'type' => 'literal' | ||
] | ||
] | ||
] | ||
], | ||
'query_time' => $res['query_time'] | ||
], | ||
$res | ||
); | ||
} | ||
|
||
public function testDescribeWhereDefaultGraph() | ||
{ | ||
// test data | ||
$this->fixture->query('INSERT INTO <http://example.com/> { | ||
<http://s> <http://p1> "baz" . | ||
}'); | ||
|
||
$res = $this->fixture->query('DESCRIBE ?s WHERE {?s ?p "baz".}'); | ||
$this->assertEquals( | ||
[ | ||
'query_type' => 'describe', | ||
'result' => [ | ||
'http://s' => [ | ||
'http://p1' => [ | ||
[ | ||
'value' => 'baz', | ||
'type' => 'literal' | ||
] | ||
] | ||
] | ||
], | ||
'query_time' => $res['query_time'] | ||
], | ||
$res | ||
); | ||
} | ||
|
||
public function testDescribeWhereDefaultGraph2() | ||
{ | ||
// test data | ||
$this->fixture->query('INSERT INTO <http://example.com/> { | ||
<http://s> <http://p1> "baz" . | ||
}'); | ||
|
||
$res = $this->fixture->query('DESCRIBE * WHERE {?s ?p "baz".}'); | ||
$this->assertEquals( | ||
[ | ||
'query_type' => 'describe', | ||
'result' => [ | ||
'http://s' => [ | ||
'http://p1' => [ | ||
[ | ||
'value' => 'baz', | ||
'type' => 'literal' | ||
] | ||
] | ||
] | ||
], | ||
'query_time' => $res['query_time'] | ||
], | ||
$res | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace Tests\integration\store\query; | ||
|
||
use Tests\ARC2_TestCase; | ||
|
||
/** | ||
* Tests for query method - focus on LOAD queries | ||
*/ | ||
class LoadQueryTest extends ARC2_TestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->fixture = \ARC2::getStore($this->dbConfig); | ||
$this->fixture->drop(); | ||
$this->fixture->setup(); | ||
} | ||
|
||
public function testLoad() | ||
{ | ||
// check that store is empty | ||
$res = $this->fixture->query('SELECT * WHERE {?s ?p ?o.}'); | ||
$this->assertEquals(0, count($res['result']['rows'])); | ||
|
||
$filepath = 'https://raw.githubusercontent.com/semsol/arc2/' | ||
.'master/tests/sparql11/w3c-tests/move/manifest.ttl'; | ||
$this->fixture->query('LOAD <'.$filepath.'>'); | ||
|
||
// check that triples were inserted | ||
$res = $this->fixture->query(' | ||
SELECT * | ||
FROM <https://raw.githubusercontent.com/semsol/arc2/' | ||
.'master/tests/sparql11/w3c-tests/move/manifest.ttl> | ||
WHERE {?s ?p ?o.} | ||
'); | ||
$this->assertEquals(106, count($res['result']['rows'])); | ||
} | ||
|
||
public function testLoadInto() | ||
{ | ||
// check that store is empty | ||
$res = $this->fixture->query('SELECT * FROM <http://load-example> WHERE {?s ?p ?o.}'); | ||
$this->assertEquals(0, count($res['result']['rows'])); | ||
|
||
$filepath = 'https://raw.githubusercontent.com/semsol/arc2/' | ||
.'master/tests/sparql11/w3c-tests/move/manifest.ttl'; | ||
$this->fixture->query('LOAD <'.$filepath.'> INTO <http://load-example>'); | ||
|
||
// check that triples were inserted | ||
$res = $this->fixture->query('SELECT * FROM <http://load-example> WHERE {?s ?p ?o.}'); | ||
$this->assertEquals(106, count($res['result']['rows'])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters