mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-12 01:54:41 +08:00
Support for redirects with a condition before date
This commit is contained in:
committed by
Alejandro Celaya
parent
77898d1edc
commit
dae52fedf4
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace ShlinkioTest\Shlink\Core\RedirectRule\Entity;
|
||||
|
||||
use Cake\Chronos\Chronos;
|
||||
use Laminas\Diactoros\ServerRequestFactory;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
@@ -195,4 +196,19 @@ class RedirectConditionTest extends TestCase
|
||||
);
|
||||
self::assertEquals($expectedType, $condition?->type);
|
||||
}
|
||||
|
||||
#[Test, DataProvider('provideVisitsWithBeforeDateCondition')]
|
||||
public function matchesBeforeDate(string $date, bool $expectedResult): void
|
||||
{
|
||||
$request = ServerRequestFactory::fromGlobals();
|
||||
$result = RedirectCondition::forBeforeDate($date)->matchesRequest($request);
|
||||
|
||||
self::assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
public static function provideVisitsWithBeforeDateCondition(): iterable
|
||||
{
|
||||
yield 'date later than current' => [Chronos::now()->addHours(1)->toIso8601String(), true];
|
||||
yield 'date earlier than current' => [Chronos::now()->subHours(1)->toIso8601String(), false];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user