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

Drop support for Symfony < 5.4, drop CI test for Symfony 7.1 #342

Merged
merged 1 commit into from
Jan 17, 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
20 changes: 4 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
env:
php-version: 8.2
php-version: 8.4
PHP_CS_FIXER_IGNORE_ENV: 1
steps:
- name: "Setup PHP"
Expand All @@ -56,30 +56,19 @@ jobs:
run: vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no --format=checkstyle | cs2pr

phpunit:
name: PHPUnit (PHP ${{ matrix.php }}) (Symfony ${{ matrix.sf_version }}) (${{ matrix.dependencies }})
name: PHPUnit (PHP ${{ matrix.php }}) (Symfony ${{ matrix.sf_version }})
runs-on: ubuntu-latest
strategy:
max-parallel: 10
fail-fast: false
matrix:
dependencies: ['highest']
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
sf_version: ['4.4.*', '5.4.*', '6.4.*', '7.1.*', '7.2.*']
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
sf_version: [ '5.4.*', '6.4.*', '7.2.*' ]
exclude:
- php: '7.4'
sf_version: '4.4.*'
- php: '8.4'
sf_version: '4.4.*'
- php: '7.4'
sf_version: '6.4.*'
- php: '8.0'
sf_version: '6.4.*'
- php: '7.4'
sf_version: '7.1.*'
- php: '8.0'
sf_version: '7.1.*'
- php: '8.1'
sf_version: '7.1.*'
- php: '7.4'
sf_version: '7.2.*'
- php: '8.0'
Expand All @@ -104,7 +93,6 @@ jobs:
uses: "ramsey/composer-install@v3"
with:
composer-options: "--optimize-autoloader"
dependency-versions: "${{ matrix.dependencies }}"

- name: "Run tests"
env:
Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
"geocoder-php/plugin": "^1.5",
"php-http/curl-client": "^2.3",
"php-http/discovery": "^1.14",
"symfony/console": "^4.4 || ^5.4 || ^6.4 || ^7.0",
"symfony/framework-bundle": "^4.4 || ^5.4 || ^6.4 || ^7.0",
"symfony/options-resolver": "^4.4 || ^5.4 || ^6.4 || ^7.0",
"symfony/console": "^5.4 || ^6.4 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.4 || ^7.0",
"willdurand/geocoder": "^4.6"
},
"require-dev": {
"doctrine/annotations": "^1.11.1 || ^2.0",
"doctrine/doctrine-bundle": "^2.3",
"doctrine/orm": "^2.8 || ^3.0",
"fakerphp/faker": "^1.20",
"friendsofphp/php-cs-fixer": "^3.0",
"friendsofphp/php-cs-fixer": "^3.13",
"geocoder-php/algolia-places-provider": "^0.4",
"geocoder-php/arcgis-online-provider": "^4.4",
"geocoder-php/bing-maps-provider": "^4.3",
Expand Down Expand Up @@ -67,12 +67,12 @@
"phpstan/phpstan": "^1.9.2",
"psr/http-client": "^1.0",
"psr/simple-cache": "^1.0 || ^2.0",
"symfony/cache": "^4.4 || ^5.0 || ^6.0 || ^7.0",
"symfony/config": "^4.4 || ^5.0 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^6.1",
"symfony/validator": "^4.4 || ^5.0 || ^6.0 || ^7.0",
"symfony/var-exporter": "^5.0 || ^6.0 || ^7.0",
"symfony/yaml": "^4.4 || ^5.0 || ^6.0 || ^7.0"
"symfony/cache": "^5.4 || ^6.4 || ^7.0",
"symfony/config": "^5.4 || ^6.4 || ^7.0",
"symfony/phpunit-bridge": "^5.4 || ^6.4 || ^7.0",
"symfony/validator": "^5.4 || ^6.4 || ^7.0",
"symfony/var-exporter": "^5.4 || ^6.4 || ^7.0",
"symfony/yaml": "^5.4 || ^6.4 || ^7.0"
},
"conflict": {
"geocoder-php/nominatim-provider": "<5.0"
Expand Down
74 changes: 38 additions & 36 deletions tests/Functional/BundleInitializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace Bazinga\GeocoderBundle\Tests\Functional;

use Bazinga\GeocoderBundle\BazingaGeocoderBundle;
use Bazinga\GeocoderBundle\Tests\PublicServicePass;
use Geocoder\Dumper\GeoArray;
use Geocoder\Dumper\GeoJson;
use Geocoder\Dumper\Gpx;
Expand Down Expand Up @@ -44,24 +43,22 @@ protected static function createKernel(array $options = []): KernelInterface
*/
$kernel = parent::createKernel($options);
$kernel->addTestBundle(BazingaGeocoderBundle::class);
$kernel->addTestCompilerPass(new PublicServicePass('|[Bb]azinga:*|'));
$kernel->addTestCompilerPass(new PublicServicePass('|[gG]eocoder:*|'));
$kernel->handleOptions($options);

return $kernel;
}

