Skip to content

Commit

Permalink
Fix more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Dec 17, 2024
1 parent bdb8bfe commit 62bc876
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 5 additions & 1 deletion module/VuFind/src/VuFindTest/Feature/TranslatorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ protected function getMockTranslator(array $translations, string $locale = 'en')
$callback = function ($str, $domain) use ($translations) {
return $translations[$domain][$str] ?? $str;
};
$translator = $this->createMock(Translator::class);
$translator = $this->getMockBuilder(Translator::class)
->disableOriginalConstructor()
->onlyMethods(['translate'])
->addMethods(['getLocale'])
->getMock();
$translator->expects($this->any())->method('translate')->willReturnCallback($callback);
$translator->expects($this->any())->method('getLocale')->willReturn($locale);
return $translator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,7 @@ public function testLocaleWithoutTranslator(): void
public function testLocaleWithTranslator(): void
{
$translate = new Translate();
$translator = $this->createMock(\Laminas\Mvc\I18n\Translator::class);
$translator->expects($this->once())->method('getLocale')
->will($this->returnValue('foo'));
$translate->setTranslator($translator);
$translate->setTranslator($this->getMockTranslator([], 'foo'));
$this->assertEquals('foo', $translate->getTranslatorLocale());
}

Expand Down

0 comments on commit 62bc876

Please sign in to comment.