From 030e3317752d7645520e6e0cb2605ca7402cc693 Mon Sep 17 00:00:00 2001 From: Alberto Rodriguez Date: Fri, 25 Jun 2021 17:13:12 -0400 Subject: [PATCH 1/8] test set --- tests/TestCase/Utility/MoneyUtilTest.php | 159 ++++++++++++++++++ .../TestCase/View/Helper/MoneyHelperTest.php | 32 +++- .../TestCase/View/Widget/MoneyWidgetTest.php | 55 ++++++ 3 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 tests/TestCase/Utility/MoneyUtilTest.php create mode 100644 tests/TestCase/View/Widget/MoneyWidgetTest.php diff --git a/tests/TestCase/Utility/MoneyUtilTest.php b/tests/TestCase/Utility/MoneyUtilTest.php new file mode 100644 index 0000000..d925412 --- /dev/null +++ b/tests/TestCase/Utility/MoneyUtilTest.php @@ -0,0 +1,159 @@ +MoneyHelper = new MoneyHelper($view); + } + + /** + * tearDown method + * + * @return void + */ + public function tearDown(): void + { + parent::tearDown(); + } + + + public function testMoney(): void + { + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + MoneyUtil::money(100) + ); + + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + MoneyUtil::money(100, true) + ); + + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + MoneyUtil::money('100') + ); + + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + MoneyUtil::money(-100) + ); + + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + MoneyUtil::money(100.15) + ); + } + + public function testFloat(): void + { + $money = MoneyUtil::money(100.15); + $this->assertEquals(100.15, MoneyUtil::float($money)); + + $money = MoneyUtil::money(200); + $this->assertEquals(200.00, MoneyUtil::float($money)); + } + + public function testFormat() + { + $money = MoneyUtil::money(100.15); + $this->assertEquals('$100.15', MoneyUtil::format($money)); + + $money = MoneyUtil::money(200); + $this->assertEquals('$200.00', MoneyUtil::format($money)); + } + + public function testZero() + { + $money = MoneyUtil::zero(); + + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + $money + ); + + $this->assertEquals('$0.00', $money->__toString()); + } + + + public function testGreaterThanZero() + { + $money = MoneyUtil::money(100); + $this->assertTrue(MoneyUtil::greaterThanZero($money)); + + $money = MoneyUtil::money(-100); + $this->assertFalse(MoneyUtil::greaterThanZero($money)); + } + + public function testGreaterThanOrEqualZero() + { + $money = MoneyUtil::money(100); + $this->assertTrue(MoneyUtil::greaterThanOrEqualZero($money)); + + $money = MoneyUtil::money(-100); + $this->assertFalse(MoneyUtil::greaterThanOrEqualZero($money)); + + $this->assertTrue(MoneyUtil::greaterThanOrEqualZero(MoneyUtil::zero())); + } + + + public function testLessThanZero() + { + $money = MoneyUtil::money(100); + $this->assertFalse(MoneyUtil::lessThanZero($money)); + + $money = MoneyUtil::money(-100); + $this->assertTrue(MoneyUtil::lessThanZero($money)); + } + + public function testLessThanOrEqualZero() + { + $money = MoneyUtil::money(100); + $this->assertFalse(MoneyUtil::lessThanOrEqualZero($money)); + + $money = MoneyUtil::money(-100); + $this->assertTrue(MoneyUtil::lessThanOrEqualZero($money)); + + $this->assertTrue(MoneyUtil::lessThanOrEqualZero(MoneyUtil::zero())); + } + + public function testEqualZero() + { + $money = MoneyUtil::money(100); + $this->assertFalse(MoneyUtil::equalZero($money)); + + $this->assertTrue(MoneyUtil::equalZero(MoneyUtil::zero())); + } + +} \ No newline at end of file diff --git a/tests/TestCase/View/Helper/MoneyHelperTest.php b/tests/TestCase/View/Helper/MoneyHelperTest.php index efd7585..fdcb0d9 100644 --- a/tests/TestCase/View/Helper/MoneyHelperTest.php +++ b/tests/TestCase/View/Helper/MoneyHelperTest.php @@ -6,6 +6,7 @@ use CakeDC\Money\View\Helper\MoneyHelper; use Cake\TestSuite\TestCase; use Cake\View\View; +use CakeDC\Money\Utility\MoneyUtil; /** * CakeDC\Money\View\Helper\MoneyHelper Test Case @@ -39,7 +40,6 @@ public function setUp(): void public function tearDown(): void { unset($this->MoneyHelper); - parent::tearDown(); } @@ -50,6 +50,34 @@ public function tearDown(): void */ public function testCurrency(): void { - $this->markTestIncomplete('Not implemented yet.'); + $this->assertEquals( + '$100.00', + $this->MoneyHelper->currency(100) + ); + + $this->assertEquals( + '$100.00', + $this->MoneyHelper->currency('100') + ); + + $this->assertEquals( + '-$100.00', + $this->MoneyHelper->currency(-100) + ); + + $this->assertEquals( + '-$100.00', + $this->MoneyHelper->currency("-100") + ); + + $this->assertEquals( + '$100.00', + $this->MoneyHelper->currency(MoneyUtil::money(100)) + ); + + $this->assertEquals( + '$100.00', + $this->MoneyHelper->currency(MoneyUtil::money('100')) + ); } } diff --git a/tests/TestCase/View/Widget/MoneyWidgetTest.php b/tests/TestCase/View/Widget/MoneyWidgetTest.php new file mode 100644 index 0000000..d6c7f4d --- /dev/null +++ b/tests/TestCase/View/Widget/MoneyWidgetTest.php @@ -0,0 +1,55 @@ +FormHelper = new FormHelper($view); + $this->MoneyHelper = new MoneyHelper($view); + } + + /** + * tearDown method + * + * @return void + */ + public function tearDown(): void + { + unset($this->MoneyHelper); + parent::tearDown(); + } + + public function testInputMoneyWidget(): void + { + $this->assertTextContains('type="number"', $this->FormHelper->money('money')); + } + +} \ No newline at end of file From c9f03290c865be75f56ddbc174947596798451ab Mon Sep 17 00:00:00 2001 From: Alberto Rodriguez Date: Thu, 1 Jul 2021 17:18:37 -0400 Subject: [PATCH 2/8] money test suit, minor fixs --- src/Money.php | 19 +++++ src/Utility/MoneyUtil.php | 10 +-- src/View/Helper/MoneyHelper.php | 10 ++- tests/TestCase/Utility/MoneyUtilTest.php | 73 ++++++++++++++++--- .../TestCase/View/Widget/MoneyWidgetTest.php | 8 +- 5 files changed, 97 insertions(+), 23 deletions(-) diff --git a/src/Money.php b/src/Money.php index b2b8c50..2ebc7cf 100644 --- a/src/Money.php +++ b/src/Money.php @@ -49,6 +49,8 @@ public function __construct(MoneyPHP $money) */ public function __call($name, $arguments) { + $arguments = self::processArguments($arguments); + return call_user_func_array([$this->_money, $name], $arguments); } @@ -59,6 +61,8 @@ public function __call($name, $arguments) */ public static function __callStatic($name, $arguments) { + $arguments = self::processArguments($arguments); + return new self(forward_static_call_array([MoneyPHP::class, $name], $arguments)); } @@ -69,4 +73,19 @@ public function __toString(): string { return MoneyUtil::format($this); } + + /** + * @param array $arguments + * @return array + */ + protected static function processArguments($arguments = []) + { + for ($i=0; $i < count($arguments); $i++) { + if ($arguments[$i] instanceof Money) { + $arguments[$i] = $arguments[$i]->getMoney(); + } + } + + return $arguments; + } } diff --git a/src/Utility/MoneyUtil.php b/src/Utility/MoneyUtil.php index 7f88e63..6f50a03 100644 --- a/src/Utility/MoneyUtil.php +++ b/src/Utility/MoneyUtil.php @@ -10,14 +10,10 @@ */ namespace CakeDC\Money\Utility; -use Cake\Core\Configure; -use Cake\Error\Debugger; -use CakeDC\Accounting\Database\Type\MoneyType; use Money\Currencies\BitcoinCurrencies; use Money\Currencies\ISOCurrencies; use Money\Currency; use Money\Formatter\BitcoinMoneyFormatter; -use Money\Formatter\DecimalMoneyFormatter; use Money\Formatter\IntlMoneyFormatter; use CakeDC\Money\Money; use Money\MoneyFormatter; @@ -31,7 +27,9 @@ */ class MoneyUtil { - /** @var MoneyFormatter */ + /** + * @var MoneyFormatter + */ protected static $_moneyFormatters = []; /** @@ -56,7 +54,7 @@ public static function money($value, $fromDb = false) : ?Money if (!isset($parts[1])) { $parts[1] = '00'; } - $decimalLength = strlen($parts[1] ?? '') ; + $decimalLength = strlen($parts[1] ?? ''); if ($decimalLength == 1) { $parts[1] = $parts[1] . '0'; diff --git a/src/View/Helper/MoneyHelper.php b/src/View/Helper/MoneyHelper.php index 0a1f2c4..7dbd8e7 100644 --- a/src/View/Helper/MoneyHelper.php +++ b/src/View/Helper/MoneyHelper.php @@ -43,14 +43,16 @@ public function currency($value): string { $class = ''; if ($value instanceof Money) { - $value = MoneyUtil::format($value); + $output = MoneyUtil::format($value); } else { - $value = $this->Number->currency($value); + $output = $this->Number->currency($value); } - if ($value < 0) { + if ((is_numeric($value) && $value < 0) || + ($value instanceof Money && MoneyUtil::lessThanZero($value)) + ) { $class = 'negative-balance'; } - return $this->Html->tag('span', $value, ['class' => $class]); + return $this->Html->tag('span', $output, ['class' => $class]); } } diff --git a/tests/TestCase/Utility/MoneyUtilTest.php b/tests/TestCase/Utility/MoneyUtilTest.php index d925412..eae0726 100644 --- a/tests/TestCase/Utility/MoneyUtilTest.php +++ b/tests/TestCase/Utility/MoneyUtilTest.php @@ -3,15 +3,10 @@ namespace CakeDC\Money\Test\TestCase\Utility; -//use CakeDC\Money\View\Helper\MoneyHelper; +use Cake\Core\Configure; use Cake\TestSuite\TestCase; use CakeDC\Money\Utility\MoneyUtil; -//use Cake\View\View; -//use CakeDC\Money\Money; -//use Money\Currency; -//use Money\Money as MoneyMoney; - /** * CakeDC\Money\View\Helper\MoneyHelper Test Case */ @@ -48,7 +43,7 @@ public function tearDown(): void } - public function testMoney(): void + public function testMoneyNumericValue(): void { $this->assertInstanceOf( \CakeDC\Money\Money::class, @@ -60,6 +55,24 @@ public function testMoney(): void MoneyUtil::money(100, true) ); + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + MoneyUtil::money(-100) + ); + + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + MoneyUtil::money(100.15) + ); + + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + MoneyUtil::money(100.1) + ); + } + + public function testMoneyStringValue(): void + { $this->assertInstanceOf( \CakeDC\Money\Money::class, MoneyUtil::money('100') @@ -67,15 +80,48 @@ public function testMoney(): void $this->assertInstanceOf( \CakeDC\Money\Money::class, - MoneyUtil::money(-100) + MoneyUtil::money('100', true) ); $this->assertInstanceOf( \CakeDC\Money\Money::class, - MoneyUtil::money(100.15) + MoneyUtil::money('-100') + ); + + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + MoneyUtil::money('100.15') ); } + public function testMoneyNullValue(): void + { + $this->assertNull( + MoneyUtil::money('') + ); + + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + MoneyUtil::money(0) + ); + } + + public function testMoneyClassValue(): void + { + $money = MoneyUtil::money(10); + + $this->assertInstanceOf( + \CakeDC\Money\Money::class, + MoneyUtil::money($money) + ); + + $this->assertEquals( + $money, + MoneyUtil::money($money) + ); + } + + public function testFloat(): void { $money = MoneyUtil::money(100.15); @@ -94,6 +140,15 @@ public function testFormat() $this->assertEquals('$200.00', MoneyUtil::format($money)); } + //public function testFormatCurrencies() + //{ + // $money = MoneyUtil::money(100.15); + // $this->assertEquals('$100.15', MoneyUtil::format($money)); + // + // $money = MoneyUtil::money(200); + // $this->assertEquals('$200.00', MoneyUtil::format($money)); + //} + public function testZero() { $money = MoneyUtil::zero(); diff --git a/tests/TestCase/View/Widget/MoneyWidgetTest.php b/tests/TestCase/View/Widget/MoneyWidgetTest.php index d6c7f4d..0d2d56a 100644 --- a/tests/TestCase/View/Widget/MoneyWidgetTest.php +++ b/tests/TestCase/View/Widget/MoneyWidgetTest.php @@ -47,9 +47,9 @@ public function tearDown(): void parent::tearDown(); } - public function testInputMoneyWidget(): void - { - $this->assertTextContains('type="number"', $this->FormHelper->money('money')); - } + //public function testInputMoneyWidget(): void + //{ + // $this->assertTextContains('type="number"', $this->FormHelper->money('money')); + //} } \ No newline at end of file From 4da861152a1002044bdd193514886a464beffa24 Mon Sep 17 00:00:00 2001 From: Alberto Rodriguez Date: Fri, 2 Jul 2021 15:11:17 -0400 Subject: [PATCH 3/8] add MoneyWidgetTest --- .../TestCase/View/Widget/MoneyWidgetTest.php | 91 ++++++++++++++++--- 1 file changed, 77 insertions(+), 14 deletions(-) diff --git a/tests/TestCase/View/Widget/MoneyWidgetTest.php b/tests/TestCase/View/Widget/MoneyWidgetTest.php index 0d2d56a..7df1411 100644 --- a/tests/TestCase/View/Widget/MoneyWidgetTest.php +++ b/tests/TestCase/View/Widget/MoneyWidgetTest.php @@ -3,19 +3,26 @@ namespace CakeDC\Money\Test\TestCase\View\Helper; -use CakeDC\Money\View\Helper\MoneyHelper; use Cake\TestSuite\TestCase; -use Cake\View\Helper\FormHelper; -use Cake\View\View; -use CakeDC\Money\Money; -use Money\Currency; -use Money\Money as MoneyMoney; +use Cake\View\StringTemplate; +use CakeDC\Money\Utility\MoneyUtil; +use CakeDC\Money\View\Widget\MoneyWidget; /** * CakeDC\Money\View\Helper\MoneyHelper Test Case */ class MoneyWidgetTest extends TestCase { + /** + * @var \Cake\View\StringTemplate + */ + public $templates; + + /** + * @var \Cake\View\Form\ContextInterface + */ + public $context; + /** * Test subject * @@ -31,9 +38,11 @@ class MoneyWidgetTest extends TestCase public function setUp(): void { parent::setUp(); - $view = new View(); - $this->FormHelper = new FormHelper($view); - $this->MoneyHelper = new MoneyHelper($view); + $templates = [ + 'input' => '', + ]; + $this->templates = new StringTemplate($templates); + $this->context = $this->getMockBuilder('Cake\View\Form\ContextInterface')->getMock(); } /** @@ -43,13 +52,67 @@ public function setUp(): void */ public function tearDown(): void { - unset($this->MoneyHelper); + unset($this->templates); + unset($this->context); parent::tearDown(); } - //public function testInputMoneyWidget(): void - //{ - // $this->assertTextContains('type="number"', $this->FormHelper->money('money')); - //} + public function testInputMoneyWidget(): void + { + $money = new MoneyWidget($this->templates); + $data = [ + 'name' => 'amount', + 'val' => 10, + 'templateVars' => [], + ]; + $this->assertTextContains('type="number"', $money->render($data, $this->context)); + + $data = [ + 'name' => 'amount', + 'val' => MoneyUtil::money(10), + 'templateVars' => [], + ]; + $this->assertTextContains('type="number"', $money->render($data, $this->context)); + } + + public function testInputMoneyWidgetMaxMin(): void + { + $money = new MoneyWidget($this->templates); + $data = [ + 'name' => 'amount', + 'val' => 10, + 'max' => 15, + 'min' => 5, + 'templateVars' => [], + ]; + + $this->assertTextContains('max="15"', $money->render($data, $this->context)); + $this->assertTextContains('min="5"', $money->render($data, $this->context)); + $money = new MoneyWidget($this->templates); + $data = [ + 'name' => 'amount', + 'val' => MoneyUtil::money(10), + 'max' => MoneyUtil::money(15), + 'min' => MoneyUtil::money(5), + 'templateVars' => [], + ]; + + $this->assertTextContains('max="15"', $money->render($data, $this->context)); + $this->assertTextContains('min="5"', $money->render($data, $this->context)); + } + + public function testSecureFields(): void + { + $money = new MoneyWidget($this->templates); + $data = [ + 'name' => 'amount', + 'val' => 10, + 'max' => 15, + 'min' => 5, + 'templateVars' => [], + ]; + + $this->assertTrue(in_array('amount', $money->secureFields($data))); + } } \ No newline at end of file From 8506c2211e5915a063298c43a7eae42ed30e775e Mon Sep 17 00:00:00 2001 From: Alberto Rodriguez Date: Fri, 2 Jul 2021 16:17:34 -0400 Subject: [PATCH 4/8] update test set --- src/Utility/MoneyUtil.php | 8 ++- .../TestCase/Database/Type/MoneyTypeTest.php | 72 +++++++++++++++++++ tests/TestCase/Utility/MoneyUtilTest.php | 43 ++++++++--- 3 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 tests/TestCase/Database/Type/MoneyTypeTest.php diff --git a/src/Utility/MoneyUtil.php b/src/Utility/MoneyUtil.php index 6f50a03..3813bdd 100644 --- a/src/Utility/MoneyUtil.php +++ b/src/Utility/MoneyUtil.php @@ -10,6 +10,7 @@ */ namespace CakeDC\Money\Utility; +use Cake\Core\Configure; use Money\Currencies\BitcoinCurrencies; use Money\Currencies\ISOCurrencies; use Money\Currency; @@ -62,8 +63,9 @@ public static function money($value, $fromDb = false) : ?Money $value = ltrim($parts[0] . $parts[1], '0'); } - - return Money::USD(!empty($value) ? str_replace(',', '', $value) : 0); + + $currency = Configure::read('Money.currency', 'USD'); + return Money::{$currency}(!empty($value) ? str_replace(',', '', $value) : 0); } /** @@ -106,7 +108,7 @@ protected static function _loadMoneyFormatter(Currency $currency) : MoneyFormatt } elseif ($currency->isAvailableWithin($bitcoin)) { $moneyFormatter = new BitcoinMoneyFormatter(7, $bitcoin); } else { - throw new \RuntimeException(sprintf('Cannot format currency \'%s\'. Only ISO currencies and Bitcoin are allowed.')); + throw new \RuntimeException(sprintf('Cannot format currency \'%s\'. Only ISO currencies and Bitcoin are allowed.', $currency)); } static::$_moneyFormatters[$currency->getCode()] = $moneyFormatter; return static::$_moneyFormatters[$currency->getCode()]; diff --git a/tests/TestCase/Database/Type/MoneyTypeTest.php b/tests/TestCase/Database/Type/MoneyTypeTest.php new file mode 100644 index 0000000..43b2053 --- /dev/null +++ b/tests/TestCase/Database/Type/MoneyTypeTest.php @@ -0,0 +1,72 @@ +moneyType = new MoneyType(); + $this->driver = $this->getMockBuilder('Cake\Database\Driver')->getMock(); + parent::setUp(); + } + + /** + * tearDown method + * + * @return void + */ + public function tearDown(): void + { + parent::tearDown(); + } + + public function testToPhp() + { + $this->assertNull($this->moneyType->toPHP(null, $this->driver)); + $this->assertInstanceOf(\CakeDC\Money\Money::class, $this->moneyType->toPHP(100, $this->driver)); + } + + public function testMarshal() + { + $this->assertNull($this->moneyType->marshal(null)); + $this->assertInstanceOf(\CakeDC\Money\Money::class, $this->moneyType->marshal(100)); + } + + public function testToDatabase() + { + $this->assertNull($this->moneyType->toDatabase(null, $this->driver)); + $this->assertEquals('10000', $this->moneyType->toDatabase(MoneyUtil::money(100), $this->driver)); + } + + public function testToDatabaseInvalidArgument() + { + $this->expectException(\InvalidArgumentException::class); + $this->moneyType->toDatabase(100, $this->driver); + } + + public function testToStatement() + { + $this->assertEquals(PDO::PARAM_NULL, $this->moneyType->toStatement(null, $this->driver)); + $this->assertEquals(PDO::PARAM_INT, $this->moneyType->toStatement(100, $this->driver)); + } + + +} \ No newline at end of file diff --git a/tests/TestCase/Utility/MoneyUtilTest.php b/tests/TestCase/Utility/MoneyUtilTest.php index eae0726..dcf7efb 100644 --- a/tests/TestCase/Utility/MoneyUtilTest.php +++ b/tests/TestCase/Utility/MoneyUtilTest.php @@ -6,6 +6,8 @@ use Cake\Core\Configure; use Cake\TestSuite\TestCase; use CakeDC\Money\Utility\MoneyUtil; +use Exception; +use RuntimeException; /** * CakeDC\Money\View\Helper\MoneyHelper Test Case @@ -27,9 +29,6 @@ class MoneyUtilTest extends TestCase public function setUp(): void { parent::setUp(); - - //$view = new View(); - //$this->MoneyHelper = new MoneyHelper($view); } /** @@ -140,14 +139,36 @@ public function testFormat() $this->assertEquals('$200.00', MoneyUtil::format($money)); } - //public function testFormatCurrencies() - //{ - // $money = MoneyUtil::money(100.15); - // $this->assertEquals('$100.15', MoneyUtil::format($money)); - // - // $money = MoneyUtil::money(200); - // $this->assertEquals('$200.00', MoneyUtil::format($money)); - //} + public function testFormatCurrencies() + { + Configure::write('Money.currency', 'EUR'); + + $money = MoneyUtil::money(100.15); + $this->assertEquals('€100.15', MoneyUtil::format($money)); + + $money = MoneyUtil::money('200'); + $this->assertEquals('€200.00', MoneyUtil::format($money)); + } + + public function testFormatBitcoin() + { + Configure::write('Money.currency', 'XBT'); + $money = MoneyUtil::money(1); + + $this->assertInstanceOf(\CakeDC\Money\Money::class, $money); + $this->assertEquals('Ƀ0.0000010', MoneyUtil::format($money)); + } + + public function testFormatOther() + { + try{ + Configure::write('Money.currency', 'NotCurrency'); + $money = MoneyUtil::money(100.15); + MoneyUtil::format($money); + } catch (\Exception $e){ + $this->assertInstanceOf(RuntimeException::class, $e); + } + } public function testZero() { From e78198a51c90e309cc0623bb2657bc7ec18ad6c4 Mon Sep 17 00:00:00 2001 From: Alberto Rodriguez Date: Thu, 8 Feb 2024 08:57:24 -0400 Subject: [PATCH 5/8] fix: fix deprecations on phpunit --- phpunit.xml.dist | 53 ++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e2b5c3a..5ccb5d2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,35 +1,22 @@ - - - - - - - - - - tests/TestCase/ - - - - - - - - - - - - - - - src/ - - - + + + + src/ + + + + + + + + + + tests/TestCase/ + + + + + + From d8b17a062e0577510bd43dd90d4f040047ced1a7 Mon Sep 17 00:00:00 2001 From: Alberto Rodriguez Date: Thu, 8 Feb 2024 10:23:20 -0400 Subject: [PATCH 6/8] update readme --- .gitignore | 1 + README.md | 42 +++++++++++++++++++++--------------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 244d127..2a55d71 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /config/Migrations/schema-dump-default.lock /vendor/ /.idea/ +/.phpunit.cache \ No newline at end of file diff --git a/README.md b/README.md index a08a980..5975d37 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -CakePHP Money Plugin -=================== +# CakePHP Money Plugin +

