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,39 @@
<?php
declare(strict_types=1);
namespace Esun\MultiLocaleTranslation\Test\Unit\Model\Queue;
use Esun\MultiLocaleTranslation\Model\Queue\CronConsumer;
use Esun\MultiLocaleTranslation\Model\Queue\QueueProcessor;
use Magento\Framework\App\Config\ScopeConfigInterface;
use PHPUnit\Framework\TestCase;
class CronConsumerTest extends TestCase
{
public function testUsesConfiguredQueueLimits(): void
{
$processor = $this->createMock(QueueProcessor::class);
$processor->expects(self::once())->method('process')->with(10, 50);
$scopeConfig = $this->createMock(ScopeConfigInterface::class);
$scopeConfig->method('getValue')->willReturnCallback(
static fn(string $path): string => str_ends_with($path, 'tasks_per_run') ? '10' : '50'
);
(new CronConsumer($processor, $scopeConfig))->execute();
}
public function testClampsQueueLimitsToAllowedRange(): void
{
$processor = $this->createMock(QueueProcessor::class);
$processor->expects(self::once())->method('process')->with(50, 10);
$scopeConfig = $this->createMock(ScopeConfigInterface::class);
$scopeConfig->method('getValue')->willReturnCallback(
static fn(string $path): string => str_ends_with($path, 'tasks_per_run') ? '999' : '1'
);
(new CronConsumer($processor, $scopeConfig))->execute();
}
}