Skip to content

Commit

Permalink
Handling and tests for malformed dates
Browse files Browse the repository at this point in the history
  • Loading branch information
joelit committed Jun 12, 2020
1 parent e5c649d commit 053b065
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion model/sparql/GenericSparql.php
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,8 @@ private function transformChangeListResults($result) {
try {
$concept['date'] = $row->date->getValue();
} catch (Exception $e) {
//don't do anything to malformed dates e.g. 1986-21-00
//don't record concepts with malformed dates e.g. 1986-21-00
continue;
}
}

Expand Down
17 changes: 17 additions & 0 deletions tests/GenericSparqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,23 @@ public function testQueryChangeList()
$this->assertEquals(array('Fourth date', 'Hurr Durr', 'Second date', 'A date'), $order);
}

/**
* @covers GenericSparql::queryChangeList
* @covers GenericSparql::generateChangeListQuery
* @covers GenericSparql::transFormChangeListResults
*/
public function testMalformedDates() {
$voc = $this->model->getVocabulary('test');
$graph = $voc->getGraph();
$sparql = new GenericSparql('http://localhost:13030/skosmos-test/sparql', $graph, $this->model);
$result = $sparql->queryChangeList('dc:modified', 'en', 0, 10);
$uris = array();
foreach($result as $concept) {
$uris[] = $concept['uri'];
}
$this->assertNotContains('http://www.skosmos.skos/test/ta114', $uris);
}

/**
* @covers GenericSparql::formatTypes
* @covers GenericSparql::queryConcepts
Expand Down
2 changes: 1 addition & 1 deletion tests/WebControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public function testGetModifiedDate($concept, $git, $config, $modifiedDate)
}

/**
* @covers WebController::getChangeList
* @covers WebController::formatChangeList
*/
public function testFormatChangeList() {
Expand All @@ -225,5 +226,4 @@ public function testFormatChangeList() {
$this->assertEquals(array('December 2011', 'February 2010', 'January 2000'), array_keys($months));
$this->assertEquals($expected, $months['February 2010']);
}

}

0 comments on commit 053b065

Please sign in to comment.