feat: upgrade project to symfony 7.4

This commit is contained in:
Björn Fromme
2026-08-31 09:03:44 +02:00
parent c1fa08fed0
commit 010cfe56b2
29 changed files with 1391 additions and 1133 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
type: php type: php
docroot: public docroot: public
php_version: "8.3" php_version: "8.4"
webserver_type: apache-fpm webserver_type: apache-fpm
xdebug_enabled: false xdebug_enabled: false
additional_hostnames: additional_hostnames:
+4
View File
@@ -37,3 +37,7 @@ yarn-error.log
###> phpstan/phpstan ### ###> phpstan/phpstan ###
phpstan.neon phpstan.neon
###< phpstan/phpstan ### ###< phpstan/phpstan ###
###> config reference ###
/config/reference.php
###< config reference ###
+36 -36
View File
@@ -4,7 +4,7 @@
"minimum-stability": "stable", "minimum-stability": "stable",
"prefer-stable": true, "prefer-stable": true,
"require": { "require": {
"php": ">=8.1", "php": ">=8.4",
"ext-ctype": "*", "ext-ctype": "*",
"ext-dom": "*", "ext-dom": "*",
"ext-iconv": "*", "ext-iconv": "*",
@@ -29,39 +29,39 @@
"phpstan/phpdoc-parser": "^2.0", "phpstan/phpdoc-parser": "^2.0",
"spatie/crypto": "^2.1", "spatie/crypto": "^2.1",
"symfony/apache-pack": "^1.0", "symfony/apache-pack": "^1.0",
"symfony/asset": "6.4.*", "symfony/asset": "7.4.*",
"symfony/console": "6.4.*", "symfony/console": "7.4.*",
"symfony/doctrine-messenger": "6.4.*", "symfony/doctrine-messenger": "7.4.*",
"symfony/dom-crawler": "6.4.*", "symfony/dom-crawler": "7.4.*",
"symfony/dotenv": "6.4.*", "symfony/dotenv": "7.4.*",
"symfony/expression-language": "6.4.*", "symfony/expression-language": "7.4.*",
"symfony/flex": "^2", "symfony/flex": "^2",
"symfony/form": "6.4.*", "symfony/form": "7.4.*",
"symfony/framework-bundle": "6.4.*", "symfony/framework-bundle": "7.4.*",
"symfony/html-sanitizer": "6.4.*", "symfony/html-sanitizer": "7.4.*",
"symfony/http-client": "6.4.*", "symfony/http-client": "7.4.*",
"symfony/intl": "6.4.*", "symfony/intl": "7.4.*",
"symfony/lock": "6.4.*", "symfony/lock": "7.4.*",
"symfony/mailer": "6.4.*", "symfony/mailer": "7.4.*",
"symfony/mime": "6.4.*", "symfony/mime": "7.4.*",
"symfony/monolog-bundle": "^3.0", "symfony/monolog-bundle": "^3.0",
"symfony/notifier": "6.4.*", "symfony/notifier": "7.4.*",
"symfony/process": "6.4.*", "symfony/process": "7.4.*",
"symfony/property-access": "6.4.*", "symfony/property-access": "7.4.*",
"symfony/property-info": "6.4.*", "symfony/property-info": "7.4.*",
"symfony/runtime": "6.4.*", "symfony/runtime": "7.4.*",
"symfony/security-bundle": "6.4.*", "symfony/security-bundle": "7.4.*",
"symfony/serializer": "6.4.*", "symfony/serializer": "7.4.*",
"symfony/stimulus-bundle": "^2.21", "symfony/stimulus-bundle": "^2.21",
"symfony/string": "6.4.*", "symfony/string": "7.4.*",
"symfony/translation": "6.4.*", "symfony/translation": "7.4.*",
"symfony/twig-bundle": "6.4.*", "symfony/twig-bundle": "7.4.*",
"symfony/uid": "6.4.*", "symfony/uid": "7.4.*",
"symfony/ux-twig-component": "^2.36", "symfony/ux-twig-component": "^2.36",
"symfony/validator": "6.4.*", "symfony/validator": "7.4.*",
"symfony/web-link": "6.4.*", "symfony/web-link": "7.4.*",
"symfony/webpack-encore-bundle": "^2.2", "symfony/webpack-encore-bundle": "^2.2",
"symfony/yaml": "6.4.*", "symfony/yaml": "7.4.*",
"twig/extra-bundle": "^2.12|^3.0", "twig/extra-bundle": "^2.12|^3.0",
"twig/html-extra": "^3.15", "twig/html-extra": "^3.15",
"twig/intl-extra": "*", "twig/intl-extra": "*",
@@ -77,7 +77,7 @@
}, },
"sort-packages": true, "sort-packages": true,
"platform": { "platform": {
"php": "8.3.30" "php": "8.4.24"
} }
}, },
"autoload": { "autoload": {
@@ -119,7 +119,7 @@
"extra": { "extra": {
"symfony": { "symfony": {
"allow-contrib": true, "allow-contrib": true,
"require": "6.4.*", "require": "7.4.*",
"docker": true "docker": true
} }
}, },
@@ -131,12 +131,12 @@
"phpstan/phpstan-symfony": "^2.0", "phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5",
"rector/rector": "^2.4", "rector/rector": "^2.4",
"symfony/browser-kit": "6.4.*", "symfony/browser-kit": "7.4.*",
"symfony/css-selector": "6.4.*", "symfony/css-selector": "7.4.*",
"symfony/debug-bundle": "6.4.*", "symfony/debug-bundle": "7.4.*",
"symfony/maker-bundle": "^1.0", "symfony/maker-bundle": "^1.0",
"symfony/phpunit-bridge": "^7.1", "symfony/phpunit-bridge": "^7.1",
"symfony/stopwatch": "6.4.*", "symfony/stopwatch": "7.4.*",
"symfony/web-profiler-bundle": "6.4.*" "symfony/web-profiler-bundle": "7.4.*"
} }
} }
Generated
+1214 -1012
View File
File diff suppressed because it is too large Load Diff
+1 -4
View File
@@ -9,8 +9,7 @@ doctrine:
profiling_collect_backtrace: '%kernel.debug%' profiling_collect_backtrace: '%kernel.debug%'
use_savepoints: true use_savepoints: true
orm: orm:
auto_generate_proxy_classes: true enable_native_lazy_objects: true
enable_lazy_ghost_objects: true
validate_xml_mapping: true validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true auto_mapping: true
@@ -33,8 +32,6 @@ when@test:
when@prod: when@prod:
doctrine: doctrine:
orm: orm:
auto_generate_proxy_classes: false
proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
query_cache_driver: query_cache_driver:
type: pool type: pool
pool: doctrine.system_cache_pool pool: doctrine.system_cache_pool
-1
View File
@@ -1,7 +1,6 @@
# see https://symfony.com/doc/current/reference/configuration/framework.html # see https://symfony.com/doc/current/reference/configuration/framework.html
framework: framework:
secret: '%env(APP_SECRET)%' secret: '%env(APP_SECRET)%'
annotations: false
http_method_override: false http_method_override: false
handle_all_throwables: true handle_all_throwables: true
+3
View File
@@ -0,0 +1,3 @@
framework:
property_info:
with_constructor_extractor: true
+3 -1
View File
@@ -14,4 +14,6 @@ when@test:
intercept_redirects: false intercept_redirects: false
framework: framework:
profiler: { collect: false } profiler:
collect: false
collect_serializer_data: true
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\BusProNet;
use Symfony\Component\DomCrawler\Crawler;
/**
* Builds a Crawler over BusPro's XML payloads.
*
* The Crawler constructor parses its content as HTML5, which flattens the
* nesting BusPro's exports and API responses rely on, so XML has to be added
* through addXmlContent() instead.
*/
final class XmlCrawlerFactory
{
public static function create(string $xml): Crawler
{
$crawler = new Crawler();
$crawler->addXmlContent($xml);
return $crawler;
}
}
+2 -1
View File
@@ -4,6 +4,7 @@ namespace App\BusProNet\XmlLoader;
use App\BusProNet\Model\Hotel; use App\BusProNet\Model\Hotel;
use App\BusProNet\Model\Travel; use App\BusProNet\Model\Travel;
use App\BusProNet\XmlCrawlerFactory;
use App\Exception\HotelNotFoundException; use App\Exception\HotelNotFoundException;
use Psr\Cache\InvalidArgumentException; use Psr\Cache\InvalidArgumentException;
use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Crawler;
@@ -73,7 +74,7 @@ class HotelLoader extends AbstractLoader
{ {
$xml = $this->xmlExport->read($filename); $xml = $this->xmlExport->read($filename);
return new Crawler($xml); return XmlCrawlerFactory::create($xml);
} }
public function parseXml(Crawler $node): Hotel public function parseXml(Crawler $node): Hotel
+2 -1
View File
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\BusProNet\XmlLoader; namespace App\BusProNet\XmlLoader;
use App\BusProNet\Model\Insurance; use App\BusProNet\Model\Insurance;
use App\BusProNet\XmlCrawlerFactory;
use App\BusProNet\XmlParser\InsuranceParser; use App\BusProNet\XmlParser\InsuranceParser;
use League\Flysystem\FilesystemOperator; use League\Flysystem\FilesystemOperator;
use Psr\Cache\InvalidArgumentException; use Psr\Cache\InvalidArgumentException;
@@ -50,6 +51,6 @@ class InsuranceLoader extends AbstractLoader
{ {
$xml = $this->xmlExport->read($filename); $xml = $this->xmlExport->read($filename);
return new Crawler($xml); return XmlCrawlerFactory::create($xml);
} }
} }
+2 -1
View File
@@ -4,6 +4,7 @@ namespace App\BusProNet\XmlLoader;
use App\BusProNet\Model\Pickup; use App\BusProNet\Model\Pickup;
use App\BusProNet\Model\Travel; use App\BusProNet\Model\Travel;
use App\BusProNet\XmlCrawlerFactory;
use Psr\Cache\InvalidArgumentException; use Psr\Cache\InvalidArgumentException;
use Symfony\Component\DomCrawler\Crawler; use Symfony\Component\DomCrawler\Crawler;
use Symfony\Contracts\Cache\ItemInterface; use Symfony\Contracts\Cache\ItemInterface;
@@ -46,7 +47,7 @@ class PickupLoader extends AbstractLoader
{ {
$xml = $this->xmlExport->read($filename); $xml = $this->xmlExport->read($filename);
return new Crawler($xml); return XmlCrawlerFactory::create($xml);
} }
public function parseXml(Crawler $node): Pickup public function parseXml(Crawler $node): Pickup
+3 -2
View File
@@ -7,6 +7,7 @@ use App\BusProNet\Model\MutableData;
use App\BusProNet\Model\ServiceAvailabilityResponse; use App\BusProNet\Model\ServiceAvailabilityResponse;
use App\BusProNet\Model\Travel; use App\BusProNet\Model\Travel;
use App\BusProNet\Utility\DateCodeUtility; use App\BusProNet\Utility\DateCodeUtility;
use App\BusProNet\XmlCrawlerFactory;
use App\BusProNet\XmlParser\TravelParser; use App\BusProNet\XmlParser\TravelParser;
use App\Exception\HotelNotInTravelException; use App\Exception\HotelNotInTravelException;
use App\Exception\TravelNotFoundException; use App\Exception\TravelNotFoundException;
@@ -71,7 +72,7 @@ class TravelLoader extends AbstractLoader
foreach ($xmlFiles as $file) { foreach ($xmlFiles as $file) {
$xml = $this->xmlExport->read($file->path()); $xml = $this->xmlExport->read($file->path());
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$travelDataNodes = $crawler->filterXPath('//reisen/reise/termin'); $travelDataNodes = $crawler->filterXPath('//reisen/reise/termin');
$travelDataNodes->each(function (Crawler $node) use (&$mapping, $hotels, $file) { $travelDataNodes->each(function (Crawler $node) use (&$mapping, $hotels, $file) {
@@ -218,7 +219,7 @@ class TravelLoader extends AbstractLoader
{ {
try { try {
$xml = $this->xmlExport->read($filename); $xml = $this->xmlExport->read($filename);
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$travelNode = $crawler->filterXPath(sprintf('//reise/termin[@idbuspro="%d"]', $dateId)); $travelNode = $crawler->filterXPath(sprintf('//reise/termin[@idbuspro="%d"]', $dateId));
@@ -4,7 +4,7 @@ namespace App\BusProNet\XmlParser;
use App\BusProNet\ApiClient; use App\BusProNet\ApiClient;
use App\BusProNet\Exception\ResponseParserException; use App\BusProNet\Exception\ResponseParserException;
use Symfony\Component\DomCrawler\Crawler; use App\BusProNet\XmlCrawlerFactory;
class ApiResponseParser extends AbstractParser class ApiResponseParser extends AbstractParser
{ {
@@ -14,7 +14,7 @@ class ApiResponseParser extends AbstractParser
/** @param array<string, mixed> $additionalArgs */ /** @param array<string, mixed> $additionalArgs */
public function parseXmlString(string $type, string $xml, array $additionalArgs = []): mixed public function parseXmlString(string $type, string $xml, array $additionalArgs = []): mixed
{ {
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
if (0 === $crawler->count()) { if (0 === $crawler->count()) {
throw new ResponseParserException('Empty response received from server'); throw new ResponseParserException('Empty response received from server');
@@ -5,7 +5,8 @@ declare(strict_types=1);
namespace App\Security\Voter; namespace App\Security\Voter;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
use Symfony\Component\Security\Core\Authorization\Voter\Voter; use Symfony\Component\Security\Core\Authorization\Voter\Voter;
/** /**
@@ -16,7 +17,7 @@ class AdministrativeAccessVoter extends Voter
public const ADMINISTRATIVE_ACCESS = 'ADMINISTRATIVE_ACCESS'; public const ADMINISTRATIVE_ACCESS = 'ADMINISTRATIVE_ACCESS';
public function __construct( public function __construct(
private readonly AuthorizationCheckerInterface $authorizationChecker, private readonly AccessDecisionManagerInterface $accessDecisionManager,
) { ) {
} }
@@ -25,9 +26,9 @@ class AdministrativeAccessVoter extends Voter
return self::ADMINISTRATIVE_ACCESS === $attribute; return self::ADMINISTRATIVE_ACCESS === $attribute;
} }
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool
{ {
return $this->authorizationChecker->isGranted('ROLE_ADMIN') return $this->accessDecisionManager->decide($token, ['ROLE_ADMIN'])
|| $this->authorizationChecker->isGranted('ROLE_GROUPS_MANAGER'); || $this->accessDecisionManager->decide($token, ['ROLE_GROUPS_MANAGER']);
} }
} }
+2 -1
View File
@@ -7,6 +7,7 @@ namespace App\Security\Voter;
use App\BusProNet\Model\Booking; use App\BusProNet\Model\Booking;
use App\Entity\User; use App\Entity\User;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
use Symfony\Component\Security\Core\Authorization\Voter\Voter; use Symfony\Component\Security\Core\Authorization\Voter\Voter;
/** /**
@@ -32,7 +33,7 @@ class BookingVoter extends Voter
return $subject instanceof Booking; return $subject instanceof Booking;
} }
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token, ?Vote $vote = null): bool
{ {
/** @var User|null $user */ /** @var User|null $user */
$user = $token->getUser(); $user = $token->getUser();
+24
View File
@@ -177,6 +177,18 @@
".env" ".env"
] ]
}, },
"symfony/form": {
"version": "7.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "7.2",
"ref": "7d86a6723f4a623f59e2bf966b6aad2fc461d36b"
},
"files": [
"config/packages/csrf.yaml"
]
},
"symfony/framework-bundle": { "symfony/framework-bundle": {
"version": "6.4", "version": "6.4",
"recipe": { "recipe": {
@@ -280,6 +292,18 @@
"tests/bootstrap.php" "tests/bootstrap.php"
] ]
}, },
"symfony/property-info": {
"version": "7.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "7.3",
"ref": "dae70df71978ae9226ae915ffd5fad817f5ca1f7"
},
"files": [
"config/packages/property_info.yaml"
]
},
"symfony/routing": { "symfony/routing": {
"version": "6.4", "version": "6.4",
"recipe": { "recipe": {
-2
View File
@@ -1,4 +1,3 @@
{% apply spaceless %}
{% for message in messages %} {% for message in messages %}
{% if message is iterable %} {% if message is iterable %}
{% set message = message.id | trans(message.parameters | default({}), message.domain | default(null), message.locale | default(null)) | raw %} {% set message = message.id | trans(message.parameters | default({}), message.domain | default(null), message.locale | default(null)) | raw %}
@@ -7,4 +6,3 @@
{% endif %} {% endif %}
<div {{ stimulus_controller('toast', { 'text': message, 'class': 'toastify--' ~ level}) }}{{ qa_attribute('toast', level)}}></div> <div {{ stimulus_controller('toast', { 'text': message, 'class': 'toastify--' ~ level}) }}{{ qa_attribute('toast', level)}}></div>
{% endfor %} {% endfor %}
{% endapply %}
@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Tests\BusProNet\XmlParser; namespace App\Tests\BusProNet\XmlParser;
use App\BusProNet\XmlCrawlerFactory;
use App\BusProNet\XmlParser\AgencyParser; use App\BusProNet\XmlParser\AgencyParser;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DomCrawler\Crawler;
class AgencyParserTest extends TestCase class AgencyParserTest extends TestCase
{ {
@@ -41,7 +41,7 @@ class AgencyParserTest extends TestCase
</agenturen> </agenturen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$resultNode = $crawler->filterXPath('//ergebnis'); $resultNode = $crawler->filterXPath('//ergebnis');
$agencies = $this->parser->parse($resultNode); $agencies = $this->parser->parse($resultNode);
@@ -79,7 +79,7 @@ class AgencyParserTest extends TestCase
</agenturen> </agenturen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$resultNode = $crawler->filterXPath('//ergebnis'); $resultNode = $crawler->filterXPath('//ergebnis');
$agencies = $this->parser->parse($resultNode); $agencies = $this->parser->parse($resultNode);
@@ -102,7 +102,7 @@ class AgencyParserTest extends TestCase
</agenturen> </agenturen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$resultNode = $crawler->filterXPath('//ergebnis'); $resultNode = $crawler->filterXPath('//ergebnis');
$agencies = $this->parser->parse($resultNode); $agencies = $this->parser->parse($resultNode);
@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Tests\BusProNet\XmlParser; namespace App\Tests\BusProNet\XmlParser;
use App\BusProNet\XmlCrawlerFactory;
use App\BusProNet\XmlParser\BookingInsurancesParser; use App\BusProNet\XmlParser\BookingInsurancesParser;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DomCrawler\Crawler;
class BookingInsurancesParserTest extends TestCase class BookingInsurancesParserTest extends TestCase
{ {
@@ -22,7 +22,7 @@ class BookingInsurancesParserTest extends TestCase
</ergebnis> </ergebnis>
XML; XML;
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$insurancesData = $crawler->filterXPath('//versicherungen/versicherung'); $insurancesData = $crawler->filterXPath('//versicherungen/versicherung');
$parser = new BookingInsurancesParser(); $parser = new BookingInsurancesParser();
@@ -53,7 +53,7 @@ XML;
</ergebnis> </ergebnis>
XML; XML;
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$insurancesData = $crawler->filterXPath('//versicherungen/versicherung'); $insurancesData = $crawler->filterXPath('//versicherungen/versicherung');
$parser = new BookingInsurancesParser(); $parser = new BookingInsurancesParser();
@@ -88,7 +88,7 @@ XML;
</ergebnis> </ergebnis>
XML; XML;
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$insurancesData = $crawler->filterXPath('//versicherungen/versicherung'); $insurancesData = $crawler->filterXPath('//versicherungen/versicherung');
$parser = new BookingInsurancesParser(); $parser = new BookingInsurancesParser();
@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Tests\BusProNet\XmlParser; namespace App\Tests\BusProNet\XmlParser;
use App\BusProNet\XmlCrawlerFactory;
use App\BusProNet\XmlParser\BookingResponseParser; use App\BusProNet\XmlParser\BookingResponseParser;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DomCrawler\Crawler;
class BookingResponseParserTest extends TestCase class BookingResponseParserTest extends TestCase
{ {
@@ -34,7 +34,7 @@ class BookingResponseParserTest extends TestCase
</zahlungsbedingungen> </zahlungsbedingungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$response = $this->parser->parse($crawler->filter('ergebnis')); $response = $this->parser->parse($crawler->filter('ergebnis'));
$this->assertTrue($response->isInquiryValid()); $this->assertTrue($response->isInquiryValid());
@@ -67,7 +67,7 @@ class BookingResponseParserTest extends TestCase
</zahlungsbedingungen> </zahlungsbedingungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$response = $this->parser->parse($crawler->filter('ergebnis')); $response = $this->parser->parse($crawler->filter('ergebnis'));
$this->assertTrue($response->isInquiryValid()); $this->assertTrue($response->isInquiryValid());
@@ -102,7 +102,7 @@ class BookingResponseParserTest extends TestCase
<zahlungsbedingungen></zahlungsbedingungen> <zahlungsbedingungen></zahlungsbedingungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$response = $this->parser->parse($crawler->filter('ergebnis')); $response = $this->parser->parse($crawler->filter('ergebnis'));
$this->assertTrue($response->isInquiryValid()); $this->assertTrue($response->isInquiryValid());
@@ -140,7 +140,7 @@ class BookingResponseParserTest extends TestCase
</zahlungsbedingungen> </zahlungsbedingungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$response = $this->parser->parse($crawler->filter('ergebnis')); $response = $this->parser->parse($crawler->filter('ergebnis'));
// Verify all voucher types are parsed // Verify all voucher types are parsed
@@ -169,7 +169,7 @@ class BookingResponseParserTest extends TestCase
</zahlungsbedingungen> </zahlungsbedingungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$response = $this->parser->parse($crawler->filter('ergebnis')); $response = $this->parser->parse($crawler->filter('ergebnis'));
$this->assertTrue($response->isInquiryValid()); $this->assertTrue($response->isInquiryValid());
@@ -200,7 +200,7 @@ class BookingResponseParserTest extends TestCase
</zahlungsbedingungen> </zahlungsbedingungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$response = $this->parser->parse($crawler->filter('ergebnis')); $response = $this->parser->parse($crawler->filter('ergebnis'));
// Verify multiple purchase vouchers are parsed // Verify multiple purchase vouchers are parsed
@@ -228,7 +228,7 @@ class BookingResponseParserTest extends TestCase
</zahlungsbedingungen> </zahlungsbedingungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$response = $this->parser->parse($crawler->filter('ergebnis')); $response = $this->parser->parse($crawler->filter('ergebnis'));
$this->assertTrue($response->isInquiryValid()); $this->assertTrue($response->isInquiryValid());
@@ -269,7 +269,7 @@ class BookingResponseParserTest extends TestCase
</zahlungsbedingungen> </zahlungsbedingungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$response = $this->parser->parse($crawler->filter('ergebnis')); $response = $this->parser->parse($crawler->filter('ergebnis'));
// Voucher discount should only include AKTION // Voucher discount should only include AKTION
@@ -305,7 +305,7 @@ class BookingResponseParserTest extends TestCase
</zahlungsbedingungen> </zahlungsbedingungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$response = $this->parser->parse($crawler->filter('ergebnis')); $response = $this->parser->parse($crawler->filter('ergebnis'));
// Verify no API-applied discounts // Verify no API-applied discounts
@@ -333,7 +333,7 @@ class BookingResponseParserTest extends TestCase
</zahlungsbedingungen> </zahlungsbedingungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$response = $this->parser->parse($crawler->filter('ergebnis')); $response = $this->parser->parse($crawler->filter('ergebnis'));
$this->assertTrue($response->isInquiryValid()); $this->assertTrue($response->isInquiryValid());
@@ -366,7 +366,7 @@ class BookingResponseParserTest extends TestCase
</zahlungsbedingungen> </zahlungsbedingungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$response = $this->parser->parse($crawler->filter('ergebnis')); $response = $this->parser->parse($crawler->filter('ergebnis'));
// Only ERM (Gruppenrabatt) should be counted as API-applied discount // Only ERM (Gruppenrabatt) should be counted as API-applied discount
@@ -5,9 +5,9 @@ declare(strict_types=1);
namespace App\Tests\BusProNet\XmlParser; namespace App\Tests\BusProNet\XmlParser;
use App\BusProNet\Model\CrmAttributes; use App\BusProNet\Model\CrmAttributes;
use App\BusProNet\XmlCrawlerFactory;
use App\BusProNet\XmlParser\CrmAttributesResponseParser; use App\BusProNet\XmlParser\CrmAttributesResponseParser;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DomCrawler\Crawler;
class CrmAttributesResponseParserTest extends TestCase class CrmAttributesResponseParserTest extends TestCase
{ {
@@ -82,7 +82,7 @@ class CrmAttributesResponseParserTest extends TestCase
// A house that is deliberately left out of bpn_crm_house_manager_ids claims nothing — // A house that is deliberately left out of bpn_crm_house_manager_ids claims nothing —
// matching is by id, never by label. // matching is by id, never by label.
$parser = new CrmAttributesResponseParser([]); $parser = new CrmAttributesResponseParser([]);
$attributes = $parser->parse((new Crawler($this->hausleitungXml()))->filterXPath('//ergebnis')); $attributes = $parser->parse(XmlCrawlerFactory::create($this->hausleitungXml())->filterXPath('//ergebnis'));
self::assertSame([], $attributes->roles); self::assertSame([], $attributes->roles);
self::assertSame([], $attributes->hotelCodes); self::assertSame([], $attributes->hotelCodes);
@@ -108,7 +108,7 @@ class CrmAttributesResponseParserTest extends TestCase
private function parse(string $xmlContent): CrmAttributes private function parse(string $xmlContent): CrmAttributes
{ {
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$resultNode = $crawler->filterXPath('//ergebnis'); $resultNode = $crawler->filterXPath('//ergebnis');
return $this->parser->parse($resultNode); return $this->parser->parse($resultNode);
@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Tests\BusProNet\XmlParser; namespace App\Tests\BusProNet\XmlParser;
use App\BusProNet\XmlCrawlerFactory;
use App\BusProNet\XmlParser\ExtendedAvailabilitiesParser; use App\BusProNet\XmlParser\ExtendedAvailabilitiesParser;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DomCrawler\Crawler;
class ExtendedAvailabilitiesParserTest extends TestCase class ExtendedAvailabilitiesParserTest extends TestCase
{ {
@@ -28,7 +28,7 @@ class ExtendedAvailabilitiesParserTest extends TestCase
<reise status="Frei" buchungstatusmoeglich="FA" /> <reise status="Frei" buchungstatusmoeglich="FA" />
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$response = $this->parser->parseServices($crawler); $response = $this->parser->parseServices($crawler);
$services = $response->getServices(); $services = $response->getServices();
@@ -58,7 +58,7 @@ class ExtendedAvailabilitiesParserTest extends TestCase
</leistungen> </leistungen>
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$response = $this->parser->parseServices($crawler); $response = $this->parser->parseServices($crawler);
$services = $response->getServices(); $services = $response->getServices();
@@ -78,7 +78,7 @@ class ExtendedAvailabilitiesParserTest extends TestCase
<reise status="Frei" buchungstatusmoeglich="FA" /> <reise status="Frei" buchungstatusmoeglich="FA" />
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$response = $this->parser->parseServices($crawler); $response = $this->parser->parseServices($crawler);
$this->assertSame('Frei', $response->travelStatus); $this->assertSame('Frei', $response->travelStatus);
@@ -93,7 +93,7 @@ class ExtendedAvailabilitiesParserTest extends TestCase
<reise status="Frei" buchungstatusmoeglich="" /> <reise status="Frei" buchungstatusmoeglich="" />
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$response = $this->parser->parseServices($crawler); $response = $this->parser->parseServices($crawler);
$this->assertSame([], $response->allowedBookingStatus); $this->assertSame([], $response->allowedBookingStatus);
@@ -106,7 +106,7 @@ class ExtendedAvailabilitiesParserTest extends TestCase
<leistungen /> <leistungen />
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$response = $this->parser->parseServices($crawler); $response = $this->parser->parseServices($crawler);
$this->assertNull($response->travelStatus); $this->assertNull($response->travelStatus);
@@ -120,7 +120,7 @@ class ExtendedAvailabilitiesParserTest extends TestCase
<leistungen /> <leistungen />
</ergebnis>'; </ergebnis>';
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$response = $this->parser->parseServices($crawler); $response = $this->parser->parseServices($crawler);
$this->assertSame([], $response->getServices()); $this->assertSame([], $response->getServices());
@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Tests\BusProNet\XmlParser; namespace App\Tests\BusProNet\XmlParser;
use App\BusProNet\XmlCrawlerFactory;
use App\BusProNet\XmlParser\InsuranceParser; use App\BusProNet\XmlParser\InsuranceParser;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DomCrawler\Crawler;
class InsuranceParserTest extends TestCase class InsuranceParserTest extends TestCase
{ {
@@ -36,7 +36,7 @@ class InsuranceParserTest extends TestCase
</versicherungspakete> </versicherungspakete>
</versicherungsstammdaten>'; </versicherungsstammdaten>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$insurances = $this->parser->parse($crawler); $insurances = $this->parser->parse($crawler);
// Test all insurances are included (2 regular + 1 complementary + 1 package = 4 total) // Test all insurances are included (2 regular + 1 complementary + 1 package = 4 total)
@@ -112,7 +112,7 @@ class InsuranceParserTest extends TestCase
</versicherungspakete> </versicherungspakete>
</versicherungsstammdaten>'; </versicherungsstammdaten>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$insurances = $this->parser->parse($crawler); $insurances = $this->parser->parse($crawler);
$this->assertCount(2, $insurances); $this->assertCount(2, $insurances);
@@ -134,7 +134,7 @@ class InsuranceParserTest extends TestCase
</versicherungen> </versicherungen>
</versicherungsstammdaten>'; </versicherungsstammdaten>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$insurances = $this->parser->parse($crawler); $insurances = $this->parser->parse($crawler);
$this->assertCount(1, $insurances); $this->assertCount(1, $insurances);
@@ -155,7 +155,7 @@ class InsuranceParserTest extends TestCase
</versicherungspakete> </versicherungspakete>
</versicherungsstammdaten>'; </versicherungsstammdaten>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$insurances = $this->parser->parse($crawler); $insurances = $this->parser->parse($crawler);
$this->assertEmpty($insurances); $this->assertEmpty($insurances);
@@ -179,7 +179,7 @@ class InsuranceParserTest extends TestCase
</versicherungspakete> </versicherungspakete>
</versicherungsstammdaten>'; </versicherungsstammdaten>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$insurances = $this->parser->parse($crawler); $insurances = $this->parser->parse($crawler);
// Should include: normal insurance (178917), both complementary insurances (177270, 999999), and package (P1000320) // Should include: normal insurance (178917), both complementary insurances (177270, 999999), and package (P1000320)
@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Tests\BusProNet\XmlParser; namespace App\Tests\BusProNet\XmlParser;
use App\BusProNet\XmlCrawlerFactory;
use App\BusProNet\XmlParser\PersonalDataParser; use App\BusProNet\XmlParser\PersonalDataParser;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DomCrawler\Crawler;
class PersonalDataParserTest extends TestCase class PersonalDataParserTest extends TestCase
{ {
@@ -46,7 +46,7 @@ class PersonalDataParserTest extends TestCase
private function parse(string $xml): \App\BusProNet\Model\PersonalData private function parse(string $xml): \App\BusProNet\Model\PersonalData
{ {
return $this->parser->parse(new Crawler($xml)); return $this->parser->parse(XmlCrawlerFactory::create($xml));
} }
/** /**
+12 -12
View File
@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Tests\BusProNet\XmlParser; namespace App\Tests\BusProNet\XmlParser;
use App\BusProNet\XmlCrawlerFactory;
use App\BusProNet\XmlParser\TravelParser; use App\BusProNet\XmlParser\TravelParser;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DomCrawler\Crawler;
class TravelParserTest extends TestCase class TravelParserTest extends TestCase
{ {
@@ -68,7 +68,7 @@ class TravelParserTest extends TestCase
</reise> </reise>
</reisen>'; </reisen>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$travelNode = $crawler->filterXPath('//reise/termin')->first(); $travelNode = $crawler->filterXPath('//reise/termin')->first();
$travel = $this->parser->parse($travelNode); $travel = $this->parser->parse($travelNode);
@@ -135,7 +135,7 @@ class TravelParserTest extends TestCase
</reise> </reise>
</reisen>'; </reisen>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$travelNode = $crawler->filterXPath('//reise/termin')->first(); $travelNode = $crawler->filterXPath('//reise/termin')->first();
$travel = $this->parser->parse($travelNode); $travel = $this->parser->parse($travelNode);
@@ -166,7 +166,7 @@ class TravelParserTest extends TestCase
</reise> </reise>
</reisen>'; </reisen>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$travelNode = $crawler->filterXPath('//reise/termin')->first(); $travelNode = $crawler->filterXPath('//reise/termin')->first();
$travel = $this->parser->parse($travelNode); $travel = $this->parser->parse($travelNode);
@@ -201,7 +201,7 @@ class TravelParserTest extends TestCase
</reise> </reise>
</reisen>'; </reisen>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$travelNode = $crawler->filterXPath('//reise/termin')->first(); $travelNode = $crawler->filterXPath('//reise/termin')->first();
$travel = $this->parser->parse($travelNode); $travel = $this->parser->parse($travelNode);
@@ -240,7 +240,7 @@ class TravelParserTest extends TestCase
</reise> </reise>
</reisen>'; </reisen>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$travelNode = $crawler->filterXPath('//reise/termin')->first(); $travelNode = $crawler->filterXPath('//reise/termin')->first();
$travel = $this->parser->parse($travelNode); $travel = $this->parser->parse($travelNode);
@@ -284,7 +284,7 @@ class TravelParserTest extends TestCase
</reise> </reise>
</reisen>'; </reisen>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$travelNode = $crawler->filterXPath('//reise/termin')->first(); $travelNode = $crawler->filterXPath('//reise/termin')->first();
$travel = $this->parser->parse($travelNode); $travel = $this->parser->parse($travelNode);
@@ -319,7 +319,7 @@ class TravelParserTest extends TestCase
</reise> </reise>
</reisen>'; </reisen>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$travelNode = $crawler->filterXPath('//reise/termin')->first(); $travelNode = $crawler->filterXPath('//reise/termin')->first();
$travel = $this->parser->parse($travelNode); $travel = $this->parser->parse($travelNode);
@@ -347,7 +347,7 @@ class TravelParserTest extends TestCase
</reise> </reise>
</reisen>'; </reisen>';
$crawler = new Crawler($xmlContent); $crawler = XmlCrawlerFactory::create($xmlContent);
$travelNode = $crawler->filterXPath('//reise/termin')->first(); $travelNode = $crawler->filterXPath('//reise/termin')->first();
$travel = $this->parser->parse($travelNode); $travel = $this->parser->parse($travelNode);
@@ -364,7 +364,7 @@ class TravelParserTest extends TestCase
<zustieg idbuspro="4" zeit="01:00" preis="0,00" /> <zustieg idbuspro="4" zeit="01:00" preis="0,00" />
</zustiege>'; </zustiege>';
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$defaultDate = new \DateTimeImmutable('2029-12-30'); $defaultDate = new \DateTimeImmutable('2029-12-30');
$pickups = $this->parser->getPickups( $pickups = $this->parser->getPickups(
@@ -392,7 +392,7 @@ class TravelParserTest extends TestCase
<zustieg idbuspro="2" zeit="30.12.2029 20:30" preis="0,00" /> <zustieg idbuspro="2" zeit="30.12.2029 20:30" preis="0,00" />
</zustiege>'; </zustiege>';
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$defaultDate = new \DateTimeImmutable('2029-12-30'); $defaultDate = new \DateTimeImmutable('2029-12-30');
$pickups = $this->parser->getPickups( $pickups = $this->parser->getPickups(
@@ -413,7 +413,7 @@ class TravelParserTest extends TestCase
<zustieg idbuspro="2" zeit="01:00" preis="0,00" /> <zustieg idbuspro="2" zeit="01:00" preis="0,00" />
</zustiege>'; </zustiege>';
$crawler = new Crawler($xml); $crawler = XmlCrawlerFactory::create($xml);
$defaultDate = new \DateTimeImmutable('2029-12-30'); $defaultDate = new \DateTimeImmutable('2029-12-30');
$pickups = $this->parser->getPickups( $pickups = $this->parser->getPickups(
@@ -88,7 +88,7 @@ class BpnSyncContingentsCommandTest extends TestCase
); );
$application = new Application(); $application = new Application();
$application->add($command); $application->addCommand($command);
$tester = new CommandTester($application->find('app:bpn:sync-contingents')); $tester = new CommandTester($application->find('app:bpn:sync-contingents'));
$tester->execute(['--horizon-months' => '1']); $tester->execute(['--horizon-months' => '1']);
@@ -299,7 +299,7 @@ final class TestablePersonalDataController extends PersonalDataController
$this->flashes[] = [$type, (string) $message]; $this->flashes[] = [$type, (string) $message];
} }
protected function render(string $view, array $parameters = [], Response $response = null): Response protected function render(string $view, array $parameters = [], ?Response $response = null): Response
{ {
$this->renderedView = $view; $this->renderedView = $view;
$this->renderedParameters = $parameters; $this->renderedParameters = $parameters;
@@ -8,8 +8,9 @@ use App\BusProNet\Constants;
use App\BusProNet\Model\Booking; use App\BusProNet\Model\Booking;
use App\BusProNet\Model\Service; use App\BusProNet\Model\Service;
use App\BusProNet\Model\Travel; use App\BusProNet\Model\Travel;
use App\BusProNet\XmlParser\TravelParser;
use App\BusProNet\Utility\DirectionMapper; use App\BusProNet\Utility\DirectionMapper;
use App\BusProNet\XmlCrawlerFactory;
use App\BusProNet\XmlParser\TravelParser;
use App\Form\Model\BookingDto; use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto; use App\Form\Model\ParticipantDto;
use App\Form\Service\ParticipantFieldOptionsProvider; use App\Form\Service\ParticipantFieldOptionsProvider;
@@ -18,7 +19,6 @@ use App\Service\InsuranceManager;
use App\Service\ServiceAvailabilityCalculator; use App\Service\ServiceAvailabilityCalculator;
use App\Service\ServiceLabelFormatter; use App\Service\ServiceLabelFormatter;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class ParticipantFieldOptionsProviderBabyTest extends TestCase class ParticipantFieldOptionsProviderBabyTest extends TestCase
@@ -488,7 +488,7 @@ class ParticipantFieldOptionsProviderBabyTest extends TestCase
private function createTravelWithExportedSkiPasses(array $serviceIds): Travel private function createTravelWithExportedSkiPasses(array $serviceIds): Travel
{ {
$parser = new TravelParser(); $parser = new TravelParser();
$crawler = new Crawler(file_get_contents('/var/www/html/var/xmlexport/Ziel_2456.xml')); $crawler = XmlCrawlerFactory::create(file_get_contents('/var/www/html/var/xmlexport/Ziel_2456.xml'));
$travelNode = $crawler->filterXPath('//reise/termin')->first(); $travelNode = $crawler->filterXPath('//reise/termin')->first();
$travel = $parser->parse($travelNode); $travel = $parser->parse($travelNode);