This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Esun\MultiLocaleTranslation\Test\Unit\Plugin\Blog;
use Esun\MultiLocaleTranslation\Model\BlogPostTranslationApplier;
use Esun\MultiLocaleTranslation\Plugin\Blog\ApplyStoreTranslationToPostCollection;
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
use PHPUnit\Framework\TestCase;
class ApplyStoreTranslationToPostCollectionTest extends TestCase
{
public function testNestedLoadDoesNotApplyCollectionTwice(): void
{
$collection = $this->createMock(Collection::class);
$applier = $this->createMock(BlogPostTranslationApplier::class);
$plugin = new ApplyStoreTranslationToPostCollection($applier);
$collection->expects(self::once())->method('getItems')->willReturnCallback(
function () use ($plugin, $collection): array {
$plugin->afterLoad($collection, $collection);
return [];
}
);
$applier->expects(self::once())->method('applyMany')->with([]);
self::assertSame($collection, $plugin->afterLoad($collection, $collection));
}
}