Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Auto commit for release 'develop' on 2025-02-24
github-actions56bac9fc97e7
diff --git a/.ci/php-cs-fixer/composer.lock b/.ci/php-cs-fixer/composer.lockindex 6ec2d09671..610267380d 100644--- a/.ci/php-cs-fixer/composer.lock+++ b/.ci/php-cs-fixer/composer.lock@@ -406,16 +406,16 @@},{"name": "friendsofphp/php-cs-fixer",- "version": "v3.69.1",+ "version": "v3.70.0","source": {"type": "git","url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",- "reference": "13b0c0eede38c11cd674b080f2b485d0f14ffa9f"+ "reference": "2ecd5aae0edc937f0d5aa4a22d1d705c6b2e084e"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/13b0c0eede38c11cd674b080f2b485d0f14ffa9f",- "reference": "13b0c0eede38c11cd674b080f2b485d0f14ffa9f",+ "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/2ecd5aae0edc937f0d5aa4a22d1d705c6b2e084e",+ "reference": "2ecd5aae0edc937f0d5aa4a22d1d705c6b2e084e","shasum": ""},"require": {@@ -497,7 +497,7 @@],"support": {"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",- "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.69.1"+ "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.70.0"},"funding": [{@@ -505,7 +505,7 @@"type": "github"}],- "time": "2025-02-18T23:57:43+00:00"+ "time": "2025-02-22T23:30:51+00:00"},{"name": "psr/container",diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.phpindex addd31b8eb..cb0a7bbb96 100644--- a/app/Api/V1/Controllers/Summary/BasicController.php+++ b/app/Api/V1/Controllers/Summary/BasicController.php@@ -185,8 +185,8 @@ class BasicController extends Controller'currency_decimal_places' => $currency->decimal_places,'value_parsed' => app('amount')->formatAnything($currency, $sums[$currencyId] ?? '0', false),'local_icon' => 'balance-scale',- 'sub_title' => app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false).- ' + '.app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false),+ 'sub_title' => app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false)+ .' + '.app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false),];$return[] = ['key' => sprintf('spent-in-%s', $currency->code),diff --git a/app/Api/V1/Requests/Data/DestroyRequest.php b/app/Api/V1/Requests/Data/DestroyRequest.phpindex 2f564567d9..082fb00adb 100644--- a/app/Api/V1/Requests/Data/DestroyRequest.php+++ b/app/Api/V1/Requests/Data/DestroyRequest.php@@ -49,9 +49,9 @@ class DestroyRequest extends FormRequest*/public function rules(): array{- $valid = 'budgets,bills,piggy_banks,rules,recurring,categories,tags,object_groups'.- ',accounts,asset_accounts,expense_accounts,revenue_accounts,liabilities,transactions,withdrawals,deposits,transfers'.- ',not_assets_liabilities';+ $valid = 'budgets,bills,piggy_banks,rules,recurring,categories,tags,object_groups'+ .',accounts,asset_accounts,expense_accounts,revenue_accounts,liabilities,transactions,withdrawals,deposits,transfers'+ .',not_assets_liabilities';return ['objects' => sprintf('required|max:255|min:1|string|in:%s', $valid),diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.phpindex 62d1e79805..24aa6a7e7e 100644--- a/app/Factory/BillFactory.php+++ b/app/Factory/BillFactory.php@@ -48,8 +48,8 @@ class BillFactory{app('log')->debug(sprintf('Now in %s', __METHOD__), $data);$factory = app(TransactionCurrencyFactory::class);- $currency = $factory->find((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null)) ??- app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);+ $currency = $factory->find((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null))+ ?? app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);try {$skip = array_key_exists('skip', $data) ? $data['skip'] : 0;diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.phpindex f5d46ec514..67a2fc6add 100644--- a/app/Http/Controllers/Transaction/MassController.php+++ b/app/Http/Controllers/Transaction/MassController.php@@ -141,8 +141,8 @@ class MassController extends Controller// reverse amountsforeach ($journals as $index => $journal) {$journals[$index]['amount'] = app('steam')->bcround(app('steam')->positive($journal['amount']), $journal['currency_decimal_places']);- $journals[$index]['foreign_amount'] = null === $journal['foreign_amount'] ?- null : app('steam')->positive($journal['foreign_amount']);+ $journals[$index]['foreign_amount'] = null === $journal['foreign_amount']+ ? null : app('steam')->positive($journal['foreign_amount']);}$this->rememberPreviousUrl('transactions.mass-edit.url');diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.phpindex d68f3054be..986bb2e5b8 100644--- a/app/Http/Middleware/TrustProxies.php+++ b/app/Http/Middleware/TrustProxies.php@@ -33,11 +33,11 @@ class TrustProxies extends Middleware{// After...protected $headers- = Request::HEADER_X_FORWARDED_FOR |- Request::HEADER_X_FORWARDED_HOST |- Request::HEADER_X_FORWARDED_PORT |- Request::HEADER_X_FORWARDED_PROTO |- Request::HEADER_X_FORWARDED_AWS_ELB;+ = Request::HEADER_X_FORWARDED_FOR+ | Request::HEADER_X_FORWARDED_HOST+ | Request::HEADER_X_FORWARDED_PORT+ | Request::HEADER_X_FORWARDED_PROTO+ | Request::HEADER_X_FORWARDED_AWS_ELB;/*** TrustProxies constructor.diff --git a/app/Services/Internal/Update/BillUpdateService.php b/app/Services/Internal/Update/BillUpdateService.phpindex 3905b21d62..d56bb2cc8c 100644--- a/app/Services/Internal/Update/BillUpdateService.php+++ b/app/Services/Internal/Update/BillUpdateService.php@@ -54,8 +54,8 @@ class BillUpdateServiceif (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {$factory = app(TransactionCurrencyFactory::class);- $currency = $factory->find((int) ($data['currency_id'] ?? null), $data['currency_code'] ?? null) ??- app('amount')->getNativeCurrencyByUserGroup($bill->user->userGroup);+ $currency = $factory->find((int) ($data['currency_id'] ?? null), $data['currency_code'] ?? null)+ ?? app('amount')->getNativeCurrencyByUserGroup($bill->user->userGroup);// enable the currency if it isn't.$currency->enabled = true;diff --git a/app/Services/Internal/Update/JournalUpdateService.php b/app/Services/Internal/Update/JournalUpdateService.phpindex b156b2705f..e596d4363b 100644--- a/app/Services/Internal/Update/JournalUpdateService.php+++ b/app/Services/Internal/Update/JournalUpdateService.php@@ -703,8 +703,8 @@ class JournalUpdateService// find currency in data array$newForeignId = $this->data['foreign_currency_id'] ?? null;$newForeignCode = $this->data['foreign_currency_code'] ?? null;- $foreignCurrency = $this->currencyRepository->findCurrencyNull($newForeignId, $newForeignCode) ??- $foreignCurrency;+ $foreignCurrency = $this->currencyRepository->findCurrencyNull($newForeignId, $newForeignCode)+ ?? $foreignCurrency;// not the same as normal currencyif (null !== $foreignCurrency && $foreignCurrency->id === $this->transactionJournal->transaction_currency_id) {diff --git a/composer.lock b/composer.lockindex fe4310b3f3..13150084d1 100644--- a/composer.lock+++ b/composer.lock@@ -11135,16 +11135,16 @@},{"name": "phpmyadmin/sql-parser",- "version": "5.10.3",+ "version": "5.11.0","source": {"type": "git","url": "https://github.com/phpmyadmin/sql-parser.git",- "reference": "5346664973d10cf1abff20837fb1183f3c11a055"+ "reference": "07044bc8c13abd542756c3fd34dc66a5d6dee8e4"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/5346664973d10cf1abff20837fb1183f3c11a055",- "reference": "5346664973d10cf1abff20837fb1183f3c11a055",+ "url": "https://api.github.com/repos/phpmyadmin/sql-parser/zipball/07044bc8c13abd542756c3fd34dc66a5d6dee8e4",+ "reference": "07044bc8c13abd542756c3fd34dc66a5d6dee8e4","shasum": ""},"require": {@@ -11159,9 +11159,11 @@"phpbench/phpbench": "^1.1","phpmyadmin/coding-standard": "^3.0","phpmyadmin/motranslator": "^4.0 || ^5.0",- "phpstan/extension-installer": "^1.1",- "phpstan/phpstan": "^1.9.12",- "phpstan/phpstan-phpunit": "^1.3.3",+ "phpstan/extension-installer": "^1.4",+ "phpstan/phpstan": "^1.12",+ "phpstan/phpstan-deprecation-rules": "^1.2",+ "phpstan/phpstan-phpunit": "^1.4",+ "phpstan/phpstan-strict-rules": "^1.6","phpunit/phpunit": "^8.5 || ^9.6","psalm/plugin-phpunit": "^0.16.1","vimeo/psalm": "^4.11",@@ -11218,7 +11220,7 @@"type": "other"}],- "time": "2025-01-19T04:14:02+00:00"+ "time": "2025-02-22T20:00:59+00:00"},{"name": "phpstan/extension-installer",diff --git a/config/firefly.php b/config/firefly.phpindex 7728e8a78e..ef64d73fc4 100644--- a/config/firefly.php+++ b/config/firefly.php@@ -81,7 +81,7 @@ return ['running_balance_column' => env('USE_RUNNING_BALANCE', false),// see cer.php for exchange rates feature flag.],- 'version' => 'develop/2025-02-22',+ 'version' => 'develop/2025-02-24','api_version' => '2.1.0', // field is no longer used.'db_version' => 25,diff --git a/package-lock.json b/package-lock.jsonindex 33805cec08..4eb7c8af94 100644--- a/package-lock.json+++ b/package-lock.json@@ -6491,18 +6491,18 @@}},"node_modules/get-intrinsic": {- "version": "1.2.7",- "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.7.tgz",- "integrity": "sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==",+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",+ "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==","dev": true,"license": "MIT","dependencies": {- "call-bind-apply-helpers": "^1.0.1",+ "call-bind-apply-helpers": "^1.0.2","es-define-property": "^1.0.1","es-errors": "^1.3.0",- "es-object-atoms": "^1.0.0",+ "es-object-atoms": "^1.1.1","function-bind": "^1.1.2",- "get-proto": "^1.0.0",+ "get-proto": "^1.0.1","gopd": "^1.2.0","has-symbols": "^1.1.0","hasown": "^2.0.2",diff --git a/resources/assets/v1/src/locales/zh-cn.json b/resources/assets/v1/src/locales/zh-cn.jsonindex faff2d7ae9..2d98265295 100644--- a/resources/assets/v1/src/locales/zh-cn.json+++ b/resources/assets/v1/src/locales/zh-cn.json@@ -1,8 +1,8 @@{"firefly": {- "administrations_page_title": "Financial administrations",- "administrations_index_menu": "Financial administrations",- "temp_administrations_introduction": "Firefly III will soon get the ability to manage multiple financial administrations. Right now, you only have the one. You can set the title of this administration and its native currency. This replaces the previous setting where you would set your \"default currency\". This setting is now tied to the financial administration and can be different per administration.",+ "administrations_page_title": "\u8d22\u52a1\u7ba1\u7406",+ "administrations_index_menu": "\u8d22\u52a1\u7ba1\u7406",+ "temp_administrations_introduction": "Firefly III \u4e0d\u4e45\u5c06\u80fd\u591f\u7ba1\u7406\u591a\u4e2a\u8d22\u52a1\u7ba1\u7406\u3002 \u73b0\u5728\uff0c\u4f60\u53ea\u80fd\u6709\u4e00\u4e2a\u8d22\u52a1\u7ba1\u7406\u3002\u4f60\u53ef\u4ee5\u8bbe\u7f6e\u8fd9\u4e2a\u8d22\u52a1\u7ba1\u7406\u7684\u6807\u9898\u53ca\u5176\u5f53\u5730\u8d27\u5e01\u3002 \u8fd9\u5c06\u53d6\u4ee3\u60a8\u5148\u524d\u8bbe\u7f6e\u7684\u201c\u9ed8\u8ba4\u8d27\u5e01\u201d\u3002 \u8fd9\u79cd\u8bbe\u7f6e\u73b0\u5728\u4e0e\u8d22\u52a1\u7ba1\u7406\u6302\u94a9\uff0c\u6bcf\u4e2a\u7ba1\u7406\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u8bbe\u7f6e\u3002","administration_currency_form_help": "It may take a long time for the page to load if you change the native currency because transaction may need to be converted to your (new) native currency.","administrations_page_edit_sub_title_js": "Edit financial administration \"{title}\"","table": "\u8868\u683c",@@ -19,7 +19,7 @@"split": "\u62c6\u5206","single_split": "\u62c6\u5206","not_enough_currencies": "Not enough currencies",- "not_enough_currencies_enabled": "If you have just one currency enabled, there is no need to add exchange rates.",+ "not_enough_currencies_enabled": "\u5982\u679c\u60a8\u53ea\u542f\u7528\u4e86\u4e00\u79cd\u8d27\u5e01\uff0c\u5c31\u4e0d\u9700\u8981\u6dfb\u52a0\u6c47\u7387\u3002","transaction_stored_link": "<a href=\"transactions\/show\/{ID}\">\u4ea4\u6613 #{ID} (\u201c{title}\u201d)<\/a> \u5df2\u4fdd\u5b58\u3002","webhook_stored_link": "<a href=\"webhooks\/show\/{ID}\">\u63a8\u9001 #{ID} (\"{title}\")<\/a> \u5df2\u4fdd\u5b58.","webhook_updated_link": "<a href=\"webhooks\/show\/{ID}\">\u63a8\u9001 #{ID}<\/a> (\"{title}\") \u5df2\u66f4\u65b0.",@@ -45,7 +45,7 @@"is_reconciled_fields_dropped": "Because this transaction is reconciled, you will not be able to update the accounts, nor the amount(s) unless you remove the reconciliation flag.","tags": "\u6807\u7b7e","no_budget": "(\u65e0\u9884\u7b97)",- "no_bill": "(no subscription)",+ "no_bill": "(\u65e0\u8ba2\u9605)","category": "\u5206\u7c7b","attachments": "\u9644\u4ef6","notes": "\u5907\u6ce8",@@ -146,8 +146,8 @@"header_exchange_rates_rates": "\u6c47\u7387","header_exchange_rates_table": "Table with exchange rates","help_rate_form": "On this day, how many {to} will you get for one {from}?",- "add_new_rate": "Add a new exchange rate",- "save_new_rate": "Save new rate"+ "add_new_rate": "\u6dfb\u52a0\u65b0\u6c47\u7387",+ "save_new_rate": "\u4fdd\u5b58\u65b0\u6c47\u7387"},"form": {"url": "\u7f51\u5740",@@ -182,6 +182,6 @@},"config": {"html_language": "zh-cn",- "date_time_fns": "YYYY\u5e74M\u6708D\u65e5 HH:mm:ss"+ "date_time_fns": "yyyy\u5e74M\u6708d\u65e5 HH:mm:ss"}}\ No newline at end of filediff --git a/tests/integration/Support/Models/BillDateCalculatorTest.php b/tests/integration/Support/Models/BillDateCalculatorTest.phpindex b4962ad6fb..bb65b1d0ac 100644--- a/tests/integration/Support/Models/BillDateCalculatorTest.php+++ b/tests/integration/Support/Models/BillDateCalculatorTest.php@@ -45,6 +45,17 @@ final class BillDateCalculatorTest extends TestCase$this->calculator = new BillDateCalculator();}+ /**+ * Stupid long method names I'm not going to do that.+ *+ * @dataProvider provideDates+ */+ public function testGivenSomeDataItWorks(Carbon $earliest, Carbon $latest, Carbon $billStart, string $period, int $skip, ?Carbon $lastPaid, array $expected): void+ {+ $result = $this->calculator->getPayDates($earliest, $latest, $billStart, $period, $skip, $lastPaid);+ self::assertSame($expected, $result);+ }+public static function provideDates(): iterable{// Carbon $earliest, Carbon $latest, Carbon $billStart, string $period, int $skip, ?Carbon $lastPaid@@ -66,15 +77,4 @@ final class BillDateCalculatorTest extends TestCase'1Ya' => ['earliest' => Carbon::parse('2023-11-01'), 'latest' => Carbon::parse('2023-11-30'), 'billStart' => Carbon::parse('2021-05-01'), 'period' => 'yearly', 'skip' => 0, 'lastPaid' => Carbon::parse('2023-05-02'), 'expected' => ['2024-05-01']],];}-- /**- * Stupid long method names I'm not going to do that.- *- * @dataProvider provideDates- */- public function testGivenSomeDataItWorks(Carbon $earliest, Carbon $latest, Carbon $billStart, string $period, int $skip, ?Carbon $lastPaid, array $expected): void- {- $result = $this->calculator->getPayDates($earliest, $latest, $billStart, $period, $skip, $lastPaid);- self::assertSame($expected, $result);- }}diff --git a/tests/unit/Support/Calendar/CalculatorTest.php b/tests/unit/Support/Calendar/CalculatorTest.phpindex 3830390c3b..4f127bf767 100644--- a/tests/unit/Support/Calendar/CalculatorTest.php+++ b/tests/unit/Support/Calendar/CalculatorTest.php@@ -50,24 +50,6 @@ use Tests\unit\Support\Calendar\Periodicity\YearlyTest;*/final class CalculatorTest extends TestCase{- public static function provideAllPeriodicity(): iterable- {- $intervals = [];- $intervals = array_merge($intervals, self::convert(Periodicity::Daily, DailyTest::provideIntervals()));- $intervals = array_merge($intervals, self::convert(Periodicity::Weekly, WeeklyTest::provideIntervals()));- $intervals = array_merge($intervals, self::convert(Periodicity::Fortnightly, FortnightlyTest::provideIntervals()));- $intervals = array_merge($intervals, self::convert(Periodicity::Monthly, MonthlyTest::provideIntervals()));- $intervals = array_merge($intervals, self::convert(Periodicity::Bimonthly, BimonthlyTest::provideIntervals()));- $intervals = array_merge($intervals, self::convert(Periodicity::Quarterly, QuarterlyTest::provideIntervals()));- $intervals = array_merge($intervals, self::convert(Periodicity::HalfYearly, HalfYearlyTest::provideIntervals()));- $intervals = array_merge($intervals, self::convert(Periodicity::Yearly, YearlyTest::provideIntervals()));-- /** @var IntervalProvider $interval */- foreach ($intervals as $label => $interval) {- yield $label => $interval;- }- }-private static function convert(Periodicity $periodicity, array $intervals): array{$periodicityIntervals = [];@@ -82,11 +64,6 @@ final class CalculatorTest extends TestCasereturn $periodicityIntervals;}- public static function provideSkippedIntervals(): iterable- {- return CalculatorProvider::providePeriodicityWithSkippedIntervals();- }-/*** @dataProvider provideAllPeriodicity*@@ -99,6 +76,24 @@ final class CalculatorTest extends TestCaseself::assertSame($provider->expected()->toDateString(), $period->toDateString());}+ public static function provideAllPeriodicity(): iterable+ {+ $intervals = [];+ $intervals = array_merge($intervals, self::convert(Periodicity::Daily, DailyTest::provideIntervals()));+ $intervals = array_merge($intervals, self::convert(Periodicity::Weekly, WeeklyTest::provideIntervals()));+ $intervals = array_merge($intervals, self::convert(Periodicity::Fortnightly, FortnightlyTest::provideIntervals()));+ $intervals = array_merge($intervals, self::convert(Periodicity::Monthly, MonthlyTest::provideIntervals()));+ $intervals = array_merge($intervals, self::convert(Periodicity::Bimonthly, BimonthlyTest::provideIntervals()));+ $intervals = array_merge($intervals, self::convert(Periodicity::Quarterly, QuarterlyTest::provideIntervals()));+ $intervals = array_merge($intervals, self::convert(Periodicity::HalfYearly, HalfYearlyTest::provideIntervals()));+ $intervals = array_merge($intervals, self::convert(Periodicity::Yearly, YearlyTest::provideIntervals()));++ /** @var IntervalProvider $interval */+ foreach ($intervals as $label => $interval) {+ yield $label => $interval;+ }+ }+/*** @dataProvider provideSkippedIntervals*@@ -110,4 +105,9 @@ final class CalculatorTest extends TestCase$period = $calculator->nextDateByInterval($provider->epoch(), $provider->periodicity, $provider->skip);self::assertSame($provider->expected()->toDateString(), $period->toDateString());}++ public static function provideSkippedIntervals(): iterable+ {+ return CalculatorProvider::providePeriodicityWithSkippedIntervals();+ }}diff --git a/tests/unit/Support/Calendar/Periodicity/IntervalTestCase.php b/tests/unit/Support/Calendar/Periodicity/IntervalTestCase.phpindex 2153f1b9a0..7e4cc812bc 100644--- a/tests/unit/Support/Calendar/Periodicity/IntervalTestCase.php+++ b/tests/unit/Support/Calendar/Periodicity/IntervalTestCase.php@@ -29,16 +29,6 @@ use Tests\integration\TestCase;abstract class IntervalTestCase extends TestCase{- public static function provider(): iterable- {- $intervals = static::provideIntervals();-- /** @var IntervalProvider $interval */- foreach ($intervals as $interval) {- yield "{$interval->label}" => [$interval];- }- }-abstract public static function provideIntervals(): array;/**@@ -50,5 +40,15 @@ abstract class IntervalTestCase extends TestCaseself::assertSame($provider->expected->toDateString(), $period->toDateString());}+ public static function provider(): iterable+ {+ $intervals = static::provideIntervals();++ /** @var IntervalProvider $interval */+ foreach ($intervals as $interval) {+ yield "{$interval->label}" => [$interval];+ }+ }+abstract public static function factory(): Interval;}diff --git a/tests/unit/Support/NavigationAddPeriodTest.php b/tests/unit/Support/NavigationAddPeriodTest.phpindex cb0cedc1f0..018258d2bf 100644--- a/tests/unit/Support/NavigationAddPeriodTest.php+++ b/tests/unit/Support/NavigationAddPeriodTest.php@@ -48,74 +48,13 @@ final class NavigationAddPeriodTest extends TestCase$this->navigation = new Navigation();}- public static function provideFrequencies(): iterable- {- return [- Periodicity::Daily->name => ['periodicity' => Periodicity::Daily, 'from' => Carbon::now(), 'expected' => Carbon::tomorrow()],- Periodicity::Weekly->name => ['periodicity' => Periodicity::Weekly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(1)],- Periodicity::Fortnightly->name => ['periodicity' => Periodicity::Fortnightly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(2)],- Periodicity::Monthly->name => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(1)],- '2019-01-01 to 2019-02-01' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2019-01-01'), 'expected' => Carbon::parse('2019-02-01')],- '2019-01-29 to 2019-02-28' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2019-01-29'), 'expected' => Carbon::parse('2019-02-28')],- '2019-01-30 to 2019-02-28' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2019-01-30'), 'expected' => Carbon::parse('2019-02-28')],- '2019-01-31 to 2019-02-28' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2019-01-31'), 'expected' => Carbon::parse('2019-02-28')],- '2023-03-31 to 2023-04-30' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2023-03-31'), 'expected' => Carbon::parse('2023-04-30')],- '2023-05-31 to 2023-06-30' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2023-05-31'), 'expected' => Carbon::parse('2023-06-30')],- '2023-08-31 to 2023-09-30' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2023-08-31'), 'expected' => Carbon::parse('2023-09-30')],- '2023-10-31 to 2023-11-30' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2023-10-31'), 'expected' => Carbon::parse('2023-11-30')],- Periodicity::Quarterly->name => ['periodicity' => Periodicity::Quarterly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],- '2019-01-29 to 2020-04-29' => ['periodicity' => Periodicity::Quarterly, 'from' => Carbon::parse('2019-01-29'), 'expected' => Carbon::parse('2019-04-29')],- '2019-01-30 to 2020-04-30' => ['periodicity' => Periodicity::Quarterly, 'from' => Carbon::parse('2019-01-30'), 'expected' => Carbon::parse('2019-04-30')],- '2019-01-31 to 2020-04-30' => ['periodicity' => Periodicity::Quarterly, 'from' => Carbon::parse('2019-01-31'), 'expected' => Carbon::parse('2019-04-30')],- Periodicity::HalfYearly->name => ['periodicity' => Periodicity::HalfYearly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(6)],- '2019-01-31 to 2020-07-29' => ['periodicity' => Periodicity::HalfYearly, 'from' => Carbon::parse('2019-01-29'), 'expected' => Carbon::parse('2019-07-29')],- '2019-01-31 to 2020-07-30' => ['periodicity' => Periodicity::HalfYearly, 'from' => Carbon::parse('2019-01-30'), 'expected' => Carbon::parse('2019-07-30')],- '2019-01-31 to 2020-07-31' => ['periodicity' => Periodicity::HalfYearly, 'from' => Carbon::parse('2019-01-31'), 'expected' => Carbon::parse('2019-07-31')],- Periodicity::Yearly->name => ['periodicity' => Periodicity::Yearly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],- '2020-02-29 to 2021-02-28' => ['periodicity' => Periodicity::Yearly, 'from' => Carbon::parse('2020-02-29'), 'expected' => Carbon::parse('2021-02-28')],- ];- }-- public static function provideMonthPeriods(): iterable- {- return [- '1M' => ['frequency' => '1M', 'from' => Carbon::parse('2023-06-25'), 'expected' => Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)],- 'month' => ['frequency' => 'month', 'from' => Carbon::parse('2023-06-25'), 'expected' => Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)],- 'monthly' => ['frequency' => 'monthly', 'from' => Carbon::parse('2023-06-25'), 'expected' => Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)],- '2019-01-29 to 2019-02-28' => ['frequency' => 'monthly', 'from' => Carbon::parse('2019-01-29'), 'expected' => Carbon::parse('2019-02-28')],- '2019-01-30 to 2019-02-28' => ['frequency' => 'monthly', 'from' => Carbon::parse('2019-01-30'), 'expected' => Carbon::parse('2019-02-28')],- '2019-01-31 to 2019-02-28' => ['frequency' => 'monthly', 'from' => Carbon::parse('2019-01-31'), 'expected' => Carbon::parse('2019-02-28')],- '2023-03-31 to 2023-04-30' => ['frequency' => 'monthly', 'from' => Carbon::parse('2023-03-31'), 'expected' => Carbon::parse('2023-04-30')],- '2023-05-31 to 2023-06-30' => ['frequency' => 'monthly', 'from' => Carbon::parse('2023-05-31'), 'expected' => Carbon::parse('2023-06-30')],- '2023-08-31 to 2023-09-30' => ['frequency' => 'monthly', 'from' => Carbon::parse('2023-08-31'), 'expected' => Carbon::parse('2023-09-30')],- '2023-10-31 to 2023-11-30' => ['frequency' => 'monthly', 'from' => Carbon::parse('2023-10-31'), 'expected' => Carbon::parse('2023-11-30')],- ];- }-- public static function providePeriods(): iterable+ /**+ * @dataProvider providePeriodsWithSkippingParam+ */+ public function testGivenAFrequencyAndSkipIntervalWhenCalculateTheDateThenReturnsTheSkippedDateSuccessful(int $skip, string $frequency, Carbon $from, Carbon $expected): void{- return [- '1D' => ['frequency' => '1D', 'from' => Carbon::now(), 'expected' => Carbon::tomorrow()],- 'daily' => ['frequency' => 'daily', 'from' => Carbon::now(), 'expected' => Carbon::tomorrow()],- '1W' => ['frequency' => '1W', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(1)],- 'weekly' => ['frequency' => 'weekly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(1)],- 'week' => ['frequency' => 'week', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(1)],- '3M' => ['frequency' => '3M', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],- 'quarter' => ['frequency' => 'quarter', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],- 'quarterly' => ['frequency' => 'quarterly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],- '6M' => ['frequency' => '6M', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(6)],- 'half-year' => ['frequency' => 'half-year', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(6)],- 'year' => ['frequency' => 'year', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],- 'yearly' => ['frequency' => 'yearly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],- '1Y' => ['frequency' => '1Y', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],- 'last7' => ['frequency' => 'last7', 'from' => Carbon::now(), 'expected' => Carbon::now()->addDays(7)],- 'last30' => ['frequency' => 'last30', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(1)],- 'last90' => ['frequency' => 'last90', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],- 'last365' => ['frequency' => 'last365', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],- 'MTD' => ['frequency' => 'MTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(1)],- 'QTD' => ['frequency' => 'QTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],- 'YTD' => ['frequency' => 'YTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],- ];+ $period = $this->navigation->addPeriod($from, $frequency, $skip);+ self::assertSame($expected->toDateString(), $period->toDateString());}public static function providePeriodsWithSkippingParam(): iterable@@ -163,15 +102,6 @@ final class NavigationAddPeriodTest extends TestCase}}- /**- * @dataProvider providePeriodsWithSkippingParam- */- public function testGivenAFrequencyAndSkipIntervalWhenCalculateTheDateThenReturnsTheSkippedDateSuccessful(int $skip, string $frequency, Carbon $from, Carbon $expected): void- {- $period = $this->navigation->addPeriod($from, $frequency, $skip);- self::assertSame($expected->toDateString(), $period->toDateString());- }-/*** @dataProvider providePeriods*/@@ -181,6 +111,32 @@ final class NavigationAddPeriodTest extends TestCaseself::assertSame($expected->toDateString(), $period->toDateString());}+ public static function providePeriods(): iterable+ {+ return [+ '1D' => ['frequency' => '1D', 'from' => Carbon::now(), 'expected' => Carbon::tomorrow()],+ 'daily' => ['frequency' => 'daily', 'from' => Carbon::now(), 'expected' => Carbon::tomorrow()],+ '1W' => ['frequency' => '1W', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(1)],+ 'weekly' => ['frequency' => 'weekly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(1)],+ 'week' => ['frequency' => 'week', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(1)],+ '3M' => ['frequency' => '3M', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],+ 'quarter' => ['frequency' => 'quarter', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],+ 'quarterly' => ['frequency' => 'quarterly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],+ '6M' => ['frequency' => '6M', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(6)],+ 'half-year' => ['frequency' => 'half-year', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(6)],+ 'year' => ['frequency' => 'year', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],+ 'yearly' => ['frequency' => 'yearly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],+ '1Y' => ['frequency' => '1Y', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],+ 'last7' => ['frequency' => 'last7', 'from' => Carbon::now(), 'expected' => Carbon::now()->addDays(7)],+ 'last30' => ['frequency' => 'last30', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(1)],+ 'last90' => ['frequency' => 'last90', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],+ 'last365' => ['frequency' => 'last365', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],+ 'MTD' => ['frequency' => 'MTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(1)],+ 'QTD' => ['frequency' => 'QTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],+ 'YTD' => ['frequency' => 'YTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],+ ];+ }+/*** @dataProvider provideFrequencies*/@@ -190,6 +146,34 @@ final class NavigationAddPeriodTest extends TestCaseself::assertSame($expected->toDateString(), $period->toDateString());}+ public static function provideFrequencies(): iterable+ {+ return [+ Periodicity::Daily->name => ['periodicity' => Periodicity::Daily, 'from' => Carbon::now(), 'expected' => Carbon::tomorrow()],+ Periodicity::Weekly->name => ['periodicity' => Periodicity::Weekly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(1)],+ Periodicity::Fortnightly->name => ['periodicity' => Periodicity::Fortnightly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(2)],+ Periodicity::Monthly->name => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(1)],+ '2019-01-01 to 2019-02-01' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2019-01-01'), 'expected' => Carbon::parse('2019-02-01')],+ '2019-01-29 to 2019-02-28' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2019-01-29'), 'expected' => Carbon::parse('2019-02-28')],+ '2019-01-30 to 2019-02-28' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2019-01-30'), 'expected' => Carbon::parse('2019-02-28')],+ '2019-01-31 to 2019-02-28' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2019-01-31'), 'expected' => Carbon::parse('2019-02-28')],+ '2023-03-31 to 2023-04-30' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2023-03-31'), 'expected' => Carbon::parse('2023-04-30')],+ '2023-05-31 to 2023-06-30' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2023-05-31'), 'expected' => Carbon::parse('2023-06-30')],+ '2023-08-31 to 2023-09-30' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2023-08-31'), 'expected' => Carbon::parse('2023-09-30')],+ '2023-10-31 to 2023-11-30' => ['periodicity' => Periodicity::Monthly, 'from' => Carbon::parse('2023-10-31'), 'expected' => Carbon::parse('2023-11-30')],+ Periodicity::Quarterly->name => ['periodicity' => Periodicity::Quarterly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],+ '2019-01-29 to 2020-04-29' => ['periodicity' => Periodicity::Quarterly, 'from' => Carbon::parse('2019-01-29'), 'expected' => Carbon::parse('2019-04-29')],+ '2019-01-30 to 2020-04-30' => ['periodicity' => Periodicity::Quarterly, 'from' => Carbon::parse('2019-01-30'), 'expected' => Carbon::parse('2019-04-30')],+ '2019-01-31 to 2020-04-30' => ['periodicity' => Periodicity::Quarterly, 'from' => Carbon::parse('2019-01-31'), 'expected' => Carbon::parse('2019-04-30')],+ Periodicity::HalfYearly->name => ['periodicity' => Periodicity::HalfYearly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(6)],+ '2019-01-31 to 2020-07-29' => ['periodicity' => Periodicity::HalfYearly, 'from' => Carbon::parse('2019-01-29'), 'expected' => Carbon::parse('2019-07-29')],+ '2019-01-31 to 2020-07-30' => ['periodicity' => Periodicity::HalfYearly, 'from' => Carbon::parse('2019-01-30'), 'expected' => Carbon::parse('2019-07-30')],+ '2019-01-31 to 2020-07-31' => ['periodicity' => Periodicity::HalfYearly, 'from' => Carbon::parse('2019-01-31'), 'expected' => Carbon::parse('2019-07-31')],+ Periodicity::Yearly->name => ['periodicity' => Periodicity::Yearly, 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],+ '2020-02-29 to 2021-02-28' => ['periodicity' => Periodicity::Yearly, 'from' => Carbon::parse('2020-02-29'), 'expected' => Carbon::parse('2021-02-28')],+ ];+ }+/*** @dataProvider provideMonthPeriods*/@@ -198,4 +182,20 @@ final class NavigationAddPeriodTest extends TestCase$period = $this->navigation->addPeriod($from, $frequency, 0);self::assertSame($expected->toDateString(), $period->toDateString());}++ public static function provideMonthPeriods(): iterable+ {+ return [+ '1M' => ['frequency' => '1M', 'from' => Carbon::parse('2023-06-25'), 'expected' => Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)],+ 'month' => ['frequency' => 'month', 'from' => Carbon::parse('2023-06-25'), 'expected' => Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)],+ 'monthly' => ['frequency' => 'monthly', 'from' => Carbon::parse('2023-06-25'), 'expected' => Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)],+ '2019-01-29 to 2019-02-28' => ['frequency' => 'monthly', 'from' => Carbon::parse('2019-01-29'), 'expected' => Carbon::parse('2019-02-28')],+ '2019-01-30 to 2019-02-28' => ['frequency' => 'monthly', 'from' => Carbon::parse('2019-01-30'), 'expected' => Carbon::parse('2019-02-28')],+ '2019-01-31 to 2019-02-28' => ['frequency' => 'monthly', 'from' => Carbon::parse('2019-01-31'), 'expected' => Carbon::parse('2019-02-28')],+ '2023-03-31 to 2023-04-30' => ['frequency' => 'monthly', 'from' => Carbon::parse('2023-03-31'), 'expected' => Carbon::parse('2023-04-30')],+ '2023-05-31 to 2023-06-30' => ['frequency' => 'monthly', 'from' => Carbon::parse('2023-05-31'), 'expected' => Carbon::parse('2023-06-30')],+ '2023-08-31 to 2023-09-30' => ['frequency' => 'monthly', 'from' => Carbon::parse('2023-08-31'), 'expected' => Carbon::parse('2023-09-30')],+ '2023-10-31 to 2023-11-30' => ['frequency' => 'monthly', 'from' => Carbon::parse('2023-10-31'), 'expected' => Carbon::parse('2023-11-30')],+ ];+ }}diff --git a/tests/unit/Support/NavigationEndOfPeriodTest.php b/tests/unit/Support/NavigationEndOfPeriodTest.phpindex f9a3b22e8e..278b2e7897 100644--- a/tests/unit/Support/NavigationEndOfPeriodTest.php+++ b/tests/unit/Support/NavigationEndOfPeriodTest.php@@ -47,6 +47,15 @@ final class NavigationEndOfPeriodTest extends TestCase$this->navigation = new Navigation();}+ /**+ * @dataProvider provideDates+ */+ public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void+ {+ $period = clone $this->navigation->endOfPeriod($from, $frequency);+ self::assertSame($expected->toDateString(), $period->toDateString());+ }+public static function provideDates(): iterable{return [@@ -78,24 +87,6 @@ final class NavigationEndOfPeriodTest extends TestCase];}- public static function provideUnknownFrequencies(): iterable- {- return [- '1day' => ['frequency' => '1day', 'from' => Carbon::now(), 'expected' => Carbon::now()],- 'unknown' => ['frequency' => 'unknown', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],- 'empty' => ['frequency' => '', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],- ];- }-- /**- * @dataProvider provideDates- */- public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void- {- $period = clone $this->navigation->endOfPeriod($from, $frequency);- self::assertSame($expected->toDateString(), $period->toDateString());- }-/*** @dataProvider provideUnknownFrequencies*/@@ -109,4 +100,13 @@ final class NavigationEndOfPeriodTest extends TestCaseLog::shouldHaveReceived('error', [$expectedMessage]);}++ public static function provideUnknownFrequencies(): iterable+ {+ return [+ '1day' => ['frequency' => '1day', 'from' => Carbon::now(), 'expected' => Carbon::now()],+ 'unknown' => ['frequency' => 'unknown', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],+ 'empty' => ['frequency' => '', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],+ ];+ }}diff --git a/tests/unit/Support/NavigationPreferredCarbonFormatByPeriodTest.php b/tests/unit/Support/NavigationPreferredCarbonFormatByPeriodTest.phpindex fcb0165476..1a6007870d 100644--- a/tests/unit/Support/NavigationPreferredCarbonFormatByPeriodTest.php+++ b/tests/unit/Support/NavigationPreferredCarbonFormatByPeriodTest.php@@ -46,6 +46,15 @@ final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase$this->navigation = new Navigation();}+ /**+ * @dataProvider providePeriods+ */+ public function testGivenAPeriodWhenCallPreferredCarbonFormatByPeriodThenReturnsExpectedFormat(string $period, string $expected): void+ {+ $formatPeriod = $this->navigation->preferredCarbonFormatByPeriod($period);+ self::assertSame($expected, $formatPeriod);+ }+public static function providePeriods(): iterable{return [@@ -57,13 +66,4 @@ final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase'yearly' => ['period' => '1Y', 'expected' => 'Y'],];}-- /**- * @dataProvider providePeriods- */- public function testGivenAPeriodWhenCallPreferredCarbonFormatByPeriodThenReturnsExpectedFormat(string $period, string $expected): void- {- $formatPeriod = $this->navigation->preferredCarbonFormatByPeriod($period);- self::assertSame($expected, $formatPeriod);- }}diff --git a/tests/unit/Support/NavigationPreferredCarbonFormatTest.php b/tests/unit/Support/NavigationPreferredCarbonFormatTest.phpindex 667cd77333..2cb4e0d074 100644--- a/tests/unit/Support/NavigationPreferredCarbonFormatTest.php+++ b/tests/unit/Support/NavigationPreferredCarbonFormatTest.php@@ -47,6 +47,15 @@ final class NavigationPreferredCarbonFormatTest extends TestCase$this->navigation = new Navigation();}+ /**+ * @dataProvider providePeriods+ */+ public function testGivenStartAndEndDatesWhenCallPreferredCarbonFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void+ {+ $carbonFormat = $this->navigation->preferredCarbonFormat($start, $end);+ self::assertSame($expected, $carbonFormat);+ }+public static function providePeriods(): iterable{return [@@ -64,13 +73,4 @@ final class NavigationPreferredCarbonFormatTest extends TestCase'2 years' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYears(2), 'expected' => 'Y'],];}-- /**- * @dataProvider providePeriods- */- public function testGivenStartAndEndDatesWhenCallPreferredCarbonFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void- {- $carbonFormat = $this->navigation->preferredCarbonFormat($start, $end);- self::assertSame($expected, $carbonFormat);- }}diff --git a/tests/unit/Support/NavigationPreferredEndOfPeriodTest.php b/tests/unit/Support/NavigationPreferredEndOfPeriodTest.phpindex d5f56ff678..f951a9a6a2 100644--- a/tests/unit/Support/NavigationPreferredEndOfPeriodTest.php+++ b/tests/unit/Support/NavigationPreferredEndOfPeriodTest.php@@ -47,6 +47,15 @@ final class NavigationPreferredEndOfPeriodTest extends TestCase$this->navigation = new Navigation();}+ /**+ * @dataProvider providePeriods+ */+ public function testGivenStartAndEndDatesWhenCallPreferredEndOfPeriodThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void+ {+ $formatPeriod = $this->navigation->preferredEndOfPeriod($start, $end);+ self::assertSame($expected, $formatPeriod);+ }+public static function providePeriods(): iterable{return [@@ -64,13 +73,4 @@ final class NavigationPreferredEndOfPeriodTest extends TestCase'2 years' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYears(2), 'expected' => 'endOfYear'],];}-- /**- * @dataProvider providePeriods- */- public function testGivenStartAndEndDatesWhenCallPreferredEndOfPeriodThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void- {- $formatPeriod = $this->navigation->preferredEndOfPeriod($start, $end);- self::assertSame($expected, $formatPeriod);- }}diff --git a/tests/unit/Support/NavigationPreferredRangeFormatTest.php b/tests/unit/Support/NavigationPreferredRangeFormatTest.phpindex fede42ff47..21c2dea91d 100644--- a/tests/unit/Support/NavigationPreferredRangeFormatTest.php+++ b/tests/unit/Support/NavigationPreferredRangeFormatTest.php@@ -47,6 +47,15 @@ final class NavigationPreferredRangeFormatTest extends TestCase$this->navigation = new Navigation();}+ /**+ * @dataProvider providePeriods+ */+ public function testGivenStartAndEndDatesWhenCallPreferredRangeFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void+ {+ $formatPeriod = $this->navigation->preferredRangeFormat($start, $end);+ self::assertSame($expected, $formatPeriod);+ }+public static function providePeriods(): iterable{return [@@ -64,13 +73,4 @@ final class NavigationPreferredRangeFormatTest extends TestCase'2 years' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYears(2), 'expected' => '1Y'],];}-- /**- * @dataProvider providePeriods- */- public function testGivenStartAndEndDatesWhenCallPreferredRangeFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void- {- $formatPeriod = $this->navigation->preferredRangeFormat($start, $end);- self::assertSame($expected, $formatPeriod);- }}diff --git a/tests/unit/Support/NavigationPreferredSqlFormatTest.php b/tests/unit/Support/NavigationPreferredSqlFormatTest.phpindex 24a9c174fa..9dce8d5d33 100644--- a/tests/unit/Support/NavigationPreferredSqlFormatTest.php+++ b/tests/unit/Support/NavigationPreferredSqlFormatTest.php@@ -47,6 +47,15 @@ final class NavigationPreferredSqlFormatTest extends TestCase$this->navigation = new Navigation();}+ /**+ * @dataProvider provideDates+ */+ public function testGivenStartAndEndDatesWhenCallPreferredSqlFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void+ {+ $formatPeriod = $this->navigation->preferredSqlFormat($start, $end);+ self::assertSame($expected, $formatPeriod);+ }+public static function provideDates(): iterable{return [@@ -64,13 +73,4 @@ final class NavigationPreferredSqlFormatTest extends TestCase'2 years' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYears(2), 'expected' => '%Y'],];}-- /**- * @dataProvider provideDates- */- public function testGivenStartAndEndDatesWhenCallPreferredSqlFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void- {- $formatPeriod = $this->navigation->preferredSqlFormat($start, $end);- self::assertSame($expected, $formatPeriod);- }}diff --git a/tests/unit/Support/NavigationStartOfPeriodTest.php b/tests/unit/Support/NavigationStartOfPeriodTest.phpindex 315cb1695c..fe9f5117b0 100644--- a/tests/unit/Support/NavigationStartOfPeriodTest.php+++ b/tests/unit/Support/NavigationStartOfPeriodTest.php@@ -48,6 +48,15 @@ final class NavigationStartOfPeriodTest extends TestCase$this->navigation = new Navigation();}+ /**+ * @dataProvider provideDates+ */+ public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void+ {+ $period = $this->navigation->startOfPeriod($from, $frequency);+ self::assertSame($expected->toDateString(), $period->toDateString());+ }+public static function provideDates(): iterable{return [@@ -78,24 +87,6 @@ final class NavigationStartOfPeriodTest extends TestCase];}- public static function provideUnknownFrequencies(): iterable- {- return [- '1day' => ['frequency' => '1day', 'from' => Carbon::now(), 'expected' => Carbon::now()],- 'unknown' => ['frequency' => 'unknown', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],- 'empty' => ['frequency' => '', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],- ];- }-- /**- * @dataProvider provideDates- */- public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void- {- $period = $this->navigation->startOfPeriod($from, $frequency);- self::assertSame($expected->toDateString(), $period->toDateString());- }-/*** @dataProvider provideUnknownFrequencies*/@@ -111,4 +102,13 @@ final class NavigationStartOfPeriodTest extends TestCase$period = $this->navigation->startOfPeriod($from, $frequency);self::assertSame($expected->toDateString(), $period->toDateString());}++ public static function provideUnknownFrequencies(): iterable+ {+ return [+ '1day' => ['frequency' => '1day', 'from' => Carbon::now(), 'expected' => Carbon::now()],+ 'unknown' => ['frequency' => 'unknown', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],+ 'empty' => ['frequency' => '', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],+ ];+ }}diff --git a/tests/unit/Support/Search/QueryParser/AbstractQueryParserInterfaceParseQueryTester.php b/tests/unit/Support/Search/QueryParser/AbstractQueryParserInterfaceParseQueryTester.phpindex c2abc6aeb2..0081ac0b19 100644--- a/tests/unit/Support/Search/QueryParser/AbstractQueryParserInterfaceParseQueryTester.php+++ b/tests/unit/Support/Search/QueryParser/AbstractQueryParserInterfaceParseQueryTester.php@@ -15,6 +15,20 @@ abstract class AbstractQueryParserInterfaceParseQueryTester extends TestCase{abstract protected function createParser(): QueryParserInterface;+ /**+ * @dataProvider queryDataProvider+ *+ * @param string $query The query string to parse+ * @param Node $expected The expected parse result+ */+ public function testQueryParsing(string $query, Node $expected): void+ {+ $actual = $this->createParser()->parse($query);++ self::assertObjectEquals($expected, $actual);++ }+public static function queryDataProvider(): iterable{return [@@ -181,18 +195,4 @@ abstract class AbstractQueryParserInterfaceParseQueryTester extends TestCase],];}-- /**- * @dataProvider queryDataProvider- *- * @param string $query The query string to parse- * @param Node $expected The expected parse result- */- public function testQueryParsing(string $query, Node $expected): void- {- $actual = $this->createParser()->parse($query);-- self::assertObjectEquals($expected, $actual);-- }}