diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ae35877 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,26 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.bat] +end_of_line = crlf + +[*.yml] +indent_size = 2 + +[*.xml] +indent_size = 2 + +[Makefile] +indent_style = tab + +[*.neon] +indent_style = tab \ No newline at end of file diff --git a/.gitignore b/.gitignore index 56b0dbd..85db205 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,41 @@ +/tmp +/vendor +/.idea +composer.lock +.php_cs* +/coverage +/config/Migrations/schema-dump-default.lock +*.pyc +docs/_build +tmp /composer.lock -/composer.phar -/phpunit.xml +*.diff +*.err +*.log +*.orig +*.rej +*.swo +*.swp +*.vi +*~ +.idea/* +nbproject/* +.vscode +.DS_Store +.cache +.phpunit.cache +.project +.settings +.svn +errors.err +tags +node_modules +package-lock.json /.phpunit.result.cache -/phpunit.phar -/config/Migrations/schema-dump-default.lock -/vendor/ -/.idea/ -/.phpunit.cache -/.ddev/ +/nbproject/ +/tools +/phpunit.xml +/webroot/css/style.css.map +/webroot/mix.js.map +/webroot/mix-manifest.json +.ddev/* diff --git a/.phive/phars.xml b/.phive/phars.xml new file mode 100644 index 0000000..9aa6dfe --- /dev/null +++ b/.phive/phars.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 63cedae..459e015 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.0.2] 2024-03-01 +- improved conde completion in `\CakeDC\Money\Money` class +- fixed issues reported by stan tools + ## [2.0.1] - 2024-02-23 -- Ported changes applied in tag `1.0.1` +- Ported changes applied in tag `1.0.1` ## [1.0.1] - 2024-02-23 diff --git a/README.md b/README.md index a76268e..43ef560 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,11 @@ It covers the following features: ## Versions and branches -| CakePHP | CakeDC Money Plugin | Notes | -| :-------------: | :------------------------: | :---- | -| ^5.0 | [2.x](https://github.com/cakedc/money/tree/2.next-cake5) | stable | -| ^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 | +| CakePHP | CakeDC Money Plugin | Notes | +|:-------:|:--------------------------------------------------------:|:-----------| +| ^5.0 | [2.x](https://github.com/cakedc/money/tree/2.next-cake5) | stable | +| ^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 diff --git a/composer.json b/composer.json index 1669dfe..54e0c9c 100644 --- a/composer.json +++ b/composer.json @@ -6,10 +6,13 @@ "require": { "php": ">=8.1", "cakephp/cakephp": "^5.0", - "moneyphp/money": "^4.0" + "moneyphp/money": "^4.0", + "ext-pdo": "*", + "ext-intl": "*" }, "require-dev": { - "phpunit/phpunit": "^10.1.0" + "phpunit/phpunit": "^10.1.0", + "cakephp/cakephp-codesniffer": "^5.1" }, "autoload": { "psr-4": { @@ -24,19 +27,26 @@ }, "scripts": { "check": [ - "@test", - "@cs-check" + "@cs-check", + "@test" ], - "analyse": [ - "@stan", + "cs-check": "phpcs --colors --parallel=16 -p src/ tests/", + "cs-fix": "phpcbf --colors --parallel=16 -p src/ tests/", + "phpstan": "tools/phpstan analyse", + "psalm": "tools/psalm --show-info=false", + "stan": [ + "@phpstan", "@psalm" ], - "cs-check": "phpcs -n -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests", - "cs-fix": "phpcbf --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests", - "test": "phpunit --stderr", - "stan": "phpstan analyse src/", - "psalm": "php vendor/psalm/phar/psalm.phar --show-info=false src/ ", - "stan-setup": "cp composer.json composer.backup && composer require --dev phpstan/phpstan:0.12.88 psalm/phar:~4.7.0 && mv composer.backup composer.json", - "coverage-test": "phpunit --stderr --coverage-clover=clover.xml" + "phpstan-tests": "tools/phpstan analyze -c tests/phpstan.neon", + "phpstan-baseline": "tools/phpstan --generate-baseline", + "psalm-baseline": "tools/psalm --set-baseline=psalm-baseline.xml", + "stan-setup": "phive install", + "test": "phpunit" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": false + } } } diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..c1ac214 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..364905f --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: diff --git a/phpstan.neon b/phpstan.neon index 2bc6593..7dc051f 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,10 @@ +includes: + - phpstan-baseline.neon parameters: - level: 6 - autoload_files: - - tests/bootstrap.php - ignoreErrors: - - '#Method CakeDC\\Auth\\Rbac\\Rules\\AbstractRule::_getTableFromRequest\(\) should return Cake\\ORM\\Table but returns Cake\\Datasource\\RepositoryInterface.#' -services: + level: 8 + checkMissingIterableValueType: false + checkGenericClassInNonGenericObjectType: false + bootstrapFiles: + - tests/bootstrap.php + paths: + - src/ diff --git a/psalm.xml b/psalm.xml index cc8fde3..3ee6ae7 100644 --- a/psalm.xml +++ b/psalm.xml @@ -6,6 +6,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" + autoloader="tests/bootstrap.php" > @@ -42,7 +43,7 @@ - + diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php index 834fd84..0043b60 100644 --- a/src/Controller/AppController.php +++ b/src/Controller/AppController.php @@ -1,4 +1,6 @@ getAmount(); @@ -86,10 +87,10 @@ public function toDatabase($value, Driver $driver) : ?string * Casts given value to its Statement equivalent. * * @param mixed $value Value to be converted to PDO statement. - * @param \Cake\Database\DriverInterface $driver Object from which database preferences and configuration will be extracted. + * @param \Cake\Database\Driver $driver Object from which database preferences and configuration will be extracted. * @return int Given value casted to its Statement equivalent. */ - public function toStatement($value, Driver $driver) : int + public function toStatement(mixed $value, Driver $driver): int { if ($value === null) { return PDO::PARAM_NULL; @@ -97,5 +98,4 @@ public function toStatement($value, Driver $driver) : int return PDO::PARAM_INT; } - } diff --git a/src/Money.php b/src/Money.php index cc2a55a..ed7857f 100644 --- a/src/Money.php +++ b/src/Money.php @@ -1,4 +1,6 @@ _money; } + /** + * Constructor + * + * @param \Money\Money $money + */ public function __construct(MoneyPHP $money) { $this->_money = $money; } /** - * @param $name - * @param $arguments - * @return false|mixed + * @param string $name + * @param array $arguments + * @return mixed|false */ - public function __call($name, $arguments) + public function __call(string $name, array $arguments): mixed { $arguments = self::processArguments($arguments); - + // @phpstan-ignore-next-line $result = call_user_func_array([$this->_money, $name], $arguments); if ($result instanceof MoneyPHP) { return new self($result); @@ -60,14 +111,15 @@ public function __call($name, $arguments) } /** - * @param $name - * @param $arguments - * @return false|mixed + * @param string $name + * @param array $arguments + * @return mixed|false */ - public static function __callStatic($name, $arguments) + public static function __callStatic(string $name, array $arguments): mixed { $arguments = self::processArguments($arguments); + // @phpstan-ignore-next-line return new self(forward_static_call_array([MoneyPHP::class, $name], $arguments)); } @@ -83,9 +135,10 @@ public function __toString(): string * @param array $arguments * @return array */ - protected static function processArguments($arguments = []) + protected static function processArguments(array $arguments = []): array { - for ($i=0; $i < count($arguments); $i++) { + $count = count($arguments); + for ($i = 0; $i < $count; $i++) { if ($arguments[$i] instanceof Money) { $arguments[$i] = $arguments[$i]->getMoney(); } diff --git a/src/Plugin.php b/src/Plugin.php index 8a00325..496aefe 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -1,4 +1,6 @@ plugin( 'CakeDC/Money', ['path' => '/money'], - function (RouteBuilder $builder) { + function (RouteBuilder $builder): void { // Add custom routes here $builder->fallbacks(); @@ -64,7 +64,7 @@ function (RouteBuilder $builder) { /** * Add middleware for the plugin. * - * @param \Cake\Http\MiddlewareQueue $middleware The middleware queue to update. + * @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to update. * @return \Cake\Http\MiddlewareQueue */ public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue diff --git a/src/Utility/MoneyUtil.php b/src/Utility/MoneyUtil.php index 4850a98..eca7137 100644 --- a/src/Utility/MoneyUtil.php +++ b/src/Utility/MoneyUtil.php @@ -1,4 +1,6 @@ */ - protected static $_moneyFormatters = []; + protected static array $moneyFormatters = []; /** * Returns a new object of type Money * - * @param int|float|string $value - * @param boolean $fromDb - * @return Money + * @param \CakeDC\Money\Money|string|float|int $value + * @param bool $fromDb + * @return \CakeDC\Money\Money */ - public static function money($value, $fromDb = false) : ?Money + public static function money(Money|int|float|string $value, bool $fromDb = false): ?Money { if (!is_numeric($value) && empty($value)) { return null; @@ -50,12 +54,12 @@ public static function money($value, $fromDb = false) : ?Money } if (!$fromDb) { - $parts = explode('.', $value ); + $parts = explode('.', (string)$value); if (!isset($parts[1])) { $parts[1] = '00'; } - $decimalLength = strlen($parts[1] ?? ''); + $decimalLength = strlen($parts[1]); if ($decimalLength == 1) { $parts[1] = $parts[1] . '0'; @@ -63,74 +67,82 @@ public static function money($value, $fromDb = false) : ?Money $value = ltrim($parts[0] . $parts[1], '0'); } - + $currency = Configure::read('Money.currency', 'USD'); - return Money::{$currency}(!empty($value) ? str_replace(',', '', $value) : 0); + + return Money::{$currency}(!empty($value) ? str_replace(',', '', (string)$value) : 0); } /** - * @param Money $money + * @param \CakeDC\Money\Money $money * @return float */ - public static function float(Money $money) : float + public static function float(Money $money): float { - return $money->getAmount() / 100; + return (float)$money->getAmount() / 100; } /** - * @param Money $value + * @param \CakeDC\Money\Money $value * @return string */ - public static function format(Money $value) : string + public static function format(Money $value): string { - /** @var Currency $currency */ + /** @var \Money\Currency $currency */ $currency = $value->getCurrency(); - return static::_loadMoneyFormatter($currency)->format($value->getMoney()); + return static::loadMoneyFormatter($currency)->format($value->getMoney()); } /** * Loads proper money formatter or returns if it is already loaded * - * @param Currency $currency - * @return MoneyFormatter + * @param \Money\Currency $currency + * @return \Money\MoneyFormatter */ - protected static function _loadMoneyFormatter(Currency $currency) : MoneyFormatter + protected static function loadMoneyFormatter(Currency $currency): MoneyFormatter { - if (isset(static::$_moneyFormatters[$currency->getCode()])) { - return static::$_moneyFormatters[$currency->getCode()]; + if (isset(static::$moneyFormatters[$currency->getCode()])) { + return static::$moneyFormatters[$currency->getCode()]; } $iso = new ISOCurrencies(); $bitcoin = new BitcoinCurrencies(); if ($iso->contains($currency)) { - $numberFormatter = new \NumberFormatter('en_US', \NumberFormatter::CURRENCY); + $numberFormatter = new NumberFormatter('en_US', NumberFormatter::CURRENCY); $moneyFormatter = new IntlMoneyFormatter($numberFormatter, $iso); } elseif ($bitcoin->contains($currency)) { $moneyFormatter = new BitcoinMoneyFormatter(7, $bitcoin); } else { - throw new \RuntimeException(sprintf('Cannot format currency \'%s\'. Only ISO currencies and Bitcoin are allowed.', $currency)); + 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()]; + static::$moneyFormatters[$currency->getCode()] = $moneyFormatter; + + return static::$moneyFormatters[$currency->getCode()]; } /** * Returns money object with value 0.00, false otherwise. * - * @return Money + * @return \CakeDC\Money\Money */ - public static function zero() : Money + public static function zero(): Money { + /** @var \CakeDC\Money\Money */ return self::money(0); } /** * Returns true if amount value is > 0.00 * - * @param Money $amount + * @param \CakeDC\Money\Money $amount * @return bool */ - public static function greaterThanZero(Money $amount) : bool + public static function greaterThanZero(Money $amount): bool { return $amount->greaterThan(self::zero()); } @@ -138,10 +150,10 @@ public static function greaterThanZero(Money $amount) : bool /** * Returns true if amount value is >= 0.00, false otherwise. * - * @param Money $amount + * @param \CakeDC\Money\Money $amount * @return bool */ - public static function greaterThanOrEqualZero(Money $amount) : bool + public static function greaterThanOrEqualZero(Money $amount): bool { return $amount->greaterThanOrEqual(self::zero()); } @@ -149,10 +161,10 @@ public static function greaterThanOrEqualZero(Money $amount) : bool /** * Returns true if amount value is < 0.00, false otherwise. * - * @param Money $amount + * @param \CakeDC\Money\Money $amount * @return bool */ - public static function lessThanZero(Money $amount) : bool + public static function lessThanZero(Money $amount): bool { return $amount->lessThan(self::zero()); } @@ -160,10 +172,10 @@ public static function lessThanZero(Money $amount) : bool /** * Returns true if amount value is <= 0.00, false otherwise. * - * @param Money $amount + * @param \CakeDC\Money\Money $amount * @return bool */ - public static function lessThanOrEqualZero(Money $amount) : bool + public static function lessThanOrEqualZero(Money $amount): bool { return $amount->lessThanOrEqual(self::zero()); } @@ -171,12 +183,11 @@ public static function lessThanOrEqualZero(Money $amount) : bool /** * Returns true if amount value is = 0.00, false otherwise. * - * @param Money $amount + * @param \CakeDC\Money\Money $amount * @return bool */ - public static function equalZero(Money $amount) : bool + public static function equalZero(Money $amount): bool { return $amount->equals(self::zero()); } - } diff --git a/src/View/Helper/MoneyHelper.php b/src/View/Helper/MoneyHelper.php index e339d71..706bde7 100644 --- a/src/View/Helper/MoneyHelper.php +++ b/src/View/Helper/MoneyHelper.php @@ -1,4 +1,6 @@ Number->currency($value); } - if ((is_numeric($value) && $value < 0) || + if ( + (is_numeric($value) && $value < 0) || ($value instanceof Money && MoneyUtil::lessThanZero($value)) ) { $class = 'negative-balance'; diff --git a/src/View/Widget/MoneyWidget.php b/src/View/Widget/MoneyWidget.php index f0f29ce..033abb5 100644 --- a/src/View/Widget/MoneyWidget.php +++ b/src/View/Widget/MoneyWidget.php @@ -1,4 +1,6 @@ _templates = $templates; + $this->templates = $templates; } /** @@ -59,11 +63,12 @@ public function render(array $data, ContextInterface $context): string } $data['class'] = ($data['class'] ?? '') . ' form-control'; $data['step'] = '.01'; - return $this->_templates->format('input', [ + + return $this->templates->format('input', [ 'name' => $data['name'], 'type' => 'number', 'templateVars' => $data['templateVars'], - 'attrs' => $this->_templates->formatAttributes( + 'attrs' => $this->templates->formatAttributes( $data, ['name', 'type'] ), diff --git a/tests/TestCase/Database/Type/MoneyTypeTest.php b/tests/TestCase/Database/Type/MoneyTypeTest.php index 43b2053..fc1a5ed 100644 --- a/tests/TestCase/Database/Type/MoneyTypeTest.php +++ b/tests/TestCase/Database/Type/MoneyTypeTest.php @@ -3,13 +3,12 @@ namespace CakeDC\Money\Test\TestCase\Utility; -use Cake\Core\Configure; use Cake\TestSuite\TestCase; use CakeDC\Money\Database\Type\MoneyType; +use CakeDC\Money\Money; use CakeDC\Money\Utility\MoneyUtil; -use Exception; +use InvalidArgumentException; use PDO; -use RuntimeException; /** * CakeDC\Money\Database\Type\MoneyTypeTest Test Case @@ -41,13 +40,13 @@ public function tearDown(): void public function testToPhp() { $this->assertNull($this->moneyType->toPHP(null, $this->driver)); - $this->assertInstanceOf(\CakeDC\Money\Money::class, $this->moneyType->toPHP(100, $this->driver)); + $this->assertInstanceOf(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)); + $this->assertInstanceOf(Money::class, $this->moneyType->marshal(100)); } public function testToDatabase() @@ -58,7 +57,7 @@ public function testToDatabase() public function testToDatabaseInvalidArgument() { - $this->expectException(\InvalidArgumentException::class); + $this->expectException(InvalidArgumentException::class); $this->moneyType->toDatabase(100, $this->driver); } @@ -67,6 +66,4 @@ 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 dcf7efb..46d71b8 100644 --- a/tests/TestCase/Utility/MoneyUtilTest.php +++ b/tests/TestCase/Utility/MoneyUtilTest.php @@ -5,6 +5,7 @@ use Cake\Core\Configure; use Cake\TestSuite\TestCase; +use CakeDC\Money\Money; use CakeDC\Money\Utility\MoneyUtil; use Exception; use RuntimeException; @@ -41,31 +42,30 @@ public function tearDown(): void parent::tearDown(); } - public function testMoneyNumericValue(): void { $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, MoneyUtil::money(100) ); $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, MoneyUtil::money(100, true) ); $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, MoneyUtil::money(-100) ); $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, MoneyUtil::money(100.15) ); $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, MoneyUtil::money(100.1) ); } @@ -73,22 +73,22 @@ public function testMoneyNumericValue(): void public function testMoneyStringValue(): void { $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, MoneyUtil::money('100') ); $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, MoneyUtil::money('100', true) ); $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, MoneyUtil::money('-100') ); $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, MoneyUtil::money('100.15') ); } @@ -100,7 +100,7 @@ public function testMoneyNullValue(): void ); $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, MoneyUtil::money(0) ); } @@ -110,7 +110,7 @@ public function testMoneyClassValue(): void $money = MoneyUtil::money(10); $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, MoneyUtil::money($money) ); @@ -120,7 +120,6 @@ public function testMoneyClassValue(): void ); } - public function testFloat(): void { $money = MoneyUtil::money(100.15); @@ -134,7 +133,7 @@ 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)); } @@ -142,30 +141,30 @@ public function testFormat() 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->assertInstanceOf(Money::class, $money); $this->assertEquals('Ƀ0.0000010', MoneyUtil::format($money)); } - + public function testFormatOther() { - try{ + try { Configure::write('Money.currency', 'NotCurrency'); $money = MoneyUtil::money(100.15); MoneyUtil::format($money); - } catch (\Exception $e){ + } catch (Exception $e) { $this->assertInstanceOf(RuntimeException::class, $e); } } @@ -175,14 +174,13 @@ public function testZero() $money = MoneyUtil::zero(); $this->assertInstanceOf( - \CakeDC\Money\Money::class, + Money::class, $money ); $this->assertEquals('$0.00', $money->__toString()); } - public function testGreaterThanZero() { $money = MoneyUtil::money(100); @@ -203,7 +201,6 @@ public function testGreaterThanOrEqualZero() $this->assertTrue(MoneyUtil::greaterThanOrEqualZero(MoneyUtil::zero())); } - public function testLessThanZero() { $money = MoneyUtil::money(100); @@ -212,7 +209,7 @@ public function testLessThanZero() $money = MoneyUtil::money(-100); $this->assertTrue(MoneyUtil::lessThanZero($money)); } - + public function testLessThanOrEqualZero() { $money = MoneyUtil::money(100); @@ -228,8 +225,7 @@ 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 fdcb0d9..92df567 100644 --- a/tests/TestCase/View/Helper/MoneyHelperTest.php +++ b/tests/TestCase/View/Helper/MoneyHelperTest.php @@ -3,10 +3,10 @@ namespace CakeDC\Money\Test\TestCase\View\Helper; -use CakeDC\Money\View\Helper\MoneyHelper; use Cake\TestSuite\TestCase; use Cake\View\View; use CakeDC\Money\Utility\MoneyUtil; +use CakeDC\Money\View\Helper\MoneyHelper; /** * CakeDC\Money\View\Helper\MoneyHelper Test Case @@ -56,7 +56,7 @@ public function testCurrency(): void ); $this->assertEquals( - '$100.00', + '$100.00', $this->MoneyHelper->currency('100') ); @@ -67,7 +67,7 @@ public function testCurrency(): void $this->assertEquals( '-$100.00', - $this->MoneyHelper->currency("-100") + $this->MoneyHelper->currency('-100') ); $this->assertEquals( diff --git a/tests/TestCase/View/Widget/MoneyWidgetTest.php b/tests/TestCase/View/Widget/MoneyWidgetTest.php index 7df1411..ecd3fc1 100644 --- a/tests/TestCase/View/Widget/MoneyWidgetTest.php +++ b/tests/TestCase/View/Widget/MoneyWidgetTest.php @@ -115,4 +115,4 @@ public function testSecureFields(): void $this->assertTrue(in_array('amount', $money->secureFields($data))); } -} \ No newline at end of file +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index abedf32..3711278 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,6 +1,8 @@