mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-07 07:43: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 Fig\Http\Message\RequestMethodInterface;
|
||||
use Laminas\Diactoros\ServerRequestFactory;
|
||||
use Mezzio\Router\Middleware\ImplicitHeadMiddleware;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
@@ -45,10 +47,7 @@ class RequestTrackerTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideNonTrackingRequests
|
||||
*/
|
||||
#[Test, DataProvider('provideNonTrackingRequests')]
|
||||
public function trackingIsDisabledWhenRequestDoesNotMeetConditions(ServerRequestInterface $request): void
|
||||
{
|
||||
$this->visitsTracker->expects($this->never())->method('track');
|
||||
@@ -81,7 +80,7 @@ class RequestTrackerTest extends TestCase
|
||||
)];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function trackingHappensOverShortUrlsWhenRequestMeetsConditions(): void
|
||||
{
|
||||
$shortUrl = ShortUrl::withLongUrl(self::LONG_URL);
|
||||
@@ -93,7 +92,7 @@ class RequestTrackerTest extends TestCase
|
||||
$this->requestTracker->trackIfApplicable($shortUrl, $this->request);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function baseUrlErrorIsTracked(): void
|
||||
{
|
||||
$this->notFoundType->expects($this->once())->method('isBaseUrl')->willReturn(true);
|
||||
@@ -108,7 +107,7 @@ class RequestTrackerTest extends TestCase
|
||||
$this->requestTracker->trackNotFoundIfApplicable($this->request);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function regularNotFoundErrorIsTracked(): void
|
||||
{
|
||||
$this->notFoundType->expects($this->once())->method('isBaseUrl')->willReturn(false);
|
||||
@@ -123,7 +122,7 @@ class RequestTrackerTest extends TestCase
|
||||
$this->requestTracker->trackNotFoundIfApplicable($this->request);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidShortUrlErrorIsTracked(): void
|
||||
{
|
||||
$this->notFoundType->expects($this->once())->method('isBaseUrl')->willReturn(false);
|
||||
@@ -138,10 +137,7 @@ class RequestTrackerTest extends TestCase
|
||||
$this->requestTracker->trackNotFoundIfApplicable($this->request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideNonTrackingRequests
|
||||
*/
|
||||
#[Test, DataProvider('provideNonTrackingRequests')]
|
||||
public function notFoundIsNotTrackedIfRequestDoesNotMeetConditions(ServerRequestInterface $request): void
|
||||
{
|
||||
$this->visitsTracker->expects($this->never())->method('trackBaseUrlVisit');
|
||||
|
||||
Reference in New Issue
Block a user