Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Resource\Tests\Translation\Provider;

use PHPUnit\Framework\TestCase;
use Sylius\Resource\Translation\Provider\ImmutableTranslationLocaleProvider;
use Sylius\Resource\Translation\Provider\TranslationLocaleProviderInterface;

final class ImmutableTranslationLocaleProviderTest extends TestCase
{
private ImmutableTranslationLocaleProvider $localeProvider;

protected function setUp(): void
{
$this->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());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Resource\Tests\Translation;

use PHPUnit\Framework\TestCase;
use Sylius\Resource\Model\TranslatableInterface;
use Sylius\Resource\Translation\Provider\TranslationLocaleProviderInterface;
use Sylius\Resource\Translation\TranslatableEntityLocaleAssigner;
use Sylius\Resource\Translation\TranslatableEntityLocaleAssignerInterface;

final class TranslatableEntityLocaleAssignerTest extends TestCase
{
private TranslationLocaleProviderInterface $translationLocaleProvider;

private TranslatableEntityLocaleAssigner $localeAssigner;

protected function setUp(): void
{
$this->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);
}
}
Loading