Migrate from PHPUnit annotations to native attributes

This commit is contained in:
Alejandro Celaya
2023-02-09 20:42:18 +01:00
parent 650a286982
commit 04bbd471ff
188 changed files with 776 additions and 1082 deletions

View File

@@ -6,6 +6,8 @@ namespace ShlinkioTest\Shlink\Rest\Action\Visit;
use Laminas\Diactoros\ServerRequestFactory;
use Pagerfanta\Adapter\ArrayAdapter;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Common\Paginator\Paginator;
@@ -25,10 +27,7 @@ class DomainVisitsActionTest extends TestCase
$this->action = new DomainVisitsAction($this->visitsHelper, 'the_default.com');
}
/**
* @test
* @dataProvider provideDomainAuthorities
*/
#[Test, DataProvider('provideDomainAuthorities')]
public function providingCorrectDomainReturnsVisits(string $providedDomain, string $expectedDomain): void
{
$apiKey = ApiKey::create();

View File

@@ -6,6 +6,7 @@ namespace ShlinkioTest\Shlink\Rest\Action\Visit;
use Laminas\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\ServerRequestFactory;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Visit\Model\VisitsStats;
@@ -24,7 +25,7 @@ class GlobalVisitsActionTest extends TestCase
$this->action = new GlobalVisitsAction($this->helper);
}
/** @test */
#[Test]
public function statsAreReturnedFromHelper(): void
{
$apiKey = ApiKey::create();

View File

@@ -7,6 +7,7 @@ namespace ShlinkioTest\Shlink\Rest\Action\Visit;
use Laminas\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\ServerRequestFactory;
use Pagerfanta\Adapter\ArrayAdapter;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Common\Paginator\Paginator;
@@ -26,7 +27,7 @@ class NonOrphanVisitsActionTest extends TestCase
$this->action = new NonOrphanVisitsAction($this->visitsHelper);
}
/** @test */
#[Test]
public function requestIsHandled(): void
{
$apiKey = ApiKey::create();

View File

@@ -7,6 +7,7 @@ namespace ShlinkioTest\Shlink\Rest\Action\Visit;
use Laminas\Diactoros\Response\JsonResponse;
use Laminas\Diactoros\ServerRequestFactory;
use Pagerfanta\Adapter\ArrayAdapter;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Common\Paginator\Paginator;
@@ -33,7 +34,7 @@ class OrphanVisitsActionTest extends TestCase
$this->action = new OrphanVisitsAction($this->visitsHelper, $this->orphanVisitTransformer);
}
/** @test */
#[Test]
public function requestIsHandled(): void
{
$visitor = Visitor::emptyInstance();

View File

@@ -7,6 +7,7 @@ namespace ShlinkioTest\Shlink\Rest\Action\Visit;
use Cake\Chronos\Chronos;
use Laminas\Diactoros\ServerRequestFactory;
use Pagerfanta\Adapter\ArrayAdapter;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ServerRequestInterface;
@@ -29,7 +30,7 @@ class ShortUrlVisitsActionTest extends TestCase
$this->action = new ShortUrlVisitsAction($this->visitsHelper);
}
/** @test */
#[Test]
public function providingCorrectShortCodeReturnsVisits(): void
{
$shortCode = 'abc123';
@@ -43,7 +44,7 @@ class ShortUrlVisitsActionTest extends TestCase
self::assertEquals(200, $response->getStatusCode());
}
/** @test */
#[Test]
public function paramsAreReadFromQuery(): void
{
$shortCode = 'abc123';

View File

@@ -6,6 +6,7 @@ namespace ShlinkioTest\Shlink\Rest\Action\Visit;
use Laminas\Diactoros\ServerRequestFactory;
use Pagerfanta\Adapter\ArrayAdapter;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Common\Paginator\Paginator;
@@ -25,7 +26,7 @@ class TagVisitsActionTest extends TestCase
$this->action = new TagVisitsAction($this->visitsHelper);
}
/** @test */
#[Test]
public function providingCorrectTagReturnsVisits(): void
{
$tag = 'foo';