Replaced usage of deprecated methods in DateRange class

This commit is contained in:
Alejandro Celaya 2022-08-04 11:27:33 +02:00
parent ba517eeeb5
commit 7acf27dd38
8 changed files with 53 additions and 51 deletions

View File

@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Shlinkio\Shlink; namespace Shlinkio\Shlink;
use Fig\Http\Message\RequestMethodInterface as RequestMethod; use Fig\Http\Message\RequestMethodInterface;
use RKA\Middleware\IpAddress; use RKA\Middleware\IpAddress;
use Shlinkio\Shlink\Core\Action as CoreAction; use Shlinkio\Shlink\Core\Action as CoreAction;
use Shlinkio\Shlink\Rest\Action; use Shlinkio\Shlink\Rest\Action;
@ -12,6 +12,7 @@ use Shlinkio\Shlink\Rest\ConfigProvider;
use Shlinkio\Shlink\Rest\Middleware; use Shlinkio\Shlink\Rest\Middleware;
use Shlinkio\Shlink\Rest\Middleware\Mercure\NotConfiguredMercureErrorHandler; use Shlinkio\Shlink\Rest\Middleware\Mercure\NotConfiguredMercureErrorHandler;
// The order of the routes defined here matters. Changing it might cause path conflicts
return (static function (): array { return (static function (): array {
$contentNegotiationMiddleware = Middleware\ShortUrl\CreateShortUrlContentNegotiationMiddleware::class; $contentNegotiationMiddleware = Middleware\ShortUrl\CreateShortUrlContentNegotiationMiddleware::class;
$dropDomainMiddleware = Middleware\ShortUrl\DropDefaultDomainFromRequestMiddleware::class; $dropDomainMiddleware = Middleware\ShortUrl\DropDefaultDomainFromRequestMiddleware::class;
@ -20,6 +21,7 @@ return (static function (): array {
return [ return [
'routes' => [ 'routes' => [
// Rest
...ConfigProvider::applyRoutesPrefix([ ...ConfigProvider::applyRoutesPrefix([
Action\HealthAction::getRouteDef(), Action\HealthAction::getRouteDef(),
@ -67,7 +69,7 @@ return (static function (): array {
'middleware' => [ 'middleware' => [
CoreAction\RobotsAction::class, CoreAction\RobotsAction::class,
], ],
'allowed_methods' => [RequestMethod::METHOD_GET], 'allowed_methods' => [RequestMethodInterface::METHOD_GET],
], ],
[ [
'name' => CoreAction\PixelAction::class, 'name' => CoreAction\PixelAction::class,
@ -76,7 +78,7 @@ return (static function (): array {
IpAddress::class, IpAddress::class,
CoreAction\PixelAction::class, CoreAction\PixelAction::class,
], ],
'allowed_methods' => [RequestMethod::METHOD_GET], 'allowed_methods' => [RequestMethodInterface::METHOD_GET],
], ],
[ [
'name' => CoreAction\QrCodeAction::class, 'name' => CoreAction\QrCodeAction::class,
@ -84,7 +86,7 @@ return (static function (): array {
'middleware' => [ 'middleware' => [
CoreAction\QrCodeAction::class, CoreAction\QrCodeAction::class,
], ],
'allowed_methods' => [RequestMethod::METHOD_GET], 'allowed_methods' => [RequestMethodInterface::METHOD_GET],
], ],
[ [
'name' => CoreAction\RedirectAction::class, 'name' => CoreAction\RedirectAction::class,
@ -93,7 +95,7 @@ return (static function (): array {
IpAddress::class, IpAddress::class,
CoreAction\RedirectAction::class, CoreAction\RedirectAction::class,
], ],
'allowed_methods' => [RequestMethod::METHOD_GET], 'allowed_methods' => [RequestMethodInterface::METHOD_GET],
], ],
], ],

View File

@ -46,7 +46,7 @@ class GetShortUrlVisitsCommandTest extends TestCase
$shortCode = 'abc123'; $shortCode = 'abc123';
$this->visitsHelper->visitsForShortUrl( $this->visitsHelper->visitsForShortUrl(
ShortUrlIdentifier::fromShortCodeAndDomain($shortCode), ShortUrlIdentifier::fromShortCodeAndDomain($shortCode),
new VisitsParams(DateRange::emptyInstance()), new VisitsParams(DateRange::allTime()),
) )
->willReturn(new Paginator(new ArrayAdapter([]))) ->willReturn(new Paginator(new ArrayAdapter([])))
->shouldBeCalledOnce(); ->shouldBeCalledOnce();
@ -81,7 +81,7 @@ class GetShortUrlVisitsCommandTest extends TestCase
$startDate = 'foo'; $startDate = 'foo';
$info = $this->visitsHelper->visitsForShortUrl( $info = $this->visitsHelper->visitsForShortUrl(
ShortUrlIdentifier::fromShortCodeAndDomain($shortCode), ShortUrlIdentifier::fromShortCodeAndDomain($shortCode),
new VisitsParams(DateRange::emptyInstance()), new VisitsParams(DateRange::allTime()),
)->willReturn(new Paginator(new ArrayAdapter([]))); )->willReturn(new Paginator(new ArrayAdapter([])));
$this->commandTester->execute([ $this->commandTester->execute([

View File

@ -19,7 +19,7 @@ final class VisitsParams extends AbstractInfinitePaginableListParams
public readonly bool $excludeBots = false, public readonly bool $excludeBots = false,
) { ) {
parent::__construct($page, $itemsPerPage); parent::__construct($page, $itemsPerPage);
$this->dateRange = $dateRange ?? DateRange::emptyInstance(); $this->dateRange = $dateRange ?? DateRange::allTime();
} }
public static function fromRawData(array $query): self public static function fromRawData(array $query): self

View File

@ -152,23 +152,23 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
self::assertSame($bar, $result[0]); self::assertSame($bar, $result[0]);
$result = $this->repo->findList( $result = $this->repo->findList(
new ShortUrlsListFiltering(null, null, Ordering::emptyInstance(), null, [], null, DateRange::withEndDate( new ShortUrlsListFiltering(null, null, Ordering::emptyInstance(), null, [], null, DateRange::until(
Chronos::now()->subDays(2), Chronos::now()->subDays(2),
)), )),
); );
self::assertCount(1, $result); self::assertCount(1, $result);
self::assertEquals(1, $this->repo->countList(new ShortUrlsCountFiltering(null, [], null, DateRange::withEndDate( self::assertEquals(1, $this->repo->countList(new ShortUrlsCountFiltering(null, [], null, DateRange::until(
Chronos::now()->subDays(2), Chronos::now()->subDays(2),
)))); ))));
self::assertSame($foo2, $result[0]); self::assertSame($foo2, $result[0]);
self::assertCount(2, $this->repo->findList( self::assertCount(2, $this->repo->findList(
new ShortUrlsListFiltering(null, null, Ordering::emptyInstance(), null, [], null, DateRange::withStartDate( new ShortUrlsListFiltering(null, null, Ordering::emptyInstance(), null, [], null, DateRange::since(
Chronos::now()->subDays(2), Chronos::now()->subDays(2),
)), )),
)); ));
self::assertEquals(2, $this->repo->countList( self::assertEquals(2, $this->repo->countList(
new ShortUrlsCountFiltering(null, [], null, DateRange::withStartDate(Chronos::now()->subDays(2))), new ShortUrlsCountFiltering(null, [], null, DateRange::since(Chronos::now()->subDays(2))),
)); ));
} }

View File

@ -114,16 +114,16 @@ class VisitRepositoryTest extends DatabaseTestCase
self::assertCount(2, $this->repo->findVisitsByShortCode( self::assertCount(2, $this->repo->findVisitsByShortCode(
ShortUrlIdentifier::fromShortCodeAndDomain($shortCode), ShortUrlIdentifier::fromShortCodeAndDomain($shortCode),
new VisitsListFiltering( new VisitsListFiltering(
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')), DateRange::between(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
), ),
)); ));
self::assertCount(4, $this->repo->findVisitsByShortCode( self::assertCount(4, $this->repo->findVisitsByShortCode(
ShortUrlIdentifier::fromShortCodeAndDomain($shortCode), ShortUrlIdentifier::fromShortCodeAndDomain($shortCode),
new VisitsListFiltering(DateRange::withStartDate(Chronos::parse('2016-01-03'))), new VisitsListFiltering(DateRange::since(Chronos::parse('2016-01-03'))),
)); ));
self::assertCount(1, $this->repo->findVisitsByShortCode( self::assertCount(1, $this->repo->findVisitsByShortCode(
ShortUrlIdentifier::fromShortCodeAndDomain($shortCode, $domain), ShortUrlIdentifier::fromShortCodeAndDomain($shortCode, $domain),
new VisitsListFiltering(DateRange::withStartDate(Chronos::parse('2016-01-03'))), new VisitsListFiltering(DateRange::since(Chronos::parse('2016-01-03'))),
)); ));
self::assertCount(3, $this->repo->findVisitsByShortCode( self::assertCount(3, $this->repo->findVisitsByShortCode(
ShortUrlIdentifier::fromShortCodeAndDomain($shortCode), ShortUrlIdentifier::fromShortCodeAndDomain($shortCode),
@ -163,16 +163,16 @@ class VisitRepositoryTest extends DatabaseTestCase
self::assertEquals(2, $this->repo->countVisitsByShortCode( self::assertEquals(2, $this->repo->countVisitsByShortCode(
ShortUrlIdentifier::fromShortCodeAndDomain($shortCode), ShortUrlIdentifier::fromShortCodeAndDomain($shortCode),
new VisitsCountFiltering( new VisitsCountFiltering(
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')), DateRange::between(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
), ),
)); ));
self::assertEquals(4, $this->repo->countVisitsByShortCode( self::assertEquals(4, $this->repo->countVisitsByShortCode(
ShortUrlIdentifier::fromShortCodeAndDomain($shortCode), ShortUrlIdentifier::fromShortCodeAndDomain($shortCode),
new VisitsCountFiltering(DateRange::withStartDate(Chronos::parse('2016-01-03'))), new VisitsCountFiltering(DateRange::since(Chronos::parse('2016-01-03'))),
)); ));
self::assertEquals(1, $this->repo->countVisitsByShortCode( self::assertEquals(1, $this->repo->countVisitsByShortCode(
ShortUrlIdentifier::fromShortCodeAndDomain($shortCode, $domain), ShortUrlIdentifier::fromShortCodeAndDomain($shortCode, $domain),
new VisitsCountFiltering(DateRange::withStartDate(Chronos::parse('2016-01-03'))), new VisitsCountFiltering(DateRange::since(Chronos::parse('2016-01-03'))),
)); ));
} }
@ -227,10 +227,10 @@ class VisitRepositoryTest extends DatabaseTestCase
self::assertCount(18, $this->repo->findVisitsByTag($foo, new VisitsListFiltering())); self::assertCount(18, $this->repo->findVisitsByTag($foo, new VisitsListFiltering()));
self::assertCount(12, $this->repo->findVisitsByTag($foo, new VisitsListFiltering(null, true))); self::assertCount(12, $this->repo->findVisitsByTag($foo, new VisitsListFiltering(null, true)));
self::assertCount(6, $this->repo->findVisitsByTag($foo, new VisitsListFiltering( self::assertCount(6, $this->repo->findVisitsByTag($foo, new VisitsListFiltering(
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')), DateRange::between(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
))); )));
self::assertCount(12, $this->repo->findVisitsByTag($foo, new VisitsListFiltering( self::assertCount(12, $this->repo->findVisitsByTag($foo, new VisitsListFiltering(
DateRange::withStartDate(Chronos::parse('2016-01-03')), DateRange::since(Chronos::parse('2016-01-03')),
))); )));
} }
@ -249,10 +249,10 @@ class VisitRepositoryTest extends DatabaseTestCase
self::assertEquals(12, $this->repo->countVisitsByTag($foo, new VisitsCountFiltering())); self::assertEquals(12, $this->repo->countVisitsByTag($foo, new VisitsCountFiltering()));
self::assertEquals(8, $this->repo->countVisitsByTag($foo, new VisitsCountFiltering(null, true))); self::assertEquals(8, $this->repo->countVisitsByTag($foo, new VisitsCountFiltering(null, true)));
self::assertEquals(4, $this->repo->countVisitsByTag($foo, new VisitsCountFiltering( self::assertEquals(4, $this->repo->countVisitsByTag($foo, new VisitsCountFiltering(
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')), DateRange::between(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
))); )));
self::assertEquals(8, $this->repo->countVisitsByTag($foo, new VisitsCountFiltering( self::assertEquals(8, $this->repo->countVisitsByTag($foo, new VisitsCountFiltering(
DateRange::withStartDate(Chronos::parse('2016-01-03')), DateRange::since(Chronos::parse('2016-01-03')),
))); )));
} }
@ -267,16 +267,16 @@ class VisitRepositoryTest extends DatabaseTestCase
self::assertCount(3, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering())); self::assertCount(3, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering()));
self::assertCount(1, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering(null, true))); self::assertCount(1, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering(null, true)));
self::assertCount(2, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering( self::assertCount(2, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering(
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')), DateRange::between(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
))); )));
self::assertCount(1, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering( self::assertCount(1, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering(
DateRange::withStartDate(Chronos::parse('2016-01-03')), DateRange::since(Chronos::parse('2016-01-03')),
))); )));
self::assertCount(2, $this->repo->findVisitsByDomain('DEFAULT', new VisitsListFiltering( self::assertCount(2, $this->repo->findVisitsByDomain('DEFAULT', new VisitsListFiltering(
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')), DateRange::between(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
))); )));
self::assertCount(4, $this->repo->findVisitsByDomain('DEFAULT', new VisitsListFiltering( self::assertCount(4, $this->repo->findVisitsByDomain('DEFAULT', new VisitsListFiltering(
DateRange::withStartDate(Chronos::parse('2016-01-03')), DateRange::since(Chronos::parse('2016-01-03')),
))); )));
} }
@ -291,16 +291,16 @@ class VisitRepositoryTest extends DatabaseTestCase
self::assertEquals(3, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering())); self::assertEquals(3, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering()));
self::assertEquals(1, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering(null, true))); self::assertEquals(1, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering(null, true)));
self::assertEquals(2, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering( self::assertEquals(2, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering(
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')), DateRange::between(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
))); )));
self::assertEquals(1, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering( self::assertEquals(1, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering(
DateRange::withStartDate(Chronos::parse('2016-01-03')), DateRange::since(Chronos::parse('2016-01-03')),
))); )));
self::assertEquals(2, $this->repo->countVisitsByDomain('DEFAULT', new VisitsListFiltering( self::assertEquals(2, $this->repo->countVisitsByDomain('DEFAULT', new VisitsListFiltering(
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')), DateRange::between(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
))); )));
self::assertEquals(4, $this->repo->countVisitsByDomain('DEFAULT', new VisitsListFiltering( self::assertEquals(4, $this->repo->countVisitsByDomain('DEFAULT', new VisitsListFiltering(
DateRange::withStartDate(Chronos::parse('2016-01-03')), DateRange::since(Chronos::parse('2016-01-03')),
))); )));
} }
@ -349,13 +349,13 @@ class VisitRepositoryTest extends DatabaseTestCase
self::assertEquals(4, $this->repo->countNonOrphanVisits(VisitsCountFiltering::withApiKey($apiKey1))); self::assertEquals(4, $this->repo->countNonOrphanVisits(VisitsCountFiltering::withApiKey($apiKey1)));
self::assertEquals(5 + 7, $this->repo->countNonOrphanVisits(VisitsCountFiltering::withApiKey($apiKey2))); self::assertEquals(5 + 7, $this->repo->countNonOrphanVisits(VisitsCountFiltering::withApiKey($apiKey2)));
self::assertEquals(4 + 7, $this->repo->countNonOrphanVisits(VisitsCountFiltering::withApiKey($domainApiKey))); self::assertEquals(4 + 7, $this->repo->countNonOrphanVisits(VisitsCountFiltering::withApiKey($domainApiKey)));
self::assertEquals(4, $this->repo->countNonOrphanVisits(new VisitsCountFiltering(DateRange::withStartDate( self::assertEquals(4, $this->repo->countNonOrphanVisits(new VisitsCountFiltering(DateRange::since(
Chronos::parse('2016-01-05')->startOfDay(), Chronos::parse('2016-01-05')->startOfDay(),
)))); ))));
self::assertEquals(2, $this->repo->countNonOrphanVisits(new VisitsCountFiltering(DateRange::withStartDate( self::assertEquals(2, $this->repo->countNonOrphanVisits(new VisitsCountFiltering(DateRange::since(
Chronos::parse('2016-01-03')->startOfDay(), Chronos::parse('2016-01-03')->startOfDay(),
), false, $apiKey1))); ), false, $apiKey1)));
self::assertEquals(1, $this->repo->countNonOrphanVisits(new VisitsCountFiltering(DateRange::withStartDate( self::assertEquals(1, $this->repo->countNonOrphanVisits(new VisitsCountFiltering(DateRange::since(
Chronos::parse('2016-01-07')->startOfDay(), Chronos::parse('2016-01-07')->startOfDay(),
), false, $apiKey2))); ), false, $apiKey2)));
self::assertEquals(3 + 5, $this->repo->countNonOrphanVisits(new VisitsCountFiltering(null, true, $apiKey2))); self::assertEquals(3 + 5, $this->repo->countNonOrphanVisits(new VisitsCountFiltering(null, true, $apiKey2)));
@ -395,20 +395,20 @@ class VisitRepositoryTest extends DatabaseTestCase
self::assertCount(5, $this->repo->findOrphanVisits(new VisitsListFiltering(null, false, null, 5))); self::assertCount(5, $this->repo->findOrphanVisits(new VisitsListFiltering(null, false, null, 5)));
self::assertCount(10, $this->repo->findOrphanVisits(new VisitsListFiltering(null, false, null, 15, 8))); self::assertCount(10, $this->repo->findOrphanVisits(new VisitsListFiltering(null, false, null, 15, 8)));
self::assertCount(9, $this->repo->findOrphanVisits(new VisitsListFiltering( self::assertCount(9, $this->repo->findOrphanVisits(new VisitsListFiltering(
DateRange::withStartDate(Chronos::parse('2020-01-04')), DateRange::since(Chronos::parse('2020-01-04')),
false, false,
null, null,
15, 15,
))); )));
self::assertCount(2, $this->repo->findOrphanVisits(new VisitsListFiltering( self::assertCount(2, $this->repo->findOrphanVisits(new VisitsListFiltering(
DateRange::withStartAndEndDate(Chronos::parse('2020-01-02'), Chronos::parse('2020-01-03')), DateRange::between(Chronos::parse('2020-01-02'), Chronos::parse('2020-01-03')),
false, false,
null, null,
6, 6,
4, 4,
))); )));
self::assertCount(3, $this->repo->findOrphanVisits(new VisitsListFiltering( self::assertCount(3, $this->repo->findOrphanVisits(new VisitsListFiltering(
DateRange::withEndDate(Chronos::parse('2020-01-01')), DateRange::until(Chronos::parse('2020-01-01')),
))); )));
} }
@ -437,15 +437,15 @@ class VisitRepositoryTest extends DatabaseTestCase
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();
self::assertEquals(18, $this->repo->countOrphanVisits(new VisitsCountFiltering())); self::assertEquals(18, $this->repo->countOrphanVisits(new VisitsCountFiltering()));
self::assertEquals(18, $this->repo->countOrphanVisits(new VisitsCountFiltering(DateRange::emptyInstance()))); self::assertEquals(18, $this->repo->countOrphanVisits(new VisitsCountFiltering(DateRange::allTime())));
self::assertEquals(9, $this->repo->countOrphanVisits( self::assertEquals(9, $this->repo->countOrphanVisits(
new VisitsCountFiltering(DateRange::withStartDate(Chronos::parse('2020-01-04'))), new VisitsCountFiltering(DateRange::since(Chronos::parse('2020-01-04'))),
)); ));
self::assertEquals(6, $this->repo->countOrphanVisits(new VisitsCountFiltering( self::assertEquals(6, $this->repo->countOrphanVisits(new VisitsCountFiltering(
DateRange::withStartAndEndDate(Chronos::parse('2020-01-02'), Chronos::parse('2020-01-03')), DateRange::between(Chronos::parse('2020-01-02'), Chronos::parse('2020-01-03')),
))); )));
self::assertEquals(3, $this->repo->countOrphanVisits( self::assertEquals(3, $this->repo->countOrphanVisits(
new VisitsCountFiltering(DateRange::withEndDate(Chronos::parse('2020-01-01'))), new VisitsCountFiltering(DateRange::until(Chronos::parse('2020-01-01'))),
)); ));
} }
@ -467,22 +467,22 @@ class VisitRepositoryTest extends DatabaseTestCase
$this->getEntityManager()->flush(); $this->getEntityManager()->flush();
self::assertCount(21, $this->repo->findNonOrphanVisits(new VisitsListFiltering())); self::assertCount(21, $this->repo->findNonOrphanVisits(new VisitsListFiltering()));
self::assertCount(21, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::emptyInstance()))); self::assertCount(21, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::allTime())));
self::assertCount(7, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::withStartDate( self::assertCount(7, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::since(
Chronos::parse('2016-01-05')->endOfDay(), Chronos::parse('2016-01-05')->endOfDay(),
)))); ))));
self::assertCount(12, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::withEndDate( self::assertCount(12, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::until(
Chronos::parse('2016-01-04')->endOfDay(), Chronos::parse('2016-01-04')->endOfDay(),
)))); ))));
self::assertCount(6, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::withStartAndEndDate( self::assertCount(6, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::between(
Chronos::parse('2016-01-03')->startOfDay(), Chronos::parse('2016-01-03')->startOfDay(),
Chronos::parse('2016-01-04')->endOfDay(), Chronos::parse('2016-01-04')->endOfDay(),
)))); ))));
self::assertCount(13, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::withStartAndEndDate( self::assertCount(13, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::between(
Chronos::parse('2016-01-03')->startOfDay(), Chronos::parse('2016-01-03')->startOfDay(),
Chronos::parse('2016-01-08')->endOfDay(), Chronos::parse('2016-01-08')->endOfDay(),
)))); ))));
self::assertCount(3, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::withStartAndEndDate( self::assertCount(3, $this->repo->findNonOrphanVisits(new VisitsListFiltering(DateRange::between(
Chronos::parse('2016-01-03')->startOfDay(), Chronos::parse('2016-01-03')->startOfDay(),
Chronos::parse('2016-01-08')->endOfDay(), Chronos::parse('2016-01-08')->endOfDay(),
), false, null, 10, 10))); ), false, null, 10, 10)));

