Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): mise à jour symfony en 5.4 #58

Merged
merged 5 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .commitlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"header-max-length": [
1,
"always",
100
150
],
"subject-empty": [
1,
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Exemple :

## Livraison d'une nouvelle version

* Consulter le [numéro de la dernière version](https://github.com/IGNF/validator-api/tags).
* Renseigner la future version dans [docs/specs/validator-api.yml](docs/specs/validator-api.yml) (ex : `info.version: 0.3.0`)
* Créer et pousser un tag (ex : `v0.3.0`)
* Créer une release à partir du tag (voir https://github.com/IGNF/validator-api/tags)
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ PHP_CS_RULES=@Symfony
PHP_MD_RULES=./phpmd.xml

test: vendor bin/validator-cli.jar
# see SYMFONY_DEPRECATIONS_HELPER in phpunit.xml.dist
rm -rf var/log/test.deprecations.log
APP_ENV=test XDEBUG_MODE=coverage vendor/bin/phpunit

bin/validator-cli.jar:
Expand Down
39 changes: 7 additions & 32 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,15 @@

use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\ErrorHandler\Debug;

if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}

set_time_limit(0);
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

require dirname(__DIR__).'/vendor/autoload.php';
return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);

if (!class_exists(Application::class)) {
throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}

$input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
}

if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}

require dirname(__DIR__).'/config/bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
umask(0000);

if (class_exists(Debug::class)) {
Debug::enable();
}
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
return new Application($kernel);
};
35 changes: 19 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@
"justinrainbow/json-schema": "^5.2",
"nelmio/cors-bundle": "^2.1",
"symfony/apache-pack": "^1.0",
"symfony/asset": "4.4.*",
"symfony/console": "4.4.*",
"symfony/dotenv": "4.4.*",
"symfony/filesystem": "4.4.*",
"symfony/asset": "5.4.*",
"symfony/console": "5.4.*",
"symfony/dotenv": "5.4.*",
"symfony/filesystem": "5.4.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "4.4.*",
"symfony/http-foundation": "4.4.*",
"symfony/framework-bundle": "5.4.*",
"symfony/http-foundation": "5.4.*",
"symfony/monolog-bundle": "^3.6",
"symfony/process": "4.4.*",
"symfony/process": "5.4.*",
"symfony/requirements-checker": "^2.0",
"symfony/twig-bundle": "4.4.*",
"symfony/validator": "4.4.*",
"symfony/yaml": "4.4.*"
"symfony/twig-bundle": "5.4.*",
"symfony/validator": "5.4.*",
"symfony/yaml": "5.4.*",
"symfony/mime": "5.4.*",
"symfony/runtime": "5.4.*"
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4",
Expand All @@ -40,12 +42,12 @@
"phpstan/phpstan": "^0.12.92",
"phpstan/phpstan-phpunit": "^0.12.17",
"phpunit/phpunit": "^9",
"symfony/browser-kit": "^4.4",
"symfony/css-selector": "4.4.*",
"symfony/browser-kit": "5.4.*",
"symfony/css-selector": "5.4.*",
"symfony/maker-bundle": "^1.29",
"symfony/phpunit-bridge": "^5.1",
"symfony/stopwatch": "^4.4",
"symfony/web-profiler-bundle": "^4.4",
"symfony/stopwatch": "5.4.*",
"symfony/web-profiler-bundle": "5.4.*",
"php-coveralls/php-coveralls": "^2.5"
},
"config": {
Expand All @@ -55,7 +57,8 @@
"sort-packages": false,
"secure-http": false,
"allow-plugins": {
"symfony/flex": true
"symfony/flex": true,
"symfony/runtime": true
}
},
"autoload": {
Expand Down Expand Up @@ -95,7 +98,7 @@
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.4.*"
"require": "5.4.*"
}
},
"repositories": {}
Expand Down
23 changes: 0 additions & 23 deletions config/bootstrap.php

This file was deleted.

3 changes: 2 additions & 1 deletion config/packages/test/framework.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
framework:
test: true
session:
storage_id: session.storage.mock_file
storage_factory_id: session.storage.factory.mock_file

2 changes: 1 addition & 1 deletion config/packages/test/monolog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ monolog:
handlers:
main:
type: fingers_crossed
action_level: error
action_level: info
handler: nested
excluded_http_codes: [404, 405]
channels: ["!event"]
Expand Down
2 changes: 1 addition & 1 deletion docs/specs/validator-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ info:
contact:
name: IGNF/validator
url: "https://github.com/IGNF/validator/issues"
version: "0.3.1"
version: "0.4.0"
title: "API Validator"
license:
name: "AGPL-3.0-or-later"
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="7.5"/>
<server name="KERNEL_CLASS" value="App\Kernel"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
<!-- ###+ symfony/framework-bundle ### -->
<env name="SYMFONY_DEPRECATIONS_HELPER" value="logFile=var/log/test.deprecations.log"/>
<env name="APP_ENV" value="test"/>
<env name="APP_SECRET" value="4049513f2a2a7597f3b61c1f199a5bfa"/>
<!-- env name="TRUSTED_PROXIES" value="127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16" -->
Expand Down
26 changes: 4 additions & 22 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
<?php

