Skip to content

Commit

Permalink
Splited TranslatorMock in test to TranslatorInterfaceMock and Transla…
Browse files Browse the repository at this point in the history
…torBagMock
  • Loading branch information
mateuszbieniek committed Apr 8, 2020
1 parent f43e080 commit 8c72a02
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/lib/Tests/UI/Config/Mapper/FieldType/RichText/CustomTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Asset\Packages;
use Symfony\Component\Translation\MessageCatalogueInterface;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\TranslatorBagInterface;
use Symfony\Component\Translation\TranslatorInterface;

/**
* UI Config Mapper test for RichText Custom Tags configuration.
Expand All @@ -31,8 +32,8 @@ public function testMapConfig(array $customTagsConfiguration, array $enabledCust
{
$mapper = new CustomTag(
$customTagsConfiguration,
$this->getTranslatorMock(),
$this->getTranslatorMock(),
$this->getTranslatorInterfaceMock(),
$this->getTranslatorBagInterfaceMock(),
'custom_tags',
$this->getPackagesMock(),
new ArrayObject([
Expand Down Expand Up @@ -164,7 +165,22 @@ public function providerForTestMapConfig(): array
/**
* @return \Symfony\Component\Translation\TranslatorInterface|\PHPUnit\Framework\MockObject\MockObject
*/
private function getTranslatorMock(): MockObject
private function getTranslatorInterfaceMock(): MockObject
{
$translatorInterfaceMock = $this->createMock(TranslatorInterface::class);
$translatorInterfaceMock
->expects($this->any())
->method('trans')
->withAnyParameters()
->willReturnArgument(0);

return $translatorInterfaceMock;
}

/**
* @return \Symfony\Component\Translation\TranslatorBagInterface|\PHPUnit\Framework\MockObject\MockObject
*/
private function getTranslatorBagInterfaceMock(): MockObject
{
$catalogueMock = $this->createMock(MessageCatalogueInterface::class);
$catalogueMock
Expand All @@ -173,21 +189,15 @@ private function getTranslatorMock(): MockObject
->withAnyParameters()
->willReturn(false);

$translatorMock = $this->createMock(Translator::class);
$translatorMock
$translatorBagMock = $this->createMock(TranslatorBagInterface::class);
$translatorBagMock
->expects($this->any())
->method('getCatalogue')
->willReturn(
$catalogueMock
);

$translatorMock
->expects($this->any())
->method('trans')
->withAnyParameters()
->willReturnArgument(0);

return $translatorMock;
return $translatorBagMock;
}

/**
Expand Down

0 comments on commit 8c72a02

Please sign in to comment.