From f3c3c7906bab74d56352f72a7e8d22fcabb62060 Mon Sep 17 00:00:00 2001 From: Romain Monteil Date: Mon, 25 Sep 2023 10:30:31 +0200 Subject: [PATCH] Drop support for Symfony < 5.4, add Symfony 6.4 and PHP 8.3 to CI, update .gitattributes file --- .github/workflows/ci.yml | 14 +-- composer.json | 20 ++-- tests/Functional/BundleInitializationTest.php | 74 +++++++-------- tests/Functional/CustomTestKernel.php | 33 +------ tests/Functional/GeocoderListenerTest.php | 72 +++++++-------- tests/Functional/PluginInteractionTest.php | 25 +++-- tests/Functional/ProviderFactoryTest.php | 31 +++---- tests/Functional/config/framework.yml | 3 + tests/Functional/config/framework_sf5.yml | 5 - tests/Functional/config/framework_sf6.yml | 4 - tests/Functional/config/listener.yml | 5 +- tests/PublicServicePass.php | 48 ---------- tests/allowed.json | 92 +++++++++++++++++++ 13 files changed, 214 insertions(+), 212 deletions(-) delete mode 100644 tests/Functional/config/framework_sf5.yml delete mode 100644 tests/PublicServicePass.php create mode 100644 tests/allowed.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7565418..42ad633 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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' diff --git a/composer.json b/composer.json index 830303a..275a05a 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,9 @@ "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": { @@ -28,7 +28,7 @@ "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", @@ -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" diff --git a/tests/Functional/BundleInitializationTest.php b/tests/Functional/BundleInitializationTest.php index aeaba3a..4e91031 100644 --- a/tests/Functional/BundleInitializationTest.php +++ b/tests/Functional/BundleInitializationTest.php @@ -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; @@ -44,8 +43,6 @@ 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; @@ -53,15 +50,15 @@ protected static function createKernel(array $options = []): KernelInterface 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)); @@ -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'); @@ -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'); @@ -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')); @@ -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'); @@ -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'); @@ -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)); diff --git a/tests/Functional/CustomTestKernel.php b/tests/Functional/CustomTestKernel.php index 0f7e5ea..e32e3fb 100644 --- a/tests/Functional/CustomTestKernel.php +++ b/tests/Functional/CustomTestKernel.php @@ -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 @@ -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) { @@ -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; } @@ -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')) { diff --git a/tests/Functional/GeocoderListenerTest.php b/tests/Functional/GeocoderListenerTest.php index d1b7f64..72513e5 100644 --- a/tests/Functional/GeocoderListenerTest.php +++ b/tests/Functional/GeocoderListenerTest.php @@ -17,7 +17,6 @@ use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\DummyWithGetter; use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\DummyWithInvalidGetter; use Bazinga\GeocoderBundle\Tests\Functional\Fixtures\Entity\DummyWithProperty; -use Bazinga\GeocoderBundle\Tests\PublicServicePass; use Doctrine\Bundle\DoctrineBundle\ConnectionFactory; use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; use Doctrine\ORM\Configuration; @@ -41,9 +40,7 @@ final class GeocoderListenerTest extends KernelTestCase { protected function tearDown(): void { - $container = Kernel::VERSION_ID >= 50000 ? self::getContainer() : self::$container; - - $em = $container->get('doctrine.orm.entity_manager'); + $em = self::getContainer()->get('doctrine.orm.entity_manager'); $tool = new SchemaTool($em); $tool->dropSchema($em->getMetadataFactory()->getAllMetadata()); @@ -62,8 +59,6 @@ protected static function createKernel(array $options = []): KernelInterface $kernel = parent::createKernel($options); $kernel->addTestBundle(DoctrineBundle::class); $kernel->addTestBundle(BazingaGeocoderBundle::class); - $kernel->addTestCompilerPass(new PublicServicePass('|[Bb]azinga:*|')); - $kernel->addTestCompilerPass(new PublicServicePass('|[gG]eocoder:*|')); if (defined(ConnectionFactory::class.'::DEFAULT_SCHEME_MAP')) { $kernel->addTestConfig(static function (ContainerBuilder $container) { $container->prependExtensionConfig('doctrine', [ @@ -98,17 +93,18 @@ protected static function createKernel(array $options = []): KernelInterface public function testPersistForProperty(): 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/listener.yml'); - $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.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/listener.yml'); + $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.yml'); }]); - $container = $kernel::VERSION_ID >= 50000 ? self::getContainer() : self::$container; + $container = self::getContainer(); $httpClient = $container->get(Client::class); $httpClient->on(new RequestMatcher(), function (RequestInterface $request) { @@ -175,17 +171,18 @@ public function testPersistForProperty(): void public function testPersistForGetter(): 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/listener.yml'); - $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.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/listener.yml'); + $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.yml'); }]); - $container = Kernel::VERSION_ID >= 50000 ? self::getContainer() : self::$container; + $container = self::getContainer(); $httpClient = $container->get(Client::class); $httpClient->on(new RequestMatcher(), function (RequestInterface $request) { @@ -252,17 +249,18 @@ public function testPersistForGetter(): void public function testPersistForInvalidGetter(): 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/listener.yml'); - $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.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/listener.yml'); + $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.yml'); }]); - $container = Kernel::VERSION_ID >= 50000 ? self::getContainer() : self::$container; + $container = self::getContainer(); $em = $container->get('doctrine.orm.entity_manager'); @@ -281,17 +279,18 @@ public function testPersistForInvalidGetter(): void public function testPersistForEmptyProperty(): 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/listener.yml'); - $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.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/listener.yml'); + $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.yml'); }]); - $container = Kernel::VERSION_ID >= 50000 ? self::getContainer() : self::$container; + $container = self::getContainer(); $em = $container->get('doctrine.orm.entity_manager'); @@ -310,17 +309,18 @@ public function testPersistForEmptyProperty(): void public function testDoesNotGeocodeIfAddressNotChanged(): 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/listener.yml'); - $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.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/listener.yml'); + $kernel->addTestConfig(__DIR__.'/config/listener_'.(PHP_VERSION_ID >= 80000 ? 'php8' : 'php7').'.yml'); }]); - $container = Kernel::VERSION_ID >= 50000 ? self::getContainer() : self::$container; + $container = self::getContainer(); $httpRequests = 0; $httpClient = $container->get(Client::class); diff --git a/tests/Functional/PluginInteractionTest.php b/tests/Functional/PluginInteractionTest.php index 87e32f4..77a6fe7 100644 --- a/tests/Functional/PluginInteractionTest.php +++ b/tests/Functional/PluginInteractionTest.php @@ -13,7 +13,6 @@ namespace Bazinga\GeocoderBundle\Tests\Functional; use Bazinga\GeocoderBundle\BazingaGeocoderBundle; -use Bazinga\GeocoderBundle\Tests\PublicServicePass; use Geocoder\Query\GeocodeQuery; use Nyholm\BundleTest\TestKernel; use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; @@ -36,8 +35,6 @@ 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; @@ -48,15 +45,16 @@ public function testCachePluginUsesIpFromFakeIpPlugin(): void $kernel = self::bootKernel(['config' => static function (TestKernel $kernel) { $kernel->setClearCacheAfterShutdown(false); $kernel->addTestConfig(__DIR__.'/config/framework.yml'); - $kernel->addTestConfig(__DIR__.'/config/cache_symfony.yml'); - $kernel->addTestConfig(__DIR__.'/config/geo_plugin_fakeip_with_cache_cn.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_symfony.yml'); + $kernel->addTestConfig(__DIR__.'/config/geo_plugin_fakeip_with_cache_cn.yml'); }]); $kernel->setClearCacheAfterShutdown(false); - $container = method_exists(__CLASS__, 'getContainer') ? self::getContainer() : $kernel->getContainer(); + $container = self::getContainer(); $geoPluginGeocoder = $container->get('bazinga_geocoder.provider.geoPlugin'); $result = $geoPluginGeocoder->geocodeQuery(GeocodeQuery::create('::1')); @@ -66,15 +64,16 @@ public function testCachePluginUsesIpFromFakeIpPlugin(): void $kernel = self::bootKernel(['config' => static function (TestKernel $kernel) { $kernel->setClearCacheAfterShutdown(false); $kernel->addTestConfig(__DIR__.'/config/framework.yml'); - $kernel->addTestConfig(__DIR__.'/config/cache_symfony.yml'); - $kernel->addTestConfig(__DIR__.'/config/geo_plugin_fakeip_with_cache_fr.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_symfony.yml'); + $kernel->addTestConfig(__DIR__.'/config/geo_plugin_fakeip_with_cache_fr.yml'); }]); $kernel->setClearCacheAfterShutdown(false); - $container = method_exists(__CLASS__, 'getContainer') ? self::getContainer() : $kernel->getContainer(); + $container = self::getContainer(); $geoPluginGeocoder = $container->get('bazinga_geocoder.provider.geoPlugin'); $result = $geoPluginGeocoder->geocodeQuery(GeocodeQuery::create('::1')); diff --git a/tests/Functional/ProviderFactoryTest.php b/tests/Functional/ProviderFactoryTest.php index 382303a..e24dbde 100644 --- a/tests/Functional/ProviderFactoryTest.php +++ b/tests/Functional/ProviderFactoryTest.php @@ -13,7 +13,6 @@ namespace Bazinga\GeocoderBundle\Tests\Functional; use Bazinga\GeocoderBundle\BazingaGeocoderBundle; -use Bazinga\GeocoderBundle\Tests\PublicServicePass; use Geocoder\Provider\AlgoliaPlaces\AlgoliaPlaces; use Geocoder\Provider\ArcGISOnline\ArcGISOnline; use Geocoder\Provider\BingMaps\BingMaps; @@ -64,8 +63,6 @@ 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; @@ -79,16 +76,17 @@ protected static function createKernel(array $options = []): KernelInterface */ public function testProviderConfiguration(string $class, array $serviceNames): void { - $kernel = self::bootKernel(['config' => static function (TestKernel $kernel) use ($class) { + self::bootKernel(['config' => static function (TestKernel $kernel) use ($class) { $kernel->addTestConfig(__DIR__.'/config/framework.yml'); - $kernel->addTestConfig(__DIR__.'/config/provider/'.strtolower(substr($class, strrpos($class, '\\') + 1)).'.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/provider/'.strtolower(substr($class, strrpos($class, '\\') + 1)).'.yml'); }]); - $container = method_exists(__CLASS__, 'getContainer') ? self::getContainer() : $kernel->getContainer(); + $container = self::getContainer(); foreach ($serviceNames as $name) { self::assertTrue($container->has('bazinga_geocoder.provider.'.$name)); @@ -141,22 +139,19 @@ public function getProviders(): iterable */ public function testProviderConfigurationWithDeprecatedHttplugClientOption(): 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/deprecated_httplug_client_option.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/deprecated_httplug_client_option.yml'); }]); - $container = method_exists(__CLASS__, 'getContainer') ? self::getContainer() : $kernel->getContainer(); + $container = self::getContainer(); - if ($kernel::VERSION_ID >= 50000) { - $this->expectDeprecation('Since willdurand/geocoder-bundle 5.19: The option "httplug_client" is deprecated, use "http_client" instead.'); - } else { - $this->expectDeprecation('willdurand/geocoder-bundle'); - } + $this->expectDeprecation('Since willdurand/geocoder-bundle 5.19: The option "httplug_client" is deprecated, use "http_client" instead.'); self::assertTrue($container->has('bazinga_geocoder.provider.acme')); $container->get('bazinga_geocoder.provider.acme'); diff --git a/tests/Functional/config/framework.yml b/tests/Functional/config/framework.yml index 727de01..47b05a2 100644 --- a/tests/Functional/config/framework.yml +++ b/tests/Functional/config/framework.yml @@ -5,3 +5,6 @@ framework: cookie_secure: auto cookie_samesite: lax handler_id: null + storage_factory_id: session.storage.factory.native + router: + utf8: true diff --git a/tests/Functional/config/framework_sf5.yml b/tests/Functional/config/framework_sf5.yml deleted file mode 100644 index 048fe59..0000000 --- a/tests/Functional/config/framework_sf5.yml +++ /dev/null @@ -1,5 +0,0 @@ -framework: - session: - storage_factory_id: session.storage.factory.mock_file - router: - utf8: true diff --git a/tests/Functional/config/framework_sf6.yml b/tests/Functional/config/framework_sf6.yml index 810703a..25f5a5b 100644 --- a/tests/Functional/config/framework_sf6.yml +++ b/tests/Functional/config/framework_sf6.yml @@ -3,7 +3,3 @@ framework: handle_all_throwables: true php_errors: log: true - session: - storage_factory_id: session.storage.factory.mock_file - router: - utf8: true diff --git a/tests/Functional/config/listener.yml b/tests/Functional/config/listener.yml index 1091a06..8fc0e6d 100644 --- a/tests/Functional/config/listener.yml +++ b/tests/Functional/config/listener.yml @@ -7,6 +7,8 @@ doctrine: path: '%kernel.cache_dir%/test.sqlite' orm: auto_generate_proxy_classes: true + validate_xml_mapping: true + report_fields_where_declared: true naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware auto_mapping: false @@ -20,5 +22,4 @@ bazinga_geocoder: http_client: '@Http\Mock\Client' services: - Http\Mock\Client: - public: true + Http\Mock\Client: ~ diff --git a/tests/PublicServicePass.php b/tests/PublicServicePass.php deleted file mode 100644 index 69abc3c..0000000 --- a/tests/PublicServicePass.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * @internal - * - * Note: this can be removed when we'll support only Symfony >5.3 - */ -final class PublicServicePass implements CompilerPassInterface -{ - private string $regex; - - public function __construct(string $regex = '|.*|') - { - $this->regex = $regex; - } - - public function process(ContainerBuilder $container): void - { - foreach ($container->getDefinitions() as $id => $definition) { - if (preg_match($this->regex, $id)) { - $definition->setPublic(true); - } - } - - foreach ($container->getAliases() as $id => $alias) { - if (preg_match($this->regex, $id)) { - $alias->setPublic(true); - } - } - } -} diff --git a/tests/allowed.json b/tests/allowed.json new file mode 100644 index 0000000..d354391 --- /dev/null +++ b/tests/allowed.json @@ -0,0 +1,92 @@ +[ + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\ProviderFactoryTest::testProviderConfiguration", + "message": "Bazinga\\GeocoderBundle\\ProviderFactory\\GeoIPsFactory is deprecated since 5.6, to be removed in 6.0. See https://github.com/geocoder-php/Geocoder/issues/965", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\ProviderFactoryTest::testProviderConfiguration", + "message": "Bazinga\\GeocoderBundle\\ProviderFactory\\MapzenFactory is deprecated since 5.6, to be removed in 6.0. See https://github.com/geocoder-php/Geocoder/issues/808", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\DependencyInjection\\Compiler\\AddProvidersPassTest::testRegistersProviders", + "message": "Class \"Nyholm\\Psr7\\Factory\\HttplugFactory\" is deprecated since version 1.8, use \"Nyholm\\Psr7\\Factory\\Psr17Factory\" instead.", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForProperty", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForProperty", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:169 called by EntityManager.php:182, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForGetter", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForGetter", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:169 called by EntityManager.php:182, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForInvalidGetter", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForInvalidGetter", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:169 called by EntityManager.php:182, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForEmptyProperty", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForEmptyProperty", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:169 called by EntityManager.php:182, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testDoesNotGeocodeIfAddressNotChanged", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testDoesNotGeocodeIfAddressNotChanged", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:169 called by EntityManager.php:182, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForProperty", + "message": "Since doctrine/doctrine-bundle 2.11: Not setting \"enable_lazy_ghost_objects\" to true is deprecated.", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForGetter", + "message": "Since doctrine/doctrine-bundle 2.11: Not setting \"enable_lazy_ghost_objects\" to true is deprecated.", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForInvalidGetter", + "message": "Since doctrine/doctrine-bundle 2.11: Not setting \"enable_lazy_ghost_objects\" to true is deprecated.", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testPersistForEmptyProperty", + "message": "Since doctrine/doctrine-bundle 2.11: Not setting \"enable_lazy_ghost_objects\" to true is deprecated.", + "count": 1 + }, + { + "location": "Bazinga\\GeocoderBundle\\Tests\\Functional\\GeocoderListenerTest::testDoesNotGeocodeIfAddressNotChanged", + "message": "Since doctrine/doctrine-bundle 2.11: Not setting \"enable_lazy_ghost_objects\" to true is deprecated.", + "count": 1 + } +]