View File

@ -36,7 +36,7 @@ class ShortUrlVisitsPaginatorAdapterTest extends TestCase
$adapter = $this->createAdapter(null); $adapter = $this->createAdapter(null);
$findVisits = $this->repo->findVisitsByShortCode( $findVisits = $this->repo->findVisitsByShortCode(
ShortUrlIdentifier::fromShortCodeAndDomain(''), ShortUrlIdentifier::fromShortCodeAndDomain(''),
new VisitsListFiltering(DateRange::emptyInstance(), false, null, $limit, $offset), new VisitsListFiltering(DateRange::allTime(), false, null, $limit, $offset),
)->willReturn([]); )->willReturn([]);
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
@ -54,7 +54,7 @@ class ShortUrlVisitsPaginatorAdapterTest extends TestCase
$adapter = $this->createAdapter($apiKey); $adapter = $this->createAdapter($apiKey);
$countVisits = $this->repo->countVisitsByShortCode( $countVisits = $this->repo->countVisitsByShortCode(
ShortUrlIdentifier::fromShortCodeAndDomain(''), ShortUrlIdentifier::fromShortCodeAndDomain(''),
new VisitsCountFiltering(DateRange::emptyInstance(), false, $apiKey), new VisitsCountFiltering(DateRange::allTime(), false, $apiKey),
)->willReturn(3); )->willReturn(3);
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {

View File

@ -35,7 +35,7 @@ class VisitsForTagPaginatorAdapterTest extends TestCase
$adapter = $this->createAdapter(null); $adapter = $this->createAdapter(null);
$findVisits = $this->repo->findVisitsByTag( $findVisits = $this->repo->findVisitsByTag(
'foo', 'foo',
new VisitsListFiltering(DateRange::emptyInstance(), false, null, $limit, $offset), new VisitsListFiltering(DateRange::allTime(), false, null, $limit, $offset),
)->willReturn([]); )->willReturn([]);
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
@ -53,7 +53,7 @@ class VisitsForTagPaginatorAdapterTest extends TestCase
$adapter = $this->createAdapter($apiKey); $adapter = $this->createAdapter($apiKey);
$countVisits = $this->repo->countVisitsByTag( $countVisits = $this->repo->countVisitsByTag(
'foo', 'foo',
new VisitsCountFiltering(DateRange::emptyInstance(), false, $apiKey), new VisitsCountFiltering(DateRange::allTime(), false, $apiKey),
)->willReturn(3); )->willReturn(3);
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {

View File

@ -53,7 +53,7 @@ class ShortUrlVisitsActionTest extends TestCase
{ {
$shortCode = 'abc123'; $shortCode = 'abc123';
$this->visitsHelper->visitsForShortUrl(ShortUrlIdentifier::fromShortCodeAndDomain($shortCode), new VisitsParams( $this->visitsHelper->visitsForShortUrl(ShortUrlIdentifier::fromShortCodeAndDomain($shortCode), new VisitsParams(
DateRange::withEndDate(Chronos::parse('2016-01-01 00:00:00')), DateRange::until(Chronos::parse('2016-01-01 00:00:00')),
3, 3,
10, 10,
), Argument::type(ApiKey::class)) ), Argument::type(ApiKey::class))