Skip to content

Commit

Permalink
Tests done
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahonen Mika J committed Sep 16, 2021
1 parent 62a728a commit aff26b4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
7 changes: 5 additions & 2 deletions model/ConceptPropertyValueLiteral.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
42 changes: 20 additions & 22 deletions tests/ConceptPropertyValueLiteralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/GenericSparqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/RestControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion tests/VocabularyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down
4 changes: 2 additions & 2 deletions tests/test-vocab-data/test.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down

0 comments on commit aff26b4

Please sign in to comment.