Software License @@ -22,45 +22,45 @@ It covers the following features: * Store Money objects onto database (as strings) * Marshal money objects into CakePHP entities. -Requirements ------------- +## Requirements * CakePHP 4.0.0+ * PHP 7.2+ -Versions and branches ---------------------- +## Versions and branches + +| CakePHP | CakeDC Money Plugin | Notes | +| :-------------: | :------------------------: | :---- | +| ^4.5 | [1.x](https://github.com/cakedc/money/tree/1.next-cake4) | stable | +| ^4.0 | [0.0.1](https://github.com/cakedc/money/tree/0.0.1) | deprecated | + +## Installation -| CakePHP | CakeDC Money Plugin | Tag | Notes | -| :-------------: | :------------------------: | :--: | :---- | -| ^4.0 | [0.1](https://github.com/cakedc/money/tree/1.next-cake4) | 0.0.1 | stable | +You can install this plugin into your CakePHP application using [composer](http://getcomposer.org). +The recommended way to install composer packages is: -Documentation -------------- +``` +composer require cakedc/cakephp-money +``` + +## Documentation For documentation, as well as tutorials, see the [Docs](Docs/Home.md) directory of this repository. -Support -------- +## Support For bugs and feature requests, please use the [issues](https://github.com/CakeDC/money/issues) section of this repository. Commercial support is also available, [contact us](https://www.cakedc.com/contact) for more information. -Contributing ------------- +## Contributing This repository follows the [CakeDC Plugin Standard](https://www.cakedc.com/plugin-standard). If you'd like to contribute new features, enhancements or bug fixes to the plugin, please read our [Contribution Guidelines](https://www.cakedc.com/contribution-guidelines) for detailed instructions. -License -------- +## License Copyright 2021 Cake Development Corporation (CakeDC). All rights reserved. Licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php) License. Redistributions of the source code included in this repository must retain the copyright notice found in each file. - -## To Do - -* Add Unit Tests From c7fe0af43e5c32fad20fdfb3b90701ef27de1423 Mon Sep 17 00:00:00 2001 From: Alberto Rodriguez Date: Thu, 8 Feb 2024 12:45:46 -0400 Subject: [PATCH 7/8] feat: update php versions on gh actions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3207304..4c636c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['7.2', '7.3', '7.4', '8.0'] + php-version: ['7.4', '8.0', '8.1', '8.2', '8.3'] db-type: [sqlite, mysql, pgsql] prefer-lowest: [''] From 3e22b3c1f3a8209e49ccdf1fc2f4b932262c3fa8 Mon Sep 17 00:00:00 2001 From: Alberto Rodriguez Date: Thu, 8 Feb 2024 13:11:59 -0400 Subject: [PATCH 8/8] update gb actions --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c636c5..812aa85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: jobs: testsuite: - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: @@ -66,7 +66,7 @@ jobs: if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp'; fi if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:postgres@127.0.0.1/postgres'; fi if [[ ${{ matrix.php-version }} == '7.4' ]]; then - export CODECOVERAGE=1 && vendor/bin/phpunit --verbose --coverage-clover=coverage.xml + export CODECOVERAGE=1 && vendor/bin/phpunit --coverage-clover=coverage.xml else vendor/bin/phpunit fi @@ -77,7 +77,7 @@ jobs: cs-stan: name: Coding Standard & Static Analysis - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2