Skip to content

Commit 737e905

Browse files
authored
Merge pull request #342 from ker0x/feature/drop-sf-4.4
Drop support for Symfony < 5.4, drop CI test for Symfony 7.1
2 parents c43f2b0 + 5ef8c19 commit 737e905

12 files changed

+123
-217
lines changed

.github/workflows/ci.yml

+4-16
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
name: PHP-CS-Fixer
3636
runs-on: ubuntu-latest
3737
env:
38-
php-version: 8.2
38+
php-version: 8.4
3939
PHP_CS_FIXER_IGNORE_ENV: 1
4040
steps:
4141
- name: "Setup PHP"
@@ -56,30 +56,19 @@ jobs:
5656
run: vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no --format=checkstyle | cs2pr
5757

5858
phpunit:
59-
name: PHPUnit (PHP ${{ matrix.php }}) (Symfony ${{ matrix.sf_version }}) (${{ matrix.dependencies }})
59+
name: PHPUnit (PHP ${{ matrix.php }}) (Symfony ${{ matrix.sf_version }})
6060
runs-on: ubuntu-latest
6161
strategy:
6262
max-parallel: 10
6363
fail-fast: false
6464
matrix:
65-
dependencies: ['highest']
66-
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
67-
sf_version: ['4.4.*', '5.4.*', '6.4.*', '7.1.*', '7.2.*']
65+
php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ]
66+
sf_version: [ '5.4.*', '6.4.*', '7.2.*' ]
6867
exclude:
69-
- php: '7.4'
70-
sf_version: '4.4.*'
71-
- php: '8.4'
72-
sf_version: '4.4.*'
7368
- php: '7.4'
7469
sf_version: '6.4.*'
7570
- php: '8.0'
7671
sf_version: '6.4.*'
77-
- php: '7.4'
78-
sf_version: '7.1.*'
79-
- php: '8.0'
80-
sf_version: '7.1.*'
81-
- php: '8.1'
82-
sf_version: '7.1.*'
8372
- php: '7.4'
8473
sf_version: '7.2.*'
8574
- php: '8.0'
@@ -104,7 +93,6 @@ jobs:
10493
uses: "ramsey/composer-install@v3"
10594
with:
10695
composer-options: "--optimize-autoloader"
107-
dependency-versions: "${{ matrix.dependencies }}"
10896

10997
- name: "Run tests"
11098
env:

