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..22e0459 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
/.idea/
/.phpunit.cache
/.ddev/
+/tools/
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/composer.json b/composer.json
index a5b1b16..a7c53bb 100644
--- a/composer.json
+++ b/composer.json
@@ -9,7 +9,9 @@
"moneyphp/money": "^3.3"
},
"require-dev": {
- "phpunit/phpunit": "^8.5 || ^9.3"
+ "phpunit/phpunit": "^8.5 || ^9.3",
+ "cakephp/cakephp-codesniffer": "^4.5",
+ "ext-pdo": "*"
},
"autoload": {
"psr-4": {
@@ -24,19 +26,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/Database/Type/MoneyType.php b/src/Database/Type/MoneyType.php
index ca72e92..111ef54 100644
--- a/src/Database/Type/MoneyType.php
+++ b/src/Database/Type/MoneyType.php
@@ -11,15 +11,11 @@
namespace CakeDC\Money\Database\Type;
use Cake\Core\Configure;
-
use Cake\Database\DriverInterface;
use Cake\Database\Type\BaseType;
use Cake\Database\TypeInterface;
-use Cake\Error\Debugger;
-use CakeDC\Money\Utility\MoneyUtil;
use CakeDC\Money\Money;
-use http\Exception\RuntimeException;
-use Money\Money as MoneyPHP;
+use CakeDC\Money\Utility\MoneyUtil;
use PDO;
/**
@@ -29,15 +25,14 @@
*/
class MoneyType extends BaseType implements TypeInterface
{
-
/**
* Casts given value from a database type to a PHP equivalent.
*
* @param mixed $value Value to be converted to PHP equivalent
* @param \Cake\Database\DriverInterface $driver Object from which database preferences and configuration will be extracted
- * @return ?Money Given value casted from a database to a PHP equivalent.
+ * @return ?\CakeDC\Money\Money Given value casted from a database to a PHP equivalent.
*/
- public function toPHP($value, DriverInterface $driver) : ?Money
+ public function toPHP($value, DriverInterface $driver): ?Money
{
if ($value === null) {
return null;
@@ -55,9 +50,9 @@ public function toPHP($value, DriverInterface $driver) : ?Money
* that make sense for the rest of the ORM/Database layers.
*
* @param mixed $value The value to convert.
- * @return ?Money Converted value.
+ * @return ?\CakeDC\Money\Money Converted value.
*/
- public function marshal($value) : ?Money
+ public function marshal($value): ?Money
{
if ($value === null) {
return null;
@@ -70,11 +65,11 @@ public function marshal($value) : ?Money
/**
* Casts given value from a PHP type to one acceptable by a database.
*
- * @param ?Money $value Value to be converted to a database equivalent.
+ * @param ?\CakeDC\Money\Money $value Value to be converted to a database equivalent.
* @param \Cake\Database\DriverInterface $driver Object from which database preferences and configuration will be extracted.
* @return ?string Given PHP type casted to one acceptable by a database.
*/
- public function toDatabase($value, DriverInterface $driver) : ?string
+ public function toDatabase($value, DriverInterface $driver): ?string
{
if ($value === null) {
@@ -94,7 +89,7 @@ public function toDatabase($value, DriverInterface $driver) : ?string
* @param \Cake\Database\DriverInterface $driver Object from which database preferences and configuration will be extracted.
* @return int Given value casted to its Statement equivalent.
*/
- public function toStatement($value, DriverInterface $driver) : int
+ public function toStatement($value, DriverInterface $driver): int
{
if ($value === null) {
return PDO::PARAM_NULL;
@@ -102,5 +97,4 @@ public function toStatement($value, DriverInterface $driver) : int
return PDO::PARAM_INT;
}
-
}
diff --git a/src/Money.php b/src/Money.php
index 4d7a075..7ff2a26 100644
--- a/src/Money.php
+++ b/src/Money.php
@@ -35,7 +35,7 @@
* @method \CakeDC\Money\Money mod(\CakeDC\Money\Money $divisor) See \Money\Money::mod()
* @method \CakeDC\Money\Money[] allocate(array $ratios) See \Money\Money::allocate()
* @method \CakeDC\Money\Money[] allocateTo($n) See \Money\Money::allocateTo()
- * @method string ratioOf(Money $money) See \Money\Money::ratioOf()
+ * @method string ratioOf(\CakeDC\Money\Money $money) See \Money\Money::ratioOf()
* @method \CakeDC\Money\Money absolute() See \Money\Money::absolute()
* @method \CakeDC\Money\Money negative() See \Money\Money::negative()
* @method bool isZero() See \Money\Money::isZero()
@@ -52,29 +52,29 @@
*/
class Money
{
- const ROUND_HALF_UP = PHP_ROUND_HALF_UP;
+ public const ROUND_HALF_UP = PHP_ROUND_HALF_UP;
- const ROUND_HALF_DOWN = PHP_ROUND_HALF_DOWN;
+ public const ROUND_HALF_DOWN = PHP_ROUND_HALF_DOWN;
- const ROUND_HALF_EVEN = PHP_ROUND_HALF_EVEN;
+ public const ROUND_HALF_EVEN = PHP_ROUND_HALF_EVEN;
- const ROUND_HALF_ODD = PHP_ROUND_HALF_ODD;
+ public const ROUND_HALF_ODD = PHP_ROUND_HALF_ODD;
- const ROUND_UP = 5;
+ public const ROUND_UP = 5;
- const ROUND_DOWN = 6;
+ public const ROUND_DOWN = 6;
- const ROUND_HALF_POSITIVE_INFINITY = 7;
+ public const ROUND_HALF_POSITIVE_INFINITY = 7;
- const ROUND_HALF_NEGATIVE_INFINITY = 8;
+ public const ROUND_HALF_NEGATIVE_INFINITY = 8;
/**
- * @var MoneyPHP
+ * @var \Money\Money
*/
protected $_money;
/**
- * @return MoneyPHP
+ * @return \Money\Money
*/
public function getMoney(): MoneyPHP
{
@@ -87,14 +87,14 @@ public function __construct(MoneyPHP $money)
}
/**
- * @param $name
- * @param $arguments
+ * @param string $name
+ * @param array $arguments
* @return false|mixed
*/
- public function __call($name, $arguments)
+ public function __call(string $name, array $arguments)
{
$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);
@@ -104,14 +104,15 @@ public function __call($name, $arguments)
}
/**
- * @param $name
- * @param $arguments
+ * @param string $name
+ * @param array $arguments
* @return false|mixed
*/
- public static function __callStatic($name, $arguments)
+ public static function __callStatic(string $name, array $arguments)
{
$arguments = self::processArguments($arguments);
+ // @phpstan-ignore-next-line
return new self(forward_static_call_array([MoneyPHP::class, $name], $arguments));
}
@@ -129,7 +130,7 @@ public function __toString(): string
*/
protected static function processArguments($arguments = [])
{
- for ($i=0; $i < count($arguments); $i++) {
+ for ($i = 0; $i < count($arguments); $i++) {
if ($arguments[$i] instanceof Money) {
$arguments[$i] = $arguments[$i]->getMoney();
}
diff --git a/src/Plugin.php b/src/Plugin.php
index 929d838..2541eea 100644
--- a/src/Plugin.php
+++ b/src/Plugin.php
@@ -14,7 +14,7 @@
use Cake\Core\BasePlugin;
use Cake\Core\PluginApplicationInterface;
-use Cake\Database\Type;
+use Cake\Database\TypeFactory;
use Cake\Http\MiddlewareQueue;
use Cake\Routing\RouteBuilder;
use CakeDC\Money\Database\Type\MoneyType;
@@ -35,7 +35,7 @@ class Plugin extends BasePlugin
*/
public function bootstrap(PluginApplicationInterface $app): void
{
- Type::map('money', MoneyType::class);
+ TypeFactory::map('money', MoneyType::class);
}
/**
@@ -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 3813bdd..797acee 100644
--- a/src/Utility/MoneyUtil.php
+++ b/src/Utility/MoneyUtil.php
@@ -11,12 +11,12 @@
namespace CakeDC\Money\Utility;
use Cake\Core\Configure;
+use CakeDC\Money\Money;
use Money\Currencies\BitcoinCurrencies;
use Money\Currencies\ISOCurrencies;
use Money\Currency;
use Money\Formatter\BitcoinMoneyFormatter;
use Money\Formatter\IntlMoneyFormatter;
-use CakeDC\Money\Money;
use Money\MoneyFormatter;
/**
@@ -29,18 +29,18 @@
class MoneyUtil
{
/**
- * @var MoneyFormatter
+ * @var \Money\MoneyFormatter[]
*/
protected static $_moneyFormatters = [];
/**
* Returns a new object of type Money
*
- * @param int|float|string $value
- * @param boolean $fromDb
- * @return Money
+ * @param \CakeDC\Money\Money|int|float|string $value
+ * @param bool $fromDb
+ * @return \CakeDC\Money\Money
*/
- public static function money($value, $fromDb = false) : ?Money
+ public static function money($value, bool $fromDb = false): ?Money
{
if (!is_numeric($value) && empty($value)) {
return null;
@@ -50,12 +50,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,27 +63,28 @@ 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());
@@ -92,10 +93,10 @@ public static function format(Money $value) : string
/**
* 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()];
@@ -111,26 +112,28 @@ protected static function _loadMoneyFormatter(Currency $currency) : MoneyFormatt
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()];
}
/**
* 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 +141,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 +152,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 +163,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 +174,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 7dbd8e7..abc143e 100644
--- a/src/View/Helper/MoneyHelper.php
+++ b/src/View/Helper/MoneyHelper.php
@@ -10,17 +10,22 @@
*/
namespace CakeDC\Money\View\Helper;
-
use Cake\View\Helper;
-use CakeDC\Money\Utility\MoneyUtil;
use CakeDC\Money\Money;
+use CakeDC\Money\Utility\MoneyUtil;
/**
* Class MoneyHelper
+ *
* @package CakeDC\Money\View\Helper
+ * @property \Cake\View\Helper\HtmlHelper $Html
+ * @property \Cake\View\Helper\NumberHelper $Number
*/
class MoneyHelper extends Helper
{
+ /**
+ * @inheritDoc
+ */
protected $helpers = ['Html', 'Number'];
/**
@@ -36,7 +41,8 @@ public function initialize(array $config): void
/**
* Format number or money as currency.
- * @param $value
+ *
+ * @param \CakeDC\Money\Money|float|string $value
* @return string
*/
public function currency($value): string
@@ -47,7 +53,8 @@ public function currency($value): string
} else {
$output = $this->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..ba7cdab 100644
--- a/src/View/Widget/MoneyWidget.php
+++ b/src/View/Widget/MoneyWidget.php
@@ -12,11 +12,12 @@
use Cake\View\Form\ContextInterface;
use Cake\View\Widget\WidgetInterface;
-use CakeDC\Money\Utility\MoneyUtil;
use CakeDC\Money\Money;
+use CakeDC\Money\Utility\MoneyUtil;
/**
* Class MoneyWidget
+ *
* @package CakeDC\Money\View\Widget
*/
class MoneyWidget implements WidgetInterface
@@ -59,6 +60,7 @@ public function render(array $data, ContextInterface $context): string
}
$data['class'] = ($data['class'] ?? '') . ' form-control';
$data['step'] = '.01';
+
return $this->_templates->format('input', [
'name' => $data['name'],
'type' => 'number',
diff --git a/tests/TestCase/Database/Type/MoneyTypeTest.php b/tests/TestCase/Database/Type/MoneyTypeTest.php
index 43b2053..13e6973 100644
--- a/tests/TestCase/Database/Type/MoneyTypeTest.php
+++ b/tests/TestCase/Database/Type/MoneyTypeTest.php
@@ -3,13 +3,10 @@
namespace CakeDC\Money\Test\TestCase\Utility;
-use Cake\Core\Configure;
use Cake\TestSuite\TestCase;
use CakeDC\Money\Database\Type\MoneyType;
use CakeDC\Money\Utility\MoneyUtil;
-use Exception;
use PDO;
-use RuntimeException;
/**
* CakeDC\Money\Database\Type\MoneyTypeTest Test Case
@@ -67,6 +64,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..bab03aa 100644
--- a/tests/TestCase/Utility/MoneyUtilTest.php
+++ b/tests/TestCase/Utility/MoneyUtilTest.php
@@ -6,7 +6,6 @@
use Cake\Core\Configure;
use Cake\TestSuite\TestCase;
use CakeDC\Money\Utility\MoneyUtil;
-use Exception;
use RuntimeException;
/**
@@ -41,7 +40,6 @@ public function tearDown(): void
parent::tearDown();
}
-
public function testMoneyNumericValue(): void
{
$this->assertInstanceOf(
@@ -120,7 +118,6 @@ public function testMoneyClassValue(): void
);
}
-
public function testFloat(): void
{
$money = MoneyUtil::money(100.15);
@@ -134,7 +131,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,14 +139,14 @@ 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');
@@ -158,14 +155,14 @@ public function testFormatBitcoin()
$this->assertInstanceOf(\CakeDC\Money\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);
}
}
@@ -182,7 +179,6 @@ public function testZero()
$this->assertEquals('$0.00', $money->__toString());
}
-
public function testGreaterThanZero()
{
$money = MoneyUtil::money(100);
@@ -203,7 +199,6 @@ public function testGreaterThanOrEqualZero()
$this->assertTrue(MoneyUtil::greaterThanOrEqualZero(MoneyUtil::zero()));
}
-
public function testLessThanZero()
{
$money = MoneyUtil::money(100);
@@ -212,7 +207,7 @@ public function testLessThanZero()
$money = MoneyUtil::money(-100);
$this->assertTrue(MoneyUtil::lessThanZero($money));
}
-
+
public function testLessThanOrEqualZero()
{
$money = MoneyUtil::money(100);
@@ -228,8 +223,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 7003609..9d5a171 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -17,7 +17,7 @@
}
} while ($root !== $lastRoot);
- throw new Exception("Cannot find the root of the application, unable to run tests");
+ throw new Exception('Cannot find the root of the application, unable to run tests');
};
$root = $findRoot(__FILE__);
unset($findRoot);
@@ -32,7 +32,7 @@
* and define the data required by your plugin here.
*/
require_once $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';
-
+class_alias(\Cake\Controller\Controller::class, 'App\Controller\AppController');
if (file_exists($root . '/config/bootstrap.php')) {
require $root . '/config/bootstrap.php';
diff --git a/webroot/.gitkeep b/webroot/.gitkeep
deleted file mode 100644
index e69de29..0000000