Skip to content

Commit

Permalink
dev: Upgrade to PHPUnit 11
Browse files Browse the repository at this point in the history
  • Loading branch information
marien-probesys committed May 7, 2024
1 parent bb0dd46 commit 989b7f9
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 256 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"require-dev": {
"dama/doctrine-test-bundle": "^8.0",
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^10.5",
"phpunit/phpunit": "^11.1",
"rector/rector": "^1.0.4",
"squizlabs/php_codesniffer": "*",
"symfony/browser-kit": "6.4.*",
Expand Down
452 changes: 230 additions & 222 deletions composer.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions tests/CommandTestsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace App\Tests;

use PHPUnit\Framework\Attributes\BeforeClass;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;

Expand All @@ -16,9 +17,7 @@ trait CommandTestsHelper
*/
protected static $application;

/**
* @beforeClass
*/
#[BeforeClass]
public static function setUpConsoleTestsHelper(): void
{
self::bootKernel();
Expand Down
4 changes: 2 additions & 2 deletions tests/SearchEngine/Query/TokenizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\SearchEngine\Query\TokenType;
use App\SearchEngine\Query\Tokenizer;
use App\SearchEngine\Query\SyntaxError;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -17,10 +18,9 @@
class TokenizerTest extends TestCase
{
/**
* @dataProvider tokensProvider
*
* @param Token[] $expectedTokens
*/
#[DataProvider('tokensProvider')]
public function testTokenize(string $query, array $expectedTokens): void
{
$tokenizer = new Tokenizer();
Expand Down
5 changes: 2 additions & 3 deletions tests/SearchEngine/QueryBuilder/TicketQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Tests\AuthorizationHelper;
use App\Tests\Factory\OrganizationFactory;
use App\Tests\Factory\UserFactory;
use PHPUnit\Framework\Attributes\Before;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand All @@ -26,9 +27,7 @@ class TicketQueryBuilderTest extends WebTestCase

private User $currentUser;

/**
* @before
*/
#[Before]
public function setUpQueryBuilder(): void
{
$client = static::createClient();
Expand Down
5 changes: 2 additions & 3 deletions tests/Security/AuthorizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use App\Tests\Factory\OrganizationFactory;
use App\Tests\Factory\UserFactory;
use App\Tests\Factory\RoleFactory;
use PHPUnit\Framework\Attributes\Before;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
Expand All @@ -28,9 +29,7 @@ class AuthorizerTest extends WebTestCase

private AuthorizationRepository $authRepository;

/**
* @before
*/
#[Before]
public function setupTest(): void
{
$this->client = static::createClient();
Expand Down
5 changes: 2 additions & 3 deletions tests/Service/ActorsListerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use App\Tests\Factory\OrganizationFactory;
use App\Tests\Factory\RoleFactory;
use App\Tests\Factory\UserFactory;
use PHPUnit\Framework\Attributes\Before;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand All @@ -30,9 +31,7 @@ class ActorsListerTest extends WebTestCase

private AuthorizationRepository $authRepository;

/**
* @before
*/
#[Before]
public function setupTest(): void
{
$client = static::createClient();
Expand Down
5 changes: 2 additions & 3 deletions tests/Service/ContractTimeAccountingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Tests\Factory\ContractFactory;
use App\Tests\Factory\TimeSpentFactory;
use App\Tests\Factory\UserFactory;
use PHPUnit\Framework\Attributes\Before;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand All @@ -21,9 +22,7 @@ class ContractTimeAccountingTest extends WebTestCase

private ContractTimeAccounting $contractTimeAccounting;

/**
* @before
*/
#[Before]
public function setupTest(): void
{
$client = static::createClient();
Expand Down
5 changes: 2 additions & 3 deletions tests/Service/DataImporter/DataImporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use App\Tests\Factory\RoleFactory;
use App\Tests\Factory\TicketFactory;
use App\Tests\Factory\UserFactory;
use PHPUnit\Framework\Attributes\Before;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Test\Factories;
use Zenstruck\Foundry\Test\ResetDatabase;
Expand All @@ -26,9 +27,7 @@ class DataImporterTest extends WebTestCase

private DataImporter $dataImporter;

/**
* @before
*/
#[Before]
public function setupTest(): void
{
$client = static::createClient();
Expand Down
5 changes: 2 additions & 3 deletions tests/Twig/TicketEventChangesFormatterExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use App\Tests\Factory\TicketFactory;
use App\Tests\Factory\UserFactory;
use App\Twig\TicketEventChangesFormatterExtension;
use PHPUnit\Framework\Attributes\Before;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Zenstruck\Foundry\Proxy;
Expand All @@ -34,9 +35,7 @@ class TicketEventChangesFormatterExtensionTest extends WebTestCase

private TicketEventChangesFormatterExtension $formatter;

/**
* @before
*/
#[Before]
public function setUpTest(): void
{
$this->client = static::createClient();
Expand Down
7 changes: 3 additions & 4 deletions tests/Utils/LocalesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
namespace App\Tests\Utils;

use App\Utils\Locales;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class LocalesTest extends TestCase
{
/**
* @dataProvider englishRequestedLocale
*
* @param string[] $requestedLocales
*/
#[DataProvider('englishRequestedLocale')]
public function testGetBestWithEnglish(array $requestedLocales): void
{
$locale = Locales::getBest($requestedLocales);
Expand All @@ -24,10 +24,9 @@ public function testGetBestWithEnglish(array $requestedLocales): void
}

/**
* @dataProvider frenchRequestedLocale
*
* @param string[] $requestedLocales
*/
#[DataProvider('frenchRequestedLocale')]
public function testGetBestWithFrench(array $requestedLocales): void
{
$locale = Locales::getBest($requestedLocales);
Expand Down
10 changes: 4 additions & 6 deletions tests/Utils/TimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@
namespace App\Tests\Utils;

use App\Utils\Time;
use PHPUnit\Framework\Attributes\AfterClass;
use PHPUnit\Framework\Attributes\BeforeClass;
use PHPUnit\Framework\TestCase;

class TimeTest extends TestCase
{
/**
* @beforeClass
*/
#[BeforeClass]
public static function freezeTime(): void
{
$now = new \DateTimeImmutable('2022-11-02');
Time::freeze($now);
}

/**
* @afterClass
*/
#[AfterClass]
public static function unfreezeTime(): void
{
Time::unfreeze();
Expand Down

0 comments on commit 989b7f9

Please sign in to comment.