diff --git a/src/Component/spec/Translation/Provider/ImmutableTranslationLocaleProviderSpec.php b/src/Component/spec/Translation/Provider/ImmutableTranslationLocaleProviderSpec.php deleted file mode 100644 index eb21a8310..000000000 --- a/src/Component/spec/Translation/Provider/ImmutableTranslationLocaleProviderSpec.php +++ /dev/null @@ -1,40 +0,0 @@ -beConstructedWith(['pl_PL', 'en_US'], 'pl_PL'); - } - - function it_implements_translation_locale_provider_interface(): void - { - $this->shouldImplement(TranslationLocaleProviderInterface::class); - } - - function it_returns_defined_locales_codes(): void - { - $this->getDefinedLocalesCodes()->shouldReturn(['pl_PL', 'en_US']); - } - - function it_returns_the_default_locale_code(): void - { - $this->getDefaultLocaleCode()->shouldReturn('pl_PL'); - } -} diff --git a/src/Component/spec/Translation/TranslatableEntityLocaleAssignerSpec.php b/src/Component/spec/Translation/TranslatableEntityLocaleAssignerSpec.php deleted file mode 100644 index f42abf0c8..000000000 --- a/src/Component/spec/Translation/TranslatableEntityLocaleAssignerSpec.php +++ /dev/null @@ -1,44 +0,0 @@ -beConstructedWith($translationLocaleProvider); - } - - function it_implements_traslatable_entity_locale_assigner_interface(): void - { - $this->shouldImplement(TranslatableEntityLocaleAssignerInterface::class); - } - - function it_should_assign_current_and_default_locale_to_given_translatable_entity( - TranslationLocaleProviderInterface $translationLocaleProvider, - TranslatableInterface $translatableEntity, - ): void { - $translationLocaleProvider->getDefaultLocaleCode()->willReturn('en_US'); - - $translatableEntity->setCurrentLocale('en_US')->shouldBeCalled(); - $translatableEntity->setFallbackLocale('en_US')->shouldBeCalled(); - - $this->assignLocale($translatableEntity); - } -} diff --git a/src/Component/tests/Translation/Provider/ImmutableTranslationLocaleProviderTest.php b/src/Component/tests/Translation/Provider/ImmutableTranslationLocaleProviderTest.php new file mode 100644 index 000000000..092cb8a6d --- /dev/null +++ b/src/Component/tests/Translation/Provider/ImmutableTranslationLocaleProviderTest.php @@ -0,0 +1,43 @@ +localeProvider = new ImmutableTranslationLocaleProvider(['pl_PL', 'en_US'], 'pl_PL'); + } + + public function testItImplementsTranslationLocaleProviderInterface(): void + { + $this->assertInstanceOf(TranslationLocaleProviderInterface::class, $this->localeProvider); + } + + public function testItReturnsDefinedLocalesCodes(): void + { + $this->assertSame(['pl_PL', 'en_US'], $this->localeProvider->getDefinedLocalesCodes()); + } + + public function testItReturnsTheDefaultLocaleCode(): void + { + $this->assertSame('pl_PL', $this->localeProvider->getDefaultLocaleCode()); + } +} diff --git a/src/Component/tests/Translation/TranslatableEntityLocaleAssignerTest.php b/src/Component/tests/Translation/TranslatableEntityLocaleAssignerTest.php new file mode 100644 index 000000000..dd3f1e870 --- /dev/null +++ b/src/Component/tests/Translation/TranslatableEntityLocaleAssignerTest.php @@ -0,0 +1,57 @@ +translationLocaleProvider = $this->createMock(TranslationLocaleProviderInterface::class); + $this->localeAssigner = new TranslatableEntityLocaleAssigner($this->translationLocaleProvider); + } + + public function testItImplementsTranslatableEntityLocaleAssignerInterface(): void + { + $this->assertInstanceOf(TranslatableEntityLocaleAssignerInterface::class, $this->localeAssigner); + } + + public function testItAssignsCurrentAndDefaultLocaleToGivenTranslatableEntity(): void + { + $translatableEntity = $this->createMock(TranslatableInterface::class); + + $this->translationLocaleProvider + ->method('getDefaultLocaleCode') + ->willReturn('en_US'); + + $translatableEntity->expects($this->once()) + ->method('setCurrentLocale') + ->with('en_US'); + + $translatableEntity->expects($this->once()) + ->method('setFallbackLocale') + ->with('en_US'); + + $this->localeAssigner->assignLocale($translatableEntity); + } +}