Skip to content

Commit

Permalink
Merge pull request #1 from byjg/4.0.1
Browse files Browse the repository at this point in the history
Fix travis and update sparql lib
  • Loading branch information
byjg committed Oct 31, 2021
2 parents d17d63c + ef10949 commit 6d7815f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 18 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
language: php

dist: bionic

php:
- "7.2"
- "7.1"
- "7.0"
- "5.6"
- "7.4"
- "7.3"

install:
- php -i
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"require": {
"php": ">=5.6.0",
"byjg/anydataset": "4.0.*",
"byjg/sparqllib": "1.0.*"
"byjg/sparqllib": "2.0.*"
},
"require-dev": {
"phpunit/phpunit": "5.7.*|7.4.*"
Expand Down
4 changes: 2 additions & 2 deletions src/SparQLDataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class SparQLDataset
*/
public function __construct($url, $namespaces = null)
{
$this->connection = new Connection($url);
$this->connection = Connection::get($url);

if (is_array($namespaces)) {
foreach ($namespaces as $key => $value) {
$this->connection->ns($key, $value);
$this->connection->withNamespace($key, $value);
}
}

Expand Down
31 changes: 20 additions & 11 deletions tests/SparQLDatasetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class SparQLDatasetTest extends TestCase
{

const SPARQL_URL = 'http://dbpedia.org/sparql';
const SPARQL_URL = 'https://dbpedia.org/sparql';

protected static $SPARQL_NS = [
'dbo' => 'http://dbpedia.org/ontology/',
Expand Down Expand Up @@ -75,15 +75,24 @@ public function test_navigateSparQLDataset()
);

$this->assertTrue($iterator->hasNext());
$this->assertEquals($iterator->count(), 1);

$sr = $iterator->moveNext();

$this->assertEquals($sr->get("name"), "Garrick");
$this->assertEquals($sr->get("name.type"), "literal");
$this->assertEquals($sr->get("meaning"), "\"spear king\"");
$this->assertEquals($sr->get("meaning.type"), "literal");

$this->assertFalse($iterator->hasNext());
$this->assertEquals(2, $iterator->count());

$this->assertEquals(
[
[
"name" => "Garrick",
"name.type" => "literal",
"meaning" => "\"one who governs with a spear\", \"oak tree grove\"",
"meaning.type" => "literal",
],
[
"name" => "Garrick",
"name.type" => "literal",
"meaning" => "\"spear king\", \"oak tree grove\"",
"meaning.type" => "literal",
]
],
$iterator->toArray()
);
}
}

0 comments on commit 6d7815f

Please sign in to comment.