Skip to content

Commit

Permalink
composer.json: allow both rdfInterface v1 and v2
Browse files Browse the repository at this point in the history
  • Loading branch information
zozlak committed Jul 26, 2023
1 parent d26cb22 commit e49d998
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"ext-pcre": "*",
"ext-xmlreader" : "*",
"zozlak/rdf-constants": "^1.1",
"sweetrdf/rdf-interface": "^1.0.0",
"sweetrdf/rdf-helpers": "^1.0.0",
"sweetrdf/rdf-interface": "^1.0.0 | ^2.0.0-RC1",
"sweetrdf/rdf-helpers": "^1.0.2",
"pietercolpaert/hardf": "*",
"ml/json-ld": "^1.2"
},
Expand All @@ -37,9 +37,9 @@
"phpstan/phpstan": "*",
"php-coveralls/php-coveralls": "^2.4",
"squizlabs/php_codesniffer": "*",
"sweetrdf/quick-rdf": "^1.0.0",
"sweetrdf/quick-rdf": "^2.0.0-RC1",
"sweetrdf/term-templates": "^1.0.0",
"sweetrdf/simple-rdf": "^1.0.0"
"sweetrdf/simple-rdf": "^2.0.0-RC1"
},
"autoload-dev": {
"psr-4": {
Expand Down
31 changes: 15 additions & 16 deletions tests/TestUtilsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@

namespace quickRdfIo;

use rdfInterface\DataFactoryInterface as iDataFactory;
use rdfInterface\QuadInterface as iQuad;
use rdfInterface\BlankNodeInterface as iBlankNode;
use rdfInterface\DatasetInterface as iDataset;
use rdfInterface\ParserInterface as iParser;
use rdfInterface\DatasetMapReduceInterface as iDatasetMapReduce;
use rdfInterface\DataFactoryInterface;
use rdfInterface\QuadInterface;
use rdfInterface\BlankNodeInterface;
use rdfInterface\DatasetInterface;
use rdfInterface\ParserInterface;
use quickRdf\Dataset;

/**
Expand All @@ -41,23 +40,23 @@
*/
trait TestUtilsTrait {

private iDataFactory $df;
private iParser $refParser;
private DataFactoryInterface $df;
private ParserInterface $refParser;

private function unblank(iQuad $quad): iQuad {
private function unblank(QuadInterface $quad): QuadInterface {
$sbj = $quad->getSubject();
if ($sbj instanceof iBlankNode) {
if ($sbj instanceof BlankNodeInterface) {
$quad = $quad->withSubject($this->df->namedNode('bn:' . $sbj->getValue()));
}
$obj = $quad->getObject();
if ($obj instanceof iBlankNode) {
if ($obj instanceof BlankNodeInterface) {
$quad = $quad->withObject($this->df->namedNode('bn:' . $obj->getValue()));
}
return $quad;
}

private function assertDatasetsEqual(iDataset $test, iDataset $ref,
string $msg = ''): void {
private function assertDatasetsEqual(DatasetInterface $test,
DatasetInterface $ref, string $msg = ''): void {
if ($ref->equals($test) === false) {
echo "\n" .
"REF:\n$ref" .
Expand All @@ -69,14 +68,14 @@ private function assertDatasetsEqual(iDataset $test, iDataset $ref,
$this->assertTrue($ref->equals($test), $msg);
}

private function blankGraphAsDefaultGraph(iQuad $q): iQuad {
if ($q->getGraph() instanceof iBlankNode) {
private function blankGraphAsDefaultGraph(QuadInterface $q): QuadInterface {
if ($q->getGraph() instanceof BlankNodeInterface) {
return $q->withGraph($this->df->defaultGraph());
}
return $q;
}

private function parseRef(string $refFile, bool $unblank): iDatasetMapReduce {
private function parseRef(string $refFile, bool $unblank): DatasetInterface {
$refInput = fopen($refFile, 'r') ?: throw new \RuntimeException("Failed to open $refFile");
$ref = new Dataset();
$ref->add($this->refParser->parseStream($refInput));
Expand Down

0 comments on commit e49d998

Please sign in to comment.