From c68377bed4f710efd7748f3d76dc3691cc527c15 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 2 Jun 2021 13:05:49 +0200 Subject: [PATCH 1/4] Initial upgrade to PHP8.0 and Github Actions --- .github/FUNDING.yml | 1 + .github/workflows/phpunit.yml | 48 +++++++++++++++++++ .travis.yml | 34 ------------- composer.json | 9 ++-- grumphp.yml | 22 --------- phpunit.xml.dist | 15 +++--- tests/GatewayTest.php | 7 ++- tests/Message/AbstractMollieRequestTest.php | 2 +- tests/Message/AssertRequestTrait.php | 4 -- tests/Message/CancelOrderRequestTest.php | 5 +- tests/Message/CompleteOrderRequestTest.php | 8 ++-- tests/Message/CompletePurchaseRequestTest.php | 9 ++-- .../CreateCustomerMandateRequestTest.php | 2 +- tests/Message/CreateCustomerRequestTest.php | 2 +- tests/Message/CreateOrderRequestTest.php | 2 +- tests/Message/CreateShipmentRequestTest.php | 2 +- .../FetchCustomerMandatesRequestTest.php | 2 +- tests/Message/FetchCustomerRequestTest.php | 2 +- tests/Message/FetchIssuersRequestTest.php | 2 +- tests/Message/FetchOrderRequestTest.php | 8 ++-- .../FetchPaymentMethodsRequestTest.php | 2 +- tests/Message/FetchTransactionRequestTest.php | 2 +- tests/Message/PurchaseRequestTest.php | 2 +- tests/Message/RefundRequestTest.php | 7 ++- .../RevokeCustomerMandateRequestTest.php | 2 +- tests/Message/UpdateCustomerRequestTest.php | 2 +- 26 files changed, 92 insertions(+), 111 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/phpunit.yml delete mode 100755 .travis.yml delete mode 100644 grumphp.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..665cb9d --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [barryvdh] \ No newline at end of file diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 0000000..12233b9 --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,48 @@ +name: "PHPUnit tests" + +on: + pull_request: + push: + branches: + - "master" + +jobs: + phpunit: + name: "PHPUnit tests" + + runs-on: ${{ matrix.operating-system }} + + strategy: + matrix: + dependencies: + - "lowest" + - "highest" + php-version: + - "7.3" + - "7.4" + - "8.0" + operating-system: + - "ubuntu-latest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "pcov" + php-version: "${{ matrix.php-version }}" + ini-values: memory_limit=-1 + tools: composer:v2 + + - name: "Install lowest dependencies" + if: ${{ matrix.dependencies == 'lowest' }} + run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest" + + - name: "Install highest dependencies" + if: ${{ matrix.dependencies == 'highest' }} + run: "composer update --no-interaction --no-progress --no-suggest" + + - name: "Tests" + run: "vendor/bin/phpunit" \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100755 index 16716b0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ -language: php - -php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - -# This triggers builds to run on the new TravisCI infrastructure. -# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ -sudo: false - -## Cache composer -cache: - directories: - - $HOME/.composer/cache - -env: - global: - - setup=basic - -matrix: - include: - - php: 5.6 - env: setup=lowest - -install: - - if [[ $setup = 'basic' ]]; then travis_retry composer install --prefer-dist --no-interaction; fi - - if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable; fi - -script: -- composer validate --strict -- vendor/bin/phpcs --standard=PSR2 src -- vendor/bin/phpunit --coverage-text diff --git a/composer.json b/composer.json index 4a351d5..a0e9f3c 100755 --- a/composer.json +++ b/composer.json @@ -33,15 +33,12 @@ "psr-4": { "Omnipay\\Mollie\\Test\\": "tests/" } }, "require": { + "php": "^7.3|^8.0", "omnipay/common": "^3.0.1" }, "require-dev": { - "omnipay/tests": "^3.1", - "squizlabs/php_codesniffer": "^3", - "phpro/grumphp": "^0.14", - "phpmd/phpmd": "^2", - "overtrue/phplint": "^1", - "jakub-onderka/php-parallel-lint": "^1" + "omnipay/tests": "^4.0.2", + "squizlabs/php_codesniffer": "^3" }, "extra": { "branch-alias": { diff --git a/grumphp.yml b/grumphp.yml deleted file mode 100644 index d643001..0000000 --- a/grumphp.yml +++ /dev/null @@ -1,22 +0,0 @@ -parameters: - git_dir: . - bin_dir: vendor/bin - tasks: - phpunit: - config_file: ~ - testsuite: ~ - group: [] - always_execute: false - phpcs: - standard: PSR2 - warning_severity: ~ - ignore_patterns: - - tests/ - triggered_by: [php] - phpmd: - exclude: [] - ruleset: ['cleancode', 'codesize', 'naming'] - triggered_by: ['php'] - phplint: - exclude: [] - triggered_by: ['php', 'phtml', 'php3', 'php4', 'php5'] \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 535809e..90448aa 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,6 @@ - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + + + ./src + + ./tests/ - - - ./src - - diff --git a/tests/GatewayTest.php b/tests/GatewayTest.php index cbd4e41..33d1d9c 100644 --- a/tests/GatewayTest.php +++ b/tests/GatewayTest.php @@ -29,7 +29,7 @@ class GatewayTest extends GatewayTestCase */ protected $gateway; - public function setUp() + public function setUp(): void { parent::setUp(); @@ -96,11 +96,10 @@ public function testRefund() ); } - /** - * @expectedException \Omnipay\Common\Exception\InvalidRequestException - */ public function testThatRefundDoesntWorkWithoutAmount() { + $this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class); + $request = $this->gateway->refund( array( 'apiKey' => 'key', diff --git a/tests/Message/AbstractMollieRequestTest.php b/tests/Message/AbstractMollieRequestTest.php index 6174e00..e47cc28 100644 --- a/tests/Message/AbstractMollieRequestTest.php +++ b/tests/Message/AbstractMollieRequestTest.php @@ -17,7 +17,7 @@ class AbstractMollieRequestTest extends TestCase */ protected $gateway; - public function setUp() + public function setUp(): void { $this->gateway = new Gateway($this->getHttpClient()); } diff --git a/tests/Message/AssertRequestTrait.php b/tests/Message/AssertRequestTrait.php index b74abba..06bb939 100644 --- a/tests/Message/AssertRequestTrait.php +++ b/tests/Message/AssertRequestTrait.php @@ -4,10 +4,6 @@ trait AssertRequestTrait { - abstract function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false); - - abstract function assertJsonStringEqualsJsonString($expected, $actual, $message = null); - public function assertEqualRequest(\Psr\Http\Message\RequestInterface $expectedRequest, \Psr\Http\Message\RequestInterface $actualRequest) { $this->assertEquals($expectedRequest->getMethod(), $actualRequest->getMethod(), "Expected request Method should be equal to actual request method."); diff --git a/tests/Message/CancelOrderRequestTest.php b/tests/Message/CancelOrderRequestTest.php index 16a4a04..a5b9a27 100644 --- a/tests/Message/CancelOrderRequestTest.php +++ b/tests/Message/CancelOrderRequestTest.php @@ -20,7 +20,7 @@ final class CancelOrderRequestTest extends TestCase */ private $request; - public function setUp() + public function setUp(): void { $this->httpClient = $this->createMock(ClientInterface::class); $this->request = new CancelOrderRequest($this->httpClient, $this->getHttpRequest()); @@ -46,12 +46,11 @@ public function responseDataProvider() /** * @dataProvider insufficientDataProvider * - * @expectedException \Omnipay\Common\Exception\InvalidRequestException - * * @param array $input */ public function testGetDataWillValidateRequiredData(array $input) { + $this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class); $this->request->initialize($input); $this->request->getData(); } diff --git a/tests/Message/CompleteOrderRequestTest.php b/tests/Message/CompleteOrderRequestTest.php index 9b703fa..3395ce6 100644 --- a/tests/Message/CompleteOrderRequestTest.php +++ b/tests/Message/CompleteOrderRequestTest.php @@ -18,7 +18,7 @@ class CompleteOrderRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new CompleteOrderRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( @@ -30,12 +30,10 @@ public function setUp() )); } - /** - * @expectedException \Omnipay\Common\Exception\InvalidRequestException - * @expectedExceptionMessage The transactionReference parameter is required - */ public function testGetDataWithoutIDParameter() { + $this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class); + $this->expectExceptionMessage('The transactionReference parameter is required'); $this->getHttpRequest()->request->remove('id'); $data = $this->request->getData(); diff --git a/tests/Message/CompletePurchaseRequestTest.php b/tests/Message/CompletePurchaseRequestTest.php index 11e4289..2c91fea 100644 --- a/tests/Message/CompletePurchaseRequestTest.php +++ b/tests/Message/CompletePurchaseRequestTest.php @@ -16,7 +16,7 @@ class CompletePurchaseRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( @@ -28,12 +28,11 @@ public function setUp() )); } - /** - * @expectedException \Omnipay\Common\Exception\InvalidRequestException - * @expectedExceptionMessage The transactionReference parameter is required - */ public function testGetDataWithoutIDParameter() { + $this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class); + $this->expectExceptionMessage('The transactionReference parameter is required'); + $this->getHttpRequest()->request->remove('id'); $data = $this->request->getData(); diff --git a/tests/Message/CreateCustomerMandateRequestTest.php b/tests/Message/CreateCustomerMandateRequestTest.php index 91e262b..414590c 100644 --- a/tests/Message/CreateCustomerMandateRequestTest.php +++ b/tests/Message/CreateCustomerMandateRequestTest.php @@ -17,7 +17,7 @@ class CreateCustomerMandateRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new CreateCustomerMandateRequest($this->getHttpClient(), $this->getHttpRequest()); diff --git a/tests/Message/CreateCustomerRequestTest.php b/tests/Message/CreateCustomerRequestTest.php index b4826b2..fa77bf3 100644 --- a/tests/Message/CreateCustomerRequestTest.php +++ b/tests/Message/CreateCustomerRequestTest.php @@ -18,7 +18,7 @@ class CreateCustomerRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new CreateCustomerRequest($this->getHttpClient(), $this->getHttpRequest()); diff --git a/tests/Message/CreateOrderRequestTest.php b/tests/Message/CreateOrderRequestTest.php index 38f0bb5..2afa0d7 100644 --- a/tests/Message/CreateOrderRequestTest.php +++ b/tests/Message/CreateOrderRequestTest.php @@ -20,7 +20,7 @@ class CreateOrderRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new CreateOrderRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( diff --git a/tests/Message/CreateShipmentRequestTest.php b/tests/Message/CreateShipmentRequestTest.php index dd23c47..a7511d1 100644 --- a/tests/Message/CreateShipmentRequestTest.php +++ b/tests/Message/CreateShipmentRequestTest.php @@ -21,7 +21,7 @@ class CreateShipmentRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new CreateShipmentRequest($this->getHttpClient(), $this->getHttpRequest()); diff --git a/tests/Message/FetchCustomerMandatesRequestTest.php b/tests/Message/FetchCustomerMandatesRequestTest.php index 1ca0d45..d64ec23 100644 --- a/tests/Message/FetchCustomerMandatesRequestTest.php +++ b/tests/Message/FetchCustomerMandatesRequestTest.php @@ -17,7 +17,7 @@ class FetchCustomerMandatesRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new FetchCustomerMandatesRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( diff --git a/tests/Message/FetchCustomerRequestTest.php b/tests/Message/FetchCustomerRequestTest.php index 7553382..565ded0 100644 --- a/tests/Message/FetchCustomerRequestTest.php +++ b/tests/Message/FetchCustomerRequestTest.php @@ -17,7 +17,7 @@ class FetchCustomerRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new FetchCustomerRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( diff --git a/tests/Message/FetchIssuersRequestTest.php b/tests/Message/FetchIssuersRequestTest.php index 5ef6cd0..a186db3 100644 --- a/tests/Message/FetchIssuersRequestTest.php +++ b/tests/Message/FetchIssuersRequestTest.php @@ -18,7 +18,7 @@ class FetchIssuersRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new FetchIssuersRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( diff --git a/tests/Message/FetchOrderRequestTest.php b/tests/Message/FetchOrderRequestTest.php index d42ea53..0e6e7d3 100644 --- a/tests/Message/FetchOrderRequestTest.php +++ b/tests/Message/FetchOrderRequestTest.php @@ -21,7 +21,7 @@ class FetchOrderRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new FetchOrderRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( @@ -122,8 +122,8 @@ public function testSendDataWithIncludingPayments() $response = $request->sendData(['id' => 'ord_kEn1PlbGa']); - self::assertInstanceOf(FetchOrderResponse::class, $response); - self::assertEquals($request, $response->getRequest()); - self::assertEquals($expectedData, $response->getData()); + $this->assertInstanceOf(FetchOrderResponse::class, $response); + $this->assertEquals($request, $response->getRequest()); + $this->assertEquals($expectedData, $response->getData()); } } diff --git a/tests/Message/FetchPaymentMethodsRequestTest.php b/tests/Message/FetchPaymentMethodsRequestTest.php index d1f48eb..4411dfd 100644 --- a/tests/Message/FetchPaymentMethodsRequestTest.php +++ b/tests/Message/FetchPaymentMethodsRequestTest.php @@ -20,7 +20,7 @@ class FetchPaymentMethodsRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new FetchPaymentMethodsRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([ diff --git a/tests/Message/FetchTransactionRequestTest.php b/tests/Message/FetchTransactionRequestTest.php index 47c9176..0bf8083 100644 --- a/tests/Message/FetchTransactionRequestTest.php +++ b/tests/Message/FetchTransactionRequestTest.php @@ -17,7 +17,7 @@ class FetchTransactionRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new FetchTransactionRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize( diff --git a/tests/Message/PurchaseRequestTest.php b/tests/Message/PurchaseRequestTest.php index ada300f..370c8d4 100644 --- a/tests/Message/PurchaseRequestTest.php +++ b/tests/Message/PurchaseRequestTest.php @@ -16,7 +16,7 @@ class PurchaseRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize(array( diff --git a/tests/Message/RefundRequestTest.php b/tests/Message/RefundRequestTest.php index 7ba7d8d..f004c87 100644 --- a/tests/Message/RefundRequestTest.php +++ b/tests/Message/RefundRequestTest.php @@ -16,7 +16,7 @@ class RefundRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new RefundRequest($this->getHttpClient(), $this->getHttpRequest()); $this->request->initialize([ @@ -45,11 +45,10 @@ public function testGetData() $this->assertCount(1, $data); } - /** - * @expectedException \Omnipay\Common\Exception\InvalidRequestException - */ public function testGetDataWithoutAmount() { + $this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class); + $this->request->initialize( [ 'apiKey' => 'mykey', diff --git a/tests/Message/RevokeCustomerMandateRequestTest.php b/tests/Message/RevokeCustomerMandateRequestTest.php index 9f655a9..5ecec50 100644 --- a/tests/Message/RevokeCustomerMandateRequestTest.php +++ b/tests/Message/RevokeCustomerMandateRequestTest.php @@ -17,7 +17,7 @@ class RevokeCustomerMandateRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new RevokeCustomerMandateRequest($this->getHttpClient(), $this->getHttpRequest()); diff --git a/tests/Message/UpdateCustomerRequestTest.php b/tests/Message/UpdateCustomerRequestTest.php index 71490c0..2e406a4 100644 --- a/tests/Message/UpdateCustomerRequestTest.php +++ b/tests/Message/UpdateCustomerRequestTest.php @@ -18,7 +18,7 @@ class UpdateCustomerRequestTest extends TestCase */ protected $request; - public function setUp() + public function setUp(): void { $this->request = new UpdateCustomerRequest($this->getHttpClient(), $this->getHttpRequest()); From 422a419f99e001f76b7bc18e21646ba91d907022 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 2 Jun 2021 13:24:48 +0200 Subject: [PATCH 2/4] Remove --- .github/workflows/phpunit.yml | 48 ----------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 .github/workflows/phpunit.yml diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml deleted file mode 100644 index 12233b9..0000000 --- a/.github/workflows/phpunit.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: "PHPUnit tests" - -on: - pull_request: - push: - branches: - - "master" - -jobs: - phpunit: - name: "PHPUnit tests" - - runs-on: ${{ matrix.operating-system }} - - strategy: - matrix: - dependencies: - - "lowest" - - "highest" - php-version: - - "7.3" - - "7.4" - - "8.0" - operating-system: - - "ubuntu-latest" - - steps: - - name: "Checkout" - uses: "actions/checkout@v2" - - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" - with: - coverage: "pcov" - php-version: "${{ matrix.php-version }}" - ini-values: memory_limit=-1 - tools: composer:v2 - - - name: "Install lowest dependencies" - if: ${{ matrix.dependencies == 'lowest' }} - run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest" - - - name: "Install highest dependencies" - if: ${{ matrix.dependencies == 'highest' }} - run: "composer update --no-interaction --no-progress --no-suggest" - - - name: "Tests" - run: "vendor/bin/phpunit" \ No newline at end of file From 9a91c7a8ab1ed664a0e1119f54e69ad8ee0e7e2f Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 2 Jun 2021 13:50:30 +0200 Subject: [PATCH 3/4] Fix header --- tests/Message/CancelOrderRequestTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Message/CancelOrderRequestTest.php b/tests/Message/CancelOrderRequestTest.php index a5b9a27..e7ad665 100644 --- a/tests/Message/CancelOrderRequestTest.php +++ b/tests/Message/CancelOrderRequestTest.php @@ -76,7 +76,9 @@ public function testSendData(array $responseData, $success) ->with( 'DELETE', 'https://api.mollie.com/v2/orders/ord_kEn1PlbGa', - ['Authorization' => 'Bearer mykey'] + $this->callback(function ($headers) { + return $headers['Authorization'] == 'Bearer mykey'; + }) )->willReturn($response); $this->request->initialize(['apiKey' => 'mykey', 'transactionReference' => 'ord_kEn1PlbGa']); From 645bc5154c0d30b147697614181a90386bc2cf2d Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Wed, 2 Jun 2021 13:51:08 +0200 Subject: [PATCH 4/4] Bump omnipay common --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a0e9f3c..2edb9fa 100755 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ }, "require": { "php": "^7.3|^8.0", - "omnipay/common": "^3.0.1" + "omnipay/common": "^3.1" }, "require-dev": { "omnipay/tests": "^4.0.2",