Skip to content

Commit 1f60090

Browse files
authored
Merge pull request #247 from thephpleague/feat-php8
Test PHP8
2 parents e1ebc22 + e2ec044 commit 1f60090

24 files changed

+161
-158
lines changed

.github/workflows/phpunit.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "PHPUnit tests"
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- "master"
8+
9+
jobs:
10+
phpunit:
11+
name: "PHPUnit tests"
12+
13+
runs-on: ${{ matrix.operating-system }}
14+
15+
strategy:
16+
matrix:
17+
dependencies:
18+
- "lowest"
19+
- "highest"
20+
php-version:
21+
- "7.3"
22+
- "7.4"
23+
- "8.0"
24+
operating-system:
25+
- "ubuntu-latest"
26+
27+
steps:
28+
- name: "Checkout"
29+
uses: "actions/checkout@v2"
30+
31+
- name: "Install PHP"
32+
uses: "shivammathur/setup-php@v2"
33+
with:
34+
coverage: "pcov"
35+
php-version: "${{ matrix.php-version }}"
36+
ini-values: memory_limit=-1
37+
tools: composer:v2
38+
39+
- name: "Install lowest dependencies"
40+
if: ${{ matrix.dependencies == 'lowest' }}
41+
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest"
42+
43+
- name: "Install highest dependencies"
44+
if: ${{ matrix.dependencies == 'highest' }}
45+
run: "composer update --no-interaction --no-progress --no-suggest"
46+
47+
- name: "Tests"
48+
run: "vendor/bin/phpunit"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
build
12
/vendor
23
composer.lock
34
composer.phar
45
phpunit.xml
56
.directory
67
reports/
78
documents/
8-
.idea
9+
.idea
10+
.phpunit.result.cache

.scrutinizer.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

