Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support symfony 7 #595

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
symfony-version:
- '^5.4'
- '^6.4'
- '^7.2'
php-version:
- "8.3"
- "8.4"
Expand All @@ -39,18 +40,25 @@ 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:
command: config
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}
9 changes: 7 additions & 2 deletions Tests/Functional/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Tests/Functional/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion Tests/Functional/Controller/ApiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions Tests/Functional/config/framework_sf7.yaml
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 12 additions & 7 deletions Tests/Model/FileSourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down Expand Up @@ -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,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Translation/Dumper/PhpDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Translation/Dumper/XliffDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Translation/Dumper/YamlDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 1 addition & 3 deletions Tests/Translation/Extractor/File/Fixture/MyFormModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Tests/Translation/Extractor/File/FormExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Translation/Loader/Symfony/PhpLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Translation/Loader/Symfony/XliffLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Translation/Loader/Symfony/YamlLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
13 changes: 3 additions & 10 deletions Tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
28 changes: 14 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
4 changes: 0 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="Tests/bootstrap.php"
>

<testsuites>
<testsuite name="JMSTranslationBundle Test Suite">
<directory>./Tests</directory>
Expand Down
Loading