diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6ec1373..81bd036 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,12 +16,16 @@ jobs: include: - php-version: 7.1 symfony-version: 4.4.* - - php-version: 8.0 + - php-version: 8.1 symfony-version: 4.4.* - php-version: 7.2 - symfony-version: 5.3.* + symfony-version: 5.4.* + - php-version: 8.1 + symfony-version: 5.4.* - php-version: 8.0 - symfony-version: 5.3.* + symfony-version: 6.0.* + - php-version: 8.1 + symfony-version: 6.0.* steps: - name: "Checkout" @@ -36,6 +40,7 @@ jobs: - name: "Install dependencies with composer" run: | composer require --no-update symfony/framework-bundle:${{ matrix.symfony-version }} + composer require --no-update --dev symfony/http-kernel:${{ matrix.symfony-version }} composer require --no-update --dev symfony/form:${{ matrix.symfony-version }} composer require --no-update --dev symfony/twig-bundle:${{ matrix.symfony-version }} composer require --no-update --dev symfony/validator:${{ matrix.symfony-version }} @@ -53,7 +58,7 @@ jobs: strategy: matrix: include: - - php-version: 8.0 + - php-version: 8.1 steps: - name: "Checkout" @@ -84,7 +89,7 @@ jobs: strategy: matrix: include: - - php-version: 8.0 + - php-version: 8.1 steps: - name: "Checkout" diff --git a/composer.json b/composer.json index bd49643..8518b37 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": "^7.1.3|^8.0", - "symfony/framework-bundle": "^4.4|^5.0" + "symfony/framework-bundle": "^4.4|^5.0|^6.0" }, "require-dev": { "doctrine/annotations": "^1.3", @@ -19,11 +19,11 @@ "phpunit/phpunit": "^7.5|^8.5|^9.5", "sensio/framework-extra-bundle": "^5.5|^6.1", "squizlabs/php_codesniffer": "^3.5", - "symfony/form": "^4.4|^5.0", - "symfony/translation": "^4.4|^5.0", - "symfony/twig-bundle": "^4.4|^5.0", - "symfony/validator": "^4.4|^5.0", - "symfony/yaml": "^4.4|^5.0", + "symfony/form": "^4.4|^5.0|^6.0", + "symfony/translation": "^4.4|^5.0|^6.0", + "symfony/twig-bundle": "^4.4|^5.0|^6.0", + "symfony/validator": "^4.4|^5.0|^6.0", + "symfony/yaml": "^4.4|^5.0|^6.0", "twig/twig": "^2.0|^3.0" }, "suggest": { diff --git a/tests/Integration/src/Kernel.php b/tests/Integration/src/Kernel.php index 9db862c..63282f0 100644 --- a/tests/Integration/src/Kernel.php +++ b/tests/Integration/src/Kernel.php @@ -5,6 +5,8 @@ namespace Yokai\EnumBundle\Tests\Integration\App; use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel as BaseKernel; /** @@ -36,4 +38,19 @@ public function registerContainerConfiguration(LoaderInterface $loader): void $loader->load(__DIR__ . '/../config/services.yaml'); } + + /** + * @inheritDoc + */ + protected function build(ContainerBuilder $container) + { + $container->addCompilerPass( + new class implements CompilerPassInterface { + public function process(ContainerBuilder $container) + { + $container->findDefinition('form.factory')->setPublic(true); + } + } + ); + } } diff --git a/tests/Integration/tests/PullRequestFormTest.php b/tests/Integration/tests/PullRequestFormTest.php index ac7b029..5f1c811 100644 --- a/tests/Integration/tests/PullRequestFormTest.php +++ b/tests/Integration/tests/PullRequestFormTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Integration\tests; +namespace Yokai\EnumBundle\Tests\Integration; use Generator; use Psr\Container\ContainerInterface; @@ -125,11 +125,16 @@ public function testSubmitInvalidData(array $formData, $model, array $errors): v public function invalid(): Generator { + $message = 'This value is not valid.'; + if (Kernel::MAJOR_VERSION >= 6) { + $message = 'The selected choice is invalid.'; + } + $newModel = self::pullRequest(); yield [ ['status' => 3, 'labels' => ['bugfix', '5.x']], $newModel, - ['status' => 'This value is not valid.', 'labels' => 'The choices "5.x" do not exist in the choice list.'] + ['status' => $message, 'labels' => 'The choices "5.x" do not exist in the choice list.'] ]; $updateModel = self::pullRequest(); @@ -138,7 +143,7 @@ public function invalid(): Generator yield [ ['status' => 3, 'labels' => ['bugfix', '5.x']], $updateModel, - ['status' => 'This value is not valid.', 'labels' => 'The choices "5.x" do not exist in the choice list.'] + ['status' => $message, 'labels' => 'The choices "5.x" do not exist in the choice list.'] ]; } diff --git a/tests/Unit/Translator.php b/tests/Unit/Translator.php index e87da11..cae83e7 100644 --- a/tests/Unit/Translator.php +++ b/tests/Unit/Translator.php @@ -1,43 +1,83 @@ - */ -class Translator implements TranslatorInterface -{ +if (Kernel::MAJOR_VERSION >= 6) { /** - * @var array + * @author Yann Eugoné */ - private $map; + class Translator implements TranslatorInterface + { + /** + * @var array + */ + private $map; + + /** + * @var string + */ + private $domain; + public function __construct(array $map, string $domain = 'messages') + { + $this->map = $map; + $this->domain = $domain; + } + + public function getLocale(): string + { + return 'fr'; + } + + public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string + { + if ($domain !== $this->domain) { + return $id; + } + + return $this->map[$id] ?? $id; + } + } +} else { /** - * @var string + * @author Yann Eugoné */ - private $domain; - - public function __construct(array $map, string $domain = 'messages') + class Translator implements TranslatorInterface { - $this->map = $map; - $this->domain = $domain; - } + /** + * @var array + */ + private $map; - public function getLocale(): string - { - return 'fr'; - } + /** + * @var string + */ + private $domain; - public function trans($id, array $parameters = [], $domain = null, $locale = null) - { - if ($domain !== $this->domain) { - return $id; + public function __construct(array $map, string $domain = 'messages') + { + $this->map = $map; + $this->domain = $domain; } - return $this->map[$id] ?? $id; + public function getLocale(): string + { + return 'fr'; + } + + public function trans($id, array $parameters = [], $domain = null, $locale = null) + { + if ($domain !== $this->domain) { + return $id; + } + + return $this->map[$id] ?? $id; + } } }