Skip to content

Commit

Permalink
feat: drop support for PHP < 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris8934 committed Jan 31, 2024
1 parent f23eece commit 47cb20c
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 41 deletions.
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
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
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 @@ -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"
},
Expand All @@ -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": {
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>

0 comments on commit 47cb20c

Please sign in to comment.