diff --git a/test/View/Helper/NumberFormatTest.php b/test/View/Helper/NumberFormatTest.php index 8286d1e5..c2b8d471 100644 --- a/test/View/Helper/NumberFormatTest.php +++ b/test/View/Helper/NumberFormatTest.php @@ -23,7 +23,7 @@ protected function setUp(): void } /** @return array, 5: float, 6: string}> */ - public static function currencyTestsDataProvider(): array + public static function numberTestsDataProvider(): array { return [ [ @@ -32,6 +32,7 @@ public static function currencyTestsDataProvider(): array NumberFormatter::TYPE_DOUBLE, null, [], + null, 1234567.891234567890000, '1.234.567,891', ], @@ -41,6 +42,7 @@ public static function currencyTestsDataProvider(): array NumberFormatter::TYPE_DOUBLE, 6, [], + null, 1234567.891234567890000, '1.234.567,891235', ], @@ -50,6 +52,7 @@ public static function currencyTestsDataProvider(): array NumberFormatter::TYPE_DOUBLE, null, [], + null, 1234567.891234567890000, '123.456.789 %', ], @@ -59,6 +62,7 @@ public static function currencyTestsDataProvider(): array NumberFormatter::TYPE_DOUBLE, 1, [], + null, 1234567.891234567890000, '123.456.789,1 %', ], @@ -68,6 +72,7 @@ public static function currencyTestsDataProvider(): array NumberFormatter::TYPE_DOUBLE, null, [], + null, 1234567.891234560000, '1,23456789123456E6', ], @@ -77,6 +82,7 @@ public static function currencyTestsDataProvider(): array NumberFormatter::TYPE_DOUBLE, null, [], + null, 1234567.891234567890000, '1 234 567,891', ], @@ -86,6 +92,7 @@ public static function currencyTestsDataProvider(): array NumberFormatter::TYPE_DOUBLE, null, [], + null, 1234567.891234567890000, '123 456 789 %', ], @@ -95,6 +102,7 @@ public static function currencyTestsDataProvider(): array NumberFormatter::TYPE_DOUBLE, null, [], + null, 1234567.891234560000, '1,23456789123456E6', ], @@ -104,6 +112,7 @@ public static function currencyTestsDataProvider(): array NumberFormatter::TYPE_DOUBLE, null, [], + null, 1234567.891234567890000, '1,234,567.891', ], @@ -113,6 +122,7 @@ public static function currencyTestsDataProvider(): array NumberFormatter::TYPE_DOUBLE, null, [], + null, 1234567.891234567890000, '123,456,789%', ], @@ -122,6 +132,7 @@ public static function currencyTestsDataProvider(): array NumberFormatter::TYPE_DOUBLE, null, [], + null, 1234567.891234560000, '1.23456789123456E6', ], @@ -133,22 +144,44 @@ public static function currencyTestsDataProvider(): array [ NumberFormatter::NEGATIVE_PREFIX => 'MINUS', ], + null, -1234567.891234567890000, 'MINUS123,456,789%', ], + [ + 'de_DE', + NumberFormatter::DECIMAL, + NumberFormatter::TYPE_DOUBLE, + 5, + [], + 0, + 1234567.891234567890000, + '1.234.567,89123', + ], + [ + 'de_DE', + NumberFormatter::DECIMAL, + NumberFormatter::TYPE_DOUBLE, + 5, + [], + 0, + 1234567, + '1.234.567', + ], ]; } /** * @param array $textAttributes */ - #[DataProvider('currencyTestsDataProvider')] + #[DataProvider('numberTestsDataProvider')] public function testBasic( string $locale, int $formatStyle, int $formatType, ?int $decimals, array $textAttributes, + ?int $minDecimals, float $number, string $expected ): void { @@ -158,29 +191,32 @@ public function testBasic( $formatType, $locale, $decimals, - $textAttributes + $textAttributes, + $minDecimals )); } /** * @param array $textAttributes */ - #[DataProvider('currencyTestsDataProvider')] + #[DataProvider('numberTestsDataProvider')] public function testSettersProvideDefaults( string $locale, int $formatStyle, int $formatType, ?int $decimals, array $textAttributes, + ?int $minDecimals, float $number, string $expected ): void { $this->helper ->setLocale($locale) ->setFormatStyle($formatStyle) - ->setDecimals($decimals) + ->setMaxDecimals($decimals) ->setFormatType($formatType) - ->setTextAttributes($textAttributes); + ->setTextAttributes($textAttributes) + ->setMinDecimals($minDecimals); self::assertMbStringEquals($expected, $this->helper->__invoke($number)); }