Skip to content

Commit

Permalink
Merge pull request #1698 from NatLibFi/dependency-updates
Browse files Browse the repository at this point in the history
Updates to php library dependencies
  • Loading branch information
joelit authored Oct 10, 2024
2 parents 2f51756 + d2626f6 commit 84b37b4
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 33 deletions.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.*",
Expand All @@ -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": {
Expand Down
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 ($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();
}
}

/**
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 ($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();
}
}

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

/**
Expand Down Expand Up @@ -210,10 +217,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 ($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 <http://skosmos.skos/dump/test/>.");

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

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

/**
Expand Down

0 comments on commit 84b37b4

Please sign in to comment.