Skip to content

Test PHP8 #247

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

Merged
merged 10 commits into from
May 31, 2021
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
48 changes: 48 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
build
/vendor
composer.lock
composer.phar
phpunit.xml
.directory
reports/
documents/
.idea
.idea
.phpunit.result.cache
23 changes: 0 additions & 23 deletions .scrutinizer.yml

This file was deleted.

14 changes: 9 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@
"psr-4": { "Omnipay\\Common\\" : "src/Common" },
"classmap": ["src/Omnipay.php"]
},
"autoload-dev": {
"psr-4": { "Omnipay\\Common\\" : "tests/Common" },
"classmap": ["tests/OmnipayTest.php"]
},
"require": {
"php": "^5.6|^7|^8",
"php": "^7.3|^8",
"php-http/client-implementation": "^1",
"php-http/message": "^1.5",
"php-http/discovery": "^1.2.1",
"php-http/discovery": "^1.13",
"php-http/guzzle7-adapter": "^0.1",
"symfony/http-foundation": "^2.1|^3|^4|^5",
"moneyphp/money": "^3.1"
},
"require-dev": {
"omnipay/tests": "^3",
"omnipay/tests": "^4",
"php-http/mock-client": "^1",
"squizlabs/php_codesniffer": "^3.5",
"phpro/grumphp": "^0.14"
"squizlabs/php_codesniffer": "^3.5"
},
"extra": {
"branch-alias": {
Expand Down
15 changes: 0 additions & 15 deletions grumphp.yml

This file was deleted.

36 changes: 23 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="Omnipay Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<testsuites>
<testsuite name="Omnipay Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AbstractGatewayTest extends TestCase
/** @var \Omnipay\Common\AbstractGateway */
protected $gateway;

public function setUp()
public function setUp() : void
{
$this->gateway = new AbstractGatewayTest_MockAbstractGateway();
$this->gateway->initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CreditCardTest extends TestCase
/** @var CreditCard */
private $card;

public function setUp()
public function setUp() : void
{
$this->card = new CreditCard;
$this->card->setNumber('4111111111111111');
Expand Down Expand Up @@ -59,60 +59,55 @@ public function testValidateFixture()
$this->card->validate();
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
* @expectedExceptionMessage The credit card number is required
*/
public function testValidateNumberRequired()
{
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
$this->expectExceptionMessage('The credit card number is required');

$this->card->setNumber(null);
$this->card->validate();
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
* @expectedExceptionMessage The expiration month is required
*/
public function testValidateExpiryMonthRequired()
{
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
$this->expectExceptionMessage('The expiration month is required');

$this->card->setExpiryMonth(null);
$this->card->validate();
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
* @expectedExceptionMessage The expiration year is required
*/
public function testValidateExpiryYearRequired()
{
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
$this->expectExceptionMessage('The expiration year is required');

$this->card->setExpiryYear(null);
$this->card->validate();
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
* @expectedExceptionMessage Card has expired
*/
public function testValidateExpiryDate()
{
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
$this->expectExceptionMessage('Card has expired');

$this->card->setExpiryYear(gmdate('Y')-1);
$this->card->validate();
}

/**
* @expectedException \Omnipay\Common\Exception\InvalidCreditCardException
* @expectedExceptionMessage Card number is invalid
*/
public function testValidateNumber()
{
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
$this->expectExceptionMessage('Card number is invalid');

$this->card->setNumber('4111111111111110');
$this->card->validate();
}

public function testGetSupportedBrands()
{
$brands = $this->card->getSupportedBrands();
$this->assertInternalType('array', $brands);
$this->assertIsArray($brands);
$this->assertArrayHasKey(CreditCard::BRAND_VISA, $brands);
}

Expand Down Expand Up @@ -671,22 +666,20 @@ public function testGender()
$this->assertEquals('female', $this->card->getGender());
}

/**
* @expectedException Omnipay\Common\Exception\InvalidCreditCardException
* @expectedExceptionMessage Card number is invalid
*/
public function testInvalidLuhn()
{
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
$this->expectExceptionMessage('Card number is invalid');

$this->card->setNumber('43');
$this->card->validate();
}

/**
* @expectedException Omnipay\Common\Exception\InvalidCreditCardException
* @expectedExceptionMessage Card number should have 12 to 19 digits
*/
public function testInvalidShortCard()
{
$this->expectException(\Omnipay\Common\Exception\InvalidCreditCardException::class);
$this->expectExceptionMessage('Card number should have 12 to 19 digits');

$this->card->setNumber('4440');
$this->card->validate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

class GatewayFactoryTest extends TestCase
{
public static function setUpBeforeClass()
public static function setUpBeforeClass() : void
{
m::mock('alias:Omnipay\\SpareChange\\TestGateway');
}

public function setUp()
public function setUp() : void
{
$this->factory = new GatewayFactory;
}
Expand Down Expand Up @@ -53,12 +53,11 @@ public function testCreateFullyQualified()
$this->assertInstanceOf('\\Omnipay\\SpareChange\\TestGateway', $gateway);
}

/**
* @expectedException \Omnipay\Common\Exception\RuntimeException
* @expectedExceptionMessage Class '\Omnipay\Invalid\Gateway' not found
*/
public function testCreateInvalid()
{
$this->expectException(\Omnipay\Common\Exception\RuntimeException::class);
$this->expectExceptionMessage("Class '\Omnipay\Invalid\Gateway' not found");

$gateway = $this->factory->create('Invalid');
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@

class ClientTest extends TestCase
{
public function testEmptyConstruct()
{
$client = new Client();

$this->assertAttributeInstanceOf(HttpClient::class, 'httpClient', $client);
$this->assertAttributeInstanceOf(RequestFactory::class, 'requestFactory', $client);
}

public function testSend()
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ItemBagTest extends TestCase
{
public function setUp()
public function setUp() : void
{
$this->bag = new ItemBag;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class ItemTest extends TestCase
{
public function setUp()
public function setUp() : void
{
$this->item = new Item;
}
Expand Down
Loading