composer.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
"geocoder-php/plugin": "^1.5",
1919
"php-http/curl-client": "^2.3",
2020
"php-http/discovery": "^1.14",
21-
"symfony/console": "^4.4 || ^5.4 || ^6.4 || ^7.0",
22-
"symfony/framework-bundle": "^4.4 || ^5.4 || ^6.4 || ^7.0",
23-
"symfony/options-resolver": "^4.4 || ^5.4 || ^6.4 || ^7.0",
21+
"symfony/console": "^5.4 || ^6.4 || ^7.0",
22+
"symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0",
23+
"symfony/options-resolver": "^5.4 || ^6.4 || ^7.0",
2424
"willdurand/geocoder": "^4.6"
2525
},
2626
"require-dev": {
2727
"doctrine/annotations": "^1.11.1 || ^2.0",
2828
"doctrine/doctrine-bundle": "^2.3",
2929
"doctrine/orm": "^2.8 || ^3.0",
3030
"fakerphp/faker": "^1.20",
31-
"friendsofphp/php-cs-fixer": "^3.0",
31+
"friendsofphp/php-cs-fixer": "^3.13",
3232
"geocoder-php/algolia-places-provider": "^0.4",
3333
"geocoder-php/arcgis-online-provider": "^4.4",
3434
"geocoder-php/bing-maps-provider": "^4.3",
@@ -67,12 +67,12 @@
6767
"phpstan/phpstan": "^1.9.2",
6868
"psr/http-client": "^1.0",
6969
"psr/simple-cache": "^1.0 || ^2.0",
70-
"symfony/cache": "^4.4 || ^5.0 || ^6.0 || ^7.0",
71-
"symfony/config": "^4.4 || ^5.0 || ^6.0 || ^7.0",
72-
"symfony/phpunit-bridge": "^6.1",
73-
"symfony/validator": "^4.4 || ^5.0 || ^6.0 || ^7.0",
74-
"symfony/var-exporter": "^5.0 || ^6.0 || ^7.0",
75-
"symfony/yaml": "^4.4 || ^5.0 || ^6.0 || ^7.0"
70+
"symfony/cache": "^5.4 || ^6.4 || ^7.0",
71+
"symfony/config": "^5.4 || ^6.4 || ^7.0",
72+
"symfony/phpunit-bridge": "^5.4 || ^6.4 || ^7.0",
73+
"symfony/validator": "^5.4 || ^6.4 || ^7.0",
74+
"symfony/var-exporter": "^5.4 || ^6.4 || ^7.0",
75+
"symfony/yaml": "^5.4 || ^6.4 || ^7.0"
7676
},
7777
"conflict": {
7878
"geocoder-php/nominatim-provider": "<5.0"

tests/Functional/BundleInitializationTest.php

+38-36
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
namespace Bazinga\GeocoderBundle\Tests\Functional;
1414

1515
use Bazinga\GeocoderBundle\BazingaGeocoderBundle;
16-
use Bazinga\GeocoderBundle\Tests\PublicServicePass;
1716
use Geocoder\Dumper\GeoArray;
1817
use Geocoder\Dumper\GeoJson;
1918
use Geocoder\Dumper\Gpx;
@@ -44,24 +43,22 @@ protected static function createKernel(array $options = []): KernelInterface
4443
*/
4544
$kernel = parent::createKernel($options);
4645
$kernel->addTestBundle(BazingaGeocoderBundle::class);
47-
$kernel->addTestCompilerPass(new PublicServicePass('|[Bb]azinga:*|'));
48-
$kernel->addTestCompilerPass(new PublicServicePass('|[gG]eocoder:*|'));
4946
$kernel->handleOptions($options);
5047

5148
return $kernel;
5249
}
5350

