From 47cb20c9503ca5c4a3a8da123c202f1e2b56888f Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Wed, 31 Jan 2024 09:37:47 +0100 Subject: [PATCH 1/4] feat: drop support for PHP < 8.1 --- .github/workflows/code_checks.yaml | 4 +- Tests/Form/Type/SimpleMoneyTypeTest.php | 2 +- Tests/Formatter/MoneyFormatterTest.php | 2 +- .../RatioProvider/AbstractRatioProvider.php | 3 +- Tests/Pair/Storage/DoctrineStorageTest.php | 3 +- Tests/PairHistory/PairHistoryManagerTest.php | 15 +++---- composer.json | 18 ++++----- phpunit.xml.dist | 39 ++++++++++--------- 8 files changed, 45 insertions(+), 41 deletions(-) diff --git a/.github/workflows/code_checks.yaml b/.github/workflows/code_checks.yaml index b7bfc793..a6a4098a 100644 --- a/.github/workflows/code_checks.yaml +++ b/.github/workflows/code_checks.yaml @@ -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' diff --git a/Tests/Form/Type/SimpleMoneyTypeTest.php b/Tests/Form/Type/SimpleMoneyTypeTest.php index bfd0097a..57c20e2d 100644 --- a/Tests/Form/Type/SimpleMoneyTypeTest.php +++ b/Tests/Form/Type/SimpleMoneyTypeTest.php @@ -122,7 +122,7 @@ protected function getExtensions(): array ->getMock(); $pairManager->expects($this->any()) ->method('getReferenceCurrencyCode') - ->will($this->returnValue('EUR')); + ->willReturn('EUR'); return [ new PreloadedExtension( diff --git a/Tests/Formatter/MoneyFormatterTest.php b/Tests/Formatter/MoneyFormatterTest.php index c2723732..464b55d3 100644 --- a/Tests/Formatter/MoneyFormatterTest.php +++ b/Tests/Formatter/MoneyFormatterTest.php @@ -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 diff --git a/Tests/Pair/RatioProvider/AbstractRatioProvider.php b/Tests/Pair/RatioProvider/AbstractRatioProvider.php index 673730df..82f1715c 100644 --- a/Tests/Pair/RatioProvider/AbstractRatioProvider.php +++ b/Tests/Pair/RatioProvider/AbstractRatioProvider.php @@ -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. @@ -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'); } diff --git a/Tests/Pair/Storage/DoctrineStorageTest.php b/Tests/Pair/Storage/DoctrineStorageTest.php index e5859e05..b0c4a36e 100644 --- a/Tests/Pair/Storage/DoctrineStorageTest.php +++ b/Tests/Pair/Storage/DoctrineStorageTest.php @@ -15,6 +15,7 @@ class DoctrineStorageTest extends KernelTestCase use DatabaseTrait; private ObjectManager $entityManager; + private DoctrineStorage $doctrineStorage; public function setUp(): void { @@ -22,7 +23,7 @@ public function setUp(): void self::bootKernel(); $this->entityManager = self::getContainer()->get('doctrine')->getManager(); $this->doctrineStorage = new DoctrineStorage($this->entityManager, 'USD'); - $this->createDatabase(); + self::createDatabase(); } protected function tearDown(): void diff --git a/Tests/PairHistory/PairHistoryManagerTest.php b/Tests/PairHistory/PairHistoryManagerTest.php index eda31b06..04a9c463 100644 --- a/Tests/PairHistory/PairHistoryManagerTest.php +++ b/Tests/PairHistory/PairHistoryManagerTest.php @@ -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 { @@ -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(); } @@ -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 @@ -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']); @@ -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 @@ -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 diff --git a/composer.json b/composer.json index ad1ea7ed..c6d4edaa 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "ext-curl" : "*", "ext-intl": "*", "ext-simplexml": "*", @@ -39,14 +39,14 @@ "require-dev": { "ext-sqlite3": "*", "symfony/browser-kit": "^5.4|^6.0|^7.0", - "doctrine/doctrine-bundle": "^1.12|^2.0", - "doctrine/orm": "^2.7|^3.0", - "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" }, @@ -62,8 +62,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": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aebb4556..edced39f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,26 +2,27 @@ + xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" +> + + + + + - - - - - + + + Tests + + - - - Tests - - + + + src + + + src/DependencyInjection + + - - - src - - - src/DependencyInjection - - From 04db23621e6ba1dfdf93627c9fe73fc31246dd98 Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Wed, 31 Jan 2024 09:37:47 +0100 Subject: [PATCH 2/4] feat: drop support for PHP < 8.1 --- .github/workflows/code_checks.yaml | 4 +- Tests/Form/Type/SimpleMoneyTypeTest.php | 2 +- Tests/Formatter/MoneyFormatterTest.php | 2 +- .../RatioProvider/AbstractRatioProvider.php | 3 +- Tests/Pair/Storage/DoctrineStorageTest.php | 3 +- Tests/PairHistory/PairHistoryManagerTest.php | 15 +++---- composer.json | 18 ++++----- phpunit.xml.dist | 39 ++++++++++--------- 8 files changed, 45 insertions(+), 41 deletions(-) diff --git a/.github/workflows/code_checks.yaml b/.github/workflows/code_checks.yaml index b7bfc793..a6a4098a 100644 --- a/.github/workflows/code_checks.yaml +++ b/.github/workflows/code_checks.yaml @@ -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' diff --git a/Tests/Form/Type/SimpleMoneyTypeTest.php b/Tests/Form/Type/SimpleMoneyTypeTest.php index bfd0097a..57c20e2d 100644 --- a/Tests/Form/Type/SimpleMoneyTypeTest.php +++ b/Tests/Form/Type/SimpleMoneyTypeTest.php @@ -122,7 +122,7 @@ protected function getExtensions(): array ->getMock(); $pairManager->expects($this->any()) ->method('getReferenceCurrencyCode') - ->will($this->returnValue('EUR')); + ->willReturn('EUR'); return [ new PreloadedExtension( diff --git a/Tests/Formatter/MoneyFormatterTest.php b/Tests/Formatter/MoneyFormatterTest.php index c2723732..464b55d3 100644 --- a/Tests/Formatter/MoneyFormatterTest.php +++ b/Tests/Formatter/MoneyFormatterTest.php @@ -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 diff --git a/Tests/Pair/RatioProvider/AbstractRatioProvider.php b/Tests/Pair/RatioProvider/AbstractRatioProvider.php index 673730df..82f1715c 100644 --- a/Tests/Pair/RatioProvider/AbstractRatioProvider.php +++ b/Tests/Pair/RatioProvider/AbstractRatioProvider.php @@ -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. @@ -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'); } diff --git a/Tests/Pair/Storage/DoctrineStorageTest.php b/Tests/Pair/Storage/DoctrineStorageTest.php index e5859e05..b0c4a36e 100644 --- a/Tests/Pair/Storage/DoctrineStorageTest.php +++ b/Tests/Pair/Storage/DoctrineStorageTest.php @@ -15,6 +15,7 @@ class DoctrineStorageTest extends KernelTestCase use DatabaseTrait; private ObjectManager $entityManager; + private DoctrineStorage $doctrineStorage; public function setUp(): void { @@ -22,7 +23,7 @@ public function setUp(): void self::bootKernel(); $this->entityManager = self::getContainer()->get('doctrine')->getManager(); $this->doctrineStorage = new DoctrineStorage($this->entityManager, 'USD'); - $this->createDatabase(); + self::createDatabase(); } protected function tearDown(): void diff --git a/Tests/PairHistory/PairHistoryManagerTest.php b/Tests/PairHistory/PairHistoryManagerTest.php index eda31b06..04a9c463 100644 --- a/Tests/PairHistory/PairHistoryManagerTest.php +++ b/Tests/PairHistory/PairHistoryManagerTest.php @@ -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 { @@ -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(); } @@ -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 @@ -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']); @@ -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 @@ -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 diff --git a/composer.json b/composer.json index ad1ea7ed..c6d4edaa 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "ext-curl" : "*", "ext-intl": "*", "ext-simplexml": "*", @@ -39,14 +39,14 @@ "require-dev": { "ext-sqlite3": "*", "symfony/browser-kit": "^5.4|^6.0|^7.0", - "doctrine/doctrine-bundle": "^1.12|^2.0", - "doctrine/orm": "^2.7|^3.0", - "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" }, @@ -62,8 +62,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": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aebb4556..edced39f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,26 +2,27 @@ + xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" +> + + + + + - - - - - + + + Tests + + - - - Tests - - + + + src + + + src/DependencyInjection + + - - - src - - - src/DependencyInjection - - From 8fc1c87731e12fc3e87e1ea8907b88ba1826a64d Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Fri, 23 Feb 2024 19:41:13 +0100 Subject: [PATCH 3/4] feat: drop support for PHP < 8.1 --- Tests/AppKernel.php | 12 +++++++++--- src/Pair/RatioProviderInterface.php | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Tests/AppKernel.php b/Tests/AppKernel.php index 34202efe..e437d634 100644 --- a/Tests/AppKernel.php +++ b/Tests/AppKernel.php @@ -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); @@ -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(), ]; } diff --git a/src/Pair/RatioProviderInterface.php b/src/Pair/RatioProviderInterface.php index 61069938..b652848c 100644 --- a/src/Pair/RatioProviderInterface.php +++ b/src/Pair/RatioProviderInterface.php @@ -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. * @@ -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; } From 35e7f12102a24bfb25f71683e63e8166f7bf659e Mon Sep 17 00:00:00 2001 From: Christopher Georg Date: Sat, 24 Feb 2024 18:40:32 +0100 Subject: [PATCH 4/4] feat: drop support for PHP < 8.1 --- change-log-6.0-and-versions.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/change-log-6.0-and-versions.md b/change-log-6.0-and-versions.md index 177052d5..92267416 100644 --- a/change-log-6.0-and-versions.md +++ b/change-log-6.0-and-versions.md @@ -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. +