diff --git a/composer.json b/composer.json index ab160e189..b125904a3 100644 --- a/composer.json +++ b/composer.json @@ -8,20 +8,20 @@ "sweetrdf/easyrdf": "1.13.*", "symfony/polyfill-php80": "1.*", "symfony/polyfill-php81": "1.*", - "twig/twig": "3.8.*", + "twig/twig": "3.14.*", "willdurand/negotiation": "3.1.*", - "punic/punic": "3.5.1", + "punic/punic": "3.8.*", "ml/json-ld": "1.*", "ext-intl": "*", "ext-mbstring": "*", "ext-xsl": "*", - "monolog/monolog": "1.27.*", + "monolog/monolog": "3.7.*", "symfony/translation": "6.4.*", - "symfony/translation-contracts": "3.0.*", + "symfony/translation-contracts": "3.5.*", "symfony/twig-bundle": "6.4.*" }, "require-dev": { - "phpunit/phpunit": "9.5.*", + "phpunit/phpunit": "9.6.*", "symfony/dom-crawler": "6.4.*", "symfony/config": "6.4.*", "symfony/runtime": "6.4.*", @@ -30,7 +30,7 @@ "symfony/dotenv": "6.4.*", "symfony/lokalise-translation-provider": "6.4.*", "symfony/console": "6.4.*", - "mockery/mockery": "1.5.1", + "mockery/mockery": "1.6.*", "friendsofphp/php-cs-fixer": "3.64.*" }, "autoload": { diff --git a/tests/ConceptPropertyValueLiteralTest.php b/tests/ConceptPropertyValueLiteralTest.php index d87fa889f..55e0d27a6 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 ($code, $message) { + throw new \PHPUnit\Framework\Error($message,$code); + }); + + try { + $vocab = $this->model->getVocabulary('dates'); + + $this->expectException(\PHPUnit\Framework\Error::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 6f5550b99..b8686d61d 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 ($code, $message) { + throw new \PHPUnit\Framework\Error($message, $code); + }); + + try { + $vocab = $this->model->getVocabulary('test'); + + $this->expectException(\PHPUnit\Framework\Error::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"); + $concept->getDate(); # this should throw an ErrorException + + } finally { + restore_error_handler(); + } } /** diff --git a/tests/VocabularyConfigTest.php b/tests/VocabularyConfigTest.php index 3e4e0616a..b2cafbe31 100644 --- a/tests/VocabularyConfigTest.php +++ b/tests/VocabularyConfigTest.php @@ -164,10 +164,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 ($code, $message) { + throw new \PHPUnit\Framework\Error($message, $code); + }); + try { + $vocab = $this->model->getVocabulary('testdiff'); + $this->expectException(\PHPUnit\Framework\Error::class); + $this->expectExceptionMessage("Default language for vocabulary 'testdiff' unknown, choosing 'en'."); + $lang = $vocab->getConfig()->getDefaultLanguage(); + } finally { + restore_error_handler(); + } } /** @@ -210,10 +217,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 ($code, $message) { + throw new \PHPUnit\Framework\Error($message, $code); + }); + + try { + $vocab = $this->model->getVocabulary('test'); + $this->expectException(\PHPUnit\Framework\Error::class); + $this->expectExceptionMessage("Could not guess format for ."); + + $url = $vocab->getConfig()->getDataURLs(); + } finally { + restore_error_handler(); + } } /** @@ -243,11 +259,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 ($code, $message) { + throw new \PHPUnit\Framework\Error($message, $code); + }); + + try { + $vocab = $this->model->getVocabulary('marc-undefined'); + + $this->expectException(\PHPUnit\Framework\Error::class); + $this->expectExceptionMessage("Could not guess format for ."); + + $url = $vocab->getConfig()->getDataURLs(); + $this->assertEquals(array(), $url); + } finally { + restore_error_handler(); + } } /** @@ -660,11 +686,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 ($code, $message) { + throw new \PHPUnit\Framework\Error($message, $code); + }); + + try { + $vocab = $this->model->getVocabulary('testUnknownPropertyOrder'); + $this->expectException(\PHPUnit\Framework\Error::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(); + } } /**