Skip to content

Commit

Permalink
Bump to PHP 8 (#3)
Browse files Browse the repository at this point in the history
* Bump to PHP 8
* Drop everything below PHP 7.2
* Update PHPUnit
  • Loading branch information
ch2877 authored Oct 19, 2021
1 parent 4280e02 commit c85bb22
Show file tree
Hide file tree
Showing 26 changed files with 110 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

strategy:
matrix:
php: ['7.0', '7.1', '7.2', '7.3', '7.4']
php: ['7.2', '7.3', '7.4', '8.0']
stability: ['prefer-lowest', 'prefer-stable']
fail-fast: false

Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# SwissPayment Changelog

## 2.0.0 (2021-10-19)

* Added support for QR Bills (BankCreditTransferWithCreditorReference, BankCreditTransferWithQRR)
* Renamed Mixed to MixedMoney (reserved word as of PHP 7).
* Added Support for PHP 8.0
* Dropped support for PHP 7.1 and 7.2

## 1.0.0 (2021-10-18)

* Forked from z38/swiss-payment due to lack of maintenance on the old Project
* Dropped support for PHP 5.6.

## 0.7.0 (2019-01-05)

* Support creation of IIDs from Lichtenstein IBANs.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# SwissPayment

[![Build Status](https://github.com/ch2877/swiss-payment/actions/workflows/tests.yml/badge.svg)](https://github.com/ch2877/swiss-payment/actions)
[![Tested on PHP PHP 7.2, 7.3, 7.4, 8.0](https://img.shields.io/badge/tested%20on-7.2%20|%207.3%20|%207.4%20|%208.0%20-brightgreen.svg?maxAge=2419200)](https://github.com/ch2877/swiss-payment/actions?query=workflow%3ATest)

**SwissPayment** is a PHP library to generate Swiss pain.001 XML messages (complies with ISO-20022).

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
}
],
"require": {
"php": "^7"
"php": ">=7.2|^8.0"
},
"require-dev": {
"phpunit/phpunit": "^6 | ^8"
"phpunit/phpunit": "^8.0|^9.0"
},
"autoload": {
"psr-0": {
Expand Down
2 changes: 1 addition & 1 deletion src/Z38/SwissPayment/Message/CustomerCreditTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function getSchemaLocation()
protected function buildDom(\DOMDocument $doc)
{
$transactionCount = 0;
$transactionSum = new Money\Mixed(0);
$transactionSum = new Money\MixedMoney(0);
foreach ($this->payments as $payment) {
$transactionCount += $payment->getTransactionCount();
$transactionSum = $transactionSum->plus($payment->getTransactionSum());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Sum of money in mixed currencies
*/
class Mixed extends Money
class MixedMoney extends Money
{
/**
* @var int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ public function getTransactionCount()
/**
* Gets the sum of transactions
*
* @return Money\Mixed Sum of transactions
* @return Money\MixedMoney Sum of transactions
*/
public function getTransactionSum()
{
$sum = new Money\Mixed(0);
$sum = new Money\MixedMoney(0);

foreach ($this->transactions as $transaction) {
$sum = $sum->plus($transaction->getAmount());
Expand Down
4 changes: 2 additions & 2 deletions tests/Z38/SwissPayment/Tests/BICTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testInvalidChars()
public function testFormat($bic)
{
$instance = new BIC($bic);
$this->assertEquals($bic, $instance->format());
self::assertEquals($bic, $instance->format());
}

public function validSamples()
Expand All @@ -60,6 +60,6 @@ protected function check($iban, $valid)
} catch (\InvalidArgumentException $e) {
$exception = true;
}
$this->assertTrue($exception != $valid);
self::assertTrue($exception != $valid);
}
}
6 changes: 3 additions & 3 deletions tests/Z38/SwissPayment/Tests/GeneralAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Z38\SwissPayment\Tests;

use InvalidArgumentException;
use Z38\SwissPayment\GeneralAccount;

class GeneralAccountTest extends TestCase
Expand All @@ -13,14 +12,15 @@ class GeneralAccountTest extends TestCase
public function testValid()
{
$instance = new GeneralAccount('A-123-4567890-78');
self::assertInstanceOf(GeneralAccount::class, $instance);
}

/**
* @covers \Z38\SwissPayment\GeneralAccount::__construct
* @expectedException InvalidArgumentException
*/
public function testInvalid()
{
$this->expectException(\InvalidArgumentException::class);
$instance = new GeneralAccount('0123456789012345678901234567890123456789');
}

Expand All @@ -30,6 +30,6 @@ public function testInvalid()
public function testFormat()
{
$instance = new GeneralAccount(' 123-4567890-78 AA ');
$this->assertSame(' 123-4567890-78 AA ', $instance->format());
self::assertSame(' 123-4567890-78 AA ', $instance->format());
}
}
10 changes: 5 additions & 5 deletions tests/Z38/SwissPayment/Tests/IBANTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testWrongChecksum()
public function testGetCountry($iban, $expectedCountry)
{
$instance = new IBAN($iban);
$this->assertEquals($expectedCountry, $instance->getCountry());
self::assertEquals($expectedCountry, $instance->getCountry());
}

/**
Expand All @@ -49,7 +49,7 @@ public function testGetCountry($iban, $expectedCountry)
public function testFormat()
{
$iban = new IBAN('ch9300762011623852 957');
$this->assertEquals('CH93 0076 2011 6238 5295 7', $iban->format());
self::assertEquals('CH93 0076 2011 6238 5295 7', $iban->format());
}

/**
Expand All @@ -58,7 +58,7 @@ public function testFormat()
public function testNormalize()
{
$iban = new IBAN('fr14 2004 10100505 0001 3M02 606');
$this->assertEquals('FR1420041010050500013M02606', $iban->normalize());
self::assertEquals('FR1420041010050500013M02606', $iban->normalize());
}

/**
Expand All @@ -69,7 +69,7 @@ public function testNormalize()
public function testToString($iban)
{
$instance = new IBAN($iban);
$this->assertEquals($instance->format(), (string) $instance);
self::assertEquals($instance->format(), (string) $instance);
}

public function samplesValid()
Expand All @@ -89,6 +89,6 @@ protected function check($iban, $valid)
} catch (\InvalidArgumentException $e) {
$exception = true;
}
$this->assertTrue($exception != $valid);
self::assertTrue($exception != $valid);
}
}
4 changes: 2 additions & 2 deletions tests/Z38/SwissPayment/Tests/IIDTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public function validSamples()
/**
* @dataProvider invalidSamples
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testInvalidLength($iid)
{
$this->expectException(\InvalidArgumentException::class);
new IID($iid);
}

Expand Down Expand Up @@ -79,10 +79,10 @@ public function fromIBANSamples()

/**
* @cover ::fromIban
* @expectedException \InvalidArgumentException
*/
public function testFromIBANForeign()
{
$this->expectException(\InvalidArgumentException::class);
IID::fromIBAN(new IBAN('GB29 NWBK 6016 1331 9268 19'));
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Z38/SwissPayment/Tests/ISRParticipantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ class ISRParticipantTest extends TestCase
*/
public function testValid($number)
{
$this->assertInstanceOf('Z38\SwissPayment\ISRParticipant', new ISRParticipant($number));
self::assertInstanceOf('Z38\SwissPayment\ISRParticipant', new ISRParticipant($number));
}

/**
* @dataProvider invalidSamples
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function testInvalid($number)
{
$this->expectException(\InvalidArgumentException::class);
new ISRParticipant($number);
}

Expand All @@ -34,7 +34,7 @@ public function testInvalid($number)
public function testFormat()
{
$instance = new ISRParticipant('010001628');
$this->assertEquals('01-162-8', $instance->format());
self::assertEquals('01-162-8', $instance->format());
}

public function validSamples()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ public function testGroupHeader()
$xpath->registerNamespace('pain001', self::SCHEMA);

$nbOfTxs = $xpath->evaluate('string(//pain001:GrpHdr/pain001:NbOfTxs)');
$this->assertEquals('14', $nbOfTxs);
self::assertEquals('14', $nbOfTxs);

$ctrlSum = $xpath->evaluate('string(//pain001:GrpHdr/pain001:CtrlSum)');
$this->assertEquals('6810.001', $ctrlSum);
self::assertEquals('6810.001', $ctrlSum);
}

public function testSchemaValidation()
Expand All @@ -282,7 +282,7 @@ public function testSchemaValidation()
foreach (libxml_get_errors() as $error) {
$this->fail($error->message);
}
$this->assertTrue($valid);
self::assertTrue($valid);
libxml_clear_errors();
libxml_use_internal_errors(false);
}
Expand All @@ -291,6 +291,6 @@ public function testGetPaymentCount()
{
$message = $this->buildMessage();

$this->assertSame(6, $message->getPaymentCount());
self::assertSame(6, $message->getPaymentCount());
}
}
8 changes: 4 additions & 4 deletions tests/Z38/SwissPayment/Tests/Money/MixedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
class MixedTest extends TestCase
{
/**
* @covers \Z38\SwissPayment\Money\Mixed::plus
* @covers \Z38\SwissPayment\Money\MixedMoney::plus
*/
public function testPlus()
{
$sum = new Money\Mixed(0);
$sum = new Money\MixedMoney(0);
$sum = $sum->plus(new Money\CHF(2456));
$sum = $sum->plus(new Money\CHF(1000));
$sum = $sum->plus(new Money\JPY(1200));
Expand All @@ -21,11 +21,11 @@ public function testPlus()
}

/**
* @covers \Z38\SwissPayment\Money\Mixed::minus
* @covers \Z38\SwissPayment\Money\MixedMoney::minus
*/
public function testMinus()
{
$sum = new Money\Mixed(100);
$sum = new Money\MixedMoney(100);
$sum = $sum->minus(new Money\CHF(5000));
$sum = $sum->minus(new Money\CHF(99));
$sum = $sum->minus(new Money\JPY(300));
Expand Down
Loading

0 comments on commit c85bb22

Please sign in to comment.