mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Migrated from standard datetime objects to chronos objects
This commit is contained in:
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Rest\Action\Visit;
|
||||
|
||||
use Cake\Chronos\Chronos;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
@@ -77,7 +78,7 @@ class GetVisitsActionTest extends TestCase
|
||||
public function datesAreReadFromQuery()
|
||||
{
|
||||
$shortCode = 'abc123';
|
||||
$this->visitsTracker->info($shortCode, new DateRange(null, new \DateTime('2016-01-01 00:00:00')))
|
||||
$this->visitsTracker->info($shortCode, new DateRange(null, Chronos::parse('2016-01-01 00:00:00')))
|
||||
->willReturn([])
|
||||
->shouldBeCalledTimes(1);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Rest\Service;
|
||||
|
||||
use Cake\Chronos\Chronos;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -48,7 +49,7 @@ class ApiKeyServiceTest extends TestCase
|
||||
$this->em->flush()->shouldBeCalledTimes(1);
|
||||
$this->em->persist(Argument::type(ApiKey::class))->shouldBeCalledTimes(1);
|
||||
|
||||
$date = new \DateTime('2030-01-01');
|
||||
$date = Chronos::parse('2030-01-01');
|
||||
$key = $this->service->create($date);
|
||||
$this->assertSame($date, $key->getExpirationDate());
|
||||
}
|
||||
@@ -87,7 +88,7 @@ class ApiKeyServiceTest extends TestCase
|
||||
public function checkReturnsFalseWhenKeyIsExpired()
|
||||
{
|
||||
$key = new ApiKey();
|
||||
$key->setExpirationDate((new \DateTime())->sub(new \DateInterval('P1D')));
|
||||
$key->setExpirationDate(Chronos::now()->subDay());
|
||||
$repo = $this->prophesize(EntityRepository::class);
|
||||
$repo->findOneBy(['key' => '12345'])->willReturn($key)
|
||||
->shouldBeCalledTimes(1);
|
||||
|
||||
Reference in New Issue
Block a user