Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PHP 8.0 support #169

Merged
merged 7 commits into from
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Unit Tests

on:
push:
branches:
- master
pull_request:
branches:
- "*"
schedule:
- cron: '0 0 * * *'

jobs:
php-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1

strategy:
matrix:
php: [8.0, 7.4, 7.3, 7.2]
dependency-version: [prefer-lowest, prefer-stable]

name: P${{ matrix.php }} - ${{ matrix.dependency-version }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2

- name: Install dependencies
run: |
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress

- name: Execute Unit Tests
run: composer test
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
}
},
"require": {
"php": "^5.6|^7",
"php": "^7.2|^8",
"omnipay/common": "~3.0"
},
"require-dev": {
"omnipay/tests": "~3.0",
"squizlabs/php_codesniffer": "^3"
"omnipay/tests": "^4.1",
"squizlabs/php_codesniffer": "^3",
"phpspec/prophecy-phpunit": "^2.0"
},
"extra": {
"branch-alias": {
Expand Down
2 changes: 1 addition & 1 deletion tests/DirectGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class DirectGatewayTest extends GatewayTestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
22 changes: 8 additions & 14 deletions tests/FormGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class FormGatewayTest extends GatewayTestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -107,10 +107,10 @@ public function testPurchaseSuccess()
* supplied, which largely amount to missing parameters.
*
* @dataProvider missingParameterProvider
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
*/
public function testAuthorizeFailure($missingParameter)
{
$this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class);
$parameters = $this->purchaseOptions;

unset($parameters[$missingParameter]);
Expand Down Expand Up @@ -180,37 +180,33 @@ public function testCompleteAuthorizeSuccess()

/**
* Invalid without any query parameter supplied.
* @expectedException Omnipay\Common\Exception\InvalidResponseException
*/
public function testCompleteAuthorizeInvalid()
{
$this->expectException(\Omnipay\Common\Exception\InvalidResponseException::class);
$response = $this->gateway->completeAuthorize($this->completePurchaseOptions)->send();
}

/**
* Invalid without any query parameter supplied.
* @expectedException Omnipay\Common\Exception\InvalidResponseException
*/
public function testCompletePurchaseInvalid1()
{
$this->expectException(\Omnipay\Common\Exception\InvalidResponseException::class);
$response = $this->gateway->completePurchase($this->completePurchaseOptions)->send();
}

/**
* @expectedException Omnipay\Common\Exception\InvalidResponseException
*/
public function testCompletePurchaseInvalid2()
{
$this->expectException(\Omnipay\Common\Exception\InvalidResponseException::class);
// No leading '@'.
$this->getHttpRequest()->initialize(['crypt' => 'ababab']);
$response = $this->gateway->completePurchase($this->completePurchaseOptions)->send();
}

/**
* @expectedException Omnipay\Common\Exception\InvalidResponseException
*/
public function testCompletePurchaseInvalid3()
{
$this->expectException(\Omnipay\Common\Exception\InvalidResponseException::class);
// Not hexadecimal.
$this->getHttpRequest()->initialize(['crypt' => '@ababxx']);
$response = $this->gateway->completePurchase($this->completePurchaseOptions)->send();
Expand Down Expand Up @@ -275,11 +271,10 @@ public function testCompletePurchaseSuccess()

/**
* The wrong transaction ID is supplied with the server request.
*
* @expectedException Omnipay\Common\Exception\InvalidResponseException
*/
public function testCompletePurchaseReplayAttack()
{
$this->expectException(\Omnipay\Common\Exception\InvalidResponseException::class);
//$this->expectException(Complicated::class);

// Set the "crypt" query parameter.
Expand All @@ -295,11 +290,10 @@ public function testCompletePurchaseReplayAttack()

/**
* The missing expected transaction ID supplied by the app.
*
* @expectedException Omnipay\Common\Exception\InvalidRequestException
*/
public function testCompletePurchaseMissingExpectedParam()
{
$this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class);
//$this->expectException(Complicated::class);

// Set the "crypt" query parameter.
Expand Down
10 changes: 5 additions & 5 deletions tests/Message/DirectAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DirectAuthorizeRequestTest extends TestCase
*/
protected $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -123,7 +123,7 @@ public function testBasket()
// The element does exist, and must contain the basket XML, with optional XML header and
// trailing newlines.
$this->assertArrayHasKey('BasketXML', $data);
$this->assertContains($basketXml, $data['BasketXML']);
$this->assertStringContainsString($basketXml, $data['BasketXML']);
}

public function testBasketExtendItem()
Expand Down Expand Up @@ -151,7 +151,7 @@ public function testBasketExtendItem()
// The element does exist, and must contain the basket XML, with optional XML header and
// trailing newlines.
$this->assertArrayHasKey('BasketXML', $data);
$this->assertContains($basketXml, $data['BasketXML']);
$this->assertStringContainsString($basketXml, $data['BasketXML']);
}

public function testGetDataNoReferrerId()
Expand Down Expand Up @@ -280,7 +280,7 @@ public function testBasketWithNoDiscount()
// The element does exist, and must contain the basket XML, with optional XML header and
// trailing newlines.
$this->assertArrayHasKey('BasketXML', $data);
$this->assertNotContains('<discount>', $data['BasketXML']);
$this->assertStringNotContainsString('<discount>', $data['BasketXML']);
}

public function testMixedBasketWithSpecialChars()
Expand Down Expand Up @@ -321,7 +321,7 @@ public function testMixedBasketWithSpecialChars()
$data = $this->request->getData();

$this->assertArrayHasKey('BasketXML', $data);
$this->assertContains($expected, $data['BasketXML'], 'Basket XML does not match the expected output');
$this->assertStringContainsString($expected, $data['BasketXML'], 'Basket XML does not match the expected output');
}

