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

@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace ShlinkioTest\Shlink\Core\EventDispatcher;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\EventDispatcher\EventDispatcherInterface;
@@ -32,7 +34,7 @@ class UpdateGeoLiteDbTest extends TestCase
$this->listener = new UpdateGeoLiteDb($this->dbUpdater, $this->logger, $this->eventDispatcher);
}
/** @test */
#[Test]
public function exceptionWhileUpdatingDbLogsError(): void
{
$e = new RuntimeException();
@@ -48,10 +50,7 @@ class UpdateGeoLiteDbTest extends TestCase
($this->listener)();
}
/**
* @test
* @dataProvider provideFlags
*/
#[Test, DataProvider('provideFlags')]
public function noticeMessageIsPrintedWhenFirstCallbackIsInvoked(bool $oldDbExists, string $expectedMessage): void
{
$this->dbUpdater->expects($this->once())->method('checkDbUpdate')->withAnyParameters()->willReturnCallback(
@@ -73,10 +72,7 @@ class UpdateGeoLiteDbTest extends TestCase
yield 'not existing old db' => [false, 'Downloading GeoLite2 db file...'];
}
/**
* @test
* @dataProvider provideDownloaded
*/
#[Test, DataProvider('provideDownloaded')]
public function noticeMessageIsPrintedWhenSecondCallbackIsInvoked(
int $total,
int $downloaded,
@@ -113,10 +109,7 @@ class UpdateGeoLiteDbTest extends TestCase
yield [100, 101, false, 'Finished downloading GeoLite2 db file'];
}
/**
* @test
* @dataProvider provideGeolocationResults
*/
#[Test, DataProvider('provideGeolocationResults')]
public function dispatchesEventOnlyWhenDbFileHasBeenCreatedForTheFirstTime(
GeolocationResult $result,
int $expectedDispatches,