mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Final fixes.
This commit is contained in:
@@ -35,7 +35,7 @@ return RectorConfig::configure()
|
|||||||
__DIR__ . '/../bootstrap',
|
__DIR__ . '/../bootstrap',
|
||||||
__DIR__ . '/../config',
|
__DIR__ . '/../config',
|
||||||
__DIR__ . '/../public',
|
__DIR__ . '/../public',
|
||||||
__DIR__ . '/../resources',
|
__DIR__ . '/../resources/lang/en_US',
|
||||||
__DIR__ . '/../routes',
|
__DIR__ . '/../routes',
|
||||||
__DIR__ . '/../tests',
|
__DIR__ . '/../tests',
|
||||||
])
|
])
|
||||||
|
@@ -21,6 +21,11 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Application;
|
||||||
|
use Illuminate\Contracts\Http\Kernel;
|
||||||
|
use Illuminate\Contracts\Debug\ExceptionHandler;
|
||||||
|
use FireflyIII\Exceptions\Handler;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Create The Application
|
| Create The Application
|
||||||
@@ -45,7 +50,7 @@ if (!function_exists('envNonEmpty')) {
|
|||||||
{
|
{
|
||||||
$result = env($key, $default); // @phpstan-ignore-line
|
$result = env($key, $default); // @phpstan-ignore-line
|
||||||
if ('' === $result) {
|
if ('' === $result) {
|
||||||
$result = $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -65,7 +70,7 @@ if (!function_exists('stringIsEqual')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$app = new Illuminate\Foundation\Application(
|
$app = new Application(
|
||||||
(string)realpath(__DIR__ . '/../')
|
(string)realpath(__DIR__ . '/../')
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -81,7 +86,7 @@ $app = new Illuminate\Foundation\Application(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$app->singleton(
|
$app->singleton(
|
||||||
Illuminate\Contracts\Http\Kernel::class,
|
Kernel::class,
|
||||||
FireflyIII\Http\Kernel::class
|
FireflyIII\Http\Kernel::class
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -91,8 +96,8 @@ $app->singleton(
|
|||||||
);
|
);
|
||||||
|
|
||||||
$app->singleton(
|
$app->singleton(
|
||||||
Illuminate\Contracts\Debug\ExceptionHandler::class,
|
ExceptionHandler::class,
|
||||||
FireflyIII\Exceptions\Handler::class
|
Handler::class
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,4 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Http\Kernel;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* index.php
|
* index.php
|
||||||
* Copyright (c) 2019 james@firefly-iii.org
|
* Copyright (c) 2019 james@firefly-iii.org
|
||||||
@@ -69,9 +74,9 @@ $app = require_once __DIR__ . '/../bootstrap/app.php';
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
|
$kernel = $app->make(Kernel::class);
|
||||||
$response = $kernel->handle(
|
$response = $kernel->handle(
|
||||||
$request = Illuminate\Http\Request::capture()
|
$request = Request::capture()
|
||||||
);
|
);
|
||||||
$response->send();
|
$response->send();
|
||||||
|
|
||||||
|
@@ -54,12 +54,11 @@ if (!function_exists('limitStringLength')) {
|
|||||||
{
|
{
|
||||||
$maxChars = 75;
|
$maxChars = 75;
|
||||||
$length = strlen($string);
|
$length = strlen($string);
|
||||||
$result = $string;
|
|
||||||
if ($length > $maxChars) {
|
if ($length > $maxChars) {
|
||||||
$result = substr_replace($string, ' ... ', (int)($maxChars / 2), $length - $maxChars);
|
return substr_replace($string, ' ... ', (int)($maxChars / 2), $length - $maxChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +108,7 @@ Breadcrumbs::for(
|
|||||||
|
|
||||||
$breadcrumbs->parent('accounts.index', $what);
|
$breadcrumbs->parent('accounts.index', $what);
|
||||||
$breadcrumbs->push(limitStringLength($account->name), route('accounts.show.all', [$account->id]));
|
$breadcrumbs->push(limitStringLength($account->name), route('accounts.show.all', [$account->id]));
|
||||||
if (null !== $start && null !== $end) {
|
if ($start instanceof Carbon && $end instanceof Carbon) {
|
||||||
$title = trans(
|
$title = trans(
|
||||||
'firefly.between_dates_breadcrumb',
|
'firefly.between_dates_breadcrumb',
|
||||||
[
|
[
|
||||||
@@ -451,7 +450,7 @@ Breadcrumbs::for(
|
|||||||
static function (Generator $breadcrumbs, ?Carbon $start = null, ?Carbon $end = null): void {
|
static function (Generator $breadcrumbs, ?Carbon $start = null, ?Carbon $end = null): void {
|
||||||
$breadcrumbs->parent('budgets.index');
|
$breadcrumbs->parent('budgets.index');
|
||||||
$breadcrumbs->push(trans('firefly.journals_without_budget'), route('budgets.no-budget'));
|
$breadcrumbs->push(trans('firefly.journals_without_budget'), route('budgets.no-budget'));
|
||||||
if (null !== $start && null !== $end) {
|
if ($start instanceof Carbon && $end instanceof Carbon) {
|
||||||
$title = trans(
|
$title = trans(
|
||||||
'firefly.between_dates_breadcrumb',
|
'firefly.between_dates_breadcrumb',
|
||||||
[
|
[
|
||||||
@@ -539,7 +538,7 @@ Breadcrumbs::for(
|
|||||||
static function (Generator $breadcrumbs, Category $category, ?Carbon $start = null, ?Carbon $end = null): void {
|
static function (Generator $breadcrumbs, Category $category, ?Carbon $start = null, ?Carbon $end = null): void {
|
||||||
$breadcrumbs->parent('categories.index');
|
$breadcrumbs->parent('categories.index');
|
||||||
$breadcrumbs->push(limitStringLength($category->name), route('categories.show', [$category->id]));
|
$breadcrumbs->push(limitStringLength($category->name), route('categories.show', [$category->id]));
|
||||||
if (null !== $start && null !== $end) {
|
if ($start instanceof Carbon && $end instanceof Carbon) {
|
||||||
$title = trans(
|
$title = trans(
|
||||||
'firefly.between_dates_breadcrumb',
|
'firefly.between_dates_breadcrumb',
|
||||||
[
|
[
|
||||||
@@ -566,7 +565,7 @@ Breadcrumbs::for(
|
|||||||
static function (Generator $breadcrumbs, ?Carbon $start = null, ?Carbon $end = null): void {
|
static function (Generator $breadcrumbs, ?Carbon $start = null, ?Carbon $end = null): void {
|
||||||
$breadcrumbs->parent('categories.index');
|
$breadcrumbs->parent('categories.index');
|
||||||
$breadcrumbs->push(trans('firefly.journals_without_category'), route('categories.no-category'));
|
$breadcrumbs->push(trans('firefly.journals_without_category'), route('categories.no-category'));
|
||||||
if (null !== $start && null !== $end) {
|
if ($start instanceof Carbon && $end instanceof Carbon) {
|
||||||
$title = trans(
|
$title = trans(
|
||||||
'firefly.between_dates_breadcrumb',
|
'firefly.between_dates_breadcrumb',
|
||||||
[
|
[
|
||||||
@@ -965,10 +964,10 @@ Breadcrumbs::for(
|
|||||||
'rules.create',
|
'rules.create',
|
||||||
static function (Generator $breadcrumbs, ?RuleGroup $ruleGroup = null): void {
|
static function (Generator $breadcrumbs, ?RuleGroup $ruleGroup = null): void {
|
||||||
$breadcrumbs->parent('rules.index');
|
$breadcrumbs->parent('rules.index');
|
||||||
if (null === $ruleGroup) {
|
if (!$ruleGroup instanceof RuleGroup) {
|
||||||
$breadcrumbs->push(trans('firefly.make_new_rule_no_group'), route('rules.create'));
|
$breadcrumbs->push(trans('firefly.make_new_rule_no_group'), route('rules.create'));
|
||||||
}
|
}
|
||||||
if (null !== $ruleGroup) {
|
if ($ruleGroup instanceof RuleGroup) {
|
||||||
$breadcrumbs->push(trans('firefly.make_new_rule', ['title' => $ruleGroup->title]), route('rules.create', [$ruleGroup]));
|
$breadcrumbs->push(trans('firefly.make_new_rule', ['title' => $ruleGroup->title]), route('rules.create', [$ruleGroup]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1096,7 +1095,7 @@ Breadcrumbs::for(
|
|||||||
$breadcrumbs->parent('tags.index');
|
$breadcrumbs->parent('tags.index');
|
||||||
|
|
||||||
$breadcrumbs->push($tag->tag, route('tags.show', [$tag->id, $start, $end]));
|
$breadcrumbs->push($tag->tag, route('tags.show', [$tag->id, $start, $end]));
|
||||||
if (null !== $start && null !== $end) {
|
if ($start instanceof Carbon && $end instanceof Carbon) {
|
||||||
$title = trans(
|
$title = trans(
|
||||||
'firefly.between_dates_breadcrumb',
|
'firefly.between_dates_breadcrumb',
|
||||||
[
|
[
|
||||||
@@ -1127,7 +1126,7 @@ Breadcrumbs::for(
|
|||||||
$breadcrumbs->parent('home');
|
$breadcrumbs->parent('home');
|
||||||
$breadcrumbs->push(trans('breadcrumbs.'.$what.'_list'), route('transactions.index', [$what]));
|
$breadcrumbs->push(trans('breadcrumbs.'.$what.'_list'), route('transactions.index', [$what]));
|
||||||
|
|
||||||
if (null !== $start && null !== $end) {
|
if ($start instanceof Carbon && $end instanceof Carbon) {
|
||||||
// add date range:
|
// add date range:
|
||||||
$title = trans(
|
$title = trans(
|
||||||
'firefly.between_dates_breadcrumb',
|
'firefly.between_dates_breadcrumb',
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\integration\Support\Models;
|
namespace Tests\integration\Support\Models;
|
||||||
|
|
||||||
|
use Override;
|
||||||
|
use Iterator;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Models\BillDateCalculator;
|
use FireflyIII\Support\Models\BillDateCalculator;
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
@@ -40,6 +42,7 @@ final class BillDateCalculatorTest extends TestCase
|
|||||||
{
|
{
|
||||||
private BillDateCalculator $calculator;
|
private BillDateCalculator $calculator;
|
||||||
|
|
||||||
|
#[Override]
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -56,25 +59,25 @@ final class BillDateCalculatorTest extends TestCase
|
|||||||
self::assertSame($expected, $result);
|
self::assertSame($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideDates(): iterable
|
public static function provideDates(): Iterator
|
||||||
{
|
{
|
||||||
// Carbon $earliest, Carbon $latest, Carbon $billStart, string $period, int $skip, ?Carbon $lastPaid
|
// Carbon $earliest, Carbon $latest, Carbon $billStart, string $period, int $skip, ?Carbon $lastPaid
|
||||||
return [
|
// basic monthly bill.x
|
||||||
// basic monthly bill.x
|
yield '1Ma' => [Carbon::parse('2023-11-01'), Carbon::parse('2023-11-30'), Carbon::parse('2023-01-01'), 'monthly', 0, null, ['2023-11-01']];
|
||||||
'1Ma' => ['earliest' => Carbon::parse('2023-11-01'), 'latest' => Carbon::parse('2023-11-30'), 'billStart' => Carbon::parse('2023-01-01'), 'period' => 'monthly', 'skip' => 0, 'lastPaid' => null, 'expected' => ['2023-11-01']],
|
|
||||||
// already paid on the first, expect it next month.
|
|
||||||
'1Mb' => ['earliest' => Carbon::parse('2023-11-01'), 'latest' => Carbon::parse('2023-11-30'), 'billStart' => Carbon::parse('2023-01-01'), 'period' => 'monthly', 'skip' => 0, 'lastPaid' => Carbon::parse('2023-11-01'), 'expected' => ['2023-12-01']],
|
|
||||||
// already paid on the 12th, expect it next month.
|
|
||||||
'1Mc' => ['earliest' => Carbon::parse('2023-11-01'), 'latest' => Carbon::parse('2023-11-30'), 'billStart' => Carbon::parse('2023-01-01'), 'period' => 'monthly', 'skip' => 0, 'lastPaid' => Carbon::parse('2023-11-12'), 'expected' => ['2023-12-01']],
|
|
||||||
|
|
||||||
// every month, start on 2024-01-30, view is quarterly
|
// already paid on the first, expect it next month.
|
||||||
'1Md' => ['earliest' => Carbon::parse('2023-01-01'), 'latest' => Carbon::parse('2023-03-31'), 'billStart' => Carbon::parse('2023-01-29'), 'period' => 'monthly', 'skip' => 0, 'lastPaid' => null, 'expected' => ['2023-01-29', '2023-02-28', '2023-03-29']],
|
yield '1Mb' => [Carbon::parse('2023-11-01'), Carbon::parse('2023-11-30'), Carbon::parse('2023-01-01'), 'monthly', 0, Carbon::parse('2023-11-01'), ['2023-12-01']];
|
||||||
|
|
||||||
// every month, start on 2024-01-30, view is quarterly
|
// already paid on the 12th, expect it next month.
|
||||||
'1Me' => ['earliest' => Carbon::parse('2024-01-01'), 'latest' => Carbon::parse('2024-03-31'), 'billStart' => Carbon::parse('2023-01-30'), 'period' => 'monthly', 'skip' => 0, 'lastPaid' => null, 'expected' => ['2024-01-30', '2024-02-29', '2024-03-30']],
|
yield '1Mc' => [Carbon::parse('2023-11-01'), Carbon::parse('2023-11-30'), Carbon::parse('2023-01-01'), 'monthly', 0, Carbon::parse('2023-11-12'), ['2023-12-01']];
|
||||||
|
|
||||||
// yearly not due this month. Should jump to next year.
|
// every month, start on 2024-01-30, view is quarterly
|
||||||
'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']],
|
yield '1Md' => [Carbon::parse('2023-01-01'), Carbon::parse('2023-03-31'), Carbon::parse('2023-01-29'), 'monthly', 0, null, ['2023-01-29', '2023-02-28', '2023-03-29']];
|
||||||
];
|
|
||||||
|
// every month, start on 2024-01-30, view is quarterly
|
||||||
|
yield '1Me' => [Carbon::parse('2024-01-01'), Carbon::parse('2024-03-31'), Carbon::parse('2023-01-30'), 'monthly', 0, null, ['2024-01-30', '2024-02-29', '2024-03-30']];
|
||||||
|
|
||||||
|
// yearly not due this month. Should jump to next year.
|
||||||
|
yield '1Ya' => [Carbon::parse('2023-11-01'), Carbon::parse('2023-11-30'), Carbon::parse('2021-05-01'), 'yearly', 0, Carbon::parse('2023-05-02'), ['2024-05-01']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||||
|
|
||||||
|
use FireflyIII\Support\Calendar\Periodicity\Bimonthly;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Calendar\Periodicity;
|
use FireflyIII\Support\Calendar\Periodicity;
|
||||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||||
@@ -42,7 +43,7 @@ final class BimonthlyTest extends IntervalTestCase
|
|||||||
{
|
{
|
||||||
public static function factory(): Interval
|
public static function factory(): Interval
|
||||||
{
|
{
|
||||||
return new Periodicity\Bimonthly();
|
return new Bimonthly();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideIntervals(): array
|
public static function provideIntervals(): array
|
||||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||||
|
|
||||||
|
use FireflyIII\Support\Calendar\Periodicity\Daily;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Calendar\Periodicity;
|
use FireflyIII\Support\Calendar\Periodicity;
|
||||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||||
@@ -42,7 +43,7 @@ final class DailyTest extends IntervalTestCase
|
|||||||
{
|
{
|
||||||
public static function factory(): Interval
|
public static function factory(): Interval
|
||||||
{
|
{
|
||||||
return new Periodicity\Daily();
|
return new Daily();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideIntervals(): array
|
public static function provideIntervals(): array
|
||||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||||
|
|
||||||
|
use FireflyIII\Support\Calendar\Periodicity\Fortnightly;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Calendar\Periodicity;
|
use FireflyIII\Support\Calendar\Periodicity;
|
||||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||||
@@ -42,7 +43,7 @@ final class FortnightlyTest extends IntervalTestCase
|
|||||||
{
|
{
|
||||||
public static function factory(): Interval
|
public static function factory(): Interval
|
||||||
{
|
{
|
||||||
return new Periodicity\Fortnightly();
|
return new Fortnightly();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideIntervals(): array
|
public static function provideIntervals(): array
|
||||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||||
|
|
||||||
|
use FireflyIII\Support\Calendar\Periodicity\HalfYearly;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Calendar\Periodicity;
|
use FireflyIII\Support\Calendar\Periodicity;
|
||||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||||
@@ -42,7 +43,7 @@ final class HalfYearlyTest extends IntervalTestCase
|
|||||||
{
|
{
|
||||||
public static function factory(): Interval
|
public static function factory(): Interval
|
||||||
{
|
{
|
||||||
return new Periodicity\HalfYearly();
|
return new HalfYearly();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideIntervals(): array
|
public static function provideIntervals(): array
|
||||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||||
|
|
||||||
|
use FireflyIII\Support\Calendar\Periodicity\Monthly;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Calendar\Periodicity;
|
use FireflyIII\Support\Calendar\Periodicity;
|
||||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||||
@@ -42,7 +43,7 @@ final class MonthlyTest extends IntervalTestCase
|
|||||||
{
|
{
|
||||||
public static function factory(): Interval
|
public static function factory(): Interval
|
||||||
{
|
{
|
||||||
return new Periodicity\Monthly();
|
return new Monthly();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideIntervals(): array
|
public static function provideIntervals(): array
|
||||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||||
|
|
||||||
|
use FireflyIII\Support\Calendar\Periodicity\Quarterly;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Calendar\Periodicity;
|
use FireflyIII\Support\Calendar\Periodicity;
|
||||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||||
@@ -42,7 +43,7 @@ final class QuarterlyTest extends IntervalTestCase
|
|||||||
{
|
{
|
||||||
public static function factory(): Interval
|
public static function factory(): Interval
|
||||||
{
|
{
|
||||||
return new Periodicity\Quarterly();
|
return new Quarterly();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideIntervals(): array
|
public static function provideIntervals(): array
|
||||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||||
|
|
||||||
|
use FireflyIII\Support\Calendar\Periodicity\Weekly;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Calendar\Periodicity;
|
use FireflyIII\Support\Calendar\Periodicity;
|
||||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||||
@@ -42,7 +43,7 @@ final class WeeklyTest extends IntervalTestCase
|
|||||||
{
|
{
|
||||||
public static function factory(): Interval
|
public static function factory(): Interval
|
||||||
{
|
{
|
||||||
return new Periodicity\Weekly();
|
return new Weekly();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideIntervals(): array
|
public static function provideIntervals(): array
|
||||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||||
|
|
||||||
|
use FireflyIII\Support\Calendar\Periodicity\Yearly;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Calendar\Periodicity;
|
use FireflyIII\Support\Calendar\Periodicity;
|
||||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||||
@@ -42,7 +43,7 @@ final class YearlyTest extends IntervalTestCase
|
|||||||
{
|
{
|
||||||
public static function factory(): Interval
|
public static function factory(): Interval
|
||||||
{
|
{
|
||||||
return new Periodicity\Yearly();
|
return new Yearly();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideIntervals(): array
|
public static function provideIntervals(): array
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support;
|
namespace Tests\unit\Support;
|
||||||
|
|
||||||
|
use Override;
|
||||||
|
use Iterator;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Calendar\Periodicity;
|
use FireflyIII\Support\Calendar\Periodicity;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
@@ -43,6 +45,7 @@ final class NavigationAddPeriodTest extends TestCase
|
|||||||
{
|
{
|
||||||
private Navigation $navigation;
|
private Navigation $navigation;
|
||||||
|
|
||||||
|
#[Override]
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -108,30 +111,47 @@ final class NavigationAddPeriodTest extends TestCase
|
|||||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function providePeriods(): iterable
|
public static function providePeriods(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield '1D' => ['1D', Carbon::now(), Carbon::tomorrow()];
|
||||||
'1D' => ['frequency' => '1D', 'from' => Carbon::now(), 'expected' => Carbon::tomorrow()],
|
|
||||||
'daily' => ['frequency' => 'daily', 'from' => Carbon::now(), 'expected' => Carbon::tomorrow()],
|
yield 'daily' => ['daily', Carbon::now(), Carbon::tomorrow()];
|
||||||
'1W' => ['frequency' => '1W', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(1)],
|
|
||||||
'weekly' => ['frequency' => 'weekly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeeks(1)],
|
yield '1W' => ['1W', Carbon::now(), 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)],
|
yield 'weekly' => ['weekly', Carbon::now(), Carbon::now()->addWeeks(1)];
|
||||||
'quarter' => ['frequency' => 'quarter', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],
|
|
||||||
'quarterly' => ['frequency' => 'quarterly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],
|
yield 'week' => ['week', Carbon::now(), Carbon::now()->addWeeks(1)];
|
||||||
'6M' => ['frequency' => '6M', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(6)],
|
|
||||||
'half-year' => ['frequency' => 'half-year', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(6)],
|
yield '3M' => ['3M', Carbon::now(), Carbon::now()->addMonthsNoOverflow(3)];
|
||||||
'year' => ['frequency' => 'year', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],
|
|
||||||
'yearly' => ['frequency' => 'yearly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],
|
yield 'quarter' => ['quarter', Carbon::now(), Carbon::now()->addMonthsNoOverflow(3)];
|
||||||
'1Y' => ['frequency' => '1Y', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],
|
|
||||||
'last7' => ['frequency' => 'last7', 'from' => Carbon::now(), 'expected' => Carbon::now()->addDays(7)],
|
yield 'quarterly' => ['quarterly', Carbon::now(), Carbon::now()->addMonthsNoOverflow(3)];
|
||||||
'last30' => ['frequency' => 'last30', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(1)],
|
|
||||||
'last90' => ['frequency' => 'last90', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],
|
yield '6M' => ['6M', Carbon::now(), Carbon::now()->addMonthsNoOverflow(6)];
|
||||||
'last365' => ['frequency' => 'last365', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],
|
|
||||||
'MTD' => ['frequency' => 'MTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(1)],
|
yield 'half-year' => ['half-year', Carbon::now(), Carbon::now()->addMonthsNoOverflow(6)];
|
||||||
'QTD' => ['frequency' => 'QTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonthsNoOverflow(3)],
|
|
||||||
'YTD' => ['frequency' => 'YTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYears(1)],
|
yield 'year' => ['year', Carbon::now(), Carbon::now()->addYears(1)];
|
||||||
];
|
|
||||||
|
yield 'yearly' => ['yearly', Carbon::now(), Carbon::now()->addYears(1)];
|
||||||
|
|
||||||
|
yield '1Y' => ['1Y', Carbon::now(), Carbon::now()->addYears(1)];
|
||||||
|
|
||||||
|
yield 'last7' => ['last7', Carbon::now(), Carbon::now()->addDays(7)];
|
||||||
|
|
||||||
|
yield 'last30' => ['last30', Carbon::now(), Carbon::now()->addMonthsNoOverflow(1)];
|
||||||
|
|
||||||
|
yield 'last90' => ['last90', Carbon::now(), Carbon::now()->addMonthsNoOverflow(3)];
|
||||||
|
|
||||||
|
yield 'last365' => ['last365', Carbon::now(), Carbon::now()->addYears(1)];
|
||||||
|
|
||||||
|
yield 'MTD' => ['MTD', Carbon::now(), Carbon::now()->addMonthsNoOverflow(1)];
|
||||||
|
|
||||||
|
yield 'QTD' => ['QTD', Carbon::now(), Carbon::now()->addMonthsNoOverflow(3)];
|
||||||
|
|
||||||
|
yield 'YTD' => ['YTD', Carbon::now(), Carbon::now()->addYears(1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[DataProvider('provideFrequencies')]
|
#[DataProvider('provideFrequencies')]
|
||||||
@@ -141,32 +161,51 @@ final class NavigationAddPeriodTest extends TestCase
|
|||||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideFrequencies(): iterable
|
public static function provideFrequencies(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield Periodicity::Daily->name => [Periodicity::Daily, Carbon::now(), Carbon::tomorrow()];
|
||||||
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)],
|
yield Periodicity::Weekly->name => [Periodicity::Weekly, Carbon::now(), 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)],
|
yield Periodicity::Fortnightly->name => [Periodicity::Fortnightly, Carbon::now(), Carbon::now()->addWeeks(2)];
|
||||||
'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')],
|
yield Periodicity::Monthly->name => [Periodicity::Monthly, Carbon::now(), Carbon::now()->addMonthsNoOverflow(1)];
|
||||||
'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')],
|
yield '2019-01-01 to 2019-02-01' => [Periodicity::Monthly, Carbon::parse('2019-01-01'), Carbon::parse('2019-02-01')];
|
||||||
'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')],
|
yield '2019-01-29 to 2019-02-28' => [Periodicity::Monthly, Carbon::parse('2019-01-29'), Carbon::parse('2019-02-28')];
|
||||||
'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')],
|
yield '2019-01-30 to 2019-02-28' => [Periodicity::Monthly, Carbon::parse('2019-01-30'), Carbon::parse('2019-02-28')];
|
||||||
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')],
|
yield '2019-01-31 to 2019-02-28' => [Periodicity::Monthly, Carbon::parse('2019-01-31'), Carbon::parse('2019-02-28')];
|
||||||
'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')],
|
yield '2023-03-31 to 2023-04-30' => [Periodicity::Monthly, Carbon::parse('2023-03-31'), Carbon::parse('2023-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')],
|
yield '2023-05-31 to 2023-06-30' => [Periodicity::Monthly, Carbon::parse('2023-05-31'), Carbon::parse('2023-06-30')];
|
||||||
'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')],
|
yield '2023-08-31 to 2023-09-30' => [Periodicity::Monthly, Carbon::parse('2023-08-31'), Carbon::parse('2023-09-30')];
|
||||||
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')],
|
yield '2023-10-31 to 2023-11-30' => [Periodicity::Monthly, Carbon::parse('2023-10-31'), Carbon::parse('2023-11-30')];
|
||||||
];
|
|
||||||
|
yield Periodicity::Quarterly->name => [Periodicity::Quarterly, Carbon::now(), Carbon::now()->addMonthsNoOverflow(3)];
|
||||||
|
|
||||||
|
yield '2019-01-29 to 2020-04-29' => [Periodicity::Quarterly, Carbon::parse('2019-01-29'), Carbon::parse('2019-04-29')];
|
||||||
|
|
||||||
|
yield '2019-01-30 to 2020-04-30' => [Periodicity::Quarterly, Carbon::parse('2019-01-30'), Carbon::parse('2019-04-30')];
|
||||||
|
|
||||||
|
yield '2019-01-31 to 2020-04-30' => [Periodicity::Quarterly, Carbon::parse('2019-01-31'), Carbon::parse('2019-04-30')];
|
||||||
|
|
||||||
|
yield Periodicity::HalfYearly->name => [Periodicity::HalfYearly, Carbon::now(), Carbon::now()->addMonthsNoOverflow(6)];
|
||||||
|
|
||||||
|
yield '2019-01-31 to 2020-07-29' => [Periodicity::HalfYearly, Carbon::parse('2019-01-29'), Carbon::parse('2019-07-29')];
|
||||||
|
|
||||||
|
yield '2019-01-31 to 2020-07-30' => [Periodicity::HalfYearly, Carbon::parse('2019-01-30'), Carbon::parse('2019-07-30')];
|
||||||
|
|
||||||
|
yield '2019-01-31 to 2020-07-31' => [Periodicity::HalfYearly, Carbon::parse('2019-01-31'), Carbon::parse('2019-07-31')];
|
||||||
|
|
||||||
|
yield Periodicity::Yearly->name => [Periodicity::Yearly, Carbon::now(), Carbon::now()->addYears(1)];
|
||||||
|
|
||||||
|
yield '2020-02-29 to 2021-02-28' => [Periodicity::Yearly, Carbon::parse('2020-02-29'), Carbon::parse('2021-02-28')];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[DataProvider('provideMonthPeriods')]
|
#[DataProvider('provideMonthPeriods')]
|
||||||
@@ -176,19 +215,26 @@ final class NavigationAddPeriodTest extends TestCase
|
|||||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideMonthPeriods(): iterable
|
public static function provideMonthPeriods(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield '1M' => ['1M', Carbon::parse('2023-06-25'), Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)];
|
||||||
'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)],
|
yield 'month' => ['month', Carbon::parse('2023-06-25'), 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')],
|
yield 'monthly' => ['monthly', Carbon::parse('2023-06-25'), Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)];
|
||||||
'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')],
|
yield '2019-01-29 to 2019-02-28' => ['monthly', Carbon::parse('2019-01-29'), 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')],
|
yield '2019-01-30 to 2019-02-28' => ['monthly', Carbon::parse('2019-01-30'), Carbon::parse('2019-02-28')];
|
||||||
'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')],
|
yield '2019-01-31 to 2019-02-28' => ['monthly', Carbon::parse('2019-01-31'), Carbon::parse('2019-02-28')];
|
||||||
];
|
|
||||||
|
yield '2023-03-31 to 2023-04-30' => ['monthly', Carbon::parse('2023-03-31'), Carbon::parse('2023-04-30')];
|
||||||
|
|
||||||
|
yield '2023-05-31 to 2023-06-30' => ['monthly', Carbon::parse('2023-05-31'), Carbon::parse('2023-06-30')];
|
||||||
|
|
||||||
|
yield '2023-08-31 to 2023-09-30' => ['monthly', Carbon::parse('2023-08-31'), Carbon::parse('2023-09-30')];
|
||||||
|
|
||||||
|
yield '2023-10-31 to 2023-11-30' => ['monthly', Carbon::parse('2023-10-31'), Carbon::parse('2023-11-30')];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support;
|
namespace Tests\unit\Support;
|
||||||
|
|
||||||
|
use Override;
|
||||||
|
use Iterator;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@@ -42,6 +44,7 @@ final class NavigationEndOfPeriodTest extends TestCase
|
|||||||
{
|
{
|
||||||
private Navigation $navigation;
|
private Navigation $navigation;
|
||||||
|
|
||||||
|
#[Override]
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -55,35 +58,56 @@ final class NavigationEndOfPeriodTest extends TestCase
|
|||||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideDates(): iterable
|
public static function provideDates(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield '1D' => ['1D', Carbon::now(), Carbon::now()->endOfDay()];
|
||||||
'1D' => ['frequency' => '1D', 'from' => Carbon::now(), 'expected' => Carbon::now()->endOfDay()],
|
|
||||||
'daily' => ['frequency' => 'daily', 'from' => Carbon::now(), 'expected' => Carbon::now()->endOfDay()],
|
yield 'daily' => ['daily', Carbon::now(), Carbon::now()->endOfDay()];
|
||||||
'1W' => ['frequency' => '1W', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeek()->subDay()->endOfDay()],
|
|
||||||
'week' => ['frequency' => 'week', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeek()->subDay()->endOfDay()],
|
yield '1W' => ['1W', Carbon::now(), Carbon::now()->addWeek()->subDay()->endOfDay()];
|
||||||
'weekly' => ['frequency' => 'weekly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeek()->subDay()->endOfDay()],
|
|
||||||
'month' => ['frequency' => 'month', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonth()->subDay()->endOfDay()],
|
yield 'week' => ['week', Carbon::now(), Carbon::now()->addWeek()->subDay()->endOfDay()];
|
||||||
'1M' => ['frequency' => '1M', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonth()->subDay()->endOfDay()],
|
|
||||||
'monthly' => ['frequency' => 'monthly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonth()->subDay()->endOfDay()],
|
yield 'weekly' => ['weekly', Carbon::now(), Carbon::now()->addWeek()->subDay()->endOfDay()];
|
||||||
'3M' => ['frequency' => '3M', 'from' => Carbon::now(), 'expected' => Carbon::now()->addQuarter()->subDay()->endOfDay()],
|
|
||||||
'quarter' => ['frequency' => 'quarter', 'from' => Carbon::now(), 'expected' => Carbon::now()->addQuarter()->subDay()->endOfDay()],
|
yield 'month' => ['month', Carbon::now(), Carbon::now()->addMonth()->subDay()->endOfDay()];
|
||||||
'quarterly' => ['frequency' => 'quarterly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addQuarter()->subDay()->endOfDay()],
|
|
||||||
'year' => ['frequency' => 'year', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYearNoOverflow()->subDay()->endOfDay()],
|
yield '1M' => ['1M', Carbon::now(), Carbon::now()->addMonth()->subDay()->endOfDay()];
|
||||||
'yearly' => ['frequency' => 'yearly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYearNoOverflow()->subDay()->endOfDay()],
|
|
||||||
'1Y' => ['frequency' => '1Y', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYearNoOverflow()->subDay()->endOfDay()],
|
yield 'monthly' => ['monthly', Carbon::now(), Carbon::now()->addMonth()->subDay()->endOfDay()];
|
||||||
'half-year' => ['frequency' => 'half-year', 'from' => Carbon::parse('2023-05-20'), 'expected' => Carbon::parse('2023-11-19')->endOfDay()],
|
|
||||||
'6M' => ['frequency' => '6M', 'from' => Carbon::parse('2023-08-20'), 'expected' => Carbon::parse('2024-02-19')],
|
yield '3M' => ['3M', Carbon::now(), Carbon::now()->addQuarter()->subDay()->endOfDay()];
|
||||||
'last7' => ['frequency' => 'last7', 'from' => Carbon::now(), 'expected' => Carbon::now()->addDays(7)->endOfDay()],
|
|
||||||
'last30' => ['frequency' => 'last30', 'from' => Carbon::now(), 'expected' => Carbon::now()->addDays(30)->endOfDay()],
|
yield 'quarter' => ['quarter', Carbon::now(), Carbon::now()->addQuarter()->subDay()->endOfDay()];
|
||||||
'last90' => ['frequency' => 'last90', 'from' => Carbon::now(), 'expected' => Carbon::now()->addDays(90)->endOfDay()],
|
|
||||||
'last365' => ['frequency' => 'last365', 'from' => Carbon::now(), 'expected' => Carbon::now()->addDays(365)->endOfDay()],
|
yield 'quarterly' => ['quarterly', Carbon::now(), Carbon::now()->addQuarter()->subDay()->endOfDay()];
|
||||||
'MTD' => ['frequency' => 'MTD', 'from' => Carbon::now(),
|
|
||||||
'expected' => Carbon::now()->isSameMonth(Carbon::now()) ? Carbon::now()->endOfDay() : Carbon::now()->endOfMonth()],
|
yield 'year' => ['year', Carbon::now(), Carbon::now()->addYearNoOverflow()->subDay()->endOfDay()];
|
||||||
'QTD' => ['frequency' => 'QTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfQuarter()->startOfDay()],
|
|
||||||
'YTD' => ['frequency' => 'YTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfYear()->startOfDay()],
|
yield 'yearly' => ['yearly', Carbon::now(), Carbon::now()->addYearNoOverflow()->subDay()->endOfDay()];
|
||||||
'week 2023-08-05 to 2023-08-11' => ['frequency' => '1W', 'from' => Carbon::parse('2023-08-05'), 'expected' => Carbon::parse('2023-08-11')->endOfDay()],
|
|
||||||
];
|
yield '1Y' => ['1Y', Carbon::now(), Carbon::now()->addYearNoOverflow()->subDay()->endOfDay()];
|
||||||
|
|
||||||
|
yield 'half-year' => ['half-year', Carbon::parse('2023-05-20'), Carbon::parse('2023-11-19')->endOfDay()];
|
||||||
|
|
||||||
|
yield '6M' => ['6M', Carbon::parse('2023-08-20'), Carbon::parse('2024-02-19')];
|
||||||
|
|
||||||
|
yield 'last7' => ['last7', Carbon::now(), Carbon::now()->addDays(7)->endOfDay()];
|
||||||
|
|
||||||
|
yield 'last30' => ['last30', Carbon::now(), Carbon::now()->addDays(30)->endOfDay()];
|
||||||
|
|
||||||
|
yield 'last90' => ['last90', Carbon::now(), Carbon::now()->addDays(90)->endOfDay()];
|
||||||
|
|
||||||
|
yield 'last365' => ['last365', Carbon::now(), Carbon::now()->addDays(365)->endOfDay()];
|
||||||
|
|
||||||
|
yield 'MTD' => ['MTD', Carbon::now(),
|
||||||
|
Carbon::now()->isSameMonth(Carbon::now()) ? Carbon::now()->endOfDay() : Carbon::now()->endOfMonth()];
|
||||||
|
|
||||||
|
yield 'QTD' => ['QTD', Carbon::now(), Carbon::now()->firstOfQuarter()->startOfDay()];
|
||||||
|
|
||||||
|
yield 'YTD' => ['YTD', Carbon::now(), Carbon::now()->firstOfYear()->startOfDay()];
|
||||||
|
|
||||||
|
yield 'week 2023-08-05 to 2023-08-11' => ['1W', Carbon::parse('2023-08-05'), Carbon::parse('2023-08-11')->endOfDay()];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[DataProvider('provideUnknownFrequencies')]
|
#[DataProvider('provideUnknownFrequencies')]
|
||||||
@@ -98,12 +122,12 @@ final class NavigationEndOfPeriodTest extends TestCase
|
|||||||
Log::shouldHaveReceived('error', [$expectedMessage]);
|
Log::shouldHaveReceived('error', [$expectedMessage]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideUnknownFrequencies(): iterable
|
public static function provideUnknownFrequencies(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield '1day' => ['1day', Carbon::now(), Carbon::now()];
|
||||||
'1day' => ['frequency' => '1day', 'from' => Carbon::now(), 'expected' => Carbon::now()],
|
|
||||||
'unknown' => ['frequency' => 'unknown', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],
|
yield 'unknown' => ['unknown', Carbon::now(), Carbon::now()->startOfDay()];
|
||||||
'empty' => ['frequency' => '', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],
|
|
||||||
];
|
yield 'empty' => ['', Carbon::now(), Carbon::now()->startOfDay()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support;
|
namespace Tests\unit\Support;
|
||||||
|
|
||||||
|
use Override;
|
||||||
|
use Iterator;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
@@ -41,6 +43,7 @@ final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
|
|||||||
{
|
{
|
||||||
private Navigation $navigation;
|
private Navigation $navigation;
|
||||||
|
|
||||||
|
#[Override]
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -54,15 +57,18 @@ final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
|
|||||||
self::assertSame($expected, $formatPeriod);
|
self::assertSame($expected, $formatPeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function providePeriods(): iterable
|
public static function providePeriods(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield 'unknown' => ['1day', 'Y-m-d'];
|
||||||
'unknown' => ['period' => '1day', 'expected' => 'Y-m-d'],
|
|
||||||
'week' => ['period' => '1W', 'expected' => '\WW,Y'],
|
yield 'week' => ['1W', '\WW,Y'];
|
||||||
'month' => ['period' => '1M', 'expected' => 'Y-m'],
|
|
||||||
'quarterly' => ['period' => '3M', 'expected' => '\QQ,Y'],
|
yield 'month' => ['1M', 'Y-m'];
|
||||||
'half-yearly' => ['period' => '6M', 'expected' => '\QQ,Y'],
|
|
||||||
'yearly' => ['period' => '1Y', 'expected' => 'Y'],
|
yield 'quarterly' => ['3M', '\QQ,Y'];
|
||||||
];
|
|
||||||
|
yield 'half-yearly' => ['6M', '\QQ,Y'];
|
||||||
|
|
||||||
|
yield 'yearly' => ['1Y', 'Y'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support;
|
namespace Tests\unit\Support;
|
||||||
|
|
||||||
|
use Override;
|
||||||
|
use Iterator;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
@@ -42,6 +44,7 @@ final class NavigationPreferredCarbonFormatTest extends TestCase
|
|||||||
{
|
{
|
||||||
private Navigation $navigation;
|
private Navigation $navigation;
|
||||||
|
|
||||||
|
#[Override]
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -55,21 +58,30 @@ final class NavigationPreferredCarbonFormatTest extends TestCase
|
|||||||
self::assertSame($expected, $carbonFormat);
|
self::assertSame($expected, $carbonFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function providePeriods(): iterable
|
public static function providePeriods(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield '1 week' => [Carbon::now(), Carbon::now()->addWeek(), 'Y-m-d'];
|
||||||
'1 week' => ['start' => Carbon::now(), 'end' => Carbon::now()->addWeek(), 'expected' => 'Y-m-d'],
|
|
||||||
'1 month' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonth(), 'expected' => 'Y-m-d'],
|
yield '1 month' => [Carbon::now(), Carbon::now()->addMonth(), 'Y-m-d'];
|
||||||
'2 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(2), 'expected' => 'Y-m'],
|
|
||||||
'3 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(3), 'expected' => 'Y-m'],
|
yield '2 months' => [Carbon::now(), Carbon::now()->addMonths(2), 'Y-m'];
|
||||||
'6 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(6), 'expected' => 'Y-m'],
|
|
||||||
'7 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(7), 'expected' => 'Y-m'],
|
yield '3 months' => [Carbon::now(), Carbon::now()->addMonths(3), 'Y-m'];
|
||||||
'11 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(11), 'expected' => 'Y-m'],
|
|
||||||
'12 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(12), 'expected' => 'Y-m'],
|
yield '6 months' => [Carbon::now(), Carbon::now()->addMonths(6), 'Y-m'];
|
||||||
'13 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(13), 'expected' => 'Y'],
|
|
||||||
'16 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(16), 'expected' => 'Y'],
|
yield '7 months' => [Carbon::now(), Carbon::now()->addMonths(7), 'Y-m'];
|
||||||
'1 year' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYear(), 'expected' => 'Y-m'],
|
|
||||||
'2 years' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYears(2), 'expected' => 'Y'],
|
yield '11 months' => [Carbon::now(), Carbon::now()->addMonths(11), 'Y-m'];
|
||||||
];
|
|
||||||
|
yield '12 months' => [Carbon::now(), Carbon::now()->addMonths(12), 'Y-m'];
|
||||||
|
|
||||||
|
yield '13 months' => [Carbon::now(), Carbon::now()->addMonths(13), 'Y'];
|
||||||
|
|
||||||
|
yield '16 months' => [Carbon::now(), Carbon::now()->addMonths(16), 'Y'];
|
||||||
|
|
||||||
|
yield '1 year' => [Carbon::now(), Carbon::now()->addYear(), 'Y-m'];
|
||||||
|
|
||||||
|
yield '2 years' => [Carbon::now(), Carbon::now()->addYears(2), 'Y'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support;
|
namespace Tests\unit\Support;
|
||||||
|
|
||||||
|
use Override;
|
||||||
|
use Iterator;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
@@ -42,6 +44,7 @@ final class NavigationPreferredEndOfPeriodTest extends TestCase
|
|||||||
{
|
{
|
||||||
private Navigation $navigation;
|
private Navigation $navigation;
|
||||||
|
|
||||||
|
#[Override]
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -55,21 +58,30 @@ final class NavigationPreferredEndOfPeriodTest extends TestCase
|
|||||||
self::assertSame($expected, $formatPeriod);
|
self::assertSame($expected, $formatPeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function providePeriods(): iterable
|
public static function providePeriods(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield '1 week' => [Carbon::now(), Carbon::now()->addWeek(), 'endOfDay'];
|
||||||
'1 week' => ['start' => Carbon::now(), 'end' => Carbon::now()->addWeek(), 'expected' => 'endOfDay'],
|
|
||||||
'1 month' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonth(), 'expected' => 'endOfDay'],
|
yield '1 month' => [Carbon::now(), Carbon::now()->addMonth(), 'endOfDay'];
|
||||||
'2 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(2), 'expected' => 'endOfMonth'],
|
|
||||||
'3 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(3), 'expected' => 'endOfMonth'],
|
yield '2 months' => [Carbon::now(), Carbon::now()->addMonths(2), 'endOfMonth'];
|
||||||
'6 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(6), 'expected' => 'endOfMonth'],
|
|
||||||
'7 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(7), 'expected' => 'endOfMonth'],
|
yield '3 months' => [Carbon::now(), Carbon::now()->addMonths(3), 'endOfMonth'];
|
||||||
'11 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(11), 'expected' => 'endOfMonth'],
|
|
||||||
'12 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(12), 'expected' => 'endOfMonth'],
|
yield '6 months' => [Carbon::now(), Carbon::now()->addMonths(6), 'endOfMonth'];
|
||||||
'13 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(13), 'expected' => 'endOfYear'],
|
|
||||||
'16 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(16), 'expected' => 'endOfYear'],
|
yield '7 months' => [Carbon::now(), Carbon::now()->addMonths(7), 'endOfMonth'];
|
||||||
'1 year' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYear(), 'expected' => 'endOfMonth'],
|
|
||||||
'2 years' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYears(2), 'expected' => 'endOfYear'],
|
yield '11 months' => [Carbon::now(), Carbon::now()->addMonths(11), 'endOfMonth'];
|
||||||
];
|
|
||||||
|
yield '12 months' => [Carbon::now(), Carbon::now()->addMonths(12), 'endOfMonth'];
|
||||||
|
|
||||||
|
yield '13 months' => [Carbon::now(), Carbon::now()->addMonths(13), 'endOfYear'];
|
||||||
|
|
||||||
|
yield '16 months' => [Carbon::now(), Carbon::now()->addMonths(16), 'endOfYear'];
|
||||||
|
|
||||||
|
yield '1 year' => [Carbon::now(), Carbon::now()->addYear(), 'endOfMonth'];
|
||||||
|
|
||||||
|
yield '2 years' => [Carbon::now(), Carbon::now()->addYears(2), 'endOfYear'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support;
|
namespace Tests\unit\Support;
|
||||||
|
|
||||||
|
use Override;
|
||||||
|
use Iterator;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
@@ -42,6 +44,7 @@ final class NavigationPreferredRangeFormatTest extends TestCase
|
|||||||
{
|
{
|
||||||
private Navigation $navigation;
|
private Navigation $navigation;
|
||||||
|
|
||||||
|
#[Override]
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -55,21 +58,30 @@ final class NavigationPreferredRangeFormatTest extends TestCase
|
|||||||
self::assertSame($expected, $formatPeriod);
|
self::assertSame($expected, $formatPeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function providePeriods(): iterable
|
public static function providePeriods(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield '1 week' => [Carbon::now(), Carbon::now()->addWeek(), '1D'];
|
||||||
'1 week' => ['start' => Carbon::now(), 'end' => Carbon::now()->addWeek(), 'expected' => '1D'],
|
|
||||||
'1 month' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonth(), 'expected' => '1D'],
|
yield '1 month' => [Carbon::now(), Carbon::now()->addMonth(), '1D'];
|
||||||
'2 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(2), 'expected' => '1M'],
|
|
||||||
'3 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(3), 'expected' => '1M'],
|
yield '2 months' => [Carbon::now(), Carbon::now()->addMonths(2), '1M'];
|
||||||
'6 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(6), 'expected' => '1M'],
|
|
||||||
'7 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(7), 'expected' => '1M'],
|
yield '3 months' => [Carbon::now(), Carbon::now()->addMonths(3), '1M'];
|
||||||
'11 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(11), 'expected' => '1M'],
|
|
||||||
'12 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(12), 'expected' => '1M'],
|
yield '6 months' => [Carbon::now(), Carbon::now()->addMonths(6), '1M'];
|
||||||
'13 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(13), 'expected' => '1Y'],
|
|
||||||
'16 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(16), 'expected' => '1Y'],
|
yield '7 months' => [Carbon::now(), Carbon::now()->addMonths(7), '1M'];
|
||||||
'1 year' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYear(), 'expected' => '1M'],
|
|
||||||
'2 years' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYears(2), 'expected' => '1Y'],
|
yield '11 months' => [Carbon::now(), Carbon::now()->addMonths(11), '1M'];
|
||||||
];
|
|
||||||
|
yield '12 months' => [Carbon::now(), Carbon::now()->addMonths(12), '1M'];
|
||||||
|
|
||||||
|
yield '13 months' => [Carbon::now(), Carbon::now()->addMonths(13), '1Y'];
|
||||||
|
|
||||||
|
yield '16 months' => [Carbon::now(), Carbon::now()->addMonths(16), '1Y'];
|
||||||
|
|
||||||
|
yield '1 year' => [Carbon::now(), Carbon::now()->addYear(), '1M'];
|
||||||
|
|
||||||
|
yield '2 years' => [Carbon::now(), Carbon::now()->addYears(2), '1Y'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support;
|
namespace Tests\unit\Support;
|
||||||
|
|
||||||
|
use Override;
|
||||||
|
use Iterator;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
use PHPUnit\Framework\Attributes\DataProvider;
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
@@ -42,6 +44,7 @@ final class NavigationPreferredSqlFormatTest extends TestCase
|
|||||||
{
|
{
|
||||||
private Navigation $navigation;
|
private Navigation $navigation;
|
||||||
|
|
||||||
|
#[Override]
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -55,21 +58,30 @@ final class NavigationPreferredSqlFormatTest extends TestCase
|
|||||||
self::assertSame($expected, $formatPeriod);
|
self::assertSame($expected, $formatPeriod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideDates(): iterable
|
public static function provideDates(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield '1 week' => [Carbon::now(), Carbon::now()->addWeek(), '%Y-%m-%d'];
|
||||||
'1 week' => ['start' => Carbon::now(), 'end' => Carbon::now()->addWeek(), 'expected' => '%Y-%m-%d'],
|
|
||||||
'1 month' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonth(), 'expected' => '%Y-%m-%d'],
|
yield '1 month' => [Carbon::now(), Carbon::now()->addMonth(), '%Y-%m-%d'];
|
||||||
'2 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(2), 'expected' => '%Y-%m'],
|
|
||||||
'3 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(3), 'expected' => '%Y-%m'],
|
yield '2 months' => [Carbon::now(), Carbon::now()->addMonths(2), '%Y-%m'];
|
||||||
'6 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(6), 'expected' => '%Y-%m'],
|
|
||||||
'7 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(7), 'expected' => '%Y-%m'],
|
yield '3 months' => [Carbon::now(), Carbon::now()->addMonths(3), '%Y-%m'];
|
||||||
'11 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(11), 'expected' => '%Y-%m'],
|
|
||||||
'12 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(12), 'expected' => '%Y-%m'],
|
yield '6 months' => [Carbon::now(), Carbon::now()->addMonths(6), '%Y-%m'];
|
||||||
'13 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(13), 'expected' => '%Y'],
|
|
||||||
'16 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(16), 'expected' => '%Y'],
|
yield '7 months' => [Carbon::now(), Carbon::now()->addMonths(7), '%Y-%m'];
|
||||||
'1 year' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYear(), 'expected' => '%Y-%m'],
|
|
||||||
'2 years' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYears(2), 'expected' => '%Y'],
|
yield '11 months' => [Carbon::now(), Carbon::now()->addMonths(11), '%Y-%m'];
|
||||||
];
|
|
||||||
|
yield '12 months' => [Carbon::now(), Carbon::now()->addMonths(12), '%Y-%m'];
|
||||||
|
|
||||||
|
yield '13 months' => [Carbon::now(), Carbon::now()->addMonths(13), '%Y'];
|
||||||
|
|
||||||
|
yield '16 months' => [Carbon::now(), Carbon::now()->addMonths(16), '%Y'];
|
||||||
|
|
||||||
|
yield '1 year' => [Carbon::now(), Carbon::now()->addYear(), '%Y-%m'];
|
||||||
|
|
||||||
|
yield '2 years' => [Carbon::now(), Carbon::now()->addYears(2), '%Y'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support;
|
namespace Tests\unit\Support;
|
||||||
|
|
||||||
|
use Override;
|
||||||
|
use Iterator;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@@ -43,6 +45,7 @@ final class NavigationStartOfPeriodTest extends TestCase
|
|||||||
{
|
{
|
||||||
private Navigation $navigation;
|
private Navigation $navigation;
|
||||||
|
|
||||||
|
#[Override]
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@@ -56,34 +59,55 @@ final class NavigationStartOfPeriodTest extends TestCase
|
|||||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideDates(): iterable
|
public static function provideDates(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield 'custom' => ['custom', Carbon::now(), Carbon::now()];
|
||||||
'custom' => ['frequency' => 'custom', 'from' => Carbon::now(), 'expected' => Carbon::now()],
|
|
||||||
'1D' => ['frequency' => '1D', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],
|
yield '1D' => ['1D', Carbon::now(), Carbon::now()->startOfDay()];
|
||||||
'daily' => ['frequency' => 'daily', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],
|
|
||||||
'1W' => ['frequency' => '1W', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfWeek()],
|
yield 'daily' => ['daily', Carbon::now(), Carbon::now()->startOfDay()];
|
||||||
'week' => ['frequency' => 'week', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfWeek()],
|
|
||||||
'weekly' => ['frequency' => 'weekly', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfWeek()],
|
yield '1W' => ['1W', Carbon::now(), Carbon::now()->startOfWeek()];
|
||||||
'month' => ['frequency' => 'month', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfMonth()],
|
|
||||||
'1M' => ['frequency' => '1M', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfMonth()],
|
yield 'week' => ['week', Carbon::now(), Carbon::now()->startOfWeek()];
|
||||||
'monthly' => ['frequency' => 'monthly', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfMonth()],
|
|
||||||
'3M' => ['frequency' => '3M', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfQuarter()],
|
yield 'weekly' => ['weekly', Carbon::now(), Carbon::now()->startOfWeek()];
|
||||||
'quarter' => ['frequency' => 'quarter', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfQuarter()],
|
|
||||||
'quarterly' => ['frequency' => 'quarterly', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfQuarter()],
|
yield 'month' => ['month', Carbon::now(), Carbon::now()->startOfMonth()];
|
||||||
'year' => ['frequency' => 'year', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfYear()],
|
|
||||||
'yearly' => ['frequency' => 'yearly', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfYear()],
|
yield '1M' => ['1M', Carbon::now(), Carbon::now()->startOfMonth()];
|
||||||
'1Y' => ['frequency' => '1Y', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfYear()],
|
|
||||||
'half-year' => ['frequency' => 'half-year', 'from' => Carbon::parse('2023-05-20'), 'expected' => Carbon::parse('2023-01-01')->startOfYear()],
|
yield 'monthly' => ['monthly', Carbon::now(), Carbon::now()->startOfMonth()];
|
||||||
'6M' => ['frequency' => '6M', 'from' => Carbon::parse('2023-08-20'), 'expected' => Carbon::parse('2023-07-01')],
|
|
||||||
'last7' => ['frequency' => 'last7', 'from' => Carbon::now(), 'expected' => Carbon::now()->subDays(7)->startOfDay()],
|
yield '3M' => ['3M', Carbon::now(), Carbon::now()->firstOfQuarter()];
|
||||||
'last30' => ['frequency' => 'last30', 'from' => Carbon::now(), 'expected' => Carbon::now()->subDays(30)->startOfDay()],
|
|
||||||
'last90' => ['frequency' => 'last90', 'from' => Carbon::now(), 'expected' => Carbon::now()->subDays(90)->startOfDay()],
|
yield 'quarter' => ['quarter', Carbon::now(), Carbon::now()->firstOfQuarter()];
|
||||||
'last365' => ['frequency' => 'last365', 'from' => Carbon::now(), 'expected' => Carbon::now()->subDays(365)->startOfDay()],
|
|
||||||
'MTD' => ['frequency' => 'MTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfMonth()->startOfDay()],
|
yield 'quarterly' => ['quarterly', Carbon::now(), Carbon::now()->firstOfQuarter()];
|
||||||
'QTD' => ['frequency' => 'QTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfQuarter()->startOfDay()],
|
|
||||||
'YTD' => ['frequency' => 'YTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfYear()->startOfDay()],
|
yield 'year' => ['year', Carbon::now(), Carbon::now()->startOfYear()];
|
||||||
];
|
|
||||||
|
yield 'yearly' => ['yearly', Carbon::now(), Carbon::now()->startOfYear()];
|
||||||
|
|
||||||
|
yield '1Y' => ['1Y', Carbon::now(), Carbon::now()->startOfYear()];
|
||||||
|
|
||||||
|
yield 'half-year' => ['half-year', Carbon::parse('2023-05-20'), Carbon::parse('2023-01-01')->startOfYear()];
|
||||||
|
|
||||||
|
yield '6M' => ['6M', Carbon::parse('2023-08-20'), Carbon::parse('2023-07-01')];
|
||||||
|
|
||||||
|
yield 'last7' => ['last7', Carbon::now(), Carbon::now()->subDays(7)->startOfDay()];
|
||||||
|
|
||||||
|
yield 'last30' => ['last30', Carbon::now(), Carbon::now()->subDays(30)->startOfDay()];
|
||||||
|
|
||||||
|
yield 'last90' => ['last90', Carbon::now(), Carbon::now()->subDays(90)->startOfDay()];
|
||||||
|
|
||||||
|
yield 'last365' => ['last365', Carbon::now(), Carbon::now()->subDays(365)->startOfDay()];
|
||||||
|
|
||||||
|
yield 'MTD' => ['MTD', Carbon::now(), Carbon::now()->startOfMonth()->startOfDay()];
|
||||||
|
|
||||||
|
yield 'QTD' => ['QTD', Carbon::now(), Carbon::now()->firstOfQuarter()->startOfDay()];
|
||||||
|
|
||||||
|
yield 'YTD' => ['YTD', Carbon::now(), Carbon::now()->startOfYear()->startOfDay()];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[DataProvider('provideUnknownFrequencies')]
|
#[DataProvider('provideUnknownFrequencies')]
|
||||||
@@ -100,12 +124,12 @@ final class NavigationStartOfPeriodTest extends TestCase
|
|||||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function provideUnknownFrequencies(): iterable
|
public static function provideUnknownFrequencies(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield '1day' => ['1day', Carbon::now(), Carbon::now()];
|
||||||
'1day' => ['frequency' => '1day', 'from' => Carbon::now(), 'expected' => Carbon::now()],
|
|
||||||
'unknown' => ['frequency' => 'unknown', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],
|
yield 'unknown' => ['unknown', Carbon::now(), Carbon::now()->startOfDay()];
|
||||||
'empty' => ['frequency' => '', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],
|
|
||||||
];
|
yield 'empty' => ['', Carbon::now(), Carbon::now()->startOfDay()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\unit\Support\Search\QueryParser;
|
namespace Tests\unit\Support\Search\QueryParser;
|
||||||
|
|
||||||
|
use Iterator;
|
||||||
use FireflyIII\Support\Search\QueryParser\FieldNode;
|
use FireflyIII\Support\Search\QueryParser\FieldNode;
|
||||||
use FireflyIII\Support\Search\QueryParser\QueryParserInterface;
|
use FireflyIII\Support\Search\QueryParser\QueryParserInterface;
|
||||||
use FireflyIII\Support\Search\QueryParser\StringNode;
|
use FireflyIII\Support\Search\QueryParser\StringNode;
|
||||||
@@ -29,170 +30,190 @@ abstract class AbstractQueryParserInterfaceParseQueryTester extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function queryDataProvider(): iterable
|
public static function queryDataProvider(): Iterator
|
||||||
{
|
{
|
||||||
return [
|
yield 'empty query' => [
|
||||||
'empty query' => [
|
'',
|
||||||
'query' => '',
|
new NodeGroup([]),
|
||||||
'expected' => new NodeGroup([]),
|
];
|
||||||
],
|
|
||||||
'simple word' => [
|
yield 'simple word' => [
|
||||||
'query' => 'groceries',
|
'groceries',
|
||||||
'expected' => new NodeGroup([new StringNode('groceries')]),
|
new NodeGroup([new StringNode('groceries')]),
|
||||||
],
|
];
|
||||||
'prohibited word' => [
|
|
||||||
'query' => '-groceries',
|
yield 'prohibited word' => [
|
||||||
'expected' => new NodeGroup([new StringNode('groceries', true)]),
|
'-groceries',
|
||||||
],
|
new NodeGroup([new StringNode('groceries', true)]),
|
||||||
'prohibited field' => [
|
];
|
||||||
'query' => '-amount:100',
|
|
||||||
'expected' => new NodeGroup([new FieldNode('amount', '100', true)]),
|
yield 'prohibited field' => [
|
||||||
],
|
'-amount:100',
|
||||||
'quoted word' => [
|
new NodeGroup([new FieldNode('amount', '100', true)]),
|
||||||
'query' => '"test phrase"',
|
];
|
||||||
'expected' => new NodeGroup([new StringNode('test phrase')]),
|
|
||||||
],
|
yield 'quoted word' => [
|
||||||
'prohibited quoted word' => [
|
'"test phrase"',
|
||||||
'query' => '-"test phrase"',
|
new NodeGroup([new StringNode('test phrase')]),
|
||||||
'expected' => new NodeGroup([new StringNode('test phrase', true)]),
|
];
|
||||||
],
|
|
||||||
'multiple words' => [
|
yield 'prohibited quoted word' => [
|
||||||
'query' => 'groceries shopping market',
|
'-"test phrase"',
|
||||||
'expected' => new NodeGroup([
|
new NodeGroup([new StringNode('test phrase', true)]),
|
||||||
new StringNode('groceries'),
|
];
|
||||||
new StringNode('shopping'),
|
|
||||||
new StringNode('market'),
|
yield 'multiple words' => [
|
||||||
]),
|
'groceries shopping market',
|
||||||
],
|
new NodeGroup([
|
||||||
'field operator' => [
|
new StringNode('groceries'),
|
||||||
'query' => 'amount:100',
|
new StringNode('shopping'),
|
||||||
'expected' => new NodeGroup([new FieldNode('amount', '100')]),
|
new StringNode('market'),
|
||||||
],
|
]),
|
||||||
'quoted field value with single space' => [
|
];
|
||||||
'query' => 'description:"test phrase"',
|
|
||||||
'expected' => new NodeGroup([new FieldNode('description', 'test phrase')]),
|
yield 'field operator' => [
|
||||||
],
|
'amount:100',
|
||||||
'multiple fields' => [
|
new NodeGroup([new FieldNode('amount', '100')]),
|
||||||
'query' => 'amount:100 category:food',
|
];
|
||||||
'expected' => new NodeGroup([
|
|
||||||
|
yield 'quoted field value with single space' => [
|
||||||
|
'description:"test phrase"',
|
||||||
|
new NodeGroup([new FieldNode('description', 'test phrase')]),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield 'multiple fields' => [
|
||||||
|
'amount:100 category:food',
|
||||||
|
new NodeGroup([
|
||||||
|
new FieldNode('amount', '100'),
|
||||||
|
new FieldNode('category', 'food'),
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield 'simple subquery' => [
|
||||||
|
'(amount:100 category:food)',
|
||||||
|
new NodeGroup([
|
||||||
|
new NodeGroup([
|
||||||
new FieldNode('amount', '100'),
|
new FieldNode('amount', '100'),
|
||||||
new FieldNode('category', 'food'),
|
new FieldNode('category', 'food'),
|
||||||
]),
|
]),
|
||||||
],
|
]),
|
||||||
'simple subquery' => [
|
];
|
||||||
'query' => '(amount:100 category:food)',
|
|
||||||
'expected' => new NodeGroup([
|
yield 'prohibited subquery' => [
|
||||||
new NodeGroup([
|
'-(amount:100 category:food)',
|
||||||
new FieldNode('amount', '100'),
|
new NodeGroup([
|
||||||
new FieldNode('category', 'food'),
|
new NodeGroup([
|
||||||
]),
|
new FieldNode('amount', '100'),
|
||||||
]),
|
new FieldNode('category', 'food'),
|
||||||
],
|
], true),
|
||||||
'prohibited subquery' => [
|
]),
|
||||||
'query' => '-(amount:100 category:food)',
|
];
|
||||||
'expected' => new NodeGroup([
|
|
||||||
new NodeGroup([
|
yield 'nested subquery' => [
|
||||||
new FieldNode('amount', '100'),
|
'(amount:100 (description:"test" category:food))',
|
||||||
new FieldNode('category', 'food'),
|
new NodeGroup([
|
||||||
], true),
|
new NodeGroup([
|
||||||
]),
|
|
||||||
],
|
|
||||||
'nested subquery' => [
|
|
||||||
'query' => '(amount:100 (description:"test" category:food))',
|
|
||||||
'expected' => new NodeGroup([
|
|
||||||
new NodeGroup([
|
|
||||||
new FieldNode('amount', '100'),
|
|
||||||
new NodeGroup([
|
|
||||||
new FieldNode('description', 'test'),
|
|
||||||
new FieldNode('category', 'food'),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
'mixed words and operators' => [
|
|
||||||
'query' => 'groceries amount:50 shopping',
|
|
||||||
'expected' => new NodeGroup([
|
|
||||||
new StringNode('groceries'),
|
|
||||||
new FieldNode('amount', '50'),
|
|
||||||
new StringNode('shopping'),
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
'subquery after field value' => [
|
|
||||||
'query' => 'amount:100 (description:"market" category:food)',
|
|
||||||
'expected' => new NodeGroup([
|
|
||||||
new FieldNode('amount', '100'),
|
new FieldNode('amount', '100'),
|
||||||
new NodeGroup([
|
new NodeGroup([
|
||||||
new FieldNode('description', 'market'),
|
new FieldNode('description', 'test'),
|
||||||
new FieldNode('category', 'food'),
|
new FieldNode('category', 'food'),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
],
|
]),
|
||||||
'word followed by subquery' => [
|
];
|
||||||
'query' => 'groceries (amount:100 description_contains:"test")',
|
|
||||||
'expected' => new NodeGroup([
|
yield 'mixed words and operators' => [
|
||||||
new StringNode('groceries'),
|
'groceries amount:50 shopping',
|
||||||
|
new NodeGroup([
|
||||||
|
new StringNode('groceries'),
|
||||||
|
new FieldNode('amount', '50'),
|
||||||
|
new StringNode('shopping'),
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield 'subquery after field value' => [
|
||||||
|
'amount:100 (description:"market" category:food)',
|
||||||
|
new NodeGroup([
|
||||||
|
new FieldNode('amount', '100'),
|
||||||
|
new NodeGroup([
|
||||||
|
new FieldNode('description', 'market'),
|
||||||
|
new FieldNode('category', 'food'),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield 'word followed by subquery' => [
|
||||||
|
'groceries (amount:100 description_contains:"test")',
|
||||||
|
new NodeGroup([
|
||||||
|
new StringNode('groceries'),
|
||||||
|
new NodeGroup([
|
||||||
|
new FieldNode('amount', '100'),
|
||||||
|
new FieldNode('description_contains', 'test'),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield 'nested subquery with prohibited field' => [
|
||||||
|
'(amount:100 (description_contains:"test payment" -has_attachments:true))',
|
||||||
|
new NodeGroup([
|
||||||
|
new NodeGroup([
|
||||||
|
new FieldNode('amount', '100'),
|
||||||
new NodeGroup([
|
new NodeGroup([
|
||||||
new FieldNode('amount', '100'),
|
new FieldNode('description_contains', 'test payment'),
|
||||||
new FieldNode('description_contains', 'test'),
|
new FieldNode('has_attachments', 'true', true),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
],
|
]),
|
||||||
'nested subquery with prohibited field' => [
|
];
|
||||||
'query' => '(amount:100 (description_contains:"test payment" -has_attachments:true))',
|
|
||||||
'expected' => new NodeGroup([
|
yield 'complex nested subqueries' => [
|
||||||
|
'shopping (amount:50 market (-category:food word description:"test phrase" (has_notes:true)))',
|
||||||
|
new NodeGroup([
|
||||||
|
new StringNode('shopping'),
|
||||||
|
new NodeGroup([
|
||||||
|
new FieldNode('amount', '50'),
|
||||||
|
new StringNode('market'),
|
||||||
new NodeGroup([
|
new NodeGroup([
|
||||||
new FieldNode('amount', '100'),
|
new FieldNode('category', 'food', true),
|
||||||
|
new StringNode('word'),
|
||||||
|
new FieldNode('description', 'test phrase'),
|
||||||
new NodeGroup([
|
new NodeGroup([
|
||||||
new FieldNode('description_contains', 'test payment'),
|
new FieldNode('has_notes', 'true'),
|
||||||
new FieldNode('has_attachments', 'true', true),
|
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
],
|
]),
|
||||||
'complex nested subqueries' => [
|
];
|
||||||
'query' => 'shopping (amount:50 market (-category:food word description:"test phrase" (has_notes:true)))',
|
|
||||||
'expected' => new NodeGroup([
|
yield 'word with multiple spaces' => [
|
||||||
new StringNode('shopping'),
|
'"multiple spaces"',
|
||||||
new NodeGroup([
|
new NodeGroup([new StringNode('multiple spaces')]),
|
||||||
new FieldNode('amount', '50'),
|
];
|
||||||
new StringNode('market'),
|
|
||||||
new NodeGroup([
|
yield 'field with multiple spaces in value' => [
|
||||||
new FieldNode('category', 'food', true),
|
'description:"multiple spaces here"',
|
||||||
new StringNode('word'),
|
new NodeGroup([new FieldNode('description', 'multiple spaces here')]),
|
||||||
new FieldNode('description', 'test phrase'),
|
];
|
||||||
new NodeGroup([
|
|
||||||
new FieldNode('has_notes', 'true'),
|
yield 'unmatched right parenthesis in word' => [
|
||||||
]),
|
'test)word',
|
||||||
]),
|
new NodeGroup([new StringNode('test)word')]),
|
||||||
]),
|
];
|
||||||
|
|
||||||
|
yield 'unmatched right parenthesis in field' => [
|
||||||
|
'description:test)phrase',
|
||||||
|
new NodeGroup([new FieldNode('description', 'test)phrase')]),
|
||||||
|
];
|
||||||
|
|
||||||
|
yield 'subquery followed by word' => [
|
||||||
|
'(amount:100 category:food) shopping',
|
||||||
|
new NodeGroup([
|
||||||
|
new NodeGroup([
|
||||||
|
new FieldNode('amount', '100'),
|
||||||
|
new FieldNode('category', 'food'),
|
||||||
]),
|
]),
|
||||||
],
|
new StringNode('shopping'),
|
||||||
'word with multiple spaces' => [
|
]),
|
||||||
'query' => '"multiple spaces"',
|
|
||||||
'expected' => new NodeGroup([new StringNode('multiple spaces')]),
|
|
||||||
],
|
|
||||||
'field with multiple spaces in value' => [
|
|
||||||
'query' => 'description:"multiple spaces here"',
|
|
||||||
'expected' => new NodeGroup([new FieldNode('description', 'multiple spaces here')]),
|
|
||||||
],
|
|
||||||
'unmatched right parenthesis in word' => [
|
|
||||||
'query' => 'test)word',
|
|
||||||
'expected' => new NodeGroup([new StringNode('test)word')]),
|
|
||||||
],
|
|
||||||
'unmatched right parenthesis in field' => [
|
|
||||||
'query' => 'description:test)phrase',
|
|
||||||
'expected' => new NodeGroup([new FieldNode('description', 'test)phrase')]),
|
|
||||||
],
|
|
||||||
'subquery followed by word' => [
|
|
||||||
'query' => '(amount:100 category:food) shopping',
|
|
||||||
'expected' => new NodeGroup([
|
|
||||||
new NodeGroup([
|
|
||||||
new FieldNode('amount', '100'),
|
|
||||||
new FieldNode('category', 'food'),
|
|
||||||
]),
|
|
||||||
new StringNode('shopping'),
|
|
||||||
]),
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user