diff --git a/.commitlintrc.json b/.commitlintrc.json index 315b28e..8e7608b 100644 --- a/.commitlintrc.json +++ b/.commitlintrc.json @@ -3,7 +3,7 @@ "header-max-length": [ 1, "always", - 100 + 150 ], "subject-empty": [ 1, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a8bd1a5..5e01c83 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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) diff --git a/Makefile b/Makefile index f916ff4..10fc511 100755 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/bin/console b/bin/console index 5de0e1c..c933dc5 100755 --- a/bin/console +++ b/bin/console @@ -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); +}; diff --git a/composer.json b/composer.json index 57e663f..a089b9a 100755 --- a/composer.json +++ b/composer.json @@ -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", @@ -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": { @@ -55,7 +57,8 @@ "sort-packages": false, "secure-http": false, "allow-plugins": { - "symfony/flex": true + "symfony/flex": true, + "symfony/runtime": true } }, "autoload": { @@ -95,7 +98,7 @@ "extra": { "symfony": { "allow-contrib": false, - "require": "4.4.*" + "require": "5.4.*" } }, "repositories": {} diff --git a/config/bootstrap.php b/config/bootstrap.php deleted file mode 100755 index 55560fb..0000000 --- a/config/bootstrap.php +++ /dev/null @@ -1,23 +0,0 @@ -=1.2) -if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) { - (new Dotenv(false))->populate($env); -} else { - // load all the .env files - (new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env'); -} - -$_SERVER += $_ENV; -$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; -$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; -$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/config/packages/test/framework.yaml b/config/packages/test/framework.yaml index d153e0d..3c43569 100755 --- a/config/packages/test/framework.yaml +++ b/config/packages/test/framework.yaml @@ -1,4 +1,5 @@ framework: test: true session: - storage_id: session.storage.mock_file + storage_factory_id: session.storage.factory.mock_file + diff --git a/config/packages/test/monolog.yaml b/config/packages/test/monolog.yaml index 2cb7d9e..d1c23b1 100644 --- a/config/packages/test/monolog.yaml +++ b/config/packages/test/monolog.yaml @@ -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"] diff --git a/docs/specs/validator-api.yml b/docs/specs/validator-api.yml index 182ad35..a3b0ea5 100644 --- a/docs/specs/validator-api.yml +++ b/docs/specs/validator-api.yml @@ -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" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f560593..2d67c32 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -26,8 +26,8 @@ - + diff --git a/public/index.php b/public/index.php index 0e30370..9982c21 100755 --- a/public/index.php +++ b/public/index.php @@ -1,27 +1,9 @@ handle($request); -$response->send(); -$kernel->terminate($request, $response); +return function (array $context) { + return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); +}; diff --git a/src/Command/Validations/ProcessOneCommand.php b/src/Command/Validations/ProcessOneCommand.php index 910ea1f..e72329f 100644 --- a/src/Command/Validations/ProcessOneCommand.php +++ b/src/Command/Validations/ProcessOneCommand.php @@ -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; @@ -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() diff --git a/src/Validation/ValidationManager.php b/src/Validation/ValidationManager.php index 7ca591a..189eee7 100644 --- a/src/Validation/ValidationManager.php +++ b/src/Validation/ValidationManager.php @@ -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(); diff --git a/tests/Controller/Api/DocumentationControllerTest.php b/tests/Controller/Api/DocumentationControllerTest.php index a2cba33..0a6e574 100644 --- a/tests/Controller/Api/DocumentationControllerTest.php +++ b/tests/Controller/Api/DocumentationControllerTest.php @@ -15,6 +15,7 @@ class DocumentationControllerTest extends WebTestCase */ public function testSwagger() { + self::ensureKernelShutdown(); $client = static::createClient(); $client->request( 'GET', @@ -37,6 +38,7 @@ public function testSwagger() */ public function testSchemaValidatorArguments() { + self::ensureKernelShutdown(); $client = static::createClient(); $client->request( 'GET', diff --git a/tests/Controller/DefaultControllerTest.php b/tests/Controller/DefaultControllerTest.php index 438c991..30d8b70 100644 --- a/tests/Controller/DefaultControllerTest.php +++ b/tests/Controller/DefaultControllerTest.php @@ -14,8 +14,9 @@ class DefaultControllerTest extends WebTestCase */ public function testHome() { + self::ensureKernelShutdown(); $client = static::createClient(); - /*$crawler =*/ $client->request( + /* $crawler = */ $client->request( 'GET', '/' ); diff --git a/tests/Export/CsvReportWriterTest.php b/tests/Export/CsvReportWriterTest.php index e19d272..dcb034b 100644 --- a/tests/Export/CsvReportWriterTest.php +++ b/tests/Export/CsvReportWriterTest.php @@ -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'); } /** @@ -36,7 +37,7 @@ public function testRegressValidator33() $writer = new CsvReportWriter(); $writer->write($validation, $targetPath); - if ( $this->updateRegressTest ){ + if ($this->updateRegressTest) { $writer->write($validation, $expectedPath); } @@ -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. * @@ -70,7 +69,7 @@ public function testRegressValidator44() $writer = new CsvReportWriter(); $writer->write($validation, $targetPath); - if ( $this->updateRegressTest ){ + if ($this->updateRegressTest) { $writer->write($validation, $expectedPath); } @@ -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', ]) ); } diff --git a/tests/Service/MimeTypeGuesserServiceTest.php b/tests/Service/MimeTypeGuesserServiceTest.php index b17a401..f7744e1 100644 --- a/tests/Service/MimeTypeGuesserServiceTest.php +++ b/tests/Service/MimeTypeGuesserServiceTest.php @@ -4,7 +4,6 @@ use App\Service\MimeTypeGuesserService; use App\Tests\WebTestCase; -use Exception; use Symfony\Component\Filesystem\Exception\FileNotFoundException; class MimeTypeGuesserServiceTest extends WebTestCase @@ -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;