diff --git a/tests/ConceptPropertyValueLiteralTest.php b/tests/ConceptPropertyValueLiteralTest.php
index d87fa889..4b7bee32 100644
--- a/tests/ConceptPropertyValueLiteralTest.php
+++ b/tests/ConceptPropertyValueLiteralTest.php
@@ -61,11 +61,22 @@ public function testGetLabelThatIsADate()
*/
public function testGetLabelThatIsABrokenDate()
{
- $this->expectWarning();
- $vocab = $this->model->getVocabulary('dates');
- $concept = $vocab->getConceptInfo("http://www.skosmos.skos/date/d2", "en");
- $props = $concept->getProperties();
- $propvals = $props['http://www.skosmos.skos/date/ownDate']->getValues();
+ set_error_handler(function ($errno, $errstr, $errfile, $errline) {
+ throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
+ });
+
+ try {
+ $vocab = $this->model->getVocabulary('dates');
+
+ $this->expectException(\ErrorException::class);
+ $this->expectExceptionMessage("Failed to parse time string (1986-21-00) at position 6 (1): Unexpected character");
+
+ $concept = $vocab->getConceptInfo("http://www.skosmos.skos/date/d2", "en");
+ $props = $concept->getProperties();
+ $propvals = $props['http://www.skosmos.skos/date/ownDate']->getValues();
+ } finally {
+ restore_error_handler();
+ }
}
/**
diff --git a/tests/ConceptTest.php b/tests/ConceptTest.php
index 6f5550b9..bd283cf1 100644
--- a/tests/ConceptTest.php
+++ b/tests/ConceptTest.php
@@ -312,10 +312,22 @@ public function testGetDateWithCreatedAndModified()
*/
public function testGetTimestampInvalidWarning()
{
- $this->expectError();
- $vocab = $this->model->getVocabulary('test');
- $concept = $vocab->getConceptInfo("http://www.skosmos.skos/test/ta114", "en");
- $props = $concept->getDate(); # this should throw a E_USER_WARNING exception
+ set_error_handler(function ($errno, $errstr, $errfile, $errline) {
+ throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
+ });
+
+ try {
+ $vocab = $this->model->getVocabulary('test');
+
+ $this->expectException(\ErrorException::class);
+ $this->expectExceptionMessage("Failed to parse time string (1986-21-00) at position 6 (1): Unexpected character");
+
+ $concept = $vocab->getConceptInfo("http://www.skosmos.skos/test/ta114", "en");
+ $props = $concept->getDate(); # this should throw an ErrorException
+
+ } finally {
+ restore_error_handler();
+ }
}
/**
diff --git a/tests/VocabularyConfigTest.php b/tests/VocabularyConfigTest.php
index 3e4e0616..907a7bf2 100644
--- a/tests/VocabularyConfigTest.php
+++ b/tests/VocabularyConfigTest.php
@@ -17,6 +17,8 @@ protected function setUp(): void
setlocale(LC_ALL, 'en_GB.utf8');
$this->model = new Model('/../../tests/testconfig.ttl');
$this->assertNotNull($this->model->getVocabulary('test')->getConfig()->getPluginRegister(), "The PluginRegister of the model was not initialized!");
+
+
}
/**
@@ -164,10 +166,17 @@ public function testGetDefaultLanguage()
*/
public function testGetDefaultLanguageWhenNotSet()
{
- $vocab = $this->model->getVocabulary('testdiff');
- $this->expectError();
- $this->expectErrorMessage("Default language for vocabulary 'testdiff' unknown, choosing 'en'.");
- $lang = $vocab->getConfig()->getDefaultLanguage();
+ set_error_handler(function ($errno, $errstr, $errfile, $errline) {
+ throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
+ });
+ try {
+ $vocab = $this->model->getVocabulary('testdiff');
+ $this->expectException(\ErrorException::class);
+ $this->expectExceptionMessage("Default language for vocabulary 'testdiff' unknown, choosing 'en'.");
+ $lang = $vocab->getConfig()->getDefaultLanguage();
+ } finally {
+ restore_error_handler();
+ }
}
/**
@@ -210,10 +219,19 @@ public function testGetDataURLs()
*/
public function testGetDataURLsNotGuessable()
{
- $vocab = $this->model->getVocabulary('test');
- $this->expectWarning();
- $this->expectWarningMessage("Could not guess format for .");
- $url = $vocab->getConfig()->getDataURLs();
+ set_error_handler(function ($errno, $errstr, $errfile, $errline) {
+ throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
+ });
+
+ try {
+ $vocab = $this->model->getVocabulary('test');
+ $this->expectException(\ErrorException::class);
+ $this->expectExceptionMessage("Could not guess format for .");
+
+ $url = $vocab->getConfig()->getDataURLs();
+ } finally {
+ restore_error_handler();
+ }
}
/**
@@ -243,11 +261,21 @@ public function testGetDataURLsMarc()
*/
public function testGetDataURLsMarcNotDefined()
{
- $vocab = $this->model->getVocabulary('marc-undefined');
- $this->expectWarning();
- $this->expectWarningMessage("Could not guess format for .");
- $url = $vocab->getConfig()->getDataURLs();
- $this->assertEquals(array(), $url);
+ set_error_handler(function ($errno, $errstr, $errfile, $errline) {
+ throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
+ });
+
+ try {
+ $vocab = $this->model->getVocabulary('marc-undefined');
+
+ $this->expectException(\ErrorException::class);
+ $this->expectExceptionMessage("Could not guess format for .");
+
+ $url = $vocab->getConfig()->getDataURLs();
+ $this->assertEquals(array(), $url);
+ } finally {
+ restore_error_handler();
+ }
}
/**
@@ -660,11 +688,20 @@ public function testGetPropertyOrderDefault()
*/
public function testGetPropertyOrderUnknown()
{
- $vocab = $this->model->getVocabulary('testUnknownPropertyOrder');
- $this->expectWarning();
- $this->expectWarningMessage("Property order for vocabulary 'testUnknownPropertyOrder' unknown, using default order");
- $params = $vocab->getConfig()->getPropertyOrder();
- $this->assertEquals(VocabularyConfig::DEFAULT_PROPERTY_ORDER, $params);
+ set_error_handler(function ($errno, $errstr, $errfile, $errline) {
+ throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
+ });
+
+ try {
+ $vocab = $this->model->getVocabulary('testUnknownPropertyOrder');
+ $this->expectException(\ErrorException::class);
+ $this->expectExceptionMessage("Property order for vocabulary 'testUnknownPropertyOrder' unknown, using default order");
+
+ $params = $vocab->getConfig()->getPropertyOrder();
+ $this->assertEquals(VocabularyConfig::DEFAULT_PROPERTY_ORDER, $params);
+ } finally {
+ restore_error_handler();
+ }
}
/**