Skip to content

Commit

Permalink
Mise à jour de presta/sitemap-bundle (afup#1654)
Browse files Browse the repository at this point in the history
* Mise à jour de `presta/sitemap-bundle`

* Ajout du test functional
  • Loading branch information
stakovicz committed Mar 1, 2025
1 parent 3270f97 commit d9c446c
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 30 deletions.
2 changes: 1 addition & 1 deletion app/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
46 changes: 23 additions & 23 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions sources/AppBundle/Subscriber/SitemapXmlSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,7 +35,7 @@ public function __construct(UrlGeneratorInterface $urlGenerator, RepositoryFacto
public static function getSubscribedEvents(): array
{
return [
SitemapPopulateEvent::ON_SITEMAP_POPULATE => 'populate',
SitemapPopulateEvent::class => 'populate',
];
}

Expand Down Expand Up @@ -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');
}
}
}
Expand Down
35 changes: 35 additions & 0 deletions tests/behat/features/PublicSite/Sitemaps.feature
Original file line number Diff line number Diff line change
@@ -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 "<loc>https://apachephptest:80/sitemap.talks.xml</loc>"
And the response should contain "<loc>https://apachephptest:80/sitemap.video.xml</loc>"
And the response should contain "<loc>https://apachephptest:80/sitemap.news.xml</loc>"
And the response should contain "<loc>https://apachephptest:80/sitemap.members.xml</loc>"
And the response should contain "<loc>https://apachephptest:80/sitemap.default.xml</loc>"

@reloadDbWithTestData
Scenario: On accède sitemap talks
Given I am on "/sitemap.talks.xml"
And the response should contain "<loc>https://apachephptest:80/talks/1-jouons-tous-ensemble-a-un-petit-jeu</loc>"

@reloadDbWithTestData
Scenario: On accède sitemap video
Given I am on "/sitemap.video.xml"
And the response should contain "<loc>https://apachephptest:80/talks/1-jouons-tous-ensemble-a-un-petit-jeu</loc>"

@reloadDbWithTestData
Scenario: On accède sitemap news
Given I am on "/sitemap.news.xml"
And the response should contain "<loc>https://apachephptest:80/news/1-les-videos-du-forum-2018-en-ligne</loc>"

@reloadDbWithTestData
Scenario: On accède sitemap members
Given I am on "/sitemap.members.xml"
And the response should contain "<loc>https://apachephptest:80/profile/company/1-mycorp</loc>"

@reloadDbWithTestData
Scenario: On accède sitemap default
Given I am on "/sitemap.default.xml"
And the response should contain "<loc>https://apachephptest:80/home</loc>"

0 comments on commit d9c446c

Please sign in to comment.