40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?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();
|
|
}
|
|
}
|