Skip to content

Commit

Permalink
Fix PHPUnit (8.2, 7.0) tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evertharmeling committed Dec 1, 2023
1 parent a8c3726 commit 02a598a
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 6 deletions.
15 changes: 15 additions & 0 deletions tests/Integration/config/7.0/framework.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tests/Integration/config/7.0/messenger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
framework:
messenger:
transports:
async: 'in-memory://'
routing:
'Presta\SitemapBundle\Messenger\DumpSitemapMessage': async
9 changes: 9 additions & 0 deletions tests/Integration/config/7.0/presta_sitemap.yaml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tests/Integration/config/7.0/routes/annotations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
controllers:
resource: ../../../src/Controller/
type: attribute
2 changes: 2 additions & 0 deletions tests/Integration/config/7.0/routes/presta_sitemap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
presta_sitemap:
resource: "@PrestaSitemapBundle/config/routing.yml"
7 changes: 7 additions & 0 deletions tests/Integration/config/7.0/routes/translated.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
about:
path:
en: /about
fr: /a-propos
defaults: { _controller: \Presta\SitemapBundle\Tests\Integration\Controller\StaticController::about }
options:
sitemap: true
14 changes: 14 additions & 0 deletions tests/Integration/config/7.0/routes/xml.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>

<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="xml" path="/company">
<default key="_controller">Presta\SitemapBundle\Tests\Integration\Controller\StaticController::company</default>
<option key="sitemap">
{"priority":"0.7", "changefreq":"weekly", "section":"static"}
</option>
</route>

</routes>
6 changes: 6 additions & 0 deletions tests/Integration/config/7.0/routes/yaml.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
yaml:
path: /contact
defaults: { _controller: \Presta\SitemapBundle\Tests\Integration\Controller\StaticController::contact }
options:
sitemap:
section: static
4 changes: 2 additions & 2 deletions tests/Integration/src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/tests/SitemapTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 . '"'
Expand All @@ -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 . '"'
Expand Down

0 comments on commit 02a598a

Please sign in to comment.