Skip to content

Commit

Permalink
Update to Symfony 7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierstoval committed Dec 20, 2023
1 parent ac4897f commit fd189dd
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 78 deletions.
38 changes: 22 additions & 16 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,39 @@ jobs:
strategy:
matrix:
include:
- { php-version: "7.4", symfony-version: "5.4", phpunit-version: "9.5" }

- { php-version: "8.0", symfony-version: "5.4", phpunit-version: "9.5" }

- { php-version: "8.1", symfony-version: "5.4", phpunit-version: "9.5" }
- { php-version: "8.1", symfony-version: "6.0", phpunit-version: "9.5" }
- { php-version: "8.1", symfony-version: "6.1", phpunit-version: "9.5" }
- { php-version: "8.1", symfony-version: "6.2", phpunit-version: "9.5" }
- { php-version: "8.1", symfony-version: "6.3", phpunit-version: "9.5" }

- { php-version: "8.2", symfony-version: "5.4", phpunit-version: "9.5" }
- { php-version: "8.2", symfony-version: "6.0", phpunit-version: "9.5" }
- { php-version: "8.2", symfony-version: "6.1", phpunit-version: "9.5" }
- { php-version: "8.2", symfony-version: "6.2", phpunit-version: "9.5" }
- { php-version: "8.2", symfony-version: "6.3", phpunit-version: "9.5" }
- { php-version: "8.0", symfony-version: "5.4", phpunit-version: "9.6" }

- { php-version: "8.1", symfony-version: "5.4", phpunit-version: "9.6" }
- { php-version: "8.1", symfony-version: "6.0", phpunit-version: "9.6" }
- { php-version: "8.1", symfony-version: "6.1", phpunit-version: "9.6" }
- { php-version: "8.1", symfony-version: "6.2", phpunit-version: "9.6" }
- { php-version: "8.1", symfony-version: "6.3", phpunit-version: "9.6" }
- { php-version: "8.1", symfony-version: "6.4", phpunit-version: "9.6" }
- { php-version: "8.1", symfony-version: "7.0", phpunit-version: "9.6" }

- { php-version: "8.2", symfony-version: "5.4", phpunit-version: "9.6" }
- { php-version: "8.2", symfony-version: "6.0", phpunit-version: "9.6" }
- { php-version: "8.2", symfony-version: "6.1", phpunit-version: "9.6" }
- { php-version: "8.2", symfony-version: "6.2", phpunit-version: "9.6" }
- { php-version: "8.2", symfony-version: "6.3", phpunit-version: "9.6" }
- { php-version: "8.2", symfony-version: "6.4", phpunit-version: "9.6" }
- { php-version: "8.2", symfony-version: "7.0", phpunit-version: "9.6" }

- { php-version: "8.1", symfony-version: "5.4", phpunit-version: "10" }
- { php-version: "8.1", symfony-version: "6.0", phpunit-version: "10" }
- { php-version: "8.1", symfony-version: "6.1", phpunit-version: "10" }
- { php-version: "8.1", symfony-version: "6.2", phpunit-version: "10" }
- { php-version: "8.1", symfony-version: "6.3", phpunit-version: "10" }
- { php-version: "8.1", symfony-version: "6.4", phpunit-version: "10" }
- { php-version: "8.1", symfony-version: "7.0", phpunit-version: "10" }

- { php-version: "8.2", symfony-version: "5.4", phpunit-version: "10" }
- { php-version: "8.2", symfony-version: "6.0", phpunit-version: "10" }
- { php-version: "8.2", symfony-version: "6.1", phpunit-version: "10" }
- { php-version: "8.2", symfony-version: "6.2", phpunit-version: "10" }
- { php-version: "8.2", symfony-version: "6.3", phpunit-version: "10" }
- { php-version: "8.2", symfony-version: "6.4", phpunit-version: "10" }
- { php-version: "8.2", symfony-version: "7.0", phpunit-version: "10" }

name: PHP ${{ matrix.php-version }}, Symfony ${{ matrix.symfony-version }}, PHPUnit ${{ matrix.phpunit-version }}
steps:
Expand Down Expand Up @@ -64,7 +70,7 @@ jobs:
- name: Setup fixture app
working-directory: ./fixture-app
run: |
sed -i 's/"require": "6.1.*"/"require": "${{ matrix.symfony-version }}.*"/g' composer.json
sed -i 's/"require": "5.4.*"/"require": "${{ matrix.symfony-version }}.*"/g' composer.json
composer update --with "phpunit/phpunit:^${{ matrix.phpunit-version }}"
- name: Test
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
],
"require": {
"php": "^7.4|^8.0",
"symfony/framework-bundle": "^5.4|^6.1"
"symfony/framework-bundle": "^5.4|^6.1|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5|^10.0",
"phpunit/phpunit": "^9.6|^10.0",
"symfony/maker-bundle": "^1.43"
}
}
Empty file modified fixture-app/bin/console
100644 → 100755
Empty file.
10 changes: 7 additions & 3 deletions fixture-app/bin/phpunit
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ if (!ini_get('date.timezone')) {
}

if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
if (PHP_VERSION_ID >= 80000) {
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
} else {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
}
} else {
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
Expand Down
29 changes: 16 additions & 13 deletions fixture-app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": "^7.4|^8.0",
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"doctrine/annotations": "^1.14",
"symfony/console": "^5.4|^6.1",
"symfony/dotenv": "^5.4|^6.1",
"symfony/flex": "^1.19|^2",
"symfony/framework-bundle": "^5.4|^6.1",
"symfony/runtime": "^5.4|^6.1",
"symfony/yaml": "^5.4|^6.1"
"doctrine/annotations": "^2.0",
"symfony/console": "^5.4|^6.1|^7.0",
"symfony/dotenv": "^5.4|^6.1|^7.0",
"symfony/flex": "^2.4",
"symfony/framework-bundle": "^5.4|^6.1|^7.0",
"symfony/runtime": "^5.4|^6.1|^7.0",
"symfony/yaml": "^5.4|^6.1|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5|^10.0",
"symfony/browser-kit": "^5.4|^6.1",
"symfony/css-selector": "^5.4|^6.1",
"symfony/browser-kit": "^5.4|^6.1|^7.0",
"symfony/css-selector": "^5.4|^6.1|^7.0",
"symfony/maker-bundle": "^1.43",
"symfony/phpunit-bridge": "^5.4|^6.1"
"symfony/phpunit-bridge": "^5.4|^6.1|^7.0"
},
"config": {
"allow-plugins": {
Expand Down Expand Up @@ -50,7 +50,10 @@
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*"
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*",
"symfony/polyfill-php82": "*"
},
"scripts": {
"auto-scripts": {
Expand All @@ -70,7 +73,7 @@
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.4.*"
"require": "5.4.*"
}
}
}
3 changes: 1 addition & 2 deletions fixture-app/config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
framework:
secret: '%env(APP_SECRET)%'
#csrf_protection: true
http_method_override: false
handle_all_throwables: true

# Enables session support. Note that the session will ONLY be started if you read or write from it.
# Remove or comment this section to explicitly disable session support.
session:
handler_id: null
cookie_secure: auto
cookie_samesite: lax
storage_factory_id: session.storage.factory.native

#esi: true
#fragments: true
Expand Down
6 changes: 4 additions & 2 deletions fixture-app/config/routes.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
controllers:
resource: ../src/Controller/
type: annotation
resource:
path: ../src/Controller/
namespace: App\Controller
type: attribute
8 changes: 2 additions & 6 deletions fixture-app/phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<server name="SYMFONY_PHPUNIT_REMOVE" value="" />
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
<server name="SYMFONY_PHPUNIT_VERSION" value="9.6" />
</php>

<testsuites>
Expand All @@ -23,7 +23,7 @@
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<coverage includeUncoveredFiles="false">
<include>
<directory suffix=".php">src</directory>
</include>
Expand All @@ -33,10 +33,6 @@
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>

<!-- Run `composer require symfony/panther` before enabling this extension -->
<!--
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
</extensions>
-->
</phpunit>
13 changes: 13 additions & 0 deletions fixture-app/src/Controller/TestRoutesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,42 +12,49 @@
class TestRoutesController extends AbstractController
{
/** @Route("/param/{id}", name="get_param_without_default") */
#[Route("/param/{id}", name: "get_param_without_default")]
public function getParameterWithoutDefault(string $id): Response
{
return new Response("Content: $id");
}

/** @Route("/other_param/{id}", name="get_param_with_default", defaults={"id": "default_value"}) */
#[Route("/other_param/{id}", name: "get_param_with_default", defaults: ["id" => "default_value"])]
public function getParameterWithDefault(string $id): Response
{
return new Response("Content: $id");
}

/** @Route("/200", name="get_200") */
#[Route("/200", name: "get_200")]
public function getOk(): Response
{
return new Response('200');
}

/** @Route("/302", name="get_302") */
#[Route("/302", name: "get_302")]
public function getRedirect(): RedirectResponse
{
return new RedirectResponse('/200');
}

/** @Route("/400", name="get_400") */
#[Route("/400", name: "get_400")]
public function get400(): Response
{
return new Response('400', 400);
}

/** @Route("/500", name="get_500") */
#[Route("/500", name: "get_500")]
public function get500(): Response
{
return new Response('500', 500);
}

/** @Route("/payload", name="get_with_payload") */
#[Route("/payload", name: "get_with_payload")]
public function getWithPayload(Request $request): Response
{
$payload = $request->getContent();
Expand All @@ -56,6 +63,7 @@ public function getWithPayload(Request $request): Response
}

/** @Route("/json/valid", name="json_valid") */
#[Route("/json/valid", name: "json_valid")]
public function getValidJson(): Response
{
return new JsonResponse([
Expand All @@ -65,6 +73,7 @@ public function getValidJson(): Response
}

/** @Route("/json/valid-header", name="json_valid_header") */
#[Route("/json/valid-header", name: "json_valid_header")]
public function getValidJsonHeader(): Response
{
return new JsonResponse([
Expand All @@ -74,6 +83,7 @@ public function getValidJsonHeader(): Response
}

/** @Route("/json/missing_header", name="json_missing_header") */
#[Route("/json/missing_header", name: "json_missing_header")]
public function getJsonInvalidHeader(): Response
{
return new Response(json_encode([
Expand All @@ -83,6 +93,7 @@ public function getJsonInvalidHeader(): Response
}

/** @Route("/json/invalid", name="json_invalid") */
#[Route("/json/invalid", name: "json_invalid")]
public function getJsonInvalid(): Response
{
return new Response('{"message":', 200, [
Expand All @@ -91,12 +102,14 @@ public function getJsonInvalid(): Response
}

/** @Route("/cookie/value", name="cookie_value") */
#[Route("/cookie/value", name: "cookie_value")]
public function getCookieValue(Request $request): Response
{
return new Response(\sprintf('Value: "%s"', $request->cookies->get('test_cookie')));
}

/** @Route("/content-type", name="content_type") */
#[Route("/content-type", name: "content_type")]
public function getContentType(Request $request): Response
{
$contentType = method_exists($request, 'getContentTypeFormat')
Expand Down
Loading

0 comments on commit fd189dd

Please sign in to comment.