mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Final fixes.
This commit is contained in:
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
|
||||
use FireflyIII\Support\Calendar\Periodicity\Bimonthly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
@@ -42,7 +43,7 @@ final class BimonthlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
return new Periodicity\Bimonthly();
|
||||
return new Bimonthly();
|
||||
}
|
||||
|
||||
public static function provideIntervals(): array
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
|
||||
use FireflyIII\Support\Calendar\Periodicity\Daily;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
@@ -42,7 +43,7 @@ final class DailyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
return new Periodicity\Daily();
|
||||
return new Daily();
|
||||
}
|
||||
|
||||
public static function provideIntervals(): array
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
|
||||
use FireflyIII\Support\Calendar\Periodicity\Fortnightly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
@@ -42,7 +43,7 @@ final class FortnightlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
return new Periodicity\Fortnightly();
|
||||
return new Fortnightly();
|
||||
}
|
||||
|
||||
public static function provideIntervals(): array
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
|
||||
use FireflyIII\Support\Calendar\Periodicity\HalfYearly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
@@ -42,7 +43,7 @@ final class HalfYearlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
return new Periodicity\HalfYearly();
|
||||
return new HalfYearly();
|
||||
}
|
||||
|
||||
public static function provideIntervals(): array
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
|
||||
use FireflyIII\Support\Calendar\Periodicity\Monthly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
@@ -42,7 +43,7 @@ final class MonthlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
return new Periodicity\Monthly();
|
||||
return new Monthly();
|
||||
}
|
||||
|
||||
public static function provideIntervals(): array
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
|
||||
use FireflyIII\Support\Calendar\Periodicity\Quarterly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
@@ -42,7 +43,7 @@ final class QuarterlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
return new Periodicity\Quarterly();
|
||||
return new Quarterly();
|
||||
}
|
||||
|
||||
public static function provideIntervals(): array
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
|
||||
use FireflyIII\Support\Calendar\Periodicity\Weekly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
@@ -42,7 +43,7 @@ final class WeeklyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
return new Periodicity\Weekly();
|
||||
return new Weekly();
|
||||
}
|
||||
|
||||
public static function provideIntervals(): array
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||
|
||||
use FireflyIII\Support\Calendar\Periodicity\Yearly;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
@@ -42,7 +43,7 @@ final class YearlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
return new Periodicity\Yearly();
|
||||
return new Yearly();
|
||||
}
|
||||
|
||||
public static function provideIntervals(): array
|
||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support;
|
||||
|
||||
use Override;
|
||||
use Iterator;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use FireflyIII\Support\Navigation;
|
||||
@@ -43,6 +45,7 @@ final class NavigationAddPeriodTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -108,30 +111,47 @@ final class NavigationAddPeriodTest extends TestCase
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function providePeriods(): iterable
|
||||
public static function providePeriods(): Iterator
|
||||
{
|
||||
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)],
|
||||
];
|
||||
yield '1D' => ['1D', Carbon::now(), Carbon::tomorrow()];
|
||||
|
||||
yield 'daily' => ['daily', Carbon::now(), Carbon::tomorrow()];
|
||||
|
||||
yield '1W' => ['1W', Carbon::now(), Carbon::now()->addWeeks(1)];
|
||||
|
||||
yield 'weekly' => ['weekly', Carbon::now(), Carbon::now()->addWeeks(1)];
|
||||
|
||||
yield 'week' => ['week', Carbon::now(), Carbon::now()->addWeeks(1)];
|
||||
|
||||
yield '3M' => ['3M', Carbon::now(), Carbon::now()->addMonthsNoOverflow(3)];
|
||||
|
||||
yield 'quarter' => ['quarter', Carbon::now(), Carbon::now()->addMonthsNoOverflow(3)];
|
||||
|
||||
yield 'quarterly' => ['quarterly', Carbon::now(), Carbon::now()->addMonthsNoOverflow(3)];
|
||||
|
||||
yield '6M' => ['6M', Carbon::now(), Carbon::now()->addMonthsNoOverflow(6)];
|
||||
|
||||
yield 'half-year' => ['half-year', Carbon::now(), Carbon::now()->addMonthsNoOverflow(6)];
|
||||
|
||||
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')]
|
||||
@@ -141,32 +161,51 @@ final class NavigationAddPeriodTest extends TestCase
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideFrequencies(): iterable
|
||||
public static function provideFrequencies(): Iterator
|
||||
{
|
||||
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')],
|
||||
];
|
||||
yield Periodicity::Daily->name => [Periodicity::Daily, Carbon::now(), Carbon::tomorrow()];
|
||||
|
||||
yield Periodicity::Weekly->name => [Periodicity::Weekly, Carbon::now(), Carbon::now()->addWeeks(1)];
|
||||
|
||||
yield Periodicity::Fortnightly->name => [Periodicity::Fortnightly, Carbon::now(), Carbon::now()->addWeeks(2)];
|
||||
|
||||
yield Periodicity::Monthly->name => [Periodicity::Monthly, Carbon::now(), Carbon::now()->addMonthsNoOverflow(1)];
|
||||
|
||||
yield '2019-01-01 to 2019-02-01' => [Periodicity::Monthly, Carbon::parse('2019-01-01'), Carbon::parse('2019-02-01')];
|
||||
|
||||
yield '2019-01-29 to 2019-02-28' => [Periodicity::Monthly, Carbon::parse('2019-01-29'), Carbon::parse('2019-02-28')];
|
||||
|
||||
yield '2019-01-30 to 2019-02-28' => [Periodicity::Monthly, Carbon::parse('2019-01-30'), Carbon::parse('2019-02-28')];
|
||||
|
||||
yield '2019-01-31 to 2019-02-28' => [Periodicity::Monthly, Carbon::parse('2019-01-31'), Carbon::parse('2019-02-28')];
|
||||
|
||||
yield '2023-03-31 to 2023-04-30' => [Periodicity::Monthly, Carbon::parse('2023-03-31'), Carbon::parse('2023-04-30')];
|
||||
|
||||
yield '2023-05-31 to 2023-06-30' => [Periodicity::Monthly, Carbon::parse('2023-05-31'), Carbon::parse('2023-06-30')];
|
||||
|
||||
yield '2023-08-31 to 2023-09-30' => [Periodicity::Monthly, Carbon::parse('2023-08-31'), Carbon::parse('2023-09-30')];
|
||||
|
||||
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')]
|
||||
@@ -176,19 +215,26 @@ final class NavigationAddPeriodTest extends TestCase
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideMonthPeriods(): iterable
|
||||
public static function provideMonthPeriods(): Iterator
|
||||
{
|
||||
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')],
|
||||
];
|
||||
yield '1M' => ['1M', Carbon::parse('2023-06-25'), Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)];
|
||||
|
||||
yield 'month' => ['month', Carbon::parse('2023-06-25'), Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)];
|
||||
|
||||
yield 'monthly' => ['monthly', Carbon::parse('2023-06-25'), Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)];
|
||||
|
||||
yield '2019-01-29 to 2019-02-28' => ['monthly', Carbon::parse('2019-01-29'), Carbon::parse('2019-02-28')];
|
||||
|
||||
yield '2019-01-30 to 2019-02-28' => ['monthly', Carbon::parse('2019-01-30'), Carbon::parse('2019-02-28')];
|
||||
|
||||
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;
|
||||
|
||||
use Override;
|
||||
use Iterator;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Navigation;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -42,6 +44,7 @@ final class NavigationEndOfPeriodTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -55,35 +58,56 @@ final class NavigationEndOfPeriodTest extends TestCase
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideDates(): iterable
|
||||
public static function provideDates(): Iterator
|
||||
{
|
||||
return [
|
||||
'1D' => ['frequency' => '1D', 'from' => Carbon::now(), 'expected' => Carbon::now()->endOfDay()],
|
||||
'daily' => ['frequency' => 'daily', 'from' => Carbon::now(), 'expected' => 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()],
|
||||
'weekly' => ['frequency' => 'weekly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addWeek()->subDay()->endOfDay()],
|
||||
'month' => ['frequency' => 'month', 'from' => Carbon::now(), 'expected' => Carbon::now()->addMonth()->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()],
|
||||
'3M' => ['frequency' => '3M', 'from' => Carbon::now(), 'expected' => Carbon::now()->addQuarter()->subDay()->endOfDay()],
|
||||
'quarter' => ['frequency' => 'quarter', 'from' => Carbon::now(), 'expected' => Carbon::now()->addQuarter()->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()],
|
||||
'yearly' => ['frequency' => 'yearly', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYearNoOverflow()->subDay()->endOfDay()],
|
||||
'1Y' => ['frequency' => '1Y', 'from' => Carbon::now(), 'expected' => Carbon::now()->addYearNoOverflow()->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')],
|
||||
'last7' => ['frequency' => 'last7', 'from' => Carbon::now(), 'expected' => Carbon::now()->addDays(7)->endOfDay()],
|
||||
'last30' => ['frequency' => 'last30', 'from' => Carbon::now(), 'expected' => Carbon::now()->addDays(30)->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()],
|
||||
'MTD' => ['frequency' => 'MTD', 'from' => Carbon::now(),
|
||||
'expected' => Carbon::now()->isSameMonth(Carbon::now()) ? Carbon::now()->endOfDay() : Carbon::now()->endOfMonth()],
|
||||
'QTD' => ['frequency' => 'QTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfQuarter()->startOfDay()],
|
||||
'YTD' => ['frequency' => 'YTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfYear()->startOfDay()],
|
||||
'week 2023-08-05 to 2023-08-11' => ['frequency' => '1W', 'from' => Carbon::parse('2023-08-05'), 'expected' => Carbon::parse('2023-08-11')->endOfDay()],
|
||||
];
|
||||
yield '1D' => ['1D', Carbon::now(), Carbon::now()->endOfDay()];
|
||||
|
||||
yield 'daily' => ['daily', Carbon::now(), Carbon::now()->endOfDay()];
|
||||
|
||||
yield '1W' => ['1W', Carbon::now(), Carbon::now()->addWeek()->subDay()->endOfDay()];
|
||||
|
||||
yield 'week' => ['week', Carbon::now(), Carbon::now()->addWeek()->subDay()->endOfDay()];
|
||||
|
||||
yield 'weekly' => ['weekly', Carbon::now(), Carbon::now()->addWeek()->subDay()->endOfDay()];
|
||||
|
||||
yield 'month' => ['month', Carbon::now(), Carbon::now()->addMonth()->subDay()->endOfDay()];
|
||||
|
||||
yield '1M' => ['1M', Carbon::now(), Carbon::now()->addMonth()->subDay()->endOfDay()];
|
||||
|
||||
yield 'monthly' => ['monthly', Carbon::now(), Carbon::now()->addMonth()->subDay()->endOfDay()];
|
||||
|
||||
yield '3M' => ['3M', Carbon::now(), Carbon::now()->addQuarter()->subDay()->endOfDay()];
|
||||
|
||||
yield 'quarter' => ['quarter', Carbon::now(), Carbon::now()->addQuarter()->subDay()->endOfDay()];
|
||||
|
||||
yield 'quarterly' => ['quarterly', Carbon::now(), Carbon::now()->addQuarter()->subDay()->endOfDay()];
|
||||
|
||||
yield 'year' => ['year', Carbon::now(), Carbon::now()->addYearNoOverflow()->subDay()->endOfDay()];
|
||||
|
||||
yield 'yearly' => ['yearly', Carbon::now(), Carbon::now()->addYearNoOverflow()->subDay()->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')]
|
||||
@@ -98,12 +122,12 @@ final class NavigationEndOfPeriodTest extends TestCase
|
||||
Log::shouldHaveReceived('error', [$expectedMessage]);
|
||||
}
|
||||
|
||||
public static function provideUnknownFrequencies(): iterable
|
||||
public static function provideUnknownFrequencies(): Iterator
|
||||
{
|
||||
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()],
|
||||
];
|
||||
yield '1day' => ['1day', Carbon::now(), Carbon::now()];
|
||||
|
||||
yield 'unknown' => ['unknown', Carbon::now(), Carbon::now()->startOfDay()];
|
||||
|
||||
yield 'empty' => ['', Carbon::now(), Carbon::now()->startOfDay()];
|
||||
}
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support;
|
||||
|
||||
use Override;
|
||||
use Iterator;
|
||||
use FireflyIII\Support\Navigation;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Tests\integration\TestCase;
|
||||
@@ -41,6 +43,7 @@ final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -54,15 +57,18 @@ final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
}
|
||||
|
||||
public static function providePeriods(): iterable
|
||||
public static function providePeriods(): Iterator
|
||||
{
|
||||
return [
|
||||
'unknown' => ['period' => '1day', 'expected' => 'Y-m-d'],
|
||||
'week' => ['period' => '1W', 'expected' => '\WW,Y'],
|
||||
'month' => ['period' => '1M', 'expected' => 'Y-m'],
|
||||
'quarterly' => ['period' => '3M', 'expected' => '\QQ,Y'],
|
||||
'half-yearly' => ['period' => '6M', 'expected' => '\QQ,Y'],
|
||||
'yearly' => ['period' => '1Y', 'expected' => 'Y'],
|
||||
];
|
||||
yield 'unknown' => ['1day', 'Y-m-d'];
|
||||
|
||||
yield 'week' => ['1W', '\WW,Y'];
|
||||
|
||||
yield 'month' => ['1M', 'Y-m'];
|
||||
|
||||
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;
|
||||
|
||||
use Override;
|
||||
use Iterator;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Navigation;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
@@ -42,6 +44,7 @@ final class NavigationPreferredCarbonFormatTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -55,21 +58,30 @@ final class NavigationPreferredCarbonFormatTest extends TestCase
|
||||
self::assertSame($expected, $carbonFormat);
|
||||
}
|
||||
|
||||
public static function providePeriods(): iterable
|
||||
public static function providePeriods(): Iterator
|
||||
{
|
||||
return [
|
||||
'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'],
|
||||
'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'],
|
||||
'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'],
|
||||
'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'],
|
||||
'13 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(13), 'expected' => 'Y'],
|
||||
'16 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(16), 'expected' => 'Y'],
|
||||
'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 '1 week' => [Carbon::now(), Carbon::now()->addWeek(), 'Y-m-d'];
|
||||
|
||||
yield '1 month' => [Carbon::now(), Carbon::now()->addMonth(), 'Y-m-d'];
|
||||
|
||||
yield '2 months' => [Carbon::now(), Carbon::now()->addMonths(2), 'Y-m'];
|
||||
|
||||
yield '3 months' => [Carbon::now(), Carbon::now()->addMonths(3), 'Y-m'];
|
||||
|
||||
yield '6 months' => [Carbon::now(), Carbon::now()->addMonths(6), 'Y-m'];
|
||||
|
||||
yield '7 months' => [Carbon::now(), Carbon::now()->addMonths(7), 'Y-m'];
|
||||
|
||||
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;
|
||||
|
||||
use Override;
|
||||
use Iterator;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Navigation;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
@@ -42,6 +44,7 @@ final class NavigationPreferredEndOfPeriodTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -55,21 +58,30 @@ final class NavigationPreferredEndOfPeriodTest extends TestCase
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
}
|
||||
|
||||
public static function providePeriods(): iterable
|
||||
public static function providePeriods(): Iterator
|
||||
{
|
||||
return [
|
||||
'1 week' => ['start' => Carbon::now(), 'end' => Carbon::now()->addWeek(), 'expected' => 'endOfDay'],
|
||||
'1 month' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonth(), 'expected' => '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'],
|
||||
'6 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(6), 'expected' => 'endOfMonth'],
|
||||
'7 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(7), 'expected' => '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'],
|
||||
'13 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(13), 'expected' => 'endOfYear'],
|
||||
'16 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(16), 'expected' => 'endOfYear'],
|
||||
'1 year' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYear(), 'expected' => 'endOfMonth'],
|
||||
'2 years' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYears(2), 'expected' => 'endOfYear'],
|
||||
];
|
||||
yield '1 week' => [Carbon::now(), Carbon::now()->addWeek(), 'endOfDay'];
|
||||
|
||||
yield '1 month' => [Carbon::now(), Carbon::now()->addMonth(), 'endOfDay'];
|
||||
|
||||
yield '2 months' => [Carbon::now(), Carbon::now()->addMonths(2), 'endOfMonth'];
|
||||
|
||||
yield '3 months' => [Carbon::now(), Carbon::now()->addMonths(3), 'endOfMonth'];
|
||||
|
||||
yield '6 months' => [Carbon::now(), Carbon::now()->addMonths(6), 'endOfMonth'];
|
||||
|
||||
yield '7 months' => [Carbon::now(), Carbon::now()->addMonths(7), 'endOfMonth'];
|
||||
|
||||
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;
|
||||
|
||||
use Override;
|
||||
use Iterator;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Navigation;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
@@ -42,6 +44,7 @@ final class NavigationPreferredRangeFormatTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -55,21 +58,30 @@ final class NavigationPreferredRangeFormatTest extends TestCase
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
}
|
||||
|
||||
public static function providePeriods(): iterable
|
||||
public static function providePeriods(): Iterator
|
||||
{
|
||||
return [
|
||||
'1 week' => ['start' => Carbon::now(), 'end' => Carbon::now()->addWeek(), 'expected' => '1D'],
|
||||
'1 month' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonth(), 'expected' => '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'],
|
||||
'6 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(6), 'expected' => '1M'],
|
||||
'7 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(7), 'expected' => '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'],
|
||||
'13 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(13), 'expected' => '1Y'],
|
||||
'16 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(16), 'expected' => '1Y'],
|
||||
'1 year' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYear(), 'expected' => '1M'],
|
||||
'2 years' => ['start' => Carbon::now(), 'end' => Carbon::now()->addYears(2), 'expected' => '1Y'],
|
||||
];
|
||||
yield '1 week' => [Carbon::now(), Carbon::now()->addWeek(), '1D'];
|
||||
|
||||
yield '1 month' => [Carbon::now(), Carbon::now()->addMonth(), '1D'];
|
||||
|
||||
yield '2 months' => [Carbon::now(), Carbon::now()->addMonths(2), '1M'];
|
||||
|
||||
yield '3 months' => [Carbon::now(), Carbon::now()->addMonths(3), '1M'];
|
||||
|
||||
yield '6 months' => [Carbon::now(), Carbon::now()->addMonths(6), '1M'];
|
||||
|
||||
yield '7 months' => [Carbon::now(), Carbon::now()->addMonths(7), '1M'];
|
||||
|
||||
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;
|
||||
|
||||
use Override;
|
||||
use Iterator;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Navigation;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
@@ -42,6 +44,7 @@ final class NavigationPreferredSqlFormatTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -55,21 +58,30 @@ final class NavigationPreferredSqlFormatTest extends TestCase
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
}
|
||||
|
||||
public static function provideDates(): iterable
|
||||
public static function provideDates(): Iterator
|
||||
{
|
||||
return [
|
||||
'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'],
|
||||
'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'],
|
||||
'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'],
|
||||
'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'],
|
||||
'13 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(13), 'expected' => '%Y'],
|
||||
'16 months' => ['start' => Carbon::now(), 'end' => Carbon::now()->addMonths(16), 'expected' => '%Y'],
|
||||
'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 '1 week' => [Carbon::now(), Carbon::now()->addWeek(), '%Y-%m-%d'];
|
||||
|
||||
yield '1 month' => [Carbon::now(), Carbon::now()->addMonth(), '%Y-%m-%d'];
|
||||
|
||||
yield '2 months' => [Carbon::now(), Carbon::now()->addMonths(2), '%Y-%m'];
|
||||
|
||||
yield '3 months' => [Carbon::now(), Carbon::now()->addMonths(3), '%Y-%m'];
|
||||
|
||||
yield '6 months' => [Carbon::now(), Carbon::now()->addMonths(6), '%Y-%m'];
|
||||
|
||||
yield '7 months' => [Carbon::now(), Carbon::now()->addMonths(7), '%Y-%m'];
|
||||
|
||||
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;
|
||||
|
||||
use Override;
|
||||
use Iterator;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Navigation;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -43,6 +45,7 @@ final class NavigationStartOfPeriodTest extends TestCase
|
||||
{
|
||||
private Navigation $navigation;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -56,34 +59,55 @@ final class NavigationStartOfPeriodTest extends TestCase
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideDates(): iterable
|
||||
public static function provideDates(): Iterator
|
||||
{
|
||||
return [
|
||||
'custom' => ['frequency' => 'custom', 'from' => Carbon::now(), 'expected' => Carbon::now()],
|
||||
'1D' => ['frequency' => '1D', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],
|
||||
'daily' => ['frequency' => 'daily', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfDay()],
|
||||
'1W' => ['frequency' => '1W', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfWeek()],
|
||||
'week' => ['frequency' => 'week', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfWeek()],
|
||||
'weekly' => ['frequency' => 'weekly', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfWeek()],
|
||||
'month' => ['frequency' => 'month', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfMonth()],
|
||||
'1M' => ['frequency' => '1M', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfMonth()],
|
||||
'monthly' => ['frequency' => 'monthly', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfMonth()],
|
||||
'3M' => ['frequency' => '3M', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfQuarter()],
|
||||
'quarter' => ['frequency' => 'quarter', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfQuarter()],
|
||||
'quarterly' => ['frequency' => 'quarterly', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfQuarter()],
|
||||
'year' => ['frequency' => 'year', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfYear()],
|
||||
'yearly' => ['frequency' => 'yearly', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfYear()],
|
||||
'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()],
|
||||
'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()],
|
||||
'last30' => ['frequency' => 'last30', 'from' => Carbon::now(), 'expected' => Carbon::now()->subDays(30)->startOfDay()],
|
||||
'last90' => ['frequency' => 'last90', 'from' => Carbon::now(), 'expected' => Carbon::now()->subDays(90)->startOfDay()],
|
||||
'last365' => ['frequency' => 'last365', 'from' => Carbon::now(), 'expected' => Carbon::now()->subDays(365)->startOfDay()],
|
||||
'MTD' => ['frequency' => 'MTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfMonth()->startOfDay()],
|
||||
'QTD' => ['frequency' => 'QTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->firstOfQuarter()->startOfDay()],
|
||||
'YTD' => ['frequency' => 'YTD', 'from' => Carbon::now(), 'expected' => Carbon::now()->startOfYear()->startOfDay()],
|
||||
];
|
||||
yield 'custom' => ['custom', Carbon::now(), Carbon::now()];
|
||||
|
||||
yield '1D' => ['1D', Carbon::now(), Carbon::now()->startOfDay()];
|
||||
|
||||
yield 'daily' => ['daily', Carbon::now(), Carbon::now()->startOfDay()];
|
||||
|
||||
yield '1W' => ['1W', Carbon::now(), Carbon::now()->startOfWeek()];
|
||||
|
||||
yield 'week' => ['week', Carbon::now(), Carbon::now()->startOfWeek()];
|
||||
|
||||
yield 'weekly' => ['weekly', Carbon::now(), Carbon::now()->startOfWeek()];
|
||||
|
||||
yield 'month' => ['month', Carbon::now(), Carbon::now()->startOfMonth()];
|
||||
|
||||
yield '1M' => ['1M', Carbon::now(), Carbon::now()->startOfMonth()];
|
||||
|
||||
yield 'monthly' => ['monthly', Carbon::now(), Carbon::now()->startOfMonth()];
|
||||
|
||||
yield '3M' => ['3M', Carbon::now(), Carbon::now()->firstOfQuarter()];
|
||||
|
||||
yield 'quarter' => ['quarter', Carbon::now(), Carbon::now()->firstOfQuarter()];
|
||||
|
||||
yield 'quarterly' => ['quarterly', Carbon::now(), Carbon::now()->firstOfQuarter()];
|
||||
|
||||
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')]
|
||||
@@ -100,12 +124,12 @@ final class NavigationStartOfPeriodTest extends TestCase
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideUnknownFrequencies(): iterable
|
||||
public static function provideUnknownFrequencies(): Iterator
|
||||
{
|
||||
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()],
|
||||
];
|
||||
yield '1day' => ['1day', Carbon::now(), Carbon::now()];
|
||||
|
||||
yield 'unknown' => ['unknown', Carbon::now(), Carbon::now()->startOfDay()];
|
||||
|
||||
yield 'empty' => ['', Carbon::now(), Carbon::now()->startOfDay()];
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\unit\Support\Search\QueryParser;
|
||||
|
||||
use Iterator;
|
||||
use FireflyIII\Support\Search\QueryParser\FieldNode;
|
||||
use FireflyIII\Support\Search\QueryParser\QueryParserInterface;
|
||||
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 [
|
||||
'empty query' => [
|
||||
'query' => '',
|
||||
'expected' => new NodeGroup([]),
|
||||
],
|
||||
'simple word' => [
|
||||
'query' => 'groceries',
|
||||
'expected' => new NodeGroup([new StringNode('groceries')]),
|
||||
],
|
||||
'prohibited word' => [
|
||||
'query' => '-groceries',
|
||||
'expected' => new NodeGroup([new StringNode('groceries', true)]),
|
||||
],
|
||||
'prohibited field' => [
|
||||
'query' => '-amount:100',
|
||||
'expected' => new NodeGroup([new FieldNode('amount', '100', true)]),
|
||||
],
|
||||
'quoted word' => [
|
||||
'query' => '"test phrase"',
|
||||
'expected' => new NodeGroup([new StringNode('test phrase')]),
|
||||
],
|
||||
'prohibited quoted word' => [
|
||||
'query' => '-"test phrase"',
|
||||
'expected' => new NodeGroup([new StringNode('test phrase', true)]),
|
||||
],
|
||||
'multiple words' => [
|
||||
'query' => 'groceries shopping market',
|
||||
'expected' => new NodeGroup([
|
||||
new StringNode('groceries'),
|
||||
new StringNode('shopping'),
|
||||
new StringNode('market'),
|
||||
]),
|
||||
],
|
||||
'field operator' => [
|
||||
'query' => 'amount:100',
|
||||
'expected' => new NodeGroup([new FieldNode('amount', '100')]),
|
||||
],
|
||||
'quoted field value with single space' => [
|
||||
'query' => 'description:"test phrase"',
|
||||
'expected' => new NodeGroup([new FieldNode('description', 'test phrase')]),
|
||||
],
|
||||
'multiple fields' => [
|
||||
'query' => 'amount:100 category:food',
|
||||
'expected' => new NodeGroup([
|
||||
yield 'empty query' => [
|
||||
'',
|
||||
new NodeGroup([]),
|
||||
];
|
||||
|
||||
yield 'simple word' => [
|
||||
'groceries',
|
||||
new NodeGroup([new StringNode('groceries')]),
|
||||
];
|
||||
|
||||
yield 'prohibited word' => [
|
||||
'-groceries',
|
||||
new NodeGroup([new StringNode('groceries', true)]),
|
||||
];
|
||||
|
||||
yield 'prohibited field' => [
|
||||
'-amount:100',
|
||||
new NodeGroup([new FieldNode('amount', '100', true)]),
|
||||
];
|
||||
|
||||
yield 'quoted word' => [
|
||||
'"test phrase"',
|
||||
new NodeGroup([new StringNode('test phrase')]),
|
||||
];
|
||||
|
||||
yield 'prohibited quoted word' => [
|
||||
'-"test phrase"',
|
||||
new NodeGroup([new StringNode('test phrase', true)]),
|
||||
];
|
||||
|
||||
yield 'multiple words' => [
|
||||
'groceries shopping market',
|
||||
new NodeGroup([
|
||||
new StringNode('groceries'),
|
||||
new StringNode('shopping'),
|
||||
new StringNode('market'),
|
||||
]),
|
||||
];
|
||||
|
||||
yield 'field operator' => [
|
||||
'amount:100',
|
||||
new NodeGroup([new FieldNode('amount', '100')]),
|
||||
];
|
||||
|
||||
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('category', 'food'),
|
||||
]),
|
||||
],
|
||||
'simple subquery' => [
|
||||
'query' => '(amount:100 category:food)',
|
||||
'expected' => new NodeGroup([
|
||||
new NodeGroup([
|
||||
new FieldNode('amount', '100'),
|
||||
new FieldNode('category', 'food'),
|
||||
]),
|
||||
]),
|
||||
],
|
||||
'prohibited subquery' => [
|
||||
'query' => '-(amount:100 category:food)',
|
||||
'expected' => new NodeGroup([
|
||||
new NodeGroup([
|
||||
new FieldNode('amount', '100'),
|
||||
new FieldNode('category', 'food'),
|
||||
], true),
|
||||
]),
|
||||
],
|
||||
'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([
|
||||
]),
|
||||
];
|
||||
|
||||
yield 'prohibited subquery' => [
|
||||
'-(amount:100 category:food)',
|
||||
new NodeGroup([
|
||||
new NodeGroup([
|
||||
new FieldNode('amount', '100'),
|
||||
new FieldNode('category', 'food'),
|
||||
], true),
|
||||
]),
|
||||
];
|
||||
|
||||
yield 'nested subquery' => [
|
||||
'(amount:100 (description:"test" category:food))',
|
||||
new NodeGroup([
|
||||
new NodeGroup([
|
||||
new FieldNode('amount', '100'),
|
||||
new NodeGroup([
|
||||
new FieldNode('description', 'market'),
|
||||
new FieldNode('description', 'test'),
|
||||
new FieldNode('category', 'food'),
|
||||
]),
|
||||
]),
|
||||
],
|
||||
'word followed by subquery' => [
|
||||
'query' => 'groceries (amount:100 description_contains:"test")',
|
||||
'expected' => new NodeGroup([
|
||||
new StringNode('groceries'),
|
||||
]),
|
||||
];
|
||||
|
||||
yield 'mixed words and operators' => [
|
||||
'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 FieldNode('amount', '100'),
|
||||
new FieldNode('description_contains', 'test'),
|
||||
new FieldNode('description_contains', 'test payment'),
|
||||
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 FieldNode('amount', '100'),
|
||||
new FieldNode('category', 'food', true),
|
||||
new StringNode('word'),
|
||||
new FieldNode('description', 'test phrase'),
|
||||
new NodeGroup([
|
||||
new FieldNode('description_contains', 'test payment'),
|
||||
new FieldNode('has_attachments', 'true', true),
|
||||
new FieldNode('has_notes', 'true'),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
],
|
||||
'complex nested subqueries' => [
|
||||
'query' => 'shopping (amount:50 market (-category:food word description:"test phrase" (has_notes:true)))',
|
||||
'expected' => new NodeGroup([
|
||||
new StringNode('shopping'),
|
||||
new NodeGroup([
|
||||
new FieldNode('amount', '50'),
|
||||
new StringNode('market'),
|
||||
new NodeGroup([
|
||||
new FieldNode('category', 'food', true),
|
||||
new StringNode('word'),
|
||||
new FieldNode('description', 'test phrase'),
|
||||
new NodeGroup([
|
||||
new FieldNode('has_notes', 'true'),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
];
|
||||
|
||||
yield 'word with multiple spaces' => [
|
||||
'"multiple spaces"',
|
||||
new NodeGroup([new StringNode('multiple spaces')]),
|
||||
];
|
||||
|
||||
yield 'field with multiple spaces in value' => [
|
||||
'description:"multiple spaces here"',
|
||||
new NodeGroup([new FieldNode('description', 'multiple spaces here')]),
|
||||
];
|
||||
|
||||
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'),
|
||||
]),
|
||||
],
|
||||
'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'),
|
||||
]),
|
||||
],
|
||||
new StringNode('shopping'),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user