31 lines
993 B
PHP
31 lines
993 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\OrderCleanup\Test\Unit\Model;
|
|
|
|
use Esun\OrderCleanup\Model\Config;
|
|
use Magento\Framework\App\Config\ScopeConfigInterface;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ConfigTest extends TestCase
|
|
{
|
|
public function testReadsLifetimeFromDefaultScope(): void
|
|
{
|
|
$scopeConfig = $this->createMock(ScopeConfigInterface::class);
|
|
$scopeConfig->expects(self::once())
|
|
->method('getValue')
|
|
->with(Config::XML_PATH_CANCEL_PENDING_AFTER, ScopeConfigInterface::SCOPE_TYPE_DEFAULT)
|
|
->willReturn('45');
|
|
|
|
self::assertSame(45, (new Config($scopeConfig))->getCancellationLifetimeMinutes());
|
|
}
|
|
|
|
public function testNegativeLifetimeDisablesCancellation(): void
|
|
{
|
|
$scopeConfig = $this->createMock(ScopeConfigInterface::class);
|
|
$scopeConfig->method('getValue')->willReturn('-10');
|
|
|
|
self::assertSame(0, (new Config($scopeConfig))->getCancellationLifetimeMinutes());
|
|
}
|
|
}
|