public function testInitBundle(): void
{
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 50000) {
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
}
}]);

$container = method_exists(__CLASS__, 'getContainer') ? self::getContainer() : $kernel->getContainer();
$container = self::getContainer();

// Test if services exists
self::assertTrue($container->has(ProviderAggregator::class));
Expand All @@ -71,16 +68,17 @@ public function testInitBundle(): void

public function testBundleWithOneProviderConfiguration(): void
{
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
$kernel->addTestConfig(__DIR__.'/config/simple.yml');

if ($kernel::VERSION_ID >= 50000) {
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
}

$kernel->addTestConfig(__DIR__.'/config/simple.yml');
}]);

$container = method_exists(__CLASS__, 'getContainer') ? self::getContainer() : $kernel->getContainer();
$container = self::getContainer();

self::assertTrue($container->has('bazinga_geocoder.provider.acme'));
$service = $container->get('bazinga_geocoder.provider.acme');
Expand All @@ -90,16 +88,17 @@ public function testBundleWithOneProviderConfiguration(): void

public function testBundleWithCachedProvider(): void
{
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
$kernel->addTestConfig(__DIR__.'/config/cache.yml');

if ($kernel::VERSION_ID >= 50000) {
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
}

$kernel->addTestConfig(__DIR__.'/config/cache.yml');
}]);

$container = method_exists(__CLASS__, 'getContainer') ? self::getContainer() : $kernel->getContainer();
$container = self::getContainer();

self::assertTrue($container->has('bazinga_geocoder.provider.acme'));
$service = $container->get('bazinga_geocoder.provider.acme');
Expand All @@ -111,16 +110,17 @@ public function testBundleWithCachedProvider(): void

public function testCacheLifetimeCanBeNull(): void
{
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
$kernel->addTestConfig(__DIR__.'/config/cache_without_lifetime.yml');

if ($kernel::VERSION_ID >= 50000) {
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
}

$kernel->addTestConfig(__DIR__.'/config/cache_without_lifetime.yml');
}]);

$container = method_exists(__CLASS__, 'getContainer') ? self::getContainer() : $kernel->getContainer();
$container = self::getContainer();

self::assertTrue($container->has('bazinga_geocoder.provider.acme'));

Expand All @@ -140,16 +140,17 @@ public function testCacheLifetimeCanBeNull(): void

public function testBundleWithPluginsYml(): void
{
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
$kernel->addTestConfig(__DIR__.'/config/service_plugin.yml');

if ($kernel::VERSION_ID >= 50000) {
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
}

$kernel->addTestConfig(__DIR__.'/config/service_plugin.yml');
}]);

$container = method_exists(__CLASS__, 'getContainer') ? self::getContainer() : $kernel->getContainer();
$container = self::getContainer();

self::assertTrue($container->has('bazinga_geocoder.provider.acme'));
$service = $container->get('bazinga_geocoder.provider.acme');
Expand All @@ -161,16 +162,17 @@ public function testBundleWithPluginsYml(): void

public function testBundleWithPluginXml(): void
{
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
$kernel->addTestConfig(__DIR__.'/config/service_plugin.xml');

if ($kernel::VERSION_ID >= 50000) {
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
}

$kernel->addTestConfig(__DIR__.'/config/service_plugin.xml');
}]);

$container = method_exists(__CLASS__, 'getContainer') ? self::getContainer() : $kernel->getContainer();
$container = self::getContainer();

self::assertTrue($container->has('bazinga_geocoder.provider.acme'));
$service = $container->get('bazinga_geocoder.provider.acme');
Expand All @@ -182,15 +184,15 @@ public function testBundleWithPluginXml(): void

public function testBundleHasRegisteredDumpers(): void
{
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
self::bootKernel(['config' => static function (TestKernel $kernel) {
$kernel->addTestConfig(__DIR__.'/config/framework.yml');

if ($kernel::VERSION_ID >= 50000) {
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
if ($kernel::VERSION_ID >= 60000) {
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
}
}]);

$container = method_exists(__CLASS__, 'getContainer') ? self::getContainer() : $kernel->getContainer();
$container = self::getContainer();

self::assertTrue($container->has(GeoArray::class));
self::assertTrue($container->has(GeoJson::class));
Expand Down
33 changes: 4 additions & 29 deletions tests/Functional/CustomTestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

use Nyholm\BundleTest\TestKernel;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
use Symfony\Component\DependencyInjection\Dumper\Preloader;
use Symfony\Component\ErrorHandler\DebugClassLoader;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;

/*
* Needed by PluginInteractionTest, so the test uses the cache for geoCoder, and doesn't clear it each time
Expand Down Expand Up @@ -114,23 +113,15 @@ protected function initializeContainer(): void
} catch (\Throwable $e) {
}

$oldContainer = \is_object($this->container) ? new \ReflectionClass($this->container) : $this->container = null;

try {
is_dir($buildDir) ?: mkdir($buildDir, 0777, true);
is_dir($buildDir) || mkdir($buildDir, 0777, true);

if ($lock = fopen($cachePath.'.lock', 'w')) {
if (!flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock) && !flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) {
fclose($lock);
$lock = null;
} elseif (true || !\is_object($this->container = include $cachePath)) {
} else {
$this->container = null;
} elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) {
flock($lock, \LOCK_UN);
fclose($lock);
$this->container->set('kernel', $this);

return;
}
}
} catch (\Throwable $e) {
Expand Down Expand Up @@ -173,7 +164,7 @@ protected function initializeContainer(): void

// Remove frames added by DebugClassLoader.
for ($i = \count($backtrace) - 2; 0 < $i; --$i) {
if (\in_array($backtrace[$i]['class'] ?? null, [DebugClassLoader::class, LegacyDebugClassLoader::class], true)) {
if ($backtrace[$i]['class'] ?? null === DebugClassLoader::class) {
$backtrace = [$backtrace[$i + 1]];
break;
}
Expand Down Expand Up @@ -215,22 +206,6 @@ protected function initializeContainer(): void
$this->container = require $cachePath;
$this->container->set('kernel', $this);

if ($oldContainer && \get_class($this->container) !== $oldContainer->name) {
// Because concurrent requests might still be using them,
// old container files are not removed immediately,
// but on a next dump of the container.
static $legacyContainers = [];
$oldContainerDir = \dirname($oldContainer->getFileName());
$legacyContainers[$oldContainerDir.'.legacy'] = true;
foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy', \GLOB_NOSORT) as $legacyContainer) {
if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) {
(new Filesystem())->remove(substr($legacyContainer, 0, -7));
}
}

touch($oldContainerDir.'.legacy');
}

$preload = $this instanceof WarmableInterface ? (array) $this->warmUp($this->container->getParameter('kernel.cache_dir')) : [];

if ($this->container->has('cache_warmer')) {
Expand Down
Loading
Loading