Skip to content

Commit

Permalink
Drop support for PHP 5.6 (paysera#24)
Browse files Browse the repository at this point in the history
* Drop support for PHP 5.6
* Update PHPUnit version
  • Loading branch information
borilyordanov authored Apr 19, 2023
1 parent 6626e92 commit 040fa82
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 85 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ vendor/
build/
bin/
composer.lock
/.phpunit.result.cache
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
},
"require": {
"php": ">=5.6",
"php": "^7.0 || ^8.0",
"ext-bcmath": "*",
"ext-mbstring": "*",
"maba/math": "^1.0",
Expand All @@ -27,7 +27,8 @@
"symfony/dependency-injection": "^2.3 || ^3.0 || ^4.0 || ^5.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0"
"phpunit/phpunit": "^6.5 || ^9.6",
"yoast/phpunit-polyfills": "^1.0"
},
"config": {
"bin-dir": "bin",
Expand Down
27 changes: 11 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
bootstrap = "vendor/autoload.php" >

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="tests/bootstrap.php"
colors="true">
<testsuites>
<testsuite name="Project Test Suite">
<testsuite name="Money Test Suite">
<directory>tests/</directory>
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
</phpunit>
5 changes: 3 additions & 2 deletions tests/AggregatedMoneyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use Evp\Component\Money\AggregatedMoney;
use Evp\Component\Money\Money;
use PHPUnit\Framework\TestCase;

class AggregatedMoneyTest extends \PHPUnit_Framework_TestCase
class AggregatedMoneyTest extends TestCase
{
/**
* @param Money $one
Expand Down Expand Up @@ -34,4 +35,4 @@ public function addProvider()
array(new Money('1', 'EUR'), new Money('-2', 'EUR'), new Money('-1', 'EUR'))
);
}
}
}
5 changes: 3 additions & 2 deletions tests/BcMathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Evp\Component\Money\Tests;

use Evp\Component\Money\BcMath;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

class BcMathTest extends \PHPUnit_Framework_TestCase
class BcMathTest extends TestCase
{
/**
* @var \Evp\Component\Money\BcMath
Expand All @@ -14,7 +15,7 @@ class BcMathTest extends \PHPUnit_Framework_TestCase
/**
* Set up
*/
public function setUp()
public function set_up()
{
$this->math = new BcMath($scale = 6);
}
Expand Down
10 changes: 5 additions & 5 deletions tests/CurrencyIsoNumberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace Evp\Component\Money\Tests;

use Evp\Component\Money\CurrencyIsoNumber;
use Evp\Component\Money\MoneyException;
use PHPUnit\Framework\TestCase;

class CurrencyIsoNumberTest extends \PHPUnit_Framework_TestCase
class CurrencyIsoNumberTest extends TestCase
{
/**
* @param string $currencyNumber
Expand All @@ -22,11 +24,10 @@ public function testGetCurrencyCode($currencyNumber, $expectedCurrencyNumber)
* @param string $currencyNumber
*
* @dataProvider getCurrencyCodeExceptionProvider
*
* @expectedException \Evp\Component\Money\MoneyException
*/
public function testGetCurrencyCodeException($currencyNumber)
{
$this->expectException(MoneyException::class);
$currencyIsoNumber = new CurrencyIsoNumber();
$currencyIsoNumber->getCurrencyCode($currencyNumber);
}
Expand All @@ -47,11 +48,10 @@ public function testGetCurrencyNumber($currencyCode, $expectedCurrencyCode)
* @param string $currencyCode
*
* @dataProvider getCurrencyNumberExceptionProvider
*
* @expectedException \Evp\Component\Money\MoneyException
*/
public function testGetCurrencyNumberException($currencyCode)
{
$this->expectException(MoneyException::class);
$currencyIsoNumber = new CurrencyIsoNumber();
$currencyIsoNumber->getCurrencyNumber($currencyCode);
}
Expand Down
33 changes: 33 additions & 0 deletions tests/MoneyComparator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Evp\Component\Money\Tests;

use Evp\Component\Money\Money;
use SebastianBergmann\Comparator\Comparator;
use SebastianBergmann\Comparator\ComparisonFailure;

class MoneyComparator extends Comparator
{

public function accepts($expected, $actual)
{
return $expected instanceof Money && $actual instanceof Money;
}

public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = false, $ignoreCase = false)
{
assert($expected instanceof Money);
assert($actual instanceof Money);

if (!$expected->isEqual($actual)) {
throw new ComparisonFailure(
$expected,
$actual,
$expected->getAsString(),
$actual->getAsString(),
false,
'Failed asserting that two Money objects are equal.'
);
}
}
}
Loading

0 comments on commit 040fa82

Please sign in to comment.