diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 3e597070..d1643e6c 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -5,10 +5,19 @@ on: branches: - 'main' workflow_dispatch: + inputs: + php-version: + description: 'PHP version to run tests on' + required: false + default: '8.1' + type: string jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + checks: write name: integration tests env: UNZER_PAPI_TEST_PRIVATE_KEY_DEFAULT: ${{ secrets.PAPI_PRIVATE_KEY_DEFAULT }} @@ -24,7 +33,8 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: ${{ inputs.php-version || '8.1' }} + ini-values: error_reporting=E_ALL, display_errors=On, display_startup_errors=On - name: Setup Apple Pay test certificate run: mkdir certs - run: echo "$APPLE_PAY_MERCHANT_ID_CERT" > certs/merchant_id.pem @@ -33,4 +43,12 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-progress - name: Run integration tests - run: php ./vendor/bin/phpunit test/integration + run: php ./vendor/bin/phpunit --log-junit test-results/junit.xml test/integration + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: always() + with: + report_paths: 'test-results/junit.xml' + check_name: 'Integration Test Report' + detailed_summary: true + fail_on_failure: true diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 9dc6dbb9..90b28cec 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -8,9 +8,12 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + checks: write strategy: matrix: - php: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] + php: [ '8.1', '8.2', '8.3', '8.4', '8.5' ] name: PHP ${{ matrix.php }} unit tests steps: - uses: actions/checkout@v3 @@ -18,7 +21,16 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} + ini-values: error_reporting=E_ALL, display_errors=On, display_startup_errors=On - name: Install dependencies run: composer install --prefer-dist --no-progress - name: Run unit tests - run: php ./vendor/bin/phpunit test/unit + run: php ./vendor/bin/phpunit --log-junit test-results/junit-${{ matrix.php }}.xml test/unit + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: failure() + with: + report_paths: 'test-results/junit-${{ matrix.php }}.xml' + check_name: 'Unit Test Report (PHP ${{ matrix.php }})' + detailed_summary: true + fail_on_failure: true diff --git a/composer.json b/composer.json index 91dee327..7a6a2a7b 100644 --- a/composer.json +++ b/composer.json @@ -4,11 +4,11 @@ "minimum-stability": "stable", "license": "Apache-2.0", "require": { - "php": "~7.4.0|~8.0.0|~8.1.0|~8.2.0|~8.3.0|~8.4.0", + "php": "~8.1.0|~8.2.0|~8.3.0|~8.4.0|~8.5.0", "ext-json": "*" }, "require-dev": { - "phpunit/phpunit": ">6.5 <10.0", + "phpunit/phpunit": "^9.6", "friendsofphp/php-cs-fixer": "^3.0" }, "suggest": { diff --git a/phpunit.xml b/phpunit.xml index df900576..b89b9dd1 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,6 +7,7 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="false" convertWarningsToExceptions="false" + convertDeprecationsToExceptions="true" processIsolation="false" stopOnFailure="false" verbose="true" diff --git a/src/Adapter/ApplepayAdapter.php b/src/Adapter/ApplepayAdapter.php index b23a4636..820655cf 100644 --- a/src/Adapter/ApplepayAdapter.php +++ b/src/Adapter/ApplepayAdapter.php @@ -42,7 +42,6 @@ public function validateApplePayMerchant( $this->setOption(CURLOPT_POSTFIELDS, $payload); $sessionResponse = $this->execute(); - $this->close(); return $sessionResponse; } @@ -131,14 +130,6 @@ public function execute(): ?string throw new ApplepayMerchantValidationException($errorMessage); } - /** - * @inheritDoc - */ - public function close(): void - { - curl_close($this->request); - } - /** * @inheritDoc */ diff --git a/src/Adapter/CurlAdapter.php b/src/Adapter/CurlAdapter.php index 5535eb40..43a781ee 100755 --- a/src/Adapter/CurlAdapter.php +++ b/src/Adapter/CurlAdapter.php @@ -95,14 +95,6 @@ public function getResponseCode(): string return curl_getinfo($this->request, CURLINFO_HTTP_CODE); } - /** - * {@inheritDoc} - */ - public function close(): void - { - curl_close($this->request); - } - /** * {@inheritDoc} */ diff --git a/src/Adapter/HttpAdapterInterface.php b/src/Adapter/HttpAdapterInterface.php index 2e2bd0a6..be80576c 100755 --- a/src/Adapter/HttpAdapterInterface.php +++ b/src/Adapter/HttpAdapterInterface.php @@ -43,11 +43,6 @@ public function execute(): ?string; */ public function getResponseCode(): string; - /** - * Closes the connection of the request. - */ - public function close(): void; - /** * Sets the headers for the request. * Expects an associative array with $key being the header name and $value being the header value. diff --git a/src/Services/HttpService.php b/src/Services/HttpService.php index cce644cb..68bcdc0c 100755 --- a/src/Services/HttpService.php +++ b/src/Services/HttpService.php @@ -135,7 +135,6 @@ public function sendRequest(ApiRequest $request): string $httpAdapter = $this->getAdapter(); $response = $httpAdapter->execute(); $responseCode = $httpAdapter->getResponseCode(); - $httpAdapter->close(); // handle response try { diff --git a/test/unit/Services/CancelServiceTest.php b/test/unit/Services/CancelServiceTest.php index 8b56bfd2..a2a6ab60 100644 --- a/test/unit/Services/CancelServiceTest.php +++ b/test/unit/Services/CancelServiceTest.php @@ -11,6 +11,7 @@ namespace UnzerSDK\test\unit\Services; +use PHPUnit\Framework\MockObject\MockObject; use UnzerSDK\Constants\ApiResponseCodes; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Resources\EmbeddedResources\Amount; @@ -24,7 +25,6 @@ use UnzerSDK\Services\CancelService; use UnzerSDK\Services\ResourceService; use UnzerSDK\test\BasePaymentTest; -use PHPUnit\Framework\MockObject\MockObject; class CancelServiceTest extends BasePaymentTest { @@ -119,7 +119,6 @@ public function maxCancelAmountShouldBeRoundedCorrectly(): void $cancelSrvMock = new CancelService($this->unzer); $reflection = new \ReflectionClass(get_class($cancelSrvMock)); $method = $reflection->getMethod('calculateMaxReversalAmount'); - $method->setAccessible(true); $chargeAmount = 12.3; $receiptAmount = 10.0; diff --git a/test/unit/Services/DummyAdapter.php b/test/unit/Services/DummyAdapter.php index a3778708..7ed18f26 100755 --- a/test/unit/Services/DummyAdapter.php +++ b/test/unit/Services/DummyAdapter.php @@ -39,14 +39,6 @@ public function getResponseCode(): string return 'responseCode'; } - /** - * {@inheritDoc} - */ - public function close(): void - { - // do nothing - } - /** * {@inheritDoc} */ diff --git a/test/unit/Services/HttpServiceTest.php b/test/unit/Services/HttpServiceTest.php index 8892f32e..816b43fe 100755 --- a/test/unit/Services/HttpServiceTest.php +++ b/test/unit/Services/HttpServiceTest.php @@ -112,7 +112,6 @@ static function ($url) { $adapterMock->expects($this->once())->method('setHeaders')->with($headers); $adapterMock->expects($this->once())->method('execute')->willReturn('myResponseString'); $adapterMock->expects($this->once())->method('getResponseCode')->willReturn('399'); - $adapterMock->expects($this->once())->method('close'); $httpServiceMock->method('getAdapter')->willReturn($adapterMock);