mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-25 13:10:35 +00:00
Final fixes.
This commit is contained in:
@@ -24,6 +24,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\integration\Support\Models;
|
||||
|
||||
use Override;
|
||||
use Iterator;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Models\BillDateCalculator;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
@@ -40,6 +42,7 @@ final class BillDateCalculatorTest extends TestCase
|
||||
{
|
||||
private BillDateCalculator $calculator;
|
||||
|
||||
#[Override]
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -56,25 +59,25 @@ final class BillDateCalculatorTest extends TestCase
|
||||
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
|
||||
return [
|
||||
// basic monthly bill.x
|
||||
'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']],
|
||||
// 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']];
|
||||
|
||||
// every month, start on 2024-01-30, view is quarterly
|
||||
'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']],
|
||||
// already paid on the first, expect it next month.
|
||||
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
|
||||
'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']],
|
||||
// already paid on the 12th, expect it next month.
|
||||
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.
|
||||
'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']],
|
||||
];
|
||||
// every month, start on 2024-01-30, view is quarterly
|
||||
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']];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user