composer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,23 @@
3737
"psr-4": { "Omnipay\\Common\\" : "src/Common" },
3838
"classmap": ["src/Omnipay.php"]
3939
},
40+
"autoload-dev": {
41+
"psr-4": { "Omnipay\\Common\\" : "tests/Common" },
42+
"classmap": ["tests/OmnipayTest.php"]
43+
},
4044
"require": {
41-
"php": "^5.6|^7|^8",
45+
"php": "^7.3|^8",
4246
"php-http/client-implementation": "^1",
4347
"php-http/message": "^1.5",
44-
"php-http/discovery": "^1.2.1",
48+
"php-http/discovery": "^1.13",
49+
"php-http/guzzle7-adapter": "^0.1",
4550
"symfony/http-foundation": "^2.1|^3|^4|^5",
4651
"moneyphp/money": "^3.1"
4752
},
4853
"require-dev": {
49-
"omnipay/tests": "^3",
54+
"omnipay/tests": "^4",
5055
"php-http/mock-client": "^1",
51-
"squizlabs/php_codesniffer": "^3.5",
52-
"phpro/grumphp": "^0.14"
56+
"squizlabs/php_codesniffer": "^3.5"
5357
},
5458
"extra": {
5559
"branch-alias": {

grumphp.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

phpunit.xml.dist

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
43
bootstrap="vendor/autoload.php"
4+
backupGlobals="false"
5+
backupStaticAttributes="false"
56
colors="true"
7+
verbose="true"
68
convertErrorsToExceptions="true"
79
convertNoticesToExceptions="true"
810
convertWarningsToExceptions="true"
911
processIsolation="false"
1012
stopOnFailure="false"
11-
syntaxCheck="false">
12-
<testsuites>
13-
<testsuite name="Omnipay Test Suite">
14-
<directory>./tests/</directory>
15-
</testsuite>
16-
</testsuites>
17-
<filter>
18-
<whitelist>
19-
<directory>./src</directory>
20-
</whitelist>
21-
</filter>
13+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
14+
<coverage>
15+
<include>
16+
<directory suffix=".php">src/</directory>
17+
</include>
18+
<report>
19+
<clover outputFile="build/logs/clover.xml"/>
20+
<html outputDirectory="build/coverage"/>
21+
<text outputFile="build/coverage.txt"/>
22+
</report>
23+
</coverage>
24+
<testsuites>
25+
<testsuite name="Omnipay Test Suite">
26+
<directory>tests</directory>
27+
</testsuite>
28+
</testsuites>
29+
<logging>
30+
<junit outputFile="build/report.junit.xml"/>
31+
</logging>
2232
</phpunit>

tests/Omnipay/Common/AbstractGatewayTest.php renamed to tests/Common/AbstractGatewayTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AbstractGatewayTest extends TestCase
1313
/** @var \Omnipay\Common\AbstractGateway */
1414
protected $gateway;
1515

16-
public function setUp()
16+
public function setUp() : void
1717
{
1818
$this->gateway = new AbstractGatewayTest_MockAbstractGateway();
1919
$this->gateway->initialize();

tests/Omnipay/Common/CreditCardTest.php renamed to tests/Common/CreditCardTest.php

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class CreditCardTest extends TestCase
1010
/** @var CreditCard */
1111
private $card;
1212

13-
public function setUp()
13+
public function setUp() : void
1414
{
1515
$this->card = new CreditCard;
1616
$this->card->setNumber('4111111111111111');
@@ -59,60 +59,55 @@ public function testValidateFixture()
5959
$this->card->validate();
6060
}
6161

62-
/**
63-
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
64-
* @expectedExceptionMessage The credit card number is required
65-
*/
6662
public function testValidateNumberRequired()
6763
{
64+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
65+
$this->expectExceptionMessage('The credit card number is required');
66+
6867
$this->card->setNumber(null);
6968
$this->card->validate();
7069
}
7170

72-
/**
73-
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
74-
* @expectedExceptionMessage The expiration month is required
75-
*/
7671
public function testValidateExpiryMonthRequired()
7772
{
73+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
74+
$this->expectExceptionMessage('The expiration month is required');
75+
7876
$this->card->setExpiryMonth(null);
7977
$this->card->validate();
8078
}
8179

82-
/**
83-
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
84-
* @expectedExceptionMessage The expiration year is required
85-
*/
8680
public function testValidateExpiryYearRequired()
8781
{
82+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
83+
$this->expectExceptionMessage('The expiration year is required');
84+
8885
$this->card->setExpiryYear(null);
8986
$this->card->validate();
9087
}
9188

92-
/**
93-
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
94-
* @expectedExceptionMessage Card has expired
95-
*/
9689
public function testValidateExpiryDate()
9790
{
91+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
92+
$this->expectExceptionMessage('Card has expired');
93+
9894
$this->card->setExpiryYear(gmdate('Y')-1);
9995
$this->card->validate();
10096
}
10197

102-
/**
103-
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
104-
* @expectedExceptionMessage Card number is invalid
105-
*/
10698
public function testValidateNumber()
10799
{
100+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
101+
$this->expectExceptionMessage('Card number is invalid');
102+
108103
$this->card->setNumber('4111111111111110');
109104
$this->card->validate();
110105
}
111106

112107
public function testGetSupportedBrands()
113108
{
114109
$brands = $this->card->getSupportedBrands();
115-
$this->assertInternalType('array', $brands);
110+
$this->assertIsArray($brands);
116111
$this->assertArrayHasKey(CreditCard::BRAND_VISA, $brands);
117112
}
118113

@@ -671,22 +666,20 @@ public function testGender()
671666
$this->assertEquals('female', $this->card->getGender());
672667
}
673668

674-
/**
675-
* @expectedException Omnipay\Common\Exception\InvalidCreditCardException
676-
* @expectedExceptionMessage Card number is invalid
677-
*/
678669
public function testInvalidLuhn()
679670
{
671+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
672+
$this->expectExceptionMessage('Card number is invalid');
673+
680674
$this->card->setNumber('43');
681675
$this->card->validate();
682676
}
683677

684-
/**
685-
* @expectedException Omnipay\Common\Exception\InvalidCreditCardException
686-
* @expectedExceptionMessage Card number should have 12 to 19 digits
687-
*/
688678
public function testInvalidShortCard()
689679
{
680+
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
681+
$this->expectExceptionMessage('Card number should have 12 to 19 digits');
682+
690683
$this->card->setNumber('4440');
691684
$this->card->validate();
692685
}

0 commit comments

Comments
 (0)