mirror of
https://github.com/shlinkio/shlink.git
synced 2026-02-28 04:03:12 +08:00
Migrate from PHPUnit annotations to native attributes
This commit is contained in:
@@ -7,6 +7,8 @@ namespace ShlinkioTest\Shlink\Core\Visit;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Laminas\Stdlib\ArrayUtils;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
|
||||
@@ -47,10 +49,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
$this->helper = new VisitsStatsHelper($this->em);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideCounts
|
||||
*/
|
||||
#[Test, DataProvider('provideCounts')]
|
||||
public function returnsExpectedVisitsStats(int $expectedCount): void
|
||||
{
|
||||
$repo = $this->createMock(VisitRepository::class);
|
||||
@@ -78,10 +77,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
return map(range(0, 50, 5), fn (int $value) => [$value]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideAdminApiKeys
|
||||
*/
|
||||
#[Test, DataProvider('provideAdminApiKeys')]
|
||||
public function infoReturnsVisitsForCertainShortCode(?ApiKey $apiKey): void
|
||||
{
|
||||
$shortCode = '123ABC';
|
||||
@@ -112,7 +108,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
self::assertEquals($list, ArrayUtils::iteratorToArray($paginator->getCurrentPageResults()));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function throwsExceptionWhenRequestingVisitsForInvalidShortCode(): void
|
||||
{
|
||||
$shortCode = '123ABC';
|
||||
@@ -127,7 +123,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
$this->helper->visitsForShortUrl($identifier, new VisitsParams());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function throwsExceptionWhenRequestingVisitsForInvalidTag(): void
|
||||
{
|
||||
$tag = 'foo';
|
||||
@@ -141,10 +137,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
$this->helper->visitsForTag($tag, new VisitsParams(), $apiKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideAdminApiKeys
|
||||
*/
|
||||
#[Test, DataProvider('provideAdminApiKeys')]
|
||||
public function visitsForTagAreReturnedAsExpected(?ApiKey $apiKey): void
|
||||
{
|
||||
$tag = 'foo';
|
||||
@@ -168,7 +161,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
self::assertEquals($list, ArrayUtils::iteratorToArray($paginator->getCurrentPageResults()));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function throwsExceptionWhenRequestingVisitsForInvalidDomain(): void
|
||||
{
|
||||
$domain = 'foo.com';
|
||||
@@ -182,10 +175,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
$this->helper->visitsForDomain($domain, new VisitsParams(), $apiKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideAdminApiKeys
|
||||
*/
|
||||
#[Test, DataProvider('provideAdminApiKeys')]
|
||||
public function visitsForNonDefaultDomainAreReturnedAsExpected(?ApiKey $apiKey): void
|
||||
{
|
||||
$domain = 'foo.com';
|
||||
@@ -213,10 +203,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
self::assertEquals($list, ArrayUtils::iteratorToArray($paginator->getCurrentPageResults()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideAdminApiKeys
|
||||
*/
|
||||
#[Test, DataProvider('provideAdminApiKeys')]
|
||||
public function visitsForDefaultDomainAreReturnedAsExpected(?ApiKey $apiKey): void
|
||||
{
|
||||
$repo = $this->createMock(DomainRepository::class);
|
||||
@@ -243,7 +230,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
self::assertEquals($list, ArrayUtils::iteratorToArray($paginator->getCurrentPageResults()));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function orphanVisitsAreReturnedAsExpected(): void
|
||||
{
|
||||
$list = map(range(0, 3), fn () => Visit::forBasePath(Visitor::emptyInstance()));
|
||||
@@ -261,7 +248,7 @@ class VisitsStatsHelperTest extends TestCase
|
||||
self::assertEquals($list, ArrayUtils::iteratorToArray($paginator->getCurrentPageResults()));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function nonOrphanVisitsAreReturnedAsExpected(): void
|
||||
{
|
||||
$list = map(range(0, 3), fn () => Visit::forValidShortUrl(ShortUrl::createFake(), Visitor::emptyInstance()));
|
||||
|
||||
Reference in New Issue
Block a user