diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c709a01..6b84581 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,6 +1,10 @@ name: Build -on: push +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] jobs: build: @@ -9,44 +13,40 @@ 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.1 - coverage: "false" # PHPUnit 8.5.14 doesn't support code coverage under PHP 8 - - php: 8.2 - coverage: "false" # PHPUnit 8.5.14 doesn't support code coverage under PHP 8 + - php: 8.0 + coverage: "true" # Collecting coverage reports only once steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup PHP & Composer - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - tools: composer:v2 - - - name: Install dependencies - run: composer install --no-interaction --no-suggest - - - name: PHPUnit - env: - COVERAGE: ${{ matrix.coverage }} - run: | - [ $COVERAGE = "true" ] \ - && mkdir -p build/logs && ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml \ - || ./vendor/bin/phpunit - - - name: Psalm - run: | - ./vendor/bin/psalm --shepherd - - - name: Coveralls - if: ${{ matrix.coverage == 'true' }} - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - ./vendor/bin/php-coveralls -v + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP & Composer + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + + - name: Install dependencies + run: composer install --no-interaction --no-suggest + + - name: PHPUnit + env: + COVERAGE: ${{ matrix.coverage }} + run: | + [ $COVERAGE = "true" ] \ + && mkdir -p build/logs && ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml \ + || ./vendor/bin/phpunit + + - name: Psalm + run: | + ./vendor/bin/psalm --shepherd + + - name: Coveralls + if: ${{ matrix.coverage == 'true' }} + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + ./vendor/bin/php-coveralls -v diff --git a/composer.json b/composer.json index e38a1da..0d66fab 100644 --- a/composer.json +++ b/composer.json @@ -4,16 +4,19 @@ "type": "library", "license": "GPL-2.0-only", "require": { - "php": ">=7.2.0", + "php": ">=8.0.0", "ext-json": "*", - "oat-sa/lib-lti1p3-core": "^6.2" + "nesbot/carbon": "^2.72", + "nyholm/psr7": "^1.8", + "oat-sa/lib-lti1p3-core": "^7.0", + "psr/http-message": "^1.1" }, "require-dev": { "cache/array-adapter": "^1.1", - "phpunit/phpunit": "8.5.14", + "phpunit/phpunit": "^9.6", "php-coveralls/php-coveralls": "^2.4", "vimeo/psalm": "^4.6", - "psalm/plugin-phpunit": "^0.15.1" + "psalm/plugin-phpunit": "^0.15" }, "autoload": { "psr-4": { 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 + + diff --git a/src/Service/Server/Handler/AcsServiceServerRequestHandler.php b/src/Service/Server/Handler/AcsServiceServerRequestHandler.php index 513c950..1013982 100644 --- a/src/Service/Server/Handler/AcsServiceServerRequestHandler.php +++ b/src/Service/Server/Handler/AcsServiceServerRequestHandler.php @@ -22,8 +22,8 @@ namespace OAT\Library\Lti1p3Proctoring\Service\Server\Handler; -use Http\Message\ResponseFactory; use Nyholm\Psr7\Factory\HttplugFactory; +use Nyholm\Psr7\Response; use OAT\Library\Lti1p3Core\Security\OAuth2\Validator\Result\RequestAccessTokenValidationResultInterface; use OAT\Library\Lti1p3Core\Service\Server\Handler\LtiServiceServerRequestHandlerInterface; use OAT\Library\Lti1p3Proctoring\Serializer\AcsControlResultSerializer; @@ -49,19 +49,14 @@ class AcsServiceServerRequestHandler implements LtiServiceServerRequestHandlerIn /** @var AcsControlResultSerializerInterface */ private $controlResultSerializer; - /** @var ResponseFactory */ - private $factory; - public function __construct( AcsServiceServerControlProcessorInterface $processor, ?AcsControlSerializerInterface $controlSerializer = null, ?AcsControlResultSerializerInterface $controlResultSerializer = null, - ?ResponseFactory $factory = null ) { $this->processor = $processor; $this->controlSerializer = $controlSerializer ?? new AcsControlSerializer(); $this->controlResultSerializer = $controlResultSerializer ?? new AcsControlResultSerializer(); - $this->factory = $factory ?? new HttplugFactory(); } public function getServiceName(): string @@ -106,6 +101,6 @@ public function handleValidatedServiceRequest( 'Content-Length' => strlen($responseBody), ]; - return $this->factory->createResponse(200, null, $responseHeaders, $responseBody); + return new Response(200, $responseHeaders, $responseBody); } } diff --git a/tests/Integration/Service/Server/Handler/AcsServiceServerRequestHandlerTest.php b/tests/Integration/Service/Server/Handler/AcsServiceServerRequestHandlerTest.php index c4844bd..c8e6242 100644 --- a/tests/Integration/Service/Server/Handler/AcsServiceServerRequestHandlerTest.php +++ b/tests/Integration/Service/Server/Handler/AcsServiceServerRequestHandlerTest.php @@ -89,7 +89,6 @@ protected function setUp(): void $this->server = new LtiServiceServer( $this->validatorMock, $this->subject, - null, $this->logger ); }