Skip to content

Commit

Permalink
Drop support for Symfony < 5.4, add Symfony 6.4 and PHP 8.3 to CI, up…
Browse files Browse the repository at this point in the history
…date .gitattributes file
  • Loading branch information
ker0x committed May 28, 2024
1 parent 0e1b7eb commit f3c3c79
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 212 deletions.
14 changes: 3 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,11 @@ jobs:
max-parallel: 10
fail-fast: false
matrix:
dependencies: ['highest']
php: [ '7.4', '8.0', '8.1', '8.2' ]
sf_version: [ '4.4.*', '5.4.*', '6.4.*', '7.0.*' ]
# include:
# - php: '7.4'
# sf_version: '4.4.*'
# dependencies: 'lowest'
# - php: '7.4'
# sf_version: '5.4.*'
# dependencies: 'lowest'
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
sf_version: [ '5.4.*', '6.4.*', '7.0.*' ]
exclude:
- php: '7.4'
sf_version: '4.4.*'
sf_version: '5.4.*'
- php: '7.4'
sf_version: '6.4.*'
- php: '8.0'
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.0 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.0 || ^7.0",
"willdurand/geocoder": "^4.6"
},
"require-dev": {
"doctrine/annotations": "^1.11.1 || ^2.0",
"doctrine/doctrine-bundle": "^2.3",
"doctrine/orm": "^2.8",
"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.0 || ^7.0",
"symfony/config": "^5.4 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^5.4 || ^6.0 || ^7.0",
"symfony/validator": "^5.4 || ^6.0 || ^7.0",
"symfony/var-exporter": "^5.4 || ^6.0 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^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

0 comments on commit f3c3c79

Please sign in to comment.