Skip to content

Commit

Permalink
[TASK] Further mock Locales-specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Jan 15, 2024
1 parent 1a6df2b commit 75ca7f1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Tests/Unit/AbstractTestCase.php
Expand Up @@ -282,12 +282,19 @@ protected function mockForLocalizationUtilityCalls(array $returnValeMap): void
}

if (class_exists(Locales::class)) {
if (method_exists(Locales::class, 'createLocaleFromRequest')) {
$methods = ['createLocaleFromRequest'];
} else {
$methods = ['getLanguages'];
}
$locale = $this->getMockBuilder(Locale::class)->disableOriginalConstructor()->getMock();
$locales = $this->getMockBuilder(Locales::class)
->onlyMethods(['createLocaleFromRequest'])
->onlyMethods($methods)
->disableOriginalConstructor()
->getMock();
$locales->method('createLocaleFromRequest')->willReturn($locale);
if (method_exists(Locales::class, 'createLocaleFromRequest')) {
$locales->method('createLocaleFromRequest')->willReturn($locale);
}

$this->singletonInstances[Locales::class] = $locales;
}
Expand Down

0 comments on commit 75ca7f1

Please sign in to comment.