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

feat: drop support for PHP < 8.1 #162

Merged
merged 7 commits into from
Feb 24, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/code_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
stability: [ prefer-stable ]
symfony-version: ['7.0.*']
include:
- php: '8.0'
- php: '8.1'
symfony-version: 5.4.*
stability: prefer-lowest
- php: '8.0'
- php: '8.1'
symfony-version: 5.4.*
stability: prefer-stable
- php: '8.1'
Expand Down
12 changes: 9 additions & 3 deletions Tests/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@

namespace Tbbc\MoneyBundle\Tests;

use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Tbbc\MoneyBundle\TbbcMoneyBundle;

class AppKernel extends Kernel
{
use MicroKernelTrait;

public function __construct()
{
parent::__construct('test', false);
Expand All @@ -17,9 +23,9 @@ public function __construct()
public function registerBundles(): iterable
{
return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Tbbc\MoneyBundle\TbbcMoneyBundle(),
yield new FrameworkBundle(),
yield new DoctrineBundle(),
yield new TbbcMoneyBundle(),
];
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Form/Type/SimpleMoneyTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected function getExtensions(): array
->getMock();
$pairManager->expects($this->any())
->method('getReferenceCurrencyCode')
->will($this->returnValue('EUR'));
->willReturn('EUR');

return [
new PreloadedExtension(
Expand Down
2 changes: 1 addition & 1 deletion Tests/Formatter/MoneyFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testFormatAmountWithCustomSeparators(): void
public function testAsFloatIsReturningAFloat(): void
{
$value = $this->formatter->asFloat($this->inputMoney);
$this->assertTrue(is_float($value));
$this->assertIsFloat($value);
}

public function testFormatCurrency(): void
Expand Down
3 changes: 2 additions & 1 deletion Tests/Pair/RatioProvider/AbstractRatioProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Money\Currency;
use PHPUnit\Framework\TestCase;
use Tbbc\MoneyBundle\Pair\RatioProviderInterface;
use Tbbc\MoneyBundle\MoneyException;

/**
* This class can be used to easily test your custom ratio providers.
Expand Down Expand Up @@ -45,7 +46,7 @@ public function testRatioFetching(): void

public function testExceptionForUnknownCurrency(): void
{
$this->expectException('Tbbc\MoneyBundle\MoneyException');
$this->expectException(MoneyException::class);
$this->ratioProvider->fetchRatio('ZZZ', 'USD');
}

Expand Down
3 changes: 2 additions & 1 deletion Tests/Pair/Storage/DoctrineStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ class DoctrineStorageTest extends KernelTestCase
use DatabaseTrait;

private ObjectManager $entityManager;
private DoctrineStorage $doctrineStorage;

public function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->entityManager = self::getContainer()->get('doctrine')->getManager();
$this->doctrineStorage = new DoctrineStorage($this->entityManager, 'USD');
$this->createDatabase();
self::createDatabase();
}

protected function tearDown(): void
Expand Down
15 changes: 8 additions & 7 deletions Tests/PairHistory/PairHistoryManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Tbbc\MoneyBundle\Pair\SaveRatioEvent;
use Tbbc\MoneyBundle\PairHistory\PairHistoryManager;
use Tbbc\MoneyBundle\Tests\DatabaseTrait;
use Tbbc\MoneyBundle\Entity\RatioHistory;

class PairHistoryManagerTest extends KernelTestCase
{
Expand All @@ -29,7 +30,7 @@ public function setUp(): void
$this->em,
'EUR'
);
$this->ratioHistoryRepo = $this->em->getRepository('Tbbc\MoneyBundle\Entity\RatioHistory');
$this->ratioHistoryRepo = $this->em->getRepository(RatioHistory::class);
$this->createDatabase();
}

Expand All @@ -46,12 +47,12 @@ public function testSaveRatioHistory(): void
$event = new SaveRatioEvent('EUR', 'USD', 1.25, new \DateTime('2012-07-08 12:00:00'));
$this->pairHistoryManager->listenSaveRatioEvent($event);
$ratioHistoryList = $this->ratioHistoryRepo->findAll();
$this->assertSame(1, count($ratioHistoryList));
$this->assertCount(1, $ratioHistoryList);

$event = new SaveRatioEvent('EUR', 'USD', 1.50, new \DateTime('2012-07-08 13:00:00'));
$this->pairHistoryManager->listenSaveRatioEvent($event);
$ratioHistoryList = $this->ratioHistoryRepo->findAll();
$this->assertSame(2, count($ratioHistoryList));
$this->assertCount(2, $ratioHistoryList);
}

public function testGetRatioList(): void
Expand All @@ -64,7 +65,7 @@ public function testGetRatioList(): void
$this->pairHistoryManager->listenSaveRatioEvent($event);

$ratioList = $this->pairHistoryManager->getRatioHistory('USD', null, null);
$this->assertSame(3, count($ratioList));
$this->assertCount(3, $ratioList);
$this->assertSame(1.25, $ratioList[0]['ratio']);
$this->assertSame(1.50, $ratioList[1]['ratio']);
$this->assertSame(1.75, $ratioList[2]['ratio']);
Expand All @@ -73,9 +74,9 @@ public function testGetRatioList(): void
$this->assertSame('2012-07-08 14:00:00', $ratioList[2]['savedAt']->format('Y-m-d H:i:s'));

$ratioList = $this->pairHistoryManager->getRatioHistory('USD', new \DateTime('2012-07-08 12:30:00'), null);
$this->assertSame(2, count($ratioList));
$this->assertCount(2, $ratioList);
$ratioList = $this->pairHistoryManager->getRatioHistory('USD', new \DateTime('2012-07-08 12:30:00'), new \DateTime('2012-07-08 13:30:00'));
$this->assertSame(1, count($ratioList));
$this->assertCount(1, $ratioList);
}

public function testGetRatio(): void
Expand All @@ -98,7 +99,7 @@ public function testGetRatio(): void

$ratio = $this->pairHistoryManager->getRatioAtDate('EUR', new \DateTime('2011-07-10 12:30:00'));
$this->assertSame(1.0, $ratio);
$this->assertTrue(is_float($ratio));
$this->assertIsFloat($ratio);
}

public function testGetRatioException(): void
Expand Down
6 changes: 6 additions & 0 deletions change-log-6.0-and-versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ Versions from 6.0
### TBD : updates for 6.0.0 version

**New features**
- Bumped minimum PHP version to PHP ^8.1
- Add support for MongoDB

**BC breaking changes**
- Drop `symfony/templating` and template function (use twig)

**Internal Developer things**
- Drop PHPUnit 9 support
- bump dev dependencies
- Migrate phpUnit config to version 10.

18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-curl" : "*",
"ext-intl": "*",
"ext-simplexml": "*",
Expand All @@ -38,14 +38,14 @@
"require-dev": {
"ext-sqlite3": "*",
"symfony/browser-kit": "^5.4|^6.0|^7.0",
"doctrine/doctrine-bundle": "^1.12|^2.0",
johanwilfer marked this conversation as resolved.
Show resolved Hide resolved
"doctrine/orm": "^2.7",
"florianv/exchanger": "^2.0",
"doctrine/doctrine-bundle": "^2.11",
"doctrine/orm": "^2.11",
"florianv/exchanger": "^2.8.1",
"php-http/message": "^1.0",
"php-http/guzzle6-adapter": "^2.0",
"vimeo/psalm": "^4.13 | ^5.20",
"php-http/guzzle7-adapter": "^1.0",
"vimeo/psalm": "^5.20",
"symfony/phpunit-bridge": "^5.4|^6.0|^7.0",
"phpunit/phpunit": "^9.6|^10.5",
"phpunit/phpunit": "^10.5.9",
"symfony/yaml": "^5.4|^6.0|^7.0",
"http-interop/http-factory-guzzle": "^1.2"
},
Expand All @@ -61,8 +61,8 @@
]
},
"suggest": {
"doctrine/doctrine-bundle": "~1.1",
"doctrine/orm": "~2.7",
"doctrine/doctrine-bundle": "~2.11",
"doctrine/orm": "~2.17",
"florianv/exchanger": "Exchanger is a PHP framework to work with currency exchange rates from various services."
},
"config": {
Expand Down
39 changes: 20 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="Tests/bootstrap.php"
colors="true"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd">
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
>
<php>
<server name="KERNEL_DIR" value="tests"/>
<env name="KERNEL_CLASS" value="Tbbc\MoneyBundle\Tests\AppKernel"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
</php>

<php>
<server name="KERNEL_DIR" value="tests"/>
<env name="KERNEL_CLASS" value="Tbbc\MoneyBundle\Tests\AppKernel"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
</php>
<testsuites>
<testsuite name="TbbcMoneyBundle test suite">
<directory>Tests</directory>
</testsuite>
</testsuites>

<testsuites>
<testsuite name="TbbcMoneyBundle test suite">
<directory>Tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>src</directory>
</include>
<exclude>
<directory>src/DependencyInjection</directory>
</exclude>
</source>

<coverage>
<include>
<directory>src</directory>
</include>
<exclude>
<directory>src/DependencyInjection</directory>
</exclude>
</coverage>
</phpunit>
4 changes: 4 additions & 0 deletions src/Pair/RatioProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Tbbc\MoneyBundle\Pair;

use Tbbc\MoneyBundle\MoneyException;

/**
* This interface is used to define the way any ratio provider has to work.
*
Expand All @@ -24,6 +26,8 @@ interface RatioProviderInterface
*
* @param string $referenceCurrencyCode (ex: "EUR")
* @param string $currencyCode (ex: "USD")
*
* @throws MoneyException
*/
public function fetchRatio(string $referenceCurrencyCode, string $currencyCode): float;
}
Loading