From 02a598aa8a82ba31a089d825b51e71886d7d328d Mon Sep 17 00:00:00 2001 From: Evert Harmeling Date: Thu, 30 Nov 2023 19:55:58 +0100 Subject: [PATCH] Fix PHPUnit (8.2, 7.0) tests --- tests/Integration/config/7.0/framework.yaml | 15 +++++++++++++++ tests/Integration/config/7.0/messenger.yaml | 6 ++++++ tests/Integration/config/7.0/presta_sitemap.yaml | 9 +++++++++ .../config/7.0/routes/annotations.yaml | 3 +++ .../config/7.0/routes/presta_sitemap.yaml | 2 ++ .../Integration/config/7.0/routes/translated.yaml | 7 +++++++ tests/Integration/config/7.0/routes/xml.xml | 14 ++++++++++++++ tests/Integration/config/7.0/routes/yaml.yaml | 6 ++++++ tests/Integration/src/Kernel.php | 4 ++-- tests/Integration/tests/SitemapTestCase.php | 8 ++++---- 10 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 tests/Integration/config/7.0/framework.yaml create mode 100644 tests/Integration/config/7.0/messenger.yaml create mode 100644 tests/Integration/config/7.0/presta_sitemap.yaml create mode 100644 tests/Integration/config/7.0/routes/annotations.yaml create mode 100644 tests/Integration/config/7.0/routes/presta_sitemap.yaml create mode 100644 tests/Integration/config/7.0/routes/translated.yaml create mode 100644 tests/Integration/config/7.0/routes/xml.xml create mode 100644 tests/Integration/config/7.0/routes/yaml.yaml diff --git a/tests/Integration/config/7.0/framework.yaml b/tests/Integration/config/7.0/framework.yaml new file mode 100644 index 00000000..3bf5e3fb --- /dev/null +++ b/tests/Integration/config/7.0/framework.yaml @@ -0,0 +1,15 @@ +framework: + test: true + secret: '%env(APP_SECRET)%' + http_method_override: false + handle_all_throwables: true + session: + handler_id: null + cookie_secure: auto + cookie_samesite: lax + storage_factory_id: session.storage.factory.mock_file + php_errors: + log: true + router: + utf8: true + cache: null diff --git a/tests/Integration/config/7.0/messenger.yaml b/tests/Integration/config/7.0/messenger.yaml new file mode 100644 index 00000000..715b4f76 --- /dev/null +++ b/tests/Integration/config/7.0/messenger.yaml @@ -0,0 +1,6 @@ +framework: + messenger: + transports: + async: 'in-memory://' + routing: + 'Presta\SitemapBundle\Messenger\DumpSitemapMessage': async diff --git a/tests/Integration/config/7.0/presta_sitemap.yaml b/tests/Integration/config/7.0/presta_sitemap.yaml new file mode 100644 index 00000000..f548ca09 --- /dev/null +++ b/tests/Integration/config/7.0/presta_sitemap.yaml @@ -0,0 +1,9 @@ +presta_sitemap: + default_section: static + dump_directory: "%kernel.project_dir%/public" + items_by_set: 10 + alternate: + enabled: true + default_locale: en + locales: [en, fr] + i18n: symfony diff --git a/tests/Integration/config/7.0/routes/annotations.yaml b/tests/Integration/config/7.0/routes/annotations.yaml new file mode 100644 index 00000000..21c201d3 --- /dev/null +++ b/tests/Integration/config/7.0/routes/annotations.yaml @@ -0,0 +1,3 @@ +controllers: + resource: ../../../src/Controller/ + type: attribute diff --git a/tests/Integration/config/7.0/routes/presta_sitemap.yaml b/tests/Integration/config/7.0/routes/presta_sitemap.yaml new file mode 100644 index 00000000..f0391692 --- /dev/null +++ b/tests/Integration/config/7.0/routes/presta_sitemap.yaml @@ -0,0 +1,2 @@ +presta_sitemap: + resource: "@PrestaSitemapBundle/config/routing.yml" diff --git a/tests/Integration/config/7.0/routes/translated.yaml b/tests/Integration/config/7.0/routes/translated.yaml new file mode 100644 index 00000000..ada2f3d2 --- /dev/null +++ b/tests/Integration/config/7.0/routes/translated.yaml @@ -0,0 +1,7 @@ +about: + path: + en: /about + fr: /a-propos + defaults: { _controller: \Presta\SitemapBundle\Tests\Integration\Controller\StaticController::about } + options: + sitemap: true diff --git a/tests/Integration/config/7.0/routes/xml.xml b/tests/Integration/config/7.0/routes/xml.xml new file mode 100644 index 00000000..826980b4 --- /dev/null +++ b/tests/Integration/config/7.0/routes/xml.xml @@ -0,0 +1,14 @@ + + + + + + Presta\SitemapBundle\Tests\Integration\Controller\StaticController::company + + + + diff --git a/tests/Integration/config/7.0/routes/yaml.yaml b/tests/Integration/config/7.0/routes/yaml.yaml new file mode 100644 index 00000000..5e24a5f1 --- /dev/null +++ b/tests/Integration/config/7.0/routes/yaml.yaml @@ -0,0 +1,6 @@ +yaml: + path: /contact + defaults: { _controller: \Presta\SitemapBundle\Tests\Integration\Controller\StaticController::contact } + options: + sitemap: + section: static diff --git a/tests/Integration/src/Kernel.php b/tests/Integration/src/Kernel.php index f92f4f6e..3cc74eff 100644 --- a/tests/Integration/src/Kernel.php +++ b/tests/Integration/src/Kernel.php @@ -62,7 +62,7 @@ public function registerBundles(): iterable yield new \Presta\SitemapBundle\PrestaSitemapBundle(); } - public function boot() + public function boot(): void { /* force "var" dir to be removed the first time this kernel boot */ static $cleanVarDirectory = true; @@ -119,7 +119,7 @@ public function registerBundles(): iterable yield new \Presta\SitemapBundle\PrestaSitemapBundle(); } - public function boot() + public function boot(): void { /* force "var" dir to be removed the first time this kernel boot */ static $cleanVarDirectory = true; diff --git a/tests/Integration/tests/SitemapTestCase.php b/tests/Integration/tests/SitemapTestCase.php index ea65136d..f4bbeece 100644 --- a/tests/Integration/tests/SitemapTestCase.php +++ b/tests/Integration/tests/SitemapTestCase.php @@ -16,11 +16,11 @@ use SimpleXMLElement; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Container; abstract class SitemapTestCase extends WebTestCase { - protected static function getContainer(): ContainerInterface + protected static function getContainer(): Container { if (\method_exists(KernelTestCase::class, 'getContainer')) { return parent::getContainer(); @@ -180,7 +180,7 @@ private static function assertUrlHasImage(SimpleXMLElement $url, string $section $urlLoc = (string)$url->loc; Assert::assertCount( 1, - $images = $url->xpath( + $url->xpath( sprintf('//image:image[ image:loc[ text() = "%s" ] ]', $loc) ), 'Sitemap URL "' . $urlLoc . '" of section "' . $section . '" has image "' . $loc . '"' @@ -192,7 +192,7 @@ private static function assertUrlHasVideo(SimpleXMLElement $url, string $section $urlLoc = (string)$url->loc; Assert::assertCount( 1, - $videos = $url->xpath( + $url->xpath( sprintf('//video:video[ video:content_loc[ text() = "%s" ] ]', $loc) ), 'Sitemap URL "' . $urlLoc . '" of section "' . $section . '" has video "' . $loc . '"'