diff --git a/model/ConceptPropertyValueLiteral.php b/model/ConceptPropertyValueLiteral.php index f22494c60..37edfe85f 100644 --- a/model/ConceptPropertyValueLiteral.php +++ b/model/ConceptPropertyValueLiteral.php @@ -44,8 +44,11 @@ public function getDatatype(): ?string return null; } $graph = $this->resource->getGraph(); - $dtLabel = $graph->resource($datatype)->label($this->clang); - return $dtLabel->getValue(); + if ($graph->resource($datatype)->label($this->clang)) { + $dtLabel = $graph->resource($datatype)->label($this->clang); + return $dtLabel->getValue(); + } + return ""; } public function getType() diff --git a/tests/ConceptPropertyValueLiteralTest.php b/tests/ConceptPropertyValueLiteralTest.php index 033090715..161605a07 100644 --- a/tests/ConceptPropertyValueLiteralTest.php +++ b/tests/ConceptPropertyValueLiteralTest.php @@ -73,29 +73,27 @@ public function testGetLabelForDatatype() { $this->assertEquals('NameOfTheDatatype', $propvals['665']->getDatatype()); } - /** - * @covers ConceptPropertyValueLiteral::getLabel - */ - public function testGetDatatypeWithoutLabel() { - $vocab = $this->model->getVocabulary('test'); - $concepts = $vocab->getConceptInfo('http://www.skosmos.skos/test/ta112', 'en'); - $props = $concepts[0]->getProperties(); - $propvals = $props['skos:notation']->getValues(); - $this->assertEquals('NameOfTheDatatype', $propvals['665']->getDatatype()); - } - - - /** - * @covers ConceptPropertyValueLiteral::getLabel - */ - public function testGetLabelForDatatypeIfNull() { - $vocab = $this->model->getVocabulary('test'); - $concepts = $vocab->getConceptInfo('http://www.skosmos.skos/test/ta126', 'en'); - $props = $concepts[0]->getProperties(); - $propvals = $props['skos:notation']->getValues(); - $this->assertNull($propvals['12.34']->getDatatype()); - } + /** + * @covers ConceptPropertyValueLiteral::getLabel + */ + public function testGetNotationDatatypeWithoutLabel() { + $vocab = $this->model->getVocabulary('test'); + $concepts = $vocab->getConceptInfo('http://www.skosmos.skos/test/ta128', 'en'); + $props = $concepts[0]->getProperties(); + $propvals = $props['skos:notation']->getValues(); + $this->assertEquals('', $propvals['testnotation']->getDatatype()); + } +/** + * @covers ConceptPropertyValueLiteral::getLabel + */ +public function testGetLabelForDatatypeIfNull() { + $vocab = $this->model->getVocabulary('test'); + $concepts = $vocab->getConceptInfo('http://www.skosmos.skos/test/ta126', 'en'); + $props = $concepts[0]->getProperties(); + $propvals = $props['skos:notation']->getValues(); + $this->assertNull($propvals['12.34']->getDatatype()); +} /** * @covers ConceptPropertyValueLiteral::getLang diff --git a/tests/GenericSparqlTest.php b/tests/GenericSparqlTest.php index 265eb2c5b..2edb74029 100644 --- a/tests/GenericSparqlTest.php +++ b/tests/GenericSparqlTest.php @@ -44,7 +44,7 @@ public function testGetGraph() { */ public function testCountConcepts() { $actual = $this->sparql->countConcepts(); - $this->assertEquals(17, $actual['http://www.w3.org/2004/02/skos/core#Concept']['count']); + $this->assertEquals(18, $actual['http://www.w3.org/2004/02/skos/core#Concept']['count']); } /** diff --git a/tests/RestControllerTest.php b/tests/RestControllerTest.php index a6c0c8e58..fb2cf7846 100644 --- a/tests/RestControllerTest.php +++ b/tests/RestControllerTest.php @@ -462,7 +462,7 @@ public function testVocabularyStatistics() { "concepts": { "class": "http://www.w3.org/2004/02/skos/core#Concept", "label": "Concept", - "count": 17, + "count": 18, "deprecatedCount": 1 }, "subTypes": [ diff --git a/tests/VocabularyTest.php b/tests/VocabularyTest.php index 80d6820a0..425d45aa8 100644 --- a/tests/VocabularyTest.php +++ b/tests/VocabularyTest.php @@ -153,7 +153,7 @@ public function testGetLabelStatistics() { public function testGetStatistics() { $vocab = $this->model->getVocabulary('test'); $stats = $vocab->getStatistics(); - $this->assertEquals(17, $stats['http://www.w3.org/2004/02/skos/core#Concept']['count']); + $this->assertEquals(18, $stats['http://www.w3.org/2004/02/skos/core#Concept']['count']); $this->assertEquals(1, $stats['http://www.w3.org/2004/02/skos/core#Concept']['deprecatedCount']); $this->assertEquals(13, $stats['http://www.skosmos.skos/test-meta/TestClass']['count']); $this->assertEquals(1, $stats['http://www.skosmos.skos/test-meta/TestClass']['deprecatedCount']); diff --git a/tests/test-vocab-data/test.ttl b/tests/test-vocab-data/test.ttl index 9bc76fae8..3630c31b0 100644 --- a/tests/test-vocab-data/test.ttl +++ b/tests/test-vocab-data/test.ttl @@ -162,8 +162,8 @@ test:ta127 test:ta128 a mads:Geographic, skos:Concept ; - skos:notation "12.34"^^test:dt2 ; - skos:prefLabel "Europa"@nb . + skos:notation "testnotation"^^test:dt2 ; + skos:prefLabel "Europa2"@nb . test:ta1 a skos:Concept, meta:TestClass ; skos:inScheme test:conceptscheme ;