Skip to content

Commit

Permalink
Specified the thrown exeptions and removed an unused variable
Browse files Browse the repository at this point in the history
  • Loading branch information
joelit committed Oct 10, 2024
1 parent e0ee622 commit 5abb0e9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions tests/ConceptPropertyValueLiteralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ public function testGetLabelThatIsADate()
*/
public function testGetLabelThatIsABrokenDate()
{
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
set_error_handler(function ($code, $message, $file, $line) {
throw new \PHPUnit\Framework\Error($message);
});

try {
$vocab = $this->model->getVocabulary('dates');

$this->expectException(\ErrorException::class);
$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");
Expand Down
8 changes: 4 additions & 4 deletions tests/ConceptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,18 @@ public function testGetDateWithCreatedAndModified()
*/
public function testGetTimestampInvalidWarning()
{
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
set_error_handler(function ($code, $message, $file, $line) {
throw new \PHPUnit\Framework\Error($message);
});

try {
$vocab = $this->model->getVocabulary('test');

$this->expectException(\ErrorException::class);
$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");
$props = $concept->getDate(); # this should throw an ErrorException
$concept->getDate(); # this should throw an ErrorException

} finally {
restore_error_handler();
Expand Down
24 changes: 12 additions & 12 deletions tests/VocabularyConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ public function testGetDefaultLanguage()
*/
public function testGetDefaultLanguageWhenNotSet()
{
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
set_error_handler(function ($code, $message, $file, $line) {
throw new \PHPUnit\Framework\Error($message);
});
try {
$vocab = $this->model->getVocabulary('testdiff');
$this->expectException(\ErrorException::class);
$this->expectException(\PHPUnit\Framework\Error::class);
$this->expectExceptionMessage("Default language for vocabulary 'testdiff' unknown, choosing 'en'.");
$lang = $vocab->getConfig()->getDefaultLanguage();
} finally {
Expand Down Expand Up @@ -219,13 +219,13 @@ public function testGetDataURLs()
*/
public function testGetDataURLsNotGuessable()
{
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
set_error_handler(function ($code, $message, $file, $line) {
throw new \PHPUnit\Framework\Error($message);
});

try {
$vocab = $this->model->getVocabulary('test');
$this->expectException(\ErrorException::class);
$this->expectException(\PHPUnit\Framework\Error::class);
$this->expectExceptionMessage("Could not guess format for <http://skosmos.skos/dump/test/>.");

$url = $vocab->getConfig()->getDataURLs();
Expand Down Expand Up @@ -261,14 +261,14 @@ public function testGetDataURLsMarc()
*/
public function testGetDataURLsMarcNotDefined()
{
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
set_error_handler(function ($code, $message, $file, $line) {
throw new \PHPUnit\Framework\Error($message);
});

try {
$vocab = $this->model->getVocabulary('marc-undefined');

$this->expectException(\ErrorException::class);
$this->expectException(\PHPUnit\Framework\Error::class);
$this->expectExceptionMessage("Could not guess format for <http://skosmos.skos/dump/test/marc-undefined.mrcx>.");

$url = $vocab->getConfig()->getDataURLs();
Expand Down Expand Up @@ -688,13 +688,13 @@ public function testGetPropertyOrderDefault()
*/
public function testGetPropertyOrderUnknown()
{
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
set_error_handler(function ($code, $message, $file, $line) {
throw new \PHPUnit\Framework\Error($message);
});

try {
$vocab = $this->model->getVocabulary('testUnknownPropertyOrder');
$this->expectException(\ErrorException::class);
$this->expectException(\PHPUnit\Framework\Error::class);
$this->expectExceptionMessage("Property order for vocabulary 'testUnknownPropertyOrder' unknown, using default order");

$params = $vocab->getConfig()->getPropertyOrder();
Expand Down

0 comments on commit 5abb0e9

Please sign in to comment.