diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bfbb45c3..1ecdf3c5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -20,6 +20,7 @@ jobs: symfony-version: - '^5.4' - '^6.4' + - '^7.2' php-version: - "8.3" - "8.4" @@ -39,6 +40,13 @@ jobs: coverage: "pcov" ini-values: "zend.assertions=1" + - name: Remove sensio/framework-extra-bundle + uses: php-actions/composer@v6 + if: matrix.symfony-version == '^7.2' + with: + command: remove + args: --dev sensio/framework-extra-bundle --no-update + - name: Configure symfony version uses: php-actions/composer@v6 with: @@ -46,11 +54,11 @@ jobs: args: extra.symfony.require ${{ matrix.symfony-version }} - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v1" + uses: "ramsey/composer-install@v3" with: dependency-versions: "${{ matrix.dependencies }}" composer-options: "${{ matrix.composer-options }}" - name: Run tests run: | - SYMFONY_DEPRECATIONS_HELPER=weak vendor/bin/simple-phpunit ${PHPUNIT_FLAGS} + SYMFONY_PHPUNIT_VERSION=11.5 SYMFONY_DEPRECATIONS_HELPER=weak vendor/bin/simple-phpunit ${PHPUNIT_FLAGS} diff --git a/Tests/Functional/AppKernel.php b/Tests/Functional/AppKernel.php index 4fcc3800..aa7f5347 100644 --- a/Tests/Functional/AppKernel.php +++ b/Tests/Functional/AppKernel.php @@ -60,13 +60,18 @@ public function __construct(string $fwConfig, ?string $config) public function registerBundles(): iterable { - return [ + $bundles = [ new TestBundle(), new FrameworkBundle(), new TwigBundle(), new JMSTranslationBundle(), - new SensioFrameworkExtraBundle(), ]; + + if (class_exists(SensioFrameworkExtraBundle::class)) { + $bundles[] = new SensioFrameworkExtraBundle(); + } + + return $bundles; } public function registerContainerConfiguration(LoaderInterface $loader): void diff --git a/Tests/Functional/BaseTestCase.php b/Tests/Functional/BaseTestCase.php index 84b13800..74cf0833 100644 --- a/Tests/Functional/BaseTestCase.php +++ b/Tests/Functional/BaseTestCase.php @@ -32,7 +32,9 @@ protected static function createKernel(array $options = []): KernelInterface $default = $isSf5 ? 'default_sf5.yml' : 'default.yml'; - if (version_compare(Kernel::VERSION, '6.0.0') >= 0) { + if (version_compare(Kernel::VERSION, '7.0.0') >= 0) { + $conf = 'framework_sf7.yaml'; + } elseif (version_compare(Kernel::VERSION, '6.0.0') >= 0) { $conf = 'framework_sf6.yml'; } elseif (version_compare(Kernel::VERSION, '5.0.0') >= 0) { $conf = 'framework.yml'; diff --git a/Tests/Functional/Controller/ApiControllerTest.php b/Tests/Functional/Controller/ApiControllerTest.php index 1ca2b6f9..c3e51652 100644 --- a/Tests/Functional/Controller/ApiControllerTest.php +++ b/Tests/Functional/Controller/ApiControllerTest.php @@ -16,7 +16,7 @@ class ApiControllerTest extends BaseTestCase public function testUpdateAction(): void { // Start application - $client = static::createClient(['config' => 'test_updating_translations.yml']); + $client = static::createClient(); $outputDir = $client->getContainer()->getParameter('translation_output_dir'); $isSf4 = version_compare(Kernel::VERSION, '4.0.0') >= 0; diff --git a/Tests/Functional/config/framework_sf7.yaml b/Tests/Functional/config/framework_sf7.yaml new file mode 100644 index 00000000..c837deb3 --- /dev/null +++ b/Tests/Functional/config/framework_sf7.yaml @@ -0,0 +1,17 @@ +framework: + secret: test + http_method_override: true + test: ~ + assets: ~ + session: + storage_factory_id: session.storage.factory.mock_file + form: true + csrf_protection: true + annotations: false + property_access: true + validation: + enabled: true + translator: + enabled: true + router: + resource: "%kernel.project_dir%/config/routing_sf6.yaml" diff --git a/Tests/Model/FileSourceTest.php b/Tests/Model/FileSourceTest.php index 3bc2f6cc..bd2c2a0c 100644 --- a/Tests/Model/FileSourceTest.php +++ b/Tests/Model/FileSourceTest.php @@ -65,7 +65,7 @@ public function testEquals($r1, $r2, $expected): void $this->assertSame($expected, $r2->equals($r1)); } - public function getEqualityTests(): array + public static function getEqualityTests(): array { $tests = []; @@ -105,14 +105,19 @@ public function getEqualityTests(): array false, ]; - $source = $this->createMock(SourceInterface::class); - $source - ->expects($this->once()) - ->method('equals') - ->willReturn(false); $tests[] = [ new FileSource('foo'), - $source, + new class implements SourceInterface { + public function equals(SourceInterface $source): bool + { + return false; + } + + public function __toString(): string + { + return ''; + } + }, false, ]; diff --git a/Tests/Translation/Dumper/BaseDumperTest.php b/Tests/Translation/Dumper/DumperTestCase.php similarity index 98% rename from Tests/Translation/Dumper/BaseDumperTest.php rename to Tests/Translation/Dumper/DumperTestCase.php index e16fbd23..2c290b9b 100644 --- a/Tests/Translation/Dumper/BaseDumperTest.php +++ b/Tests/Translation/Dumper/DumperTestCase.php @@ -25,7 +25,7 @@ use JMS\TranslationBundle\Model\MessageCatalogue; use PHPUnit\Framework\TestCase; -abstract class BaseDumperTest extends TestCase +abstract class DumperTestCase extends TestCase { public function testSimpleDump(): void { diff --git a/Tests/Translation/Dumper/PhpDumperTest.php b/Tests/Translation/Dumper/PhpDumperTest.php index b536a636..69dbcdbd 100644 --- a/Tests/Translation/Dumper/PhpDumperTest.php +++ b/Tests/Translation/Dumper/PhpDumperTest.php @@ -25,7 +25,7 @@ use JMS\TranslationBundle\Model\MessageCatalogue; use JMS\TranslationBundle\Translation\Dumper\PhpDumper; -class PhpDumperTest extends BaseDumperTest +class PhpDumperTest extends DumperTestCase { public function testDumpStructureWithoutPrettyPrint(): void { diff --git a/Tests/Translation/Dumper/XliffDumperTest.php b/Tests/Translation/Dumper/XliffDumperTest.php index 6acaf1ad..6104ddd8 100644 --- a/Tests/Translation/Dumper/XliffDumperTest.php +++ b/Tests/Translation/Dumper/XliffDumperTest.php @@ -26,7 +26,7 @@ use JMS\TranslationBundle\Model\MessageCatalogue; use JMS\TranslationBundle\Translation\Dumper\XliffDumper; -class XliffDumperTest extends BaseDumperTest +class XliffDumperTest extends DumperTestCase { public function testCdataOutput(): void { diff --git a/Tests/Translation/Dumper/YamlDumperTest.php b/Tests/Translation/Dumper/YamlDumperTest.php index c3300646..5938b1fd 100644 --- a/Tests/Translation/Dumper/YamlDumperTest.php +++ b/Tests/Translation/Dumper/YamlDumperTest.php @@ -25,7 +25,7 @@ use JMS\TranslationBundle\Model\MessageCatalogue; use JMS\TranslationBundle\Translation\Dumper\YamlDumper; -class YamlDumperTest extends BaseDumperTest +class YamlDumperTest extends DumperTestCase { public function testDumpStructureWithoutPrettyPrint(): void { diff --git a/Tests/Translation/Extractor/File/AuthenticationMessagesExtractorTest.php b/Tests/Translation/Extractor/File/AuthenticationMessagesExtractorTest.php index ba548fd9..20b51314 100644 --- a/Tests/Translation/Extractor/File/AuthenticationMessagesExtractorTest.php +++ b/Tests/Translation/Extractor/File/AuthenticationMessagesExtractorTest.php @@ -24,7 +24,7 @@ use JMS\TranslationBundle\Model\MessageCatalogue; use JMS\TranslationBundle\Translation\Extractor\File\AuthenticationMessagesExtractor; -class AuthenticationMessagesExtractorTest extends BasePhpFileExtractorTest +class AuthenticationMessagesExtractorTest extends PhpFileExtractorTestCase { public function testExtract(): void { diff --git a/Tests/Translation/Extractor/File/DefaultPhpFileExtractorTest.php b/Tests/Translation/Extractor/File/DefaultPhpFileExtractorTest.php index 921ebb75..59a4b69b 100644 --- a/Tests/Translation/Extractor/File/DefaultPhpFileExtractorTest.php +++ b/Tests/Translation/Extractor/File/DefaultPhpFileExtractorTest.php @@ -24,7 +24,7 @@ use JMS\TranslationBundle\Model\MessageCatalogue; use JMS\TranslationBundle\Translation\Extractor\File\DefaultPhpFileExtractor; -class DefaultPhpFileExtractorTest extends BasePhpFileExtractorTest +class DefaultPhpFileExtractorTest extends PhpFileExtractorTestCase { public function testExtractController(): void { diff --git a/Tests/Translation/Extractor/File/Fixture/MyFormModel.php b/Tests/Translation/Extractor/File/Fixture/MyFormModel.php index 3838c5aa..12a28e64 100644 --- a/Tests/Translation/Extractor/File/Fixture/MyFormModel.php +++ b/Tests/Translation/Extractor/File/Fixture/MyFormModel.php @@ -32,9 +32,7 @@ class MyFormModel implements TranslationContainerInterface 'bar' => 'form.label.choice.bar', ]; - /** - * @Assert\NotBlank(message = "form.error.name_required") - */ + #[Assert\NotBlank(message: 'form.error.name_required')] public $name; public static function getTranslationMessages() diff --git a/Tests/Translation/Extractor/File/FormExtractorTest.php b/Tests/Translation/Extractor/File/FormExtractorTest.php index 339d3143..8f00b75b 100644 --- a/Tests/Translation/Extractor/File/FormExtractorTest.php +++ b/Tests/Translation/Extractor/File/FormExtractorTest.php @@ -24,7 +24,7 @@ use JMS\TranslationBundle\Model\MessageCatalogue; use JMS\TranslationBundle\Translation\Extractor\File\FormExtractor; -class FormExtractorTest extends BasePhpFileExtractorTest +class FormExtractorTest extends PhpFileExtractorTestCase { /** * @group placeholder diff --git a/Tests/Translation/Extractor/File/BasePhpFileExtractorTest.php b/Tests/Translation/Extractor/File/PhpFileExtractorTestCase.php similarity index 97% rename from Tests/Translation/Extractor/File/BasePhpFileExtractorTest.php rename to Tests/Translation/Extractor/File/PhpFileExtractorTestCase.php index 5c6a205d..b4cc0c7f 100644 --- a/Tests/Translation/Extractor/File/BasePhpFileExtractorTest.php +++ b/Tests/Translation/Extractor/File/PhpFileExtractorTestCase.php @@ -30,7 +30,7 @@ use PhpParser\ParserFactory; use PHPUnit\Framework\TestCase; -abstract class BasePhpFileExtractorTest extends TestCase +abstract class PhpFileExtractorTestCase extends TestCase { final protected function extract($file, ?FileVisitorInterface $extractor = null): MessageCatalogue { diff --git a/Tests/Translation/Loader/Symfony/BaseLoaderTest.php b/Tests/Translation/Loader/Symfony/LoaderTestCase.php similarity index 98% rename from Tests/Translation/Loader/Symfony/BaseLoaderTest.php rename to Tests/Translation/Loader/Symfony/LoaderTestCase.php index 63df3ee2..6fe6e5bd 100644 --- a/Tests/Translation/Loader/Symfony/BaseLoaderTest.php +++ b/Tests/Translation/Loader/Symfony/LoaderTestCase.php @@ -25,7 +25,7 @@ use Symfony\Component\Translation\Loader\LoaderInterface; use Symfony\Component\Translation\MessageCatalogue; -abstract class BaseLoaderTest extends TestCase +abstract class LoaderTestCase extends TestCase { public function testLoadSimple(): void { diff --git a/Tests/Translation/Loader/Symfony/PhpLoaderTest.php b/Tests/Translation/Loader/Symfony/PhpLoaderTest.php index ce12074e..487b9441 100644 --- a/Tests/Translation/Loader/Symfony/PhpLoaderTest.php +++ b/Tests/Translation/Loader/Symfony/PhpLoaderTest.php @@ -23,7 +23,7 @@ use JMS\TranslationBundle\Exception\InvalidArgumentException; use Symfony\Component\Translation\Loader\PhpFileLoader; -class PhpLoaderTest extends BaseLoaderTest +class PhpLoaderTest extends LoaderTestCase { protected function getLoader(): PhpFileLoader { diff --git a/Tests/Translation/Loader/Symfony/XliffLoaderTest.php b/Tests/Translation/Loader/Symfony/XliffLoaderTest.php index db290eae..1c2a4f38 100644 --- a/Tests/Translation/Loader/Symfony/XliffLoaderTest.php +++ b/Tests/Translation/Loader/Symfony/XliffLoaderTest.php @@ -25,7 +25,7 @@ use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Translation\MessageCatalogue; -class XliffLoaderTest extends BaseLoaderTest +class XliffLoaderTest extends LoaderTestCase { public function testLoadOldFormat(): void { diff --git a/Tests/Translation/Loader/Symfony/YamlLoaderTest.php b/Tests/Translation/Loader/Symfony/YamlLoaderTest.php index c9c5222f..fbea1401 100644 --- a/Tests/Translation/Loader/Symfony/YamlLoaderTest.php +++ b/Tests/Translation/Loader/Symfony/YamlLoaderTest.php @@ -23,7 +23,7 @@ use JMS\TranslationBundle\Exception\InvalidArgumentException; use Symfony\Component\Translation\Loader\YamlFileLoader; -class YamlLoaderTest extends BaseLoaderTest +class YamlLoaderTest extends LoaderTestCase { protected function getLoader(): YamlFileLoader { diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index bac8e959..6ed60340 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -2,15 +2,8 @@ declare(strict_types=1); -use Doctrine\Common\Annotations\AnnotationRegistry; +require __DIR__ . '/../vendor/autoload.php'; -call_user_func(static function () { - $autoloadFile = __DIR__ . '/../vendor/autoload.php'; - if (! is_file($autoloadFile)) { - throw new LogicException('Could not find vendor/autoload.php. Did you forget to run "composer install --dev"?'); - } +use Symfony\Component\ErrorHandler\ErrorHandler; - require $autoloadFile; - - AnnotationRegistry::registerLoader('class_exists'); -}); +ErrorHandler::register(null, false); diff --git a/composer.json b/composer.json index 23ff0b15..f9a0f17c 100644 --- a/composer.json +++ b/composer.json @@ -23,10 +23,10 @@ "require": { "php": "^8.1", "nikic/php-parser": "^5", - "symfony/console": "^5.4 || ^6.4", - "symfony/framework-bundle": "^5.4 || ^6.4", + "symfony/console": "^5.4 || ^6.4 || ^7.1", + "symfony/framework-bundle": "^5.4 || ^6.4 || ^7.1", "symfony/config": "^5.4 || ^6.4 || ^7.1", - "symfony/translation": "^5.4 || ^6.4", + "symfony/translation": "^5.4 || ^6.4 || ^7.1", "symfony/translation-contracts": "^2.0 || ^3.0", "symfony/validator": "^5.4 || ^6.4 || ^7.1", "twig/twig": "^3.15", @@ -35,19 +35,19 @@ "require-dev": { "doctrine/annotations": "^1.11", "doctrine/coding-standard": "^9.0", - "matthiasnoback/symfony-dependency-injection-test": "^4.1", + "matthiasnoback/symfony-dependency-injection-test": "^6.0", "nyholm/nsa": "^1.0.1", - "symfony/phpunit-bridge": "^5.4 || ^6.4", + "symfony/phpunit-bridge": "^7.2", "sensio/framework-extra-bundle": "^6.2.4", - "symfony/asset": "^5.4 || ^6.4", - "symfony/browser-kit": "^5.4 || ^6.4", - "symfony/css-selector": "^5.4 || ^6.4", - "symfony/filesystem": "^5.4 || ^6.4", - "symfony/form": "^5.4 || ^6.4", - "symfony/security-csrf": "^5.4 || ^6.4", - "symfony/property-access": "^5.4 || ^6.4", - "symfony/routing": "^5.4 || ^6.4", - "symfony/twig-bundle": "^5.4 || ^6.4", + "symfony/asset": "^5.4 || ^6.4 || ^7.1", + "symfony/browser-kit": "^5.4 || ^6.4 || ^7.1", + "symfony/css-selector": "^5.4 || ^6.4 || ^7.1", + "symfony/filesystem": "^5.4 || ^6.4 || ^7.1", + "symfony/form": "^5.4 || ^6.4 || ^7.1", + "symfony/security-csrf": "^5.4 || ^6.4 || ^7.1", + "symfony/property-access": "^5.4 || ^6.4 || ^7.1", + "symfony/routing": "^5.4 || ^6.4 || ^7.1", + "symfony/twig-bundle": "^5.4 || ^6.4 || ^7.1", "symfony/flex": "^2.4" }, "config": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 712c2c61..0fabf6fb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,14 +3,10 @@ - ./Tests