use App\Kernel;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;

require dirname(__DIR__).'/config/bootstrap.php';
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

if ($_SERVER['APP_DEBUG']) {
umask(0000);

Debug::enable();
}

if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}

if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
Request::setTrustedHosts([$trustedHosts]);
}

$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
9 changes: 1 addition & 8 deletions src/Command/Validations/ProcessOneCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace App\Command\Validations;

use App\Validation\ValidationManager;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -21,16 +19,11 @@ class ProcessOneCommand extends Command
*/
private $validationManager;


public function __construct(
EntityManagerInterface $em,
ValidationManager $validationManager,
LoggerInterface $logger
ValidationManager $validationManager
) {
parent::__construct();
$this->em = $em;
$this->validationManager = $validationManager;
$this->logger = $logger;
}

protected function configure()
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/ValidationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private function zipNormData(Validation $validation)
return;
}

$process = new Process("(cd $normDataParentDir && zip -r $datasetName.zip $datasetName)");
$process = new Process(["zip","-r","$datasetName.zip",$datasetName],$normDataParentDir);
$process->setTimeout(600);
$process->setIdleTimeout(600);
$process->run();
Expand Down
2 changes: 2 additions & 0 deletions tests/Controller/Api/DocumentationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class DocumentationControllerTest extends WebTestCase
*/
public function testSwagger()
{
self::ensureKernelShutdown();
$client = static::createClient();
$client->request(
'GET',
Expand All @@ -37,6 +38,7 @@ public function testSwagger()
*/
public function testSchemaValidatorArguments()
{
self::ensureKernelShutdown();
$client = static::createClient();
$client->request(
'GET',
Expand Down
3 changes: 2 additions & 1 deletion tests/Controller/DefaultControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class DefaultControllerTest extends WebTestCase
*/
public function testHome()
{
self::ensureKernelShutdown();
$client = static::createClient();
/*$crawler =*/ $client->request(
/* $crawler = */ $client->request(
'GET',
'/'
);
Expand Down
15 changes: 7 additions & 8 deletions tests/Export/CsvReportWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class CsvReportWriterTest extends WebTestCase
*/
private $updateRegressTest;

public function setUp(): void {
public function setUp(): void
{
parent::setUp();
$this->updateRegressTest = getenv('UPDATE_REGRESS_TEST') == '1';
$this->updateRegressTest = '1' == getenv('UPDATE_REGRESS_TEST');
}

/**
Expand All @@ -36,7 +37,7 @@ public function testRegressValidator33()
$writer = new CsvReportWriter();
$writer->write($validation, $targetPath);

if ( $this->updateRegressTest ){
if ($this->updateRegressTest) {
$writer->write($validation, $expectedPath);
}

Expand All @@ -45,13 +46,11 @@ public function testRegressValidator33()
$expectedPath,
implode(' ', [
'Unexpected result for CsvReportWriterTest.',
'Fix the problem or run test once with env UPDATE_REGRESS_TEST=1 if a change is expected'
'Fix the problem or run test once with env UPDATE_REGRESS_TEST=1 if a change is expected',
])
);
}



/**
* Test with a report generated with validator 4.4.x.
*
Expand All @@ -70,7 +69,7 @@ public function testRegressValidator44()
$writer = new CsvReportWriter();
$writer->write($validation, $targetPath);

if ( $this->updateRegressTest ){
if ($this->updateRegressTest) {
$writer->write($validation, $expectedPath);
}

Expand All @@ -79,7 +78,7 @@ public function testRegressValidator44()
$expectedPath,
implode(' ', [
'Unexpected result for CsvReportWriterTest.',
'Fix the problem or run test once with env UPDATE_REGRESS_TEST=1 if a change is expected'
'Fix the problem or run test once with env UPDATE_REGRESS_TEST=1 if a change is expected',
])
);
}
Expand Down
3 changes: 1 addition & 2 deletions tests/Service/MimeTypeGuesserServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use App\Service\MimeTypeGuesserService;
use App\Tests\WebTestCase;
use Exception;
use Symfony\Component\Filesystem\Exception\FileNotFoundException;

class MimeTypeGuesserServiceTest extends WebTestCase
Expand Down Expand Up @@ -42,7 +41,7 @@ public function testFileNotFound()
$thrown = false;
try {
$this->mimeTypeGuesser->guessMimeType(__DIR__.'/not-found.txt');
} catch (Exception $e) {
} catch (\Exception $e) {
$this->assertInstanceOf(FileNotFoundException::class, $e);
$this->assertStringContainsString("not-found.txt' not found", $e->getMessage());
$thrown = true;
Expand Down
Loading