Skip to content

Commit 67a9646

Browse files
committed
added a (limited) TermsTest from rdfInterface
1 parent f0d4c78 commit 67a9646

File tree

8 files changed

+83
-25
lines changed

8 files changed

+83
-25
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"require": {
1717
"php": ">=8.0",
18-
"sweetrdf/rdf-interface": "^0.3.1"
18+
"sweetrdf/rdf-interface": "0.*"
1919
},
2020
"require-dev": {
2121
"friendsofphp/php-cs-fixer": "^2.18.1",

src/Rdf/BlankNode.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
use rdfInterface\BlankNode as iBlankNode;
1616
use rdfInterface\Term;
17-
use rdfInterface\TYPE_BLANK_NODE;
1817

1918
class BlankNode implements iBlankNode
2019
{
@@ -41,12 +40,12 @@ public function __toString(): string
4140

4241
public function equals(Term $term): bool
4342
{
44-
return $this === $term;
43+
return $this == $term;
4544
}
4645

4746
public function getType(): string
4847
{
49-
return TYPE_BLANK_NODE;
48+
return \rdfInterface\TYPE_BLANK_NODE;
5049
}
5150

5251
public function getValue(): string

src/Rdf/DataFactory.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* file that was distributed with this source code.
1313
*/
1414

15+
use Exception;
1516
use rdfInterface\BlankNode as iBlankNode;
1617
use rdfInterface\DataFactory as iDataFactory;
1718
use rdfInterface\DefaultGraph as iDefaultGraph;
@@ -35,8 +36,9 @@ public static function namedNode(string | Stringable $iri): iNamedNode
3536
return new NamedNode($iri);
3637
}
3738

38-
public static function defaultGraph(string | Stringable | null $iri = null): iDefaultGraph
39-
{
39+
public static function defaultGraph(
40+
string | Stringable | null $iri = null
41+
): iDefaultGraph {
4042
return new DefaultGraph($iri);
4143
}
4244

@@ -52,7 +54,7 @@ public static function quad(
5254
iTerm $subject,
5355
iNamedNode $predicate,
5456
iTerm $object,
55-
iNamedNode | iBlankNode | null $graphIri = null
57+
iNamedNode | iBlankNode | iDefaultGraph | null $graphIri = null
5658
): iQuad {
5759
return new Quad($subject, $predicate, $object, $graphIri);
5860
}
@@ -61,13 +63,13 @@ public static function quadTemplate(
6163
iTerm | null $subject = null,
6264
iNamedNode | null $predicate = null,
6365
iTerm | null $object = null,
64-
iNamedNode | iBlankNode | null $graphIri = null
66+
iNamedNode | iBlankNode | iDefaultGraph | null $graphIri = null
6567
): iQuadTemplate {
66-
throw new RdfException('quadTemplate is not implemented yet.');
68+
throw new Exception('quadTemplate is not implemented yet.');
6769
}
6870

6971
public static function variable(string | Stringable $name): iVariable
7072
{
71-
throw new RdfException('variable is not implemented yet.');
73+
throw new Exception('variable is not implemented yet.');
7274
}
7375
}

src/Rdf/DefaultGraph.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* file that was distributed with this source code.
1313
*/
1414

15-
use rdfInterface\DefaultGraph;
15+
use rdfInterface\DefaultGraph as iDefaultGraph;
1616
use rdfInterface\Term;
1717
use rdfInterface\TYPE_DEFAULT_GRAPH;
1818
use sweetrdf\InMemoryStoreSqlite\NamespaceHelper;

src/Rdf/Literal.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Exception;
1616
use rdfInterface\Literal as iLiteral;
1717
use rdfInterface\Term;
18-
use rdfInterface\TYPE_LITERAL;
1918
use Stringable;
2019
use sweetrdf\InMemoryStoreSqlite\NamespaceHelper;
2120

@@ -33,8 +32,10 @@ public function __construct(
3332
?string $datatype = null
3433
) {
3534
$this->value = $value;
36-
$this->lang = $lang;
37-
$this->datatype = $datatype;
35+
// TODO later check with feedback on
36+
// https://github.com/sweetrdf/rdfInterface/issues/14
37+
$this->lang = !empty($lang) ? $lang : null;
38+
$this->datatype = $datatype ?? NamespaceHelper::NAMESPACE_XSD.'string';
3839
}
3940

4041
public function __toString(): string
@@ -61,17 +62,17 @@ public function getLang(): ?string
6162

6263
public function getDatatype(): string
6364
{
64-
return $this->datatype ?? NamespaceHelper::NAMESPACE_XSD;
65+
return $this->datatype;
6566
}
6667

6768
public function getType(): string
6869
{
69-
return TYPE_LITERAL;
70+
return \rdfInterface\TYPE_LITERAL;
7071
}
7172

7273
public function equals(Term $term): bool
7374
{
74-
return $this === $term;
75+
return $this == $term;
7576
}
7677

7778
public function withValue(int | float | string | bool | Stringable $value): self

src/Rdf/NamedNode.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
use rdfInterface\NamedNode as iNamedNode;
1616
use rdfInterface\Term;
17-
use rdfInterface\TYPE_NAMED_NODE;
1817

1918
class NamedNode implements iNamedNode
2019
{
@@ -37,11 +36,11 @@ public function getValue(): string
3736

3837
public function getType(): string
3938
{
40-
return TYPE_NAMED_NODE;
39+
return \rdfInterface\TYPE_NAMED_NODE;
4140
}
4241

4342
public function equals(Term $term): bool
4443
{
45-
return $this === $term;
44+
return $this == $term;
4645
}
4746
}

src/Rdf/Quad.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use BadMethodCallException;
1616
use Exception;
1717
use rdfInterface\BlankNode as iBlankNode;
18+
use rdfInterface\DefaultGraph as iDefaultGraph;
1819
use rdfInterface\Literal as iLiteral;
1920
use rdfInterface\NamedNode as iNamedNode;
2021
use rdfInterface\Quad as iQuad;
@@ -28,13 +29,13 @@ class Quad implements iQuad
2829

2930
private iTerm $object;
3031

31-
private iNamedNode | iBlankNode | null $graphIri;
32+
private iNamedNode | iBlankNode | iDefaultGraph | null $graphIri;
3233

3334
public function __construct(
3435
iTerm $subject,
3536
iNamedNode $predicate,
3637
iTerm $object,
37-
iNamedNode | iBlankNode | null $graphIri = null
38+
iNamedNode | iBlankNode | iDefaultGraph | null $graphIri = null
3839
) {
3940
if ($subject instanceof iLiteral) {
4041
throw new BadMethodCallException('Subject must be of type NamedNode or BlankNode');
@@ -57,7 +58,7 @@ public function getType(): string
5758

5859
public function equals(iTerm $term): bool
5960
{
60-
return $this === $term;
61+
return $this == $term;
6162
}
6263

6364
public function getValue(): string
@@ -134,8 +135,9 @@ public function withObject(iTerm $object): iQuad
134135
throw new Exception('withObject not implemented yet.');
135136
}
136137

137-
public function withGraphIri(iNamedNode | iBlankNode $graphIri): iQuad
138-
{
138+
public function withGraphIri(
139+
iNamedNode | iBlankNode | iDefaultGraph | null $graphIri
140+
): iQuad {
139141
throw new Exception('withGraphIri not implemented yet.');
140142
}
141143
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the sweetrdf/InMemoryStoreSqlite package and licensed under
5+
* the terms of the GPL-3 license.
6+
*
7+
* (c) Konrad Abicht <[email protected]>
8+
*
9+
* For the full copyright and license information, please view the LICENSE
10+
* file that was distributed with this source code.
11+
*/
12+
13+
namespace Tests\Integration;
14+
15+
use rdfInterface\DataFactory as iDataFactory;
16+
use rdfInterface\tests\TermsTest as _TermsTest;
17+
use sweetrdf\InMemoryStoreSqlite\Rdf\DataFactory;
18+
19+
class TermsTest extends _TermsTest
20+
{
21+
public static function getDataFactory(): iDataFactory
22+
{
23+
return new DataFactory();
24+
}
25+
26+
public function testLiteralWith(): void
27+
{
28+
$this->markTestSkipped('Function to test not implemented yet.');
29+
}
30+
31+
public function testQuadWith(): void
32+
{
33+
$this->markTestSkipped('Function to test not implemented yet.');
34+
}
35+
36+
public function testQuadTemplate(): void
37+
{
38+
$this->markTestSkipped('Function to test not implemented yet.');
39+
}
40+
41+
public function testQuadTemplateQuad(): void
42+
{
43+
$this->markTestSkipped('Function to test not implemented yet.');
44+
}
45+
46+
public function testQuadTemplateWith(): void
47+
{
48+
$this->markTestSkipped('Function to test not implemented yet.');
49+
}
50+
51+
public function testQuadTemplateExceptions(): void
52+
{
53+
$this->markTestSkipped('Function to test not implemented yet.');
54+
}
55+
}

0 commit comments

Comments
 (0)