From 906df8d943624abb1538765946bc6e911826a357 Mon Sep 17 00:00:00 2001 From: Benjamin Cremer Date: Fri, 26 Aug 2022 11:07:23 +0200 Subject: [PATCH] Allow PHP 8.1 --- .github/workflows/build.yml | 4 + composer.json | 10 +- .../Acceptance/ApplicationAcceptanceTest.php | 272 ++++++++++++------ 3 files changed, 194 insertions(+), 92 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ad9d8f..8677b2e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,10 @@ jobs: composer-deps: lowest - php-version: "8.0" composer-deps: latest + - php-version: "8.1" + composer-deps: lowest + - php-version: "8.1" + composer-deps: latest steps: - name: "Checkout" uses: "actions/checkout@v2" diff --git a/composer.json b/composer.json index ddc0278..9cee628 100644 --- a/composer.json +++ b/composer.json @@ -14,9 +14,9 @@ } ], "require": { - "php": "^7.4 || ~8.0.0", + "php": "^7.4 || ~8.0.0 || ~8.1.0", "cebe/php-openapi": "^1.5.2", - "symfony/console": "^v5.1.9" + "symfony/console": "^5.1.9 || ^6.0" }, "require-dev": { "doctrine/coding-standard": "^9.0.0", @@ -59,7 +59,11 @@ "infection": "infection --threads=4 --coverage=build/coverage" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, + "infection/extension-installer": true + } }, "bin": [ "bin/openapi-merge" diff --git a/tests/Acceptance/ApplicationAcceptanceTest.php b/tests/Acceptance/ApplicationAcceptanceTest.php index bcaea82..74ceeb5 100644 --- a/tests/Acceptance/ApplicationAcceptanceTest.php +++ b/tests/Acceptance/ApplicationAcceptanceTest.php @@ -9,6 +9,9 @@ use function implode; use function shell_exec; use function sprintf; +use function version_compare; + +use const PHP_VERSION; /** * @coversNothing @@ -28,97 +31,188 @@ public function testApplicationRuns(): void ]) )); - self::assertSame( - <<<'EXPECTED_YAML' - openapi: 3.0.2 - info: - title: 'Example OpenAPI Definition' - description: 'This is the example Description' - contact: - name: 'Base Author' - url: base.example.org - email: base-file@example.org - license: - name: MIT - url: 'https://tldrlegal.com/license/mit-license' - version: '1.0' - servers: - - - url: 'https://api.base.example.org' - description: 'Main Base URL' - paths: - /ping: - get: - tags: - - 'Base Route' - summary: 'Your GET endpoint' - description: 'Description of Ping' - operationId: get-ping - parameters: - - - name: responseWith - in: query - description: 'response with this message' - schema: - maxLength: 20 - minLength: 0 - type: string - responses: - '200': - description: OK - content: - application/json: - schema: - required: - - response - type: object - properties: - response: - type: string - '400': - description: 'Bad Request' - content: - application/problem+json: + if (version_compare(PHP_VERSION, '8.1.0', '>=')) { + $expected = <<<'EXPECTED_YAML' + openapi: 3.0.2 + info: + title: 'Example OpenAPI Definition' + description: 'This is the example Description' + contact: + name: 'Base Author' + url: base.example.org + email: base-file@example.org + license: + name: MIT + url: 'https://tldrlegal.com/license/mit-license' + version: '1.0' + servers: + - + url: 'https://api.base.example.org' + description: 'Main Base URL' + paths: + /ping: + get: + tags: + - 'Base Route' + summary: 'Your GET endpoint' + description: 'Description of Ping' + operationId: get-ping + parameters: + - + name: responseWith + in: query + description: 'response with this message' schema: - title: ProblemResponse - required: - - type - - title - type: object - properties: - type: - type: string - description: 'type of the problem' - example: ValidationError - title: - type: string - example: 'Your request parameters didn''t validate.' - description: 'Default Problem Response' - post: - summary: 'Your POST endpoint' - description: 'Description of post Ping' - operationId: post-ping - responses: - '200': - description: OK - content: - application/json: + maxLength: 20 + minLength: 0 + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + required: + - response + type: object + properties: + response: + type: string + '400': + description: 'Bad Request' + content: + application/problem+json: + schema: + title: ProblemResponse + required: + - type + - title + type: object + properties: + type: + type: string + description: 'type of the problem' + example: ValidationError + title: + type: string + example: "Your request parameters didn't validate." + description: 'Default Problem Response' + post: + summary: 'Your POST endpoint' + description: 'Description of post Ping' + operationId: post-ping + responses: + '200': + description: OK + content: + application/json: + schema: + required: + - response + type: object + properties: + response: + type: string + components: + schemas: { } + security: [] + tags: + - + name: Base + + EXPECTED_YAML; + } else { + $expected = <<<'EXPECTED_YAML' + openapi: 3.0.2 + info: + title: 'Example OpenAPI Definition' + description: 'This is the example Description' + contact: + name: 'Base Author' + url: base.example.org + email: base-file@example.org + license: + name: MIT + url: 'https://tldrlegal.com/license/mit-license' + version: '1.0' + servers: + - + url: 'https://api.base.example.org' + description: 'Main Base URL' + paths: + /ping: + get: + tags: + - 'Base Route' + summary: 'Your GET endpoint' + description: 'Description of Ping' + operationId: get-ping + parameters: + - + name: responseWith + in: query + description: 'response with this message' schema: - required: - - response - type: object - properties: - response: - type: string - components: - schemas: [] - security: [] - tags: - - - name: Base + maxLength: 20 + minLength: 0 + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + required: + - response + type: object + properties: + response: + type: string + '400': + description: 'Bad Request' + content: + application/problem+json: + schema: + title: ProblemResponse + required: + - type + - title + type: object + properties: + type: + type: string + description: 'type of the problem' + example: ValidationError + title: + type: string + example: 'Your request parameters didn''t validate.' + description: 'Default Problem Response' + post: + summary: 'Your POST endpoint' + description: 'Description of post Ping' + operationId: post-ping + responses: + '200': + description: OK + content: + application/json: + schema: + required: + - response + type: object + properties: + response: + type: string + components: + schemas: { } + security: [] + tags: + - + name: Base + + EXPECTED_YAML; + } - EXPECTED_YAML, - $output - ); + self::assertSame($expected, $output); } }