From 9054b7420aceb20f8d6e0fed4dfce6f63429f8f7 Mon Sep 17 00:00:00 2001 From: kouralex <1723419+kouralex@users.noreply.github.com> Date: Wed, 4 Mar 2020 13:56:27 +0200 Subject: [PATCH] fixes #934 --- composer.json | 2 +- tests/FeedbackTest.php | 4 ++++ tests/GlobalConfigTest.php | 8 ++------ tests/ModelTest.php | 8 +++++++- tests/RestControllerTest.php | 4 ++++ tests/VocabularyTest.php | 1 - tests/jenatestconfig.ttl | 2 +- tests/testconfig-fordefaults.ttl | 2 +- tests/testconfig.ttl | 2 +- 9 files changed, 21 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index e2bea24a6..d8f26bd55 100644 --- a/composer.json +++ b/composer.json @@ -77,7 +77,7 @@ "grimmlink/qtip2": "3.0.3" }, "require-dev": { - "phpunit/phpunit": "4.8 - 7.5.10", + "phpunit/phpunit": "7.2.0 - 7.5.20", "umpirsky/twig-gettext-extractor": "1.3.*", "symfony/dom-crawler": "3.4.3", "mockery/mockery": "1.0" diff --git a/tests/FeedbackTest.php b/tests/FeedbackTest.php index d842eba09..a0c81ee08 100644 --- a/tests/FeedbackTest.php +++ b/tests/FeedbackTest.php @@ -44,6 +44,7 @@ public function testHoneypotFieldsGenerated() { * @covers Honeypot::validateHoneytime */ public function testHoneypotAndHoneypot() { + $this->expectNotToPerformAssertions(); $this->request ->shouldReceive('getQueryParamPOST') ->with('message') @@ -84,6 +85,7 @@ public function testHoneypotAndHoneypot() { * @covers Honeypot::validateHoneytime */ public function testHoneypotAndHoneypotDisabled() { + $this->expectNotToPerformAssertions(); $this->controller->honeypot->disable(); $this->request ->shouldReceive('getQueryParamPOST') @@ -126,6 +128,7 @@ public function testHoneypotAndHoneypotDisabled() { * @covers Honeypot::validateHoneytime */ public function testHoneytimeTooFast() { + $this->expectNotToPerformAssertions(); $this->request ->shouldReceive('getQueryParamPOST') ->with('message') @@ -165,6 +168,7 @@ public function testHoneytimeTooFast() { * @covers Honeypot::validateHoneypot */ public function testHoneypotNotEmpty() { + $this->expectNotToPerformAssertions(); $this->request ->shouldReceive('getQueryParamPOST') ->with('message') diff --git a/tests/GlobalConfigTest.php b/tests/GlobalConfigTest.php index 53f7313a4..e9d75a689 100644 --- a/tests/GlobalConfigTest.php +++ b/tests/GlobalConfigTest.php @@ -133,20 +133,16 @@ public function testGetGlobalPlugins() // --- tests for the exception paths - /** - * @expectedException - */ public function testInitializeConfigWithoutGraph() { + $this->expectOutputString('Error: config.ttl must have exactly one skosmos:Configuration'); $conf = new GlobalConfig('/../tests/testconfig-nograph.ttl'); $this->assertNotNull($conf); } - /** - * @expectedException - */ public function testInexistentFile() { + $this->expectOutputString('Error: config.ttl file is missing, please provide one.'); $conf = new GlobalConfig('/../tests/testconfig-idonotexist.ttl'); $this->assertNotNull($conf); } diff --git a/tests/ModelTest.php b/tests/ModelTest.php index ba4da5fb0..cd440bea8 100644 --- a/tests/ModelTest.php +++ b/tests/ModelTest.php @@ -59,7 +59,7 @@ public function testGetVocabularyCategories() { * @covers Model::getVocabulariesInCategory */ public function testGetVocabulariesInCategory() { - $category = $this->model->getVocabulariesInCategory('cat_science'); + $category = $this->model->getVocabulariesInCategory(new EasyRdf\Resource('http://base/#cat_science')); foreach($category as $vocab) $this->assertInstanceOf('Vocabulary', $vocab); } @@ -237,6 +237,12 @@ public function testSearchConceptsWithMultipleBroaders() { $result = $this->model->searchConcepts($this->params); $this->assertEquals('http://www.skosmos.skos/test/ta123', $result[0]['uri']); $this->assertEquals('multiple broaders', $result[0]['prefLabel']); + + // sort by URI to ensure their relative order + usort($result[0]['skos:broader'], function($a, $b) { + return strnatcasecmp($a['uri'], $b['uri']); + }); + $this->assertCount(2, $result[0]['skos:broader']); // two broader concepts $this->assertEquals('http://www.skosmos.skos/test/ta118', $result[0]['skos:broader'][0]['uri']); $this->assertEquals('-"special" character \\example\\', $result[0]['skos:broader'][0]['prefLabel']); diff --git a/tests/RestControllerTest.php b/tests/RestControllerTest.php index eb8793bfb..850869812 100644 --- a/tests/RestControllerTest.php +++ b/tests/RestControllerTest.php @@ -19,6 +19,10 @@ protected function setUp() { $this->controller = new RestController($this->model); } + protected function tearDown() { + ob_clean(); + } + /** * @covers RestController::data */ diff --git a/tests/VocabularyTest.php b/tests/VocabularyTest.php index 163710ce8..c6b018ea6 100644 --- a/tests/VocabularyTest.php +++ b/tests/VocabularyTest.php @@ -443,7 +443,6 @@ public function testGetConceptScheme() { $vocab = $this->model->getVocabulary('http304'); $conceptSchemeUri = $vocab->getDefaultConceptScheme(); $conceptScheme = $vocab->getConceptScheme($conceptSchemeUri); - print($conceptSchemeUri); $this->assertEquals( "Test Main Concept Scheme", $conceptScheme->getLiteral($conceptSchemeUri,"skos:prefLabel") diff --git a/tests/jenatestconfig.ttl b/tests/jenatestconfig.ttl index ae43fb5f1..036f1ba59 100644 --- a/tests/jenatestconfig.ttl +++ b/tests/jenatestconfig.ttl @@ -14,7 +14,7 @@ @prefix meta: . @prefix my: . @prefix mdrtype: . -@prefix : <#> . +@prefix : . # Skosmos main configuration diff --git a/tests/testconfig-fordefaults.ttl b/tests/testconfig-fordefaults.ttl index 429cde549..fba8424b1 100644 --- a/tests/testconfig-fordefaults.ttl +++ b/tests/testconfig-fordefaults.ttl @@ -11,7 +11,7 @@ @prefix skosmos: . @prefix isothes: . @prefix mdrtype: . -@prefix : <#> . +@prefix : . # Skosmos main configuration diff --git a/tests/testconfig.ttl b/tests/testconfig.ttl index ba53976a5..a653ca725 100644 --- a/tests/testconfig.ttl +++ b/tests/testconfig.ttl @@ -15,7 +15,7 @@ @prefix my: . @prefix mdrtype: . @prefix test: . -@prefix : <#> . +@prefix : . # Skosmos main configuration