From d9c446c5e4c56510dc50545c216dcaa9d8fc2960 Mon Sep 17 00:00:00 2001 From: Albin Kester <83301974+stakovicz@users.noreply.github.com> Date: Sat, 1 Mar 2025 08:49:45 +0100 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20presta/sitemap-bund?= =?UTF-8?q?le=20(#1654)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Mise à jour de `presta/sitemap-bundle` * Ajout du test functional --- app/config/routing.yml | 2 +- composer.json | 2 +- composer.lock | 46 +++++++++---------- .../Subscriber/SitemapXmlSubscriber.php | 12 +++-- .../features/PublicSite/Sitemaps.feature | 35 ++++++++++++++ 5 files changed, 67 insertions(+), 30 deletions(-) create mode 100644 tests/behat/features/PublicSite/Sitemaps.feature diff --git a/app/config/routing.yml b/app/config/routing.yml index fed5f7576..2086037ed 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -70,7 +70,7 @@ feed_rss: defaults: { _controller: AppBundle\Controller\Website\RssFeedController } presta_sitemap: - resource: "@PrestaSitemapBundle/Resources/config/routing.yml" + resource: "@PrestaSitemapBundle/config/routing.yml" global: resource: "routing/global.yml" diff --git a/composer.json b/composer.json index 5b0aae3a5..6248a3f46 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "pear/pear": "^1.10", "phpmailer/phpmailer": "5.2.9", "phpoffice/phpspreadsheet": "^1.6", - "presta/sitemap-bundle": "^1.5", + "presta/sitemap-bundle": "3.3.0", "robmorgan/phinx": "^0.9.2", "sabre/vobject": "^4.1", "setasign/fpdf": "^1.8", diff --git a/composer.lock b/composer.lock index a4da7a6ef..04eef154f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f9721dd640b33fa4c97bf2bab3b7797d", + "content-hash": "562d751636c429107d15424f0f988736", "packages": [ { "name": "algolia/algoliasearch-client-php", @@ -3974,46 +3974,46 @@ }, { "name": "presta/sitemap-bundle", - "version": "v1.7.3", + "version": "v3.3.0", "source": { "type": "git", "url": "https://github.com/prestaconcept/PrestaSitemapBundle.git", - "reference": "46048485925fbc99fb519acc30202fa5c77e7335" + "reference": "ad23fe594ff0fedb4e7be638873a19c39eb6ed7b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/prestaconcept/PrestaSitemapBundle/zipball/46048485925fbc99fb519acc30202fa5c77e7335", - "reference": "46048485925fbc99fb519acc30202fa5c77e7335", + "url": "https://api.github.com/repos/prestaconcept/PrestaSitemapBundle/zipball/ad23fe594ff0fedb4e7be638873a19c39eb6ed7b", + "reference": "ad23fe594ff0fedb4e7be638873a19c39eb6ed7b", "shasum": "" }, "require": { - "php": ">=5.4.0", - "symfony/console": "~2.2|~3.0|~4.0", - "symfony/framework-bundle": "~2.2|~3.0|~4.0" + "ext-simplexml": "*", + "php": ">=7.1.3", + "symfony/console": "^4.4|^5.0|^6.0", + "symfony/framework-bundle": "^4.4|^5.0|^6.0" }, "require-dev": { - "doctrine/annotations": "~1.0", - "phpunit/phpunit": "5.*", - "symfony/browser-kit": "~2.2|~3.0|~4.0", - "symfony/form": "~2.2|~3.0|~4.0", - "symfony/phpunit-bridge": "~2.7|~3.0|~4.0", - "symfony/security-bundle": "~2.2|~3.0|~4.0", - "symfony/translation": "~2.2|~3.0|~4.0", - "symfony/validator": "~2.2|~3.0|~4.0" - }, - "suggest": { - "doctrine/doctrine-cache-bundle": "Allows to store sitemaps in cache" + "doctrine/annotations": "^1.0", + "phpstan/phpstan": "^0.12.82", + "phpunit/phpunit": "^7.5|^8.0", + "sensio/framework-extra-bundle": "^5.5|^6.1", + "squizlabs/php_codesniffer": "^3.5", + "symfony/browser-kit": "^4.4|^5.0|^6.0", + "symfony/messenger": "^4.4|^5.0|^6.0", + "symfony/phpunit-bridge": "^4.4|^5.0|^6.0", + "symfony/yaml": "^4.4|^5.0|^6.0" }, "type": "symfony-bundle", "extra": { "branch-alias": { "1.x": "1.x-dev", - "dev-master": "2.x-dev" + "2.x": "2.x-dev", + "3.x": "3.x-dev" } }, "autoload": { "psr-4": { - "Presta\\SitemapBundle\\": "" + "Presta\\SitemapBundle\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -4036,9 +4036,9 @@ ], "support": { "issues": "https://github.com/prestaconcept/PrestaSitemapBundle/issues", - "source": "https://github.com/prestaconcept/PrestaSitemapBundle/tree/v1.7.3" + "source": "https://github.com/prestaconcept/PrestaSitemapBundle/tree/v3.3.0" }, - "time": "2020-10-03T07:37:31+00:00" + "time": "2022-01-24T07:37:28+00:00" }, { "name": "psr/cache", diff --git a/sources/AppBundle/Subscriber/SitemapXmlSubscriber.php b/sources/AppBundle/Subscriber/SitemapXmlSubscriber.php index ce1edf902..a6f3f3bb9 100644 --- a/sources/AppBundle/Subscriber/SitemapXmlSubscriber.php +++ b/sources/AppBundle/Subscriber/SitemapXmlSubscriber.php @@ -15,6 +15,7 @@ use CCMBenchmark\TingBundle\Repository\RepositoryFactory; use Presta\SitemapBundle\Event\SitemapPopulateEvent; use Presta\SitemapBundle\Service\UrlContainerInterface; +use Presta\SitemapBundle\Sitemap\Url\GoogleVideo; use Presta\SitemapBundle\Sitemap\Url\GoogleVideoUrlDecorator; use Presta\SitemapBundle\Sitemap\Url\UrlConcrete; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -34,7 +35,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator, RepositoryFacto public static function getSubscribedEvents(): array { return [ - SitemapPopulateEvent::ON_SITEMAP_POPULATE => 'populate', + SitemapPopulateEvent::class => 'populate', ]; } @@ -67,14 +68,15 @@ public function registerTalksUrls(UrlContainerInterface $urls): void $urls->addUrl($url,'talks'); if ($talk->hasYoutubeId()) { - $urlVideo = new GoogleVideoUrlDecorator( - $url, + $video = new GoogleVideo( sprintf('https://img.youtube.com/vi/%s/0.jpg', $talk->getYoutubeId()), $talk->getTitle(), strip_tags(html_entity_decode($talk->getDescription())), - ['player_loc' => $talk->getYoutubeUrl()] + ['player_location' => $talk->getYoutubeUrl()] ); - $urls->addUrl($urlVideo,'video'); + $decoratedUrl = new GoogleVideoUrlDecorator($url); + $decoratedUrl->addVideo($video); + $urls->addUrl($decoratedUrl,'video'); } } } diff --git a/tests/behat/features/PublicSite/Sitemaps.feature b/tests/behat/features/PublicSite/Sitemaps.feature new file mode 100644 index 000000000..ec49720e3 --- /dev/null +++ b/tests/behat/features/PublicSite/Sitemaps.feature @@ -0,0 +1,35 @@ +Feature: Site Public - Sitemaps + + @reloadDbWithTestData + Scenario: On accède sitemap XML global + Given I am on "/sitemap.xml" + And the response should contain "https://apachephptest:80/sitemap.talks.xml" + And the response should contain "https://apachephptest:80/sitemap.video.xml" + And the response should contain "https://apachephptest:80/sitemap.news.xml" + And the response should contain "https://apachephptest:80/sitemap.members.xml" + And the response should contain "https://apachephptest:80/sitemap.default.xml" + + @reloadDbWithTestData + Scenario: On accède sitemap talks + Given I am on "/sitemap.talks.xml" + And the response should contain "https://apachephptest:80/talks/1-jouons-tous-ensemble-a-un-petit-jeu" + + @reloadDbWithTestData + Scenario: On accède sitemap video + Given I am on "/sitemap.video.xml" + And the response should contain "https://apachephptest:80/talks/1-jouons-tous-ensemble-a-un-petit-jeu" + + @reloadDbWithTestData + Scenario: On accède sitemap news + Given I am on "/sitemap.news.xml" + And the response should contain "https://apachephptest:80/news/1-les-videos-du-forum-2018-en-ligne" + + @reloadDbWithTestData + Scenario: On accède sitemap members + Given I am on "/sitemap.members.xml" + And the response should contain "https://apachephptest:80/profile/company/1-mycorp" + + @reloadDbWithTestData + Scenario: On accède sitemap default + Given I am on "/sitemap.default.xml" + And the response should contain "https://apachephptest:80/home"