mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
More code cleanup
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* CalculatorProvider.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
@@ -27,7 +26,6 @@ namespace Tests\unit\Support\Calendar;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Support\Calendar\Periodicity;
|
||||
use Generator;
|
||||
use Tests\unit\Support\Calendar\Periodicity\IntervalProvider;
|
||||
|
||||
readonly class CalculatorProvider
|
||||
@@ -45,7 +43,7 @@ readonly class CalculatorProvider
|
||||
$this->label = "{$periodicity->name} {$intervalProvider->label}";
|
||||
}
|
||||
|
||||
public static function providePeriodicityWithSkippedIntervals(): Generator
|
||||
public static function providePeriodicityWithSkippedIntervals(): \Generator
|
||||
{
|
||||
$intervals = [
|
||||
self::from(Periodicity::Daily, new IntervalProvider(Carbon::now(), Carbon::now()->addDays(2)), 1),
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* CalculatorTest.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
@@ -44,8 +43,12 @@ use Tests\unit\Support\Calendar\Periodicity\YearlyTest;
|
||||
* @group support
|
||||
* @group calendar
|
||||
* @group calculator
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class CalculatorTest extends TestCase
|
||||
final class CalculatorTest extends TestCase
|
||||
{
|
||||
public static function provideAllPeriodicity(): iterable
|
||||
{
|
||||
@@ -65,18 +68,6 @@ class CalculatorTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
private static function convert(Periodicity $periodicity, array $intervals): array
|
||||
{
|
||||
$periodicityIntervals = [];
|
||||
/** @var IntervalProvider $interval */
|
||||
foreach ($intervals as $index => $interval) {
|
||||
$calculator = CalculatorProvider::from($periodicity, $interval);
|
||||
|
||||
$periodicityIntervals["#{$index} {$calculator->label}"] = [$calculator];
|
||||
}
|
||||
return $periodicityIntervals;
|
||||
}
|
||||
|
||||
public static function provideSkippedIntervals(): iterable
|
||||
{
|
||||
return CalculatorProvider::providePeriodicityWithSkippedIntervals();
|
||||
@@ -84,6 +75,7 @@ class CalculatorTest extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider provideAllPeriodicity
|
||||
*
|
||||
* @throws IntervalException
|
||||
*/
|
||||
public function testGivenADailyPeriodicityWhenCallTheNextDateByIntervalMethodThenReturnsTheExpectedDateSuccessful(CalculatorProvider $provider)
|
||||
@@ -95,6 +87,7 @@ class CalculatorTest extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider provideSkippedIntervals
|
||||
*
|
||||
* @throws IntervalException
|
||||
*/
|
||||
public function testGivenAnEpochWithSkipIntervalNumberWhenCallTheNextDateBySkippedIntervalMethodThenReturnsTheExpectedDateSuccessful(CalculatorProvider $provider)
|
||||
@@ -103,4 +96,18 @@ class CalculatorTest extends TestCase
|
||||
$period = $calculator->nextDateByInterval($provider->epoch(), $provider->periodicity, $provider->skip);
|
||||
self::assertSame($provider->expected()->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
private static function convert(Periodicity $periodicity, array $intervals): array
|
||||
{
|
||||
$periodicityIntervals = [];
|
||||
|
||||
/** @var IntervalProvider $interval */
|
||||
foreach ($intervals as $index => $interval) {
|
||||
$calculator = CalculatorProvider::from($periodicity, $interval);
|
||||
|
||||
$periodicityIntervals["#{$index} {$calculator->label}"] = [$calculator];
|
||||
}
|
||||
|
||||
return $periodicityIntervals;
|
||||
}
|
||||
}
|
||||
|
@@ -33,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
* @group support
|
||||
* @group calendar
|
||||
* @group periodicity
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class BimonthlyTest extends IntervalTestCase
|
||||
final class BimonthlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* DailyTest.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
* @group support
|
||||
* @group calendar
|
||||
* @group periodicity
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class DailyTest extends IntervalTestCase
|
||||
final class DailyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* FortnightlyTest.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
* @group support
|
||||
* @group calendar
|
||||
* @group periodicity
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class FortnightlyTest extends IntervalTestCase
|
||||
final class FortnightlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* HalfYearlyTest.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
* @group support
|
||||
* @group calendar
|
||||
* @group periodicity
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class HalfYearlyTest extends IntervalTestCase
|
||||
final class HalfYearlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* IntervalProvider.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* IntervalTestCase.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
@@ -33,6 +32,7 @@ abstract class IntervalTestCase extends TestCase
|
||||
public static function provider(): iterable
|
||||
{
|
||||
$intervals = static::provideIntervals();
|
||||
|
||||
/** @var IntervalProvider $interval */
|
||||
foreach ($intervals as $interval) {
|
||||
yield "{$interval->label}" => [$interval];
|
||||
@@ -43,10 +43,6 @@ abstract class IntervalTestCase extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider provider
|
||||
*
|
||||
* @param IntervalProvider $provider
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGivenAnEpochWhenCallTheNextDateThenReturnsTheExpectedDateSuccessful(IntervalProvider $provider): void
|
||||
{
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* MonthlyTest.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
* @group support
|
||||
* @group calendar
|
||||
* @group periodicity
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class MonthlyTest extends IntervalTestCase
|
||||
final class MonthlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
@@ -55,7 +58,7 @@ class MonthlyTest extends IntervalTestCase
|
||||
new IntervalProvider(Carbon::parse('2021-01-31'), Carbon::parse('2021-02-28')),
|
||||
new IntervalProvider(Carbon::parse('2023-03-31'), Carbon::parse('2023-04-30')),
|
||||
new IntervalProvider(Carbon::parse('2023-05-31'), Carbon::parse('2023-06-30')),
|
||||
//new IntervalProvider(Carbon::parse('2023-08-31'), Carbon::parse('2023-09-30')),
|
||||
// new IntervalProvider(Carbon::parse('2023-08-31'), Carbon::parse('2023-09-30')),
|
||||
new IntervalProvider(Carbon::parse('2023-10-31'), Carbon::parse('2023-11-30')),
|
||||
];
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* QuarterlyTest.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
* @group support
|
||||
* @group calendar
|
||||
* @group periodicity
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class QuarterlyTest extends IntervalTestCase
|
||||
final class QuarterlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* WeeklyTest.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
* @group support
|
||||
* @group calendar
|
||||
* @group periodicity
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class WeeklyTest extends IntervalTestCase
|
||||
final class WeeklyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
|
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
* YearlyTest.php
|
||||
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
|
||||
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||
* @group support
|
||||
* @group calendar
|
||||
* @group periodicity
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
class YearlyTest extends IntervalTestCase
|
||||
final class YearlyTest extends IntervalTestCase
|
||||
{
|
||||
public static function factory(): Interval
|
||||
{
|
||||
|
Reference in New Issue
Block a user