Skip to content

Commit 3c954e4

Browse files
committed
Update dependencies to support PSR Simple Cache v2/v3 and replace ArrayCachePool with PsrCache wrapping yii\caching\ArrayCache in FormulaEngine
1 parent 196e10e commit 3c954e4

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
"php": "^8.3",
4747
"moneyphp/money": "^3.0 | ^4.0",
4848
"hiqdev/php-units": "dev-master",
49-
"psr/simple-cache": "^1.0",
50-
"cache/array-adapter": "^1.2"
49+
"psr/simple-cache": "^2.0 | ^3.0"
5150
},
5251
"require-dev": {
5352
"php": "^8.3",

tests/behat/bootstrap/FeatureContext.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
namespace hiqdev\php\billing\tests\behat\bootstrap;
1212

1313
use Behat\Behat\Context\Context;
14-
use Behat\Behat\Tester\Exception\PendingException;
15-
use Cache\Adapter\PHPArray\ArrayCachePool;
1614
use Closure;
1715
use DateTimeImmutable;
1816
use Exception;
@@ -34,14 +32,15 @@
3432
use hiqdev\php\billing\tests\support\order\SimpleBilling;
3533
use hiqdev\php\billing\type\Type;
3634
use hiqdev\php\units\Quantity;
37-
use hiqdev\php\units\Unit;
35+
use hiqdev\yii\compat\PsrCache;
3836
use Money\Currencies\ISOCurrencies;
3937
use Money\Currency;
4038
use Money\Money;
4139
use Money\Parser\DecimalMoneyParser;
4240
use NumberFormatter;
4341
use PHPUnit\Framework\Assert;
4442
use ReflectionClass;
43+
use yii\caching\ArrayCache;
4544

4645
/**
4746
* Defines application features from the specific context.
@@ -224,7 +223,8 @@ public function formulaContinues(string $formula): void
224223
protected function getFormulaEngine()
225224
{
226225
if ($this->engine === null) {
227-
$this->engine = new FormulaEngine(new ArrayCachePool());
226+
$cache = new PsrCache(new ArrayCache());
227+
$this->engine = new FormulaEngine($cache);
228228
}
229229

230230
return $this->engine;

tests/unit/formula/FormulaEngineTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010

1111
namespace hiqdev\php\billing\tests\unit\formula;
1212

13-
use Cache\Adapter\PHPArray\ArrayCachePool;
1413
use DateTimeImmutable;
1514
use hiqdev\php\billing\charge\modifiers\addons\MonthPeriod;
1615
use hiqdev\php\billing\charge\modifiers\addons\Reason;
1716
use hiqdev\php\billing\charge\modifiers\addons\Since;
1817
use hiqdev\php\billing\charge\modifiers\FixedDiscount;
1918
use hiqdev\php\billing\charge\modifiers\Installment;
2019
use hiqdev\php\billing\formula\FormulaEngine;
20+
use hiqdev\yii\compat\PsrCache;
2121
use PHPUnit\Framework\TestCase;
22+
use yii\caching\ArrayCache;
2223

2324
/**
2425
* @author Andrii Vasyliev <sol@hiqdev.com>
@@ -32,7 +33,8 @@ class FormulaEngineTest extends TestCase
3233

3334
public function setUp(): void
3435
{
35-
$this->engine = new FormulaEngine(new ArrayCachePool());
36+
$cache = new PsrCache(new ArrayCache());
37+
$this->engine = new FormulaEngine($cache);
3638
}
3739

3840
public function testSimpleDiscount()

0 commit comments

Comments
 (0)