From 74bec45be26db147ba7771a5d73486c980c877ac Mon Sep 17 00:00:00 2001 From: Sergei Mikhailov Date: Thu, 21 Dec 2023 21:58:13 +0100 Subject: [PATCH 1/7] feat: min php 8.0 --- .github/workflows/build.yaml | 8 ++++---- composer.json | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 28c7876..90db5df 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,11 +9,11 @@ jobs: strategy: fail-fast: false matrix: - php: [7.2, 7.3, 7.4] - coverage: ["true"] + php: [8.0, 8.1, 8.2, 8.3] + coverage: ["false"] include: - - php: 8.0 - coverage: "false" # PHPUnit 8.5.14 doesn't support code coverage under PHP 8 + - php: 8.3 + coverage: "true" # Collecting coverage reports only once steps: - name: Checkout diff --git a/composer.json b/composer.json index 6ae64ad..3f0237e 100644 --- a/composer.json +++ b/composer.json @@ -5,16 +5,16 @@ "license": "GPL-2.0-only", "require": { "ext-json": "*", - "php": ">=7.2.0", - "oat-sa/lib-lti1p3-core": "^6.0", + "php": ">=8.0.0", + "oat-sa/lib-lti1p3-core": "^7.0", "psr/http-server-handler": "^1.0", "symfony/dom-crawler": "^4.4 || ^5.1", "twig/twig": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^8.5.14", + "phpunit/phpunit": "^9.6", "php-coveralls/php-coveralls": "^2.4", - "psalm/plugin-phpunit": "^0.15.1", + "psalm/plugin-phpunit": "^0.15", "vimeo/psalm": "^4.6" }, "autoload": { From 32ba36d6fd050d2d76c5fa4654d47a27d3c95200 Mon Sep 17 00:00:00 2001 From: Sergei Mikhailov Date: Thu, 21 Dec 2023 21:59:14 +0100 Subject: [PATCH 2/7] ci: execute Build workflow on pull requests to `main` --- .github/workflows/build.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 90db5df..0e02efa 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,10 @@ name: Build -on: push +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] jobs: build: From bd08719f88f1f074c49c5bb1ceba0d23e68e1699 Mon Sep 17 00:00:00 2001 From: Sergei Mikhailov Date: Thu, 21 Dec 2023 22:01:16 +0100 Subject: [PATCH 3/7] chore: temporarily depend on an unreleased version of `oat-sa/lib-lti1p3-core` --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3f0237e..9e71c79 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "require": { "ext-json": "*", "php": ">=8.0.0", - "oat-sa/lib-lti1p3-core": "^7.0", + "oat-sa/lib-lti1p3-core": "dev-feature/TR-5944/upgrade-dependencies as 7.0.0", "psr/http-server-handler": "^1.0", "symfony/dom-crawler": "^4.4 || ^5.1", "twig/twig": "^3.0" From 330baf1546753ebfd2145b1476366118b1c9f947 Mon Sep 17 00:00:00 2001 From: Sergei Mikhailov Date: Thu, 21 Dec 2023 22:03:19 +0100 Subject: [PATCH 4/7] chore: adjust request handlers to the lack of response factories --- .../BasicOutcomeServiceServerRequestHandler.php | 13 +++---------- .../BasicOutcomeServiceServerRequestHandlerTest.php | 2 -- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Service/Server/Handler/BasicOutcomeServiceServerRequestHandler.php b/src/Service/Server/Handler/BasicOutcomeServiceServerRequestHandler.php index 2b596c4..12f97b0 100644 --- a/src/Service/Server/Handler/BasicOutcomeServiceServerRequestHandler.php +++ b/src/Service/Server/Handler/BasicOutcomeServiceServerRequestHandler.php @@ -22,9 +22,8 @@ namespace OAT\Library\Lti1p3BasicOutcome\Service\Server\Handler; -use Http\Message\ResponseFactory; use InvalidArgumentException; -use Nyholm\Psr7\Factory\HttplugFactory; +use Nyholm\Psr7\Response; use OAT\Library\Lti1p3BasicOutcome\Factory\Response\BasicOutcomeResponseFactory; use OAT\Library\Lti1p3BasicOutcome\Factory\Response\BasicOutcomeResponseFactoryInterface; use OAT\Library\Lti1p3BasicOutcome\Message\BasicOutcomeMessageInterface; @@ -56,9 +55,6 @@ class BasicOutcomeServiceServerRequestHandler implements LtiServiceServerRequest /** @var BasicOutcomeResponseFactoryInterface */ private $basicOutcomeResponseFactory; - /** @var ResponseFactory */ - private $httpResponseFactory; - /** @var LoggerInterface */ private $logger; @@ -67,14 +63,12 @@ public function __construct( ?BasicOutcomeRequestSerializerInterface $basicOutcomeRequestSerializer = null, ?BasicOutcomeResponseSerializerInterface $basicOutcomeResponseSerializer = null, ?BasicOutcomeResponseFactoryInterface $basicOutcomeResponseFactory = null, - ?ResponseFactory $httpResponseFactory = null, ?LoggerInterface $logger = null ) { $this->processor = $processor; $this->basicOutcomeRequestSerializer = $basicOutcomeRequestSerializer ?? new BasicOutcomeRequestSerializer(); $this->basicOutcomeResponseSerializer = $basicOutcomeResponseSerializer ?? new BasicOutcomeResponseSerializer(); $this->basicOutcomeResponseFactory = $basicOutcomeResponseFactory ?? new BasicOutcomeResponseFactory(); - $this->httpResponseFactory = $httpResponseFactory ?? new HttplugFactory(); $this->logger = $logger ?? new NullLogger(); } @@ -114,7 +108,7 @@ public function handleValidatedServiceRequest( } catch (Throwable $exception) { $this->logger->error($exception->getMessage()); - return $this->httpResponseFactory->createResponse(400, null, [], $exception->getMessage()); + return new Response(400, [], $exception->getMessage()); } switch ($basicOutcomeRequest->getType()) { @@ -156,9 +150,8 @@ public function handleValidatedServiceRequest( $responseBody = $this->basicOutcomeResponseSerializer->serialize($basicOutcomeResponse); - return $this->httpResponseFactory->createResponse( + return new Response( 200, - null, [ 'Content-Type' => static::CONTENT_TYPE_BASIC_OUTCOME, 'Content-Length' => strlen($responseBody), diff --git a/tests/Integration/Service/Server/Handler/BasicOutcomeServiceServerRequestHandlerTest.php b/tests/Integration/Service/Server/Handler/BasicOutcomeServiceServerRequestHandlerTest.php index 05f79d3..3364911 100644 --- a/tests/Integration/Service/Server/Handler/BasicOutcomeServiceServerRequestHandlerTest.php +++ b/tests/Integration/Service/Server/Handler/BasicOutcomeServiceServerRequestHandlerTest.php @@ -84,14 +84,12 @@ protected function setUp(): void null, null, new BasicOutcomeResponseFactory($this->generatorMock), - null, $this->logger ); $this->server = new LtiServiceServer( $this->validatorMock, $subject, - null, $this->logger ); } From ca9f365950379f360f7456000d2b4578e674547e Mon Sep 17 00:00:00 2001 From: Sergei Mikhailov Date: Thu, 21 Dec 2023 22:05:07 +0100 Subject: [PATCH 5/7] fix: migrate phpunit.xml.dist configuration to phpunit 9 --- phpunit.xml.dist | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 84b07a9..5441481 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,20 @@ - - - - - - - - - tests/Integration - - - tests/Unit - - - - - - src - - + + + + src + + + + + + + + tests/Integration + + + tests/Unit + + From fda288903fd6b0cab9e7c171671114cb00469114 Mon Sep 17 00:00:00 2001 From: Sergei Mikhailov Date: Thu, 21 Dec 2023 22:07:04 +0100 Subject: [PATCH 6/7] fix: add direct dependencies explicitly to the root-level composer.json --- composer.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 9e71c79..b990bcd 100644 --- a/composer.json +++ b/composer.json @@ -4,16 +4,20 @@ "type": "library", "license": "GPL-2.0-only", "require": { - "ext-json": "*", "php": ">=8.0.0", + "ext-json": "*", + "nyholm/psr7": "^1.8", "oat-sa/lib-lti1p3-core": "dev-feature/TR-5944/upgrade-dependencies as 7.0.0", + "psr/http-message": "^1.1", "psr/http-server-handler": "^1.0", "symfony/dom-crawler": "^4.4 || ^5.1", "twig/twig": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^9.6", + "guzzlehttp/guzzle": "^7.8", + "nesbot/carbon": "^2.72", "php-coveralls/php-coveralls": "^2.4", + "phpunit/phpunit": "^9.6", "psalm/plugin-phpunit": "^0.15", "vimeo/psalm": "^4.6" }, From 6bbc4306c26c904deee9eb877208cc8b0742adbd Mon Sep 17 00:00:00 2001 From: Sergei Mikhailov Date: Fri, 22 Dec 2023 09:21:18 +0100 Subject: [PATCH 7/7] chore: require the released `oat-sa/lib-lti1p3-core` Signed-off-by: Sergei Mikhailov --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b990bcd..300d7f6 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "php": ">=8.0.0", "ext-json": "*", "nyholm/psr7": "^1.8", - "oat-sa/lib-lti1p3-core": "dev-feature/TR-5944/upgrade-dependencies as 7.0.0", + "oat-sa/lib-lti1p3-core": "^7.0", "psr/http-message": "^1.1", "psr/http-server-handler": "^1.0", "symfony/dom-crawler": "^4.4 || ^5.1",