5451
public function testInitBundle(): void
5552
{
56-
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
53+
self::bootKernel(['config' => static function (TestKernel $kernel) {
5754
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
5855

59-
if ($kernel::VERSION_ID >= 50000) {
60-
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
56+
if ($kernel::VERSION_ID >= 60000) {
57+
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
6158
}
6259
}]);
6360

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

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

7269
public function testBundleWithOneProviderConfiguration(): void
7370
{
74-
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
71+
self::bootKernel(['config' => static function (TestKernel $kernel) {
7572
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
76-
$kernel->addTestConfig(__DIR__.'/config/simple.yml');
7773

78-
if ($kernel::VERSION_ID >= 50000) {
79-
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
74+
if ($kernel::VERSION_ID >= 60000) {
75+
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
8076
}
77+
78+
$kernel->addTestConfig(__DIR__.'/config/simple.yml');
8179
}]);
8280

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

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

9189
public function testBundleWithCachedProvider(): void
9290
{
93-
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
91+
self::bootKernel(['config' => static function (TestKernel $kernel) {
9492
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
95-
$kernel->addTestConfig(__DIR__.'/config/cache.yml');
9693

97-
if ($kernel::VERSION_ID >= 50000) {
98-
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
94+
if ($kernel::VERSION_ID >= 60000) {
95+
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
9996
}
97+
98+
$kernel->addTestConfig(__DIR__.'/config/cache.yml');
10099
}]);
101100

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

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

112111
public function testCacheLifetimeCanBeNull(): void
113112
{
114-
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
113+
self::bootKernel(['config' => static function (TestKernel $kernel) {
115114
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
116-
$kernel->addTestConfig(__DIR__.'/config/cache_without_lifetime.yml');
117115

118-
if ($kernel::VERSION_ID >= 50000) {
119-
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
116+
if ($kernel::VERSION_ID >= 60000) {
117+
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
120118
}
119+
120+
$kernel->addTestConfig(__DIR__.'/config/cache_without_lifetime.yml');
121121
}]);
122122

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

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

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

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

147-
if ($kernel::VERSION_ID >= 50000) {
148-
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
146+
if ($kernel::VERSION_ID >= 60000) {
147+
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
149148
}
149+
150+
$kernel->addTestConfig(__DIR__.'/config/service_plugin.yml');
150151
}]);
151152

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

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

162163
public function testBundleWithPluginXml(): void
163164
{
164-
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
165+
self::bootKernel(['config' => static function (TestKernel $kernel) {
165166
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
166-
$kernel->addTestConfig(__DIR__.'/config/service_plugin.xml');
167167

168-
if ($kernel::VERSION_ID >= 50000) {
169-
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
168+
if ($kernel::VERSION_ID >= 60000) {
169+
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
170170
}
171+
172+
$kernel->addTestConfig(__DIR__.'/config/service_plugin.xml');
171173
}]);
172174

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

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

183185
public function testBundleHasRegisteredDumpers(): void
184186
{
185-
$kernel = self::bootKernel(['config' => static function (TestKernel $kernel) {
187+
self::bootKernel(['config' => static function (TestKernel $kernel) {
186188
$kernel->addTestConfig(__DIR__.'/config/framework.yml');
187189

188-
if ($kernel::VERSION_ID >= 50000) {
189-
$kernel->addTestConfig(__DIR__.'/config/framework_'.($kernel::VERSION_ID >= 60000 ? 'sf6' : 'sf5').'.yml');
190+
if ($kernel::VERSION_ID >= 60000) {
191+
$kernel->addTestConfig(__DIR__.'/config/framework_sf6.yml');
190192
}
191193
}]);
192194

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

195197
self::assertTrue($container->has(GeoArray::class));
196198
self::assertTrue($container->has(GeoJson::class));

tests/Functional/CustomTestKernel.php

+4-29
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
use Nyholm\BundleTest\TestKernel;
1616
use Symfony\Component\Config\ConfigCache;
17-
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
1817
use Symfony\Component\DependencyInjection\Dumper\Preloader;
1918
use Symfony\Component\ErrorHandler\DebugClassLoader;
20-
use Symfony\Component\Filesystem\Filesystem;
19+
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
2120

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

117-
$oldContainer = \is_object($this->container) ? new \ReflectionClass($this->container) : $this->container = null;
118-
119116
try {
120-
is_dir($buildDir) ?: mkdir($buildDir, 0777, true);
117+
is_dir($buildDir) || mkdir($buildDir, 0777, true);
121118

122119
if ($lock = fopen($cachePath.'.lock', 'w')) {
123120
if (!flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock) && !flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) {
124121
fclose($lock);
125122
$lock = null;
126-
} elseif (true || !\is_object($this->container = include $cachePath)) {
123+
} else {
127124
$this->container = null;
128-
} elseif (!$oldContainer || \get_class($this->container) !== $oldContainer->name) {
129-
flock($lock, \LOCK_UN);
130-
fclose($lock);
131-
$this->container->set('kernel', $this);
132-
133-
return;
134125
}
135126
}
136127
} catch (\Throwable $e) {
@@ -173,7 +164,7 @@ protected function initializeContainer(): void
173164

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

218-
if ($oldContainer && \get_class($this->container) !== $oldContainer->name) {
219-
// Because concurrent requests might still be using them,
220-
// old container files are not removed immediately,
221-
// but on a next dump of the container.
222-
static $legacyContainers = [];
223-
$oldContainerDir = \dirname($oldContainer->getFileName());
224-
$legacyContainers[$oldContainerDir.'.legacy'] = true;
225-
foreach (glob(\dirname($oldContainerDir).\DIRECTORY_SEPARATOR.'*.legacy', \GLOB_NOSORT) as $legacyContainer) {
226-
if (!isset($legacyContainers[$legacyContainer]) && @unlink($legacyContainer)) {
227-
(new Filesystem())->remove(substr($legacyContainer, 0, -7));
228-
}
229-
}
230-
231-
touch($oldContainerDir.'.legacy');
232-
}
233-
234209
$preload = $this instanceof WarmableInterface ? (array) $this->warmUp($this->container->getParameter('kernel.cache_dir')) : [];
235210

236211
if ($this->container->has('cache_warmer')) {

0 commit comments

Comments
 (0)