public function testNonXmlBasket()
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/DirectPurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DirectPurchaseRequestTest extends DirectAuthorizeRequestTest
*/
protected $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/DirectTokenRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DirectTokenRequestTest extends TestCase
*/
protected $card;

public function setUp()
public function setUp(): void
{
$this->request = new DirectTokenRegistrationRequest(
$this->getHttpClient(),
Expand Down
5 changes: 4 additions & 1 deletion tests/Message/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

use Omnipay\Common\Message\RequestInterface;
use Omnipay\Tests\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

class ResponseTest extends TestCase
{
public function setUp()
use ProphecyTrait;

public function setUp(): void
{
$this->getMockRequest()->shouldReceive('getTransactionId')->andReturn('123456');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/ServerAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ServerAuthorizeRequestTest extends TestCase
{
const SURCHARGE_XML = '<surcharges><surcharge><paymentType>VISA</paymentType><percentage>2.50</percentage></surcharge></surcharges>';

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/ServerAuthorizeResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ServerAuthorizeResponseTest extends TestCase
{
public function setUp()
public function setUp(): void
{
$this->getMockRequest()->shouldReceive('getTransactionId')->andReturn('123456');
}
Expand Down
10 changes: 4 additions & 6 deletions tests/Message/ServerNotifyRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,10 @@ public function testError()
$this->request->error('https://www.example.com/', 'detail');
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidResponseException
*/
public function testConfirmInvalidSignature()
{
$this->expectException(\Omnipay\Common\Exception\InvalidResponseException::class);

$this->request = new ServerNotifyRequest(
$this->getHttpClient(),
$this->getHttpRequest()
Expand All @@ -200,11 +199,10 @@ public function testConfirmInvalidSignature()
$this->request->confirm('https://www.example.com/', 'detail');
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidResponseException
*/
public function testErrorInvalidSignature()
{
$this->expectException(\Omnipay\Common\Exception\InvalidResponseException::class);

$this->request = new ServerNotifyRequest(
$this->getHttpClient(),
$this->getHttpRequest()
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/ServerTokenRegistrationRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ServerTokenRegistrationRequestTest extends TestCase
*/
private $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/ServerTokenRegistrationResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ServerTokenRegistrationResponseTest extends TestCase
{
public function setUp()
public function setUp(): void
{
$this->getMockRequest()->shouldReceive('getTransactionId')->andReturn('123456');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/SharedAbortRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SharedAbortRequestTest extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
17 changes: 7 additions & 10 deletions tests/Message/SharedCaptureRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SharedCaptureRequestTest extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -38,11 +38,10 @@ public function testTxType()
$this->assertSame('RELEASE', $this->request->getTxType());
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
*/
public function testMissingAmount()
{
$this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class);

$this->request->getData();
}

Expand All @@ -60,22 +59,20 @@ public function testValid()
$this->assertSame('4255', $data['TxAuthNo']);
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
*/
public function testAuthMissingDescription()
{
$this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class);

$this->request->setAmount(123.45);
$this->request->setUseAuthenticate(true);

$this->request->getData();
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidRequestException
*/
public function testAuthMissingTransactionId()
{
$this->expectException(\Omnipay\Common\Exception\InvalidRequestException::class);

$this->request->setAmount(123.45);
$this->request->setDescription('desc');
$this->request->setUseAuthenticate(true);
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/SharedRefundRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SharedRefundRequestTest extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/Message/SharedRepeatAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SharedRepeatAuthorizeRequestTest extends TestCase
*/
protected $request;

public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
Loading