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 d67fb26
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 80 deletions.
36 changes: 17 additions & 19 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,35 @@ jobs:
strategy:
matrix:
include:
- { php-version: "7.4", symfony-version: "5.4", phpunit-version: "9.5" }
- { 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.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.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.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.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:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
Expand All @@ -51,7 +49,7 @@ jobs:
- id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- uses: actions/cache@v1
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
}
],
"require": {
"php": "^7.4|^8.0",
"symfony/framework-bundle": "^5.4|^6.1"
"php": "^8.1",
"symfony/framework-bundle": "^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
24 changes: 12 additions & 12 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.1",
"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": "^6.1|^7.0",
"symfony/dotenv": "^6.1|^7.0",
"symfony/flex": "^2.4",
"symfony/framework-bundle": "^6.1|^7.0",
"symfony/runtime": "^6.1|^7.0",
"symfony/yaml": "^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": "^6.1|^7.0",
"symfony/css-selector": "^6.1|^7.0",
"symfony/maker-bundle": "^1.43",
"symfony/phpunit-bridge": "^5.4|^6.1"
"symfony/phpunit-bridge": "^6.1|^7.0"
},
"config": {
"allow-plugins": {
Expand Down Expand Up @@ -70,7 +70,7 @@
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.4.*"
"require": "6.1.*"
}
}
}
2 changes: 0 additions & 2 deletions fixture-app/config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
framework:
secret: '%env(APP_SECRET)%'
#csrf_protection: true
http_method_override: false

# 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
2 changes: 1 addition & 1 deletion fixture-app/config/routes.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
controllers:
resource: ../src/Controller/
type: annotation
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
66 changes: 32 additions & 34 deletions fixture-app/symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "1.0",
"ref": "a2759dd6123694c8d901d0ec80006e044c2e6457"
"version": "1.10",
"ref": "64d8583af5ea57b7afa4aba4b159907f3a148b05"
},
"files": [
"./config/routes/annotations.yaml"
]
"files": []
},
"phpunit/phpunit": {
"version": "9.5",
"version": "10.5",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "9.3",
"ref": "a6249a6c4392e9169b87abf93225f7f9f59025e6"
"version": "9.6",
"ref": "7364a21d87e658eb363c5020c072ecfdc12e2326"
},
"files": [
"./.env.test",
"./phpunit.xml.dist",
"./tests/bootstrap.php"
".env.test",
"phpunit.xml.dist",
"tests/bootstrap.php"
]
},
"symfony/console": {
Expand Down Expand Up @@ -50,22 +48,22 @@
]
},
"symfony/framework-bundle": {
"version": "6.1",
"version": "7.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.4",
"ref": "3cd216a4d007b78d8554d44a5b1c0a446dab24fb"
"version": "7.0",
"ref": "de6e1b3e2bbbe69e36262d72c3f3db858b1ab391"
},
"files": [
"./config/packages/cache.yaml",
"./config/packages/framework.yaml",
"./config/preload.php",
"./config/routes/framework.yaml",
"./config/services.yaml",
"./public/index.php",
"./src/Controller/.gitignore",
"./src/Kernel.php"
"config/packages/cache.yaml",
"config/packages/framework.yaml",
"config/preload.php",
"config/routes/framework.yaml",
"config/services.yaml",
"public/index.php",
"src/Controller/.gitignore",
"src/Kernel.php"
]
},
"symfony/maker-bundle": {
Expand All @@ -78,31 +76,31 @@
}
},
"symfony/phpunit-bridge": {
"version": "6.1",
"version": "6.4",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.3",
"ref": "97cb3dc7b0f39c7cfc4b7553504c9d7b7795de96"
"version": "6.3",
"ref": "1f5830c331065b6e4c9d5fa2105e322d29fcd573"
},
"files": [
"./.env.test",
"./bin/phpunit",
"./phpunit.xml.dist",
"./tests/bootstrap.php"
".env.test",
"bin/phpunit",
"phpunit.xml.dist",
"tests/bootstrap.php"
]
},
"symfony/routing": {
"version": "6.1",
"version": "7.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "6.1",
"ref": "a44010c0d06989bd4f154aa07d2542d47caf5b83"
"version": "6.2",
"ref": "e0a11b4ccb8c9e70b574ff5ad3dfdcd41dec5aa6"
},
"files": [
"./config/packages/routing.yaml",
"./config/routes.yaml"
"config/packages/routing.yaml",
"config/routes.yaml"
]
}
}
Loading

0 comments on commit d67fb26

Please sign in to comment.