45 lines
1.8 KiB
PHP
45 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\MultiLocaleTranslation\Test\Unit\Model;
|
|
|
|
use Esun\MultiLocaleTranslation\Model\CmsTranslationRepository;
|
|
use Esun\MultiLocaleTranslation\Model\WikiTranslationApplier;
|
|
use Esun\Wiki\Model\Category;
|
|
use Magento\Framework\App\State;
|
|
use Magento\Store\Api\Data\StoreInterface;
|
|
use Magento\Store\Model\StoreManagerInterface;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class WikiTranslationApplierTest extends TestCase
|
|
{
|
|
public function testAppliesCategoryCollectionTranslationsInOneQuery(): void
|
|
{
|
|
$first = $this->createMock(Category::class);
|
|
$first->method('getId')->willReturn(12);
|
|
$first->expects(self::once())->method('setData')->with('title', 'Titel 12');
|
|
$second = $this->createMock(Category::class);
|
|
$second->method('getId')->willReturn(13);
|
|
$second->expects(self::once())->method('setData')->with('summary', 'Zusammenfassung 13');
|
|
$repository = $this->createMock(CmsTranslationRepository::class);
|
|
$repository->expects(self::once())->method('getTranslationsForEntities')->with(
|
|
[12, 13],
|
|
16,
|
|
CmsTranslationRepository::ENTITY_WIKI_CATEGORY,
|
|
self::isType('array')
|
|
)->willReturn([
|
|
12 => ['title' => 'Titel 12'],
|
|
13 => ['summary' => 'Zusammenfassung 13'],
|
|
]);
|
|
$store = $this->createMock(StoreInterface::class);
|
|
$store->method('getId')->willReturn(16);
|
|
$storeManager = $this->createMock(StoreManagerInterface::class);
|
|
$storeManager->method('getStore')->willReturn($store);
|
|
$state = $this->createMock(State::class);
|
|
$state->method('getAreaCode')->willReturn('frontend');
|
|
|
|
(new WikiTranslationApplier($repository, $storeManager, $state))->applyMany([$first, $second]);
|
|
}
|
|
}
|