From 7844f318bc8a33a6af1b60c6b5cba9c1edb1c90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=BB=C3=B3=C5=82tak?= Date: Wed, 28 Feb 2024 09:18:26 +0100 Subject: [PATCH] TriGParserTest::testBlankNodes() adjusted * removed the prefixed-only IRIs input line from the first test scenario as this does not belong to the testBlankNodes() tests and is tested aleady in testIssue37() * turned the empty prefixed IRIs test scenario into two - first, where and error is expected due to unknown document base IRI and second, where parsing succeeds thanks to `documentIRI` parser option being set --- test/TriGParserTest.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/TriGParserTest.php b/test/TriGParserTest.php index d5072f0..3b7d649 100644 --- a/test/TriGParserTest.php +++ b/test/TriGParserTest.php @@ -273,13 +273,18 @@ public function testZeroOrMoreTriples(): void public function testBlankNodes(): void { - // should parse diamonds - $this->shouldParse("<> <> <> <>.\n(<>) <> (<>) <>.", - ['', '', '', ''], - ['_:b0', '', '_:b1', ''], - ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', ''], + // should throw an error on empty list item with lacking document base IRI + $this->shouldNotParse("(<>) <> (<>) <>.", + "list item on line 1 can not be parsed without knowing the the document base IRI.\n". + "Please set the document base IRI using the documentIRI parser configuration option.\n". + "See https://github.com/pietercolpaert/hardf/#empty-document-base-IRI ."); + // but should manage if the parser has documentIRI set + $this->shouldParse(function () { return new TriGParser(['documentIRI' => 'http://base/']); }, + "(<>) <> (<>) <>.", + ['_:b0', 'http://base/', '_:b1', 'http://base/'], + ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'http://base/'], ['_:b0', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'], - ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', ''], + ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first', 'http://base/'], ['_:b1', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil']); // should parse statements with named blank nodes