Skip to content

Commit

Permalink
Merge pull request #29 from oat-sa/feature/TR-5944/upgrade-dependencies
Browse files Browse the repository at this point in the history
BREAKING CHANGE TR-5944 upgrade dependencies, removing `Http\Message\ResponseFactory` from dependencies
  • Loading branch information
wazelin authored Dec 22, 2023
2 parents 8fd2885 + 6bbc430 commit 0f0141f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 45 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Build

on: push
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
Expand All @@ -9,11 +13,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
Expand Down
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@
"type": "library",
"license": "GPL-2.0-only",
"require": {
"php": ">=8.0.0",
"ext-json": "*",
"php": ">=7.2.0",
"oat-sa/lib-lti1p3-core": "^6.0",
"nyholm/psr7": "^1.8",
"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",
"twig/twig": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5.14",
"guzzlehttp/guzzle": "^7.8",
"nesbot/carbon": "^2.72",
"php-coveralls/php-coveralls": "^2.4",
"psalm/plugin-phpunit": "^0.15.1",
"phpunit/phpunit": "^9.6",
"psalm/plugin-phpunit": "^0.15",
"vimeo/psalm": "^4.6"
},
"autoload": {
Expand Down
41 changes: 17 additions & 24 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
backupGlobals="false"
colors="true"
>
<php>
<env name="TEST_KEYS_ROOT_DIR" value="file://vendor/oat-sa/lib-lti1p3-core/tests/Resource/Key/RSA" />
</php>

<testsuites>
<testsuite name="Integration">
<directory>tests/Integration</directory>
</testsuite>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory>src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory>src</directory>
</include>
</coverage>
<php>
<env name="TEST_KEYS_ROOT_DIR" value="file://vendor/oat-sa/lib-lti1p3-core/tests/Resource/Key/RSA"/>
</php>
<testsuites>
<testsuite name="Integration">
<directory>tests/Integration</directory>
</testsuite>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,9 +55,6 @@ class BasicOutcomeServiceServerRequestHandler implements LtiServiceServerRequest
/** @var BasicOutcomeResponseFactoryInterface */
private $basicOutcomeResponseFactory;

/** @var ResponseFactory */
private $httpResponseFactory;

/** @var LoggerInterface */
private $logger;

Expand All @@ -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();
}

Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down

0 comments on commit 0f0141f

Please sign in to comment.