Skip to content

Commit

Permalink
MNT Handle LogicExceptions when calling setI18nLocale()
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jan 23, 2025
1 parent 1ea87f8 commit 7869f1a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Dev/SapphireTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,15 @@ protected function mockSleep(int $seconds): DBDatetime
*/
private function setI18nLocale(): void
{
$path = $this->getCurrentRelativePath();
$path = null;
try {
$path = $this->getCurrentRelativePath();
} catch (LogicException) {
// Calling getCurrentRelativePath() may result in a LogicException being thrown in some scenarios
// such as running silverstripe/behat-extension SilverStripeContextTest
// In such cases, simply use the default locale
return;
}
$packagistName = '';
if (preg_match('#(^|/)vendor/([^/]+/[^/]+)/.+#', $path, $matches)) {
// Running unit tests of a module in the vendor folder
Expand Down

0 comments on commit 7869f1a

Please sign in to comment.