Skip to content

Commit

Permalink
adding a unit test case
Browse files Browse the repository at this point in the history
(cherry picked from commit a5a938e)
  • Loading branch information
henriyli authored and osma committed Aug 22, 2023
1 parent b5e7c7f commit 13c8656
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/ConceptPropertyValueLiteralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
10 changes: 10 additions & 0 deletions tests/test-vocab-data/xl.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://en.wikipedia.org/wiki/Concept> .

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 <https://en.wikipedia.org/wiki/Ontology> .

0 comments on commit 13c8656

Please sign in to comment.