Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to php library dependencies #1698

Merged
merged 7 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions tests/ConceptPropertyValueLiteralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

/**
Expand Down
20 changes: 16 additions & 4 deletions tests/ConceptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

/**
Expand Down
73 changes: 55 additions & 18 deletions tests/VocabularyConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!");

joelit marked this conversation as resolved.
Show resolved Hide resolved

}

/**
Expand Down Expand Up @@ -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();
}
}

/**
Expand Down Expand Up @@ -210,10 +219,19 @@ public function testGetDataURLs()
*/
public function testGetDataURLsNotGuessable()
{
$vocab = $this->model->getVocabulary('test');
$this->expectWarning();
$this->expectWarningMessage("Could not guess format for <http://skosmos.skos/dump/test/>.");
$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 <http://skosmos.skos/dump/test/>.");

$url = $vocab->getConfig()->getDataURLs();
} finally {
restore_error_handler();
}
}

/**
Expand Down Expand Up @@ -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 <http://skosmos.skos/dump/test/marc-undefined.mrcx>.");
$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 <http://skosmos.skos/dump/test/marc-undefined.mrcx>.");

$url = $vocab->getConfig()->getDataURLs();
$this->assertEquals(array(), $url);
} finally {
restore_error_handler();
}
}

/**
Expand Down Expand Up @@ -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();
}
}

/**
Expand Down
Loading