From 13c86561ee5dc9c4d8ca2a491685da22d4026d76 Mon Sep 17 00:00:00 2001 From: Henri Ylikotila Date: Mon, 27 Mar 2023 12:49:49 +0300 Subject: [PATCH] adding a unit test case (cherry picked from commit a5a938e6e040c0651be7a4c49f545963c24a5c35) --- tests/ConceptPropertyValueLiteralTest.php | 34 +++++++++++++++++++++++ tests/test-vocab-data/xl.ttl | 10 +++++++ 2 files changed, 44 insertions(+) diff --git a/tests/ConceptPropertyValueLiteralTest.php b/tests/ConceptPropertyValueLiteralTest.php index 72eb76991..a490ef7cd 100644 --- a/tests/ConceptPropertyValueLiteralTest.php +++ b/tests/ConceptPropertyValueLiteralTest.php @@ -214,4 +214,38 @@ public function testGetXlLabel() { $this->assertArrayNotHasKey('skosxl:literalForm', $reified_vals); $this->assertArrayHasKey('skosxl:labelRelation', $reified_vals); } + + /** + * @covers ConceptPropertyValueLiteral::getXlLabel + * @covers ConceptPropertyValueLiteral::hasXlProperties + */ + public function testGetXlPropertiesByLang() { + $voc = $this->model->getVocabulary('xl'); + $conc = $voc->getConceptInfo('http://www.skosmos.skos/xl/c2', 'en')[0]; + $props = $conc->getProperties(); + $vals = $props['skos:altLabel']->getValues(); + $val = reset($vals); + + $reified_vals = array(); + if ($val->hasXlProperties()) + { + $reified_vals = $val->getXlLabel()->getProperties(); + } + $this->assertArrayHasKey('dc:source', $reified_vals); + $this->assertArrayHasKey('dc:modified', $reified_vals); + $this->assertCount(2, $reified_vals); + + // testing that XlProperties are only shown for matching language + $conc = $voc->getConceptInfo('http://www.skosmos.skos/xl/c2', 'fi')[0]; + $props = $conc->getProperties(); + $vals = $props['skos:altLabel']->getValues(); + $val = reset($vals); + + $reified_vals = array(); + if ($val->hasXlProperties()) + { + $reified_vals = $val->getXlLabel()->getProperties(); + } + $this->assertEmpty($reified_vals); + } } diff --git a/tests/test-vocab-data/xl.ttl b/tests/test-vocab-data/xl.ttl index 962fd7387..90db36b9c 100644 --- a/tests/test-vocab-data/xl.ttl +++ b/tests/test-vocab-data/xl.ttl @@ -27,3 +27,13 @@ xl:d1 rdf:value "Unit of thought"@en ; dct:modified "2018-04-13T10:29:03+00:00"^^xsd:dateTime ; dc:source . + +xl:c2 a skos:Concept ; + skos:prefLabel "Ontology"@en, "Ontologia"@fi ; + skos:altLabel "Onto"@en, "Onto"@fi ; + skosxl:altLabel xl:l3 . + +xl:l3 a skosxl:Label ; + skosxl:literalForm "Onto"@en ; + dct:modified "2018-04-13T10:29:03+00:00"^^xsd:dateTime ; + dc:source .