Skip to content

Commit

Permalink
Merge pull request #634 from alexislefebvre/chore-allow-symfony-7
Browse files Browse the repository at this point in the history
chore: allow Symfony 7
  • Loading branch information
alexislefebvre authored Jan 7, 2024
2 parents 5658b8a + bb01956 commit 124c7a6
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 324 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2']
# Symfony 6.3 requires PHP >= 8.0, it will be installed on PHP >= 8.0
# Symfony 7.0 requires PHP >= 8.2, it will be installed on PHP >= 8.2
php-version: ['8.1', '8.2']
composer-flags: ['']
symfony-version: ['^5.4']
symfony-version: ['^6.4']
include:
- php-version: 7.4
symfony-version: "^4.4"
symfony-version: "^5.4"
composer-flags: "--prefer-lowest"
- php-version: 7.4
symfony-version: "^4.4"
- php-version: 8.0
symfony-version: "^4.4"
- php-version: 8.1
symfony-version: "^6.2"
symfony-version: "^5.4"
- php-version: 8.1
symfony-version: "^6.4"
- php-version: 8.2
symfony-version: "^6.4"
- php-version: 8.2
symfony-version: "^6.2"
symfony-version: "^7.0"

steps:
- name: Checkout
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@
"require": {
"php": "^7.4 || ^8.0",
"phpunit/phpunit": "^9.6 || ^10.0",
"symfony/browser-kit": "^4.4 || ^5.1 || ^6.0",
"symfony/framework-bundle": "^4.4 || ^5.1 || ^6.0"
"symfony/browser-kit": "^5.4 || ^6.4 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.4 || ^7.0"
},
"require-dev": {
"ext-json": "*",
"doctrine/annotations": "^1.3 || ^2.0",
"doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-bundle": "^2.11",
"doctrine/orm": "^2.7",
"monolog/monolog": "~1.11",
"symfony/css-selector": "^4.4 || ^5.1 || ^6.0",
"symfony/doctrine-bridge": "^4.4 || ^5.1 || ^6.0",
"symfony/form": "^4.4 || ^5.1 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.1 || ^6.0",
"monolog/monolog": "^1.25.1 || ^2.0 || ^3.0",
"symfony/css-selector": "^5.4 || ^6.4 || ^7.0",
"symfony/doctrine-bridge": "^5.4 || ^6.4 || ^7.0",
"symfony/form": "^5.4 || ^6.4 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.0",
"symfony/monolog-bundle": "^3.4",
"symfony/security-bundle": "^4.4 || ^5.1 || ^6.0",
"symfony/twig-bundle": "^4.4 || ^5.1 || ^6.0",
"symfony/validator": "^4.4 || ^5.1 || ^6.0",
"symfony/yaml": "^4.4 || ^5.1 || ^6.0",
"twig/twig": "^2.0 || ^3.0"
"symfony/security-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/validator": "^5.4 || ^6.4 || ^7.0",
"symfony/yaml": "^5.4 || ^6.4 || ^7.0",
"twig/twig": "^2.0 || ^3.8"
},
"conflict": {
"symfony/framework-bundle": "4.3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function setException(GetResponseForExceptionEvent $event): void

public function clearLastException(GetResponseEvent $event): void
{
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
if (HttpKernelInterface::MAIN_REQUEST === $event->getRequestType()) {
$this->lastException = null;
}
}
Expand Down
13 changes: 7 additions & 6 deletions src/QueryCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@

final class QueryCounter
{
/** @var int */
private $defaultMaxCount;
private ?int $defaultMaxCount;
private ?Reader $annotationReader;

/** @var Reader */
private $annotationReader;

public function __construct(?int $defaultMaxCount, Reader $annotationReader)
public function __construct(?int $defaultMaxCount, ?Reader $annotationReader)
{
$this->defaultMaxCount = $defaultMaxCount;
$this->annotationReader = $annotationReader;
Expand Down Expand Up @@ -57,6 +54,10 @@ private function getMaxQueryCount(): ?int

private function getMaxQueryAnnotation(): ?int
{
if (null === $this->annotationReader) {
@trigger_error('The annotationReader is not available', \E_USER_ERROR);
}

foreach (debug_backtrace() as $step) {
if ('test' === substr($step['function'], 0, 4)) { //TODO: handle tests with the @test annotation
$annotations = $this->annotationReader->getMethodAnnotations(
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/functional_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<service id="liip_functional_test.query.counter" class="Liip\FunctionalTestBundle\QueryCounter">
<argument>%liip_functional_test.query.max_query_count%</argument>
<argument type="service" id="annotation_reader" />
<argument type="service" id="annotation_reader" on-invalid="null" />
</service>
</services>
</container>
9 changes: 2 additions & 7 deletions tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__.'/config.yml');

if (Kernel::MAJOR_VERSION >= 5) {
$loader->load(__DIR__.'/security_5.yml');
$loader->load(__DIR__.'/session_5.yml');
} else {
$loader->load(__DIR__.'/security_4.yml');
$loader->load(__DIR__.'/session_4.yml');
}
$loader->load(__DIR__.'/security_5.yml');
$loader->load(__DIR__.'/session_5.yml');
}

public function getCacheDir(): string
Expand Down
2 changes: 1 addition & 1 deletion tests/App/Command/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function configure(): void
->setDescription('Test command');
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
// Symfony version check
$version = Kernel::VERSION_ID;
Expand Down
2 changes: 1 addition & 1 deletion tests/App/Command/TestInteractiveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function configure(): void
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$helper = $this->getHelper('question');
$question = new Question('Please enter the input', 'AcmeDemoBundle');
Expand Down
5 changes: 5 additions & 0 deletions tests/App/Controller/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,9 @@ public function embeddedAction(): Response
{
return new Response('Embedded Content', Response::HTTP_OK);
}

public function exceptionAction(): Response
{
throw new \Exception('foo');
}
}
Loading

0 comments on commit 124c7a6

Please sign in to comment.