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

@@ -5,6 +5,8 @@ declare(strict_types=1);
namespace ShlinkioTest\Shlink\Core\Domain;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Config\EmptyNotFoundRedirectConfig;
@@ -29,10 +31,7 @@ class DomainServiceTest extends TestCase
$this->domainService = new DomainService($this->em, 'default.com');
}
/**
* @test
* @dataProvider provideExcludedDomains
*/
#[Test, DataProvider('provideExcludedDomains')]
public function listDomainsDelegatesIntoRepository(array $domains, array $expectedResult, ?ApiKey $apiKey): void
{
$repo = $this->createMock(DomainRepositoryInterface::class);
@@ -102,7 +101,7 @@ class DomainServiceTest extends TestCase
];
}
/** @test */
#[Test]
public function getDomainThrowsExceptionWhenDomainIsNotFound(): void
{
$this->em->expects($this->once())->method('find')->with(Domain::class, '123')->willReturn(null);
@@ -112,7 +111,7 @@ class DomainServiceTest extends TestCase
$this->domainService->getDomain('123');
}
/** @test */
#[Test]
public function getDomainReturnsEntityWhenFound(): void
{
$domain = Domain::withAuthority('');
@@ -123,10 +122,7 @@ class DomainServiceTest extends TestCase
self::assertSame($domain, $result);
}
/**
* @test
* @dataProvider provideFoundDomains
*/
#[Test, DataProvider('provideFoundDomains')]
public function getOrCreateAlwaysPersistsDomain(?Domain $foundDomain, ?ApiKey $apiKey): void
{
$authority = 'example.com';
@@ -145,7 +141,7 @@ class DomainServiceTest extends TestCase
}
}
/** @test */
#[Test]
public function getOrCreateThrowsExceptionForApiKeysWithDomainRole(): void
{
$authority = 'example.com';
@@ -163,10 +159,7 @@ class DomainServiceTest extends TestCase
$this->domainService->getOrCreate($authority, $apiKey);
}
/**
* @test
* @dataProvider provideFoundDomains
*/
#[Test, DataProvider('provideFoundDomains')]
public function configureNotFoundRedirectsConfiguresFetchedDomain(?Domain $foundDomain, ?ApiKey $apiKey): void
{
$authority = 'example.com';