mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix code quality and run.
This commit is contained in:
parent
bcf1e4dc13
commit
7436f94feb
@ -41,6 +41,7 @@ return $config->setRules([
|
||||
'declare_strict_types' => true,
|
||||
'strict_param' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'native_function_invocation' => false,
|
||||
'native_function_invocation' => false, // annoying
|
||||
'php_unit_data_provider_name' => false, // bloody annoying long test names
|
||||
])
|
||||
->setFinder($finder);
|
||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
@ -31,7 +32,6 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
@ -42,8 +42,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property bool $enabled
|
||||
* @property bool $userDefault
|
||||
* @property bool $userEnabled
|
||||
* @property bool|null $userDefault
|
||||
* @property bool|null $userEnabled
|
||||
* @property string $code
|
||||
* @property string $name
|
||||
* @property string $symbol
|
||||
|
@ -42,6 +42,6 @@ class NavigationCustomEndOfPeriodTest extends TestCase
|
||||
$navigation = new Navigation();
|
||||
|
||||
$period = $navigation->endOfPeriod($from, 'custom');
|
||||
$this->assertEquals($expected->toDateString(), $period->toDateString());
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ use Tests\integration\Traits\CollectsValues;
|
||||
*/
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
use CollectsValues;
|
||||
use CreatesApplication;
|
||||
|
||||
protected const MAX_ITERATIONS = 2;
|
||||
|
||||
|
@ -48,69 +48,69 @@ readonly class CalculatorProvider
|
||||
public static function providePeriodicityWithSkippedIntervals(): Generator
|
||||
{
|
||||
$intervals = [
|
||||
CalculatorProvider::from(Periodicity::Daily, new IntervalProvider(Carbon::now(), Carbon::now()->addDays(2)), 1),
|
||||
CalculatorProvider::from(Periodicity::Daily, new IntervalProvider(Carbon::now(), Carbon::now()->addDays(3)), 2),
|
||||
CalculatorProvider::from(Periodicity::Daily, new IntervalProvider(Carbon::parse('2023-01-31'), Carbon::parse('2023-02-11')), 10),
|
||||
self::from(Periodicity::Daily, new IntervalProvider(Carbon::now(), Carbon::now()->addDays(2)), 1),
|
||||
self::from(Periodicity::Daily, new IntervalProvider(Carbon::now(), Carbon::now()->addDays(3)), 2),
|
||||
self::from(Periodicity::Daily, new IntervalProvider(Carbon::parse('2023-01-31'), Carbon::parse('2023-02-11')), 10),
|
||||
|
||||
CalculatorProvider::from(Periodicity::Weekly, new IntervalProvider(Carbon::now(), Carbon::now()->addWeeks(3)), 2),
|
||||
CalculatorProvider::from(Periodicity::Weekly, new IntervalProvider(Carbon::parse('2023-01-31'), Carbon::parse('2023-02-14')), 1),
|
||||
self::from(Periodicity::Weekly, new IntervalProvider(Carbon::now(), Carbon::now()->addWeeks(3)), 2),
|
||||
self::from(Periodicity::Weekly, new IntervalProvider(Carbon::parse('2023-01-31'), Carbon::parse('2023-02-14')), 1),
|
||||
|
||||
CalculatorProvider::from(Periodicity::Fortnightly, new IntervalProvider(Carbon::now(), Carbon::now()->addWeeks(4)), 1),
|
||||
CalculatorProvider::from(Periodicity::Fortnightly, new IntervalProvider(Carbon::parse('2023-01-29'), Carbon::parse('2023-02-26')), 1),
|
||||
CalculatorProvider::from(Periodicity::Fortnightly, new IntervalProvider(Carbon::parse('2023-01-30'), Carbon::parse('2023-02-27')), 1),
|
||||
CalculatorProvider::from(Periodicity::Fortnightly, new IntervalProvider(Carbon::parse('2023-01-31'), Carbon::parse('2023-02-28')), 1),
|
||||
self::from(Periodicity::Fortnightly, new IntervalProvider(Carbon::now(), Carbon::now()->addWeeks(4)), 1),
|
||||
self::from(Periodicity::Fortnightly, new IntervalProvider(Carbon::parse('2023-01-29'), Carbon::parse('2023-02-26')), 1),
|
||||
self::from(Periodicity::Fortnightly, new IntervalProvider(Carbon::parse('2023-01-30'), Carbon::parse('2023-02-27')), 1),
|
||||
self::from(Periodicity::Fortnightly, new IntervalProvider(Carbon::parse('2023-01-31'), Carbon::parse('2023-02-28')), 1),
|
||||
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(2)), 1),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2019-12-30'), Carbon::parse('2020-02-29')), 1),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2019-12-31'), Carbon::parse('2020-02-29')), 1),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2020-01-29'), Carbon::parse('2020-03-29')), 1),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2020-01-31'), Carbon::parse('2020-09-30')), 7),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2020-12-29'), Carbon::parse('2021-02-28')), 1),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2020-12-30'), Carbon::parse('2021-02-28')), 1),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2020-12-31'), Carbon::parse('2021-02-28')), 1),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2023-03-31'), Carbon::parse('2023-11-30')), 7),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2023-05-31'), Carbon::parse('2023-08-31')), 2),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2023-07-31'), Carbon::parse('2023-09-30')), 1),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2023-10-30'), Carbon::parse('2024-02-29')), 3),
|
||||
CalculatorProvider::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2023-10-31'), Carbon::parse('2024-02-29')), 3),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(2)), 1),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2019-12-30'), Carbon::parse('2020-02-29')), 1),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2019-12-31'), Carbon::parse('2020-02-29')), 1),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2020-01-29'), Carbon::parse('2020-03-29')), 1),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2020-01-31'), Carbon::parse('2020-09-30')), 7),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2020-12-29'), Carbon::parse('2021-02-28')), 1),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2020-12-30'), Carbon::parse('2021-02-28')), 1),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2020-12-31'), Carbon::parse('2021-02-28')), 1),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2023-03-31'), Carbon::parse('2023-11-30')), 7),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2023-05-31'), Carbon::parse('2023-08-31')), 2),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2023-07-31'), Carbon::parse('2023-09-30')), 1),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2023-10-30'), Carbon::parse('2024-02-29')), 3),
|
||||
self::from(Periodicity::Monthly, new IntervalProvider(Carbon::parse('2023-10-31'), Carbon::parse('2024-02-29')), 3),
|
||||
|
||||
CalculatorProvider::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(6)), 2),
|
||||
CalculatorProvider::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2019-08-29'), Carbon::parse('2020-02-29')), 2),
|
||||
CalculatorProvider::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2019-08-30'), Carbon::parse('2020-02-29')), 2),
|
||||
CalculatorProvider::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2019-08-31'), Carbon::parse('2020-02-29')), 2),
|
||||
CalculatorProvider::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2019-10-30'), Carbon::parse('2020-02-29')), 1),
|
||||
CalculatorProvider::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2019-10-31'), Carbon::parse('2020-02-29')), 1),
|
||||
CalculatorProvider::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2020-02-29'), Carbon::parse('2021-02-28')), 5),
|
||||
CalculatorProvider::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2020-08-29'), Carbon::parse('2021-02-28')), 2),
|
||||
CalculatorProvider::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2020-08-30'), Carbon::parse('2021-02-28')), 2),
|
||||
CalculatorProvider::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2020-08-31'), Carbon::parse('2021-02-28')), 2),
|
||||
self::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(6)), 2),
|
||||
self::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2019-08-29'), Carbon::parse('2020-02-29')), 2),
|
||||
self::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2019-08-30'), Carbon::parse('2020-02-29')), 2),
|
||||
self::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2019-08-31'), Carbon::parse('2020-02-29')), 2),
|
||||
self::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2019-10-30'), Carbon::parse('2020-02-29')), 1),
|
||||
self::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2019-10-31'), Carbon::parse('2020-02-29')), 1),
|
||||
self::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2020-02-29'), Carbon::parse('2021-02-28')), 5),
|
||||
self::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2020-08-29'), Carbon::parse('2021-02-28')), 2),
|
||||
self::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2020-08-30'), Carbon::parse('2021-02-28')), 2),
|
||||
self::from(Periodicity::Bimonthly, new IntervalProvider(Carbon::parse('2020-08-31'), Carbon::parse('2021-02-28')), 2),
|
||||
|
||||
CalculatorProvider::from(Periodicity::Quarterly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(9)), 2),
|
||||
CalculatorProvider::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2019-05-29'), Carbon::parse('2020-02-29')), 2),
|
||||
CalculatorProvider::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2019-05-30'), Carbon::parse('2020-02-29')), 2),
|
||||
CalculatorProvider::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2019-05-31'), Carbon::parse('2020-02-29')), 2),
|
||||
CalculatorProvider::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2020-02-29'), Carbon::parse('2021-02-28')), 3),
|
||||
CalculatorProvider::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2020-08-29'), Carbon::parse('2021-02-28')), 1),
|
||||
CalculatorProvider::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2020-08-30'), Carbon::parse('2021-02-28')), 1),
|
||||
CalculatorProvider::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2020-08-31'), Carbon::parse('2021-02-28')), 1),
|
||||
self::from(Periodicity::Quarterly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(9)), 2),
|
||||
self::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2019-05-29'), Carbon::parse('2020-02-29')), 2),
|
||||
self::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2019-05-30'), Carbon::parse('2020-02-29')), 2),
|
||||
self::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2019-05-31'), Carbon::parse('2020-02-29')), 2),
|
||||
self::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2020-02-29'), Carbon::parse('2021-02-28')), 3),
|
||||
self::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2020-08-29'), Carbon::parse('2021-02-28')), 1),
|
||||
self::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2020-08-30'), Carbon::parse('2021-02-28')), 1),
|
||||
self::from(Periodicity::Quarterly, new IntervalProvider(Carbon::parse('2020-08-31'), Carbon::parse('2021-02-28')), 1),
|
||||
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(12)), 1),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(18)), 2),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(24)), 3),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2018-08-29'), Carbon::parse('2020-02-29')), 2),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2018-08-30'), Carbon::parse('2020-02-29')), 2),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2018-08-31'), Carbon::parse('2020-02-29')), 2),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2019-01-31'), Carbon::parse('2021-01-31')), 3),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2019-02-28'), Carbon::parse('2021-08-28')), 4),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2020-01-31'), Carbon::parse('2021-01-31')), 1),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2020-02-29'), Carbon::parse('2021-02-28')), 1),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2020-08-29'), Carbon::parse('2022-02-28')), 2),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2020-08-30'), Carbon::parse('2022-02-28')), 2),
|
||||
CalculatorProvider::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2020-08-31'), Carbon::parse('2022-02-28')), 2),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(12)), 1),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(18)), 2),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::now(), Carbon::now()->addMonthsNoOverflow(24)), 3),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2018-08-29'), Carbon::parse('2020-02-29')), 2),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2018-08-30'), Carbon::parse('2020-02-29')), 2),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2018-08-31'), Carbon::parse('2020-02-29')), 2),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2019-01-31'), Carbon::parse('2021-01-31')), 3),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2019-02-28'), Carbon::parse('2021-08-28')), 4),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2020-01-31'), Carbon::parse('2021-01-31')), 1),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2020-02-29'), Carbon::parse('2021-02-28')), 1),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2020-08-29'), Carbon::parse('2022-02-28')), 2),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2020-08-30'), Carbon::parse('2022-02-28')), 2),
|
||||
self::from(Periodicity::HalfYearly, new IntervalProvider(Carbon::parse('2020-08-31'), Carbon::parse('2022-02-28')), 2),
|
||||
|
||||
CalculatorProvider::from(Periodicity::Yearly, new IntervalProvider(Carbon::now(), Carbon::now()->addYearsNoOverflow(3)), 2),
|
||||
CalculatorProvider::from(Periodicity::Yearly, new IntervalProvider(Carbon::parse('2019-01-29'), Carbon::parse('2025-01-29')), 5),
|
||||
CalculatorProvider::from(Periodicity::Yearly, new IntervalProvider(Carbon::parse('2020-02-29'), Carbon::parse('2031-02-28')), 10),
|
||||
self::from(Periodicity::Yearly, new IntervalProvider(Carbon::now(), Carbon::now()->addYearsNoOverflow(3)), 2),
|
||||
self::from(Periodicity::Yearly, new IntervalProvider(Carbon::parse('2019-01-29'), Carbon::parse('2025-01-29')), 5),
|
||||
self::from(Periodicity::Yearly, new IntervalProvider(Carbon::parse('2020-02-29'), Carbon::parse('2031-02-28')), 10),
|
||||
];
|
||||
|
||||
/** @var IntervalProvider $interval */
|
||||
@ -119,7 +119,7 @@ readonly class CalculatorProvider
|
||||
}
|
||||
}
|
||||
|
||||
public static function from(Periodicity $periodicity, IntervalProvider $interval, int $skip = 0): CalculatorProvider
|
||||
public static function from(Periodicity $periodicity, IntervalProvider $interval, int $skip = 0): self
|
||||
{
|
||||
return new self($interval, $periodicity, $skip);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ use Tests\unit\Support\Calendar\Periodicity\YearlyTest;
|
||||
*/
|
||||
class CalculatorTest extends TestCase
|
||||
{
|
||||
public static function provideAllPeriodicity(): Generator
|
||||
public static function provideAllPeriodicity(): iterable
|
||||
{
|
||||
$intervals = [];
|
||||
$intervals = array_merge($intervals, self::convert(Periodicity::Daily, DailyTest::provideIntervals()));
|
||||
@ -78,7 +78,7 @@ class CalculatorTest extends TestCase
|
||||
return $periodicityIntervals;
|
||||
}
|
||||
|
||||
public static function provideSkippedIntervals(): Generator
|
||||
public static function provideSkippedIntervals(): iterable
|
||||
{
|
||||
return CalculatorProvider::providePeriodicityWithSkippedIntervals();
|
||||
}
|
||||
@ -91,7 +91,7 @@ class CalculatorTest extends TestCase
|
||||
{
|
||||
$calculator = new Calculator();
|
||||
$period = $calculator->nextDateByInterval($provider->epoch(), $provider->periodicity);
|
||||
$this->assertEquals($provider->expected()->toDateString(), $period->toDateString());
|
||||
self::assertSame($provider->expected()->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,6 +102,6 @@ class CalculatorTest extends TestCase
|
||||
{
|
||||
$calculator = new Calculator();
|
||||
$period = $calculator->nextDateByInterval($provider->epoch(), $provider->periodicity, $provider->skip);
|
||||
$this->assertEquals($provider->expected()->toDateString(), $period->toDateString());
|
||||
self::assertSame($provider->expected()->toDateString(), $period->toDateString());
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class IntervalTestCase extends TestCase
|
||||
{
|
||||
public static function provider(): Generator
|
||||
public static function provider(): iterable
|
||||
{
|
||||
$intervals = static::provideIntervals();
|
||||
/** @var IntervalProvider $interval */
|
||||
@ -52,7 +52,7 @@ abstract class IntervalTestCase extends TestCase
|
||||
public function testGivenAnEpochWhenCallTheNextDateThenReturnsTheExpectedDateSuccessful(IntervalProvider $provider): void
|
||||
{
|
||||
$period = static::factory()->nextDate($provider->epoch);
|
||||
$this->assertEquals($provider->expected->toDateString(), $period->toDateString());
|
||||
self::assertSame($provider->expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
abstract public static function factory(): Interval;
|
||||
|
@ -45,7 +45,7 @@ class NavigationAddPeriodTest extends TestCase
|
||||
$this->navigation = new Navigation();
|
||||
}
|
||||
|
||||
public static function provideFrequencies(): array
|
||||
public static function provideFrequencies(): iterable
|
||||
{
|
||||
return [
|
||||
Periodicity::Daily->name => ['periodicity' => Periodicity::Daily, 'from' => Carbon::now(), 'expected' => Carbon::tomorrow()],
|
||||
@ -73,7 +73,7 @@ class NavigationAddPeriodTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public static function provideMonthPeriods(): array
|
||||
public static function provideMonthPeriods(): iterable
|
||||
{
|
||||
return [
|
||||
'1M' => ['frequency' => '1M', 'from' => Carbon::parse('2023-06-25'), 'expected' => Carbon::parse('2023-06-25')->addMonthsNoOverflow(1)],
|
||||
@ -89,7 +89,7 @@ class NavigationAddPeriodTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public static function providePeriods(): array
|
||||
public static function providePeriods(): iterable
|
||||
{
|
||||
return [
|
||||
'1D' => ['frequency' => '1D', 'from' => Carbon::now(), 'expected' => Carbon::tomorrow()],
|
||||
@ -115,7 +115,7 @@ class NavigationAddPeriodTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public static function providePeriodsWithSkippingParam(): Generator
|
||||
public static function providePeriodsWithSkippingParam(): iterable
|
||||
{
|
||||
$intervals = [
|
||||
'2019-01-31 to 2019-02-11' => ['skip' => 10, 'frequency' => 'daily', 'from' => Carbon::parse('2019-01-31'), 'expected' => Carbon::parse('2019-02-11')],
|
||||
@ -166,7 +166,7 @@ class NavigationAddPeriodTest extends TestCase
|
||||
public function testGivenAFrequencyAndSkipIntervalWhenCalculateTheDateThenReturnsTheSkippedDateSuccessful(int $skip, string $frequency, Carbon $from, Carbon $expected)
|
||||
{
|
||||
$period = $this->navigation->addPeriod($from, $frequency, $skip);
|
||||
$this->assertEquals($expected->toDateString(), $period->toDateString());
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,7 +175,7 @@ class NavigationAddPeriodTest extends TestCase
|
||||
public function testGivenAFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected)
|
||||
{
|
||||
$period = $this->navigation->addPeriod($from, $frequency, 0);
|
||||
$this->assertEquals($expected->toDateString(), $period->toDateString());
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,7 +184,7 @@ class NavigationAddPeriodTest extends TestCase
|
||||
public function testGivenAIntervalWhenCallTheNextDateByIntervalMethodThenReturnsTheExpectedDateSuccessful(Periodicity $periodicity, Carbon $from, Carbon $expected)
|
||||
{
|
||||
$period = $this->navigation->nextDateByInterval($from, $periodicity);
|
||||
$this->assertEquals($expected->toDateString(), $period->toDateString());
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,6 +193,6 @@ class NavigationAddPeriodTest extends TestCase
|
||||
public function testGivenAMonthFrequencyWhenCalculateTheDateThenReturnsTheLastDayOfMonthSuccessful(string $frequency, Carbon $from, Carbon $expected)
|
||||
{
|
||||
$period = $this->navigation->addPeriod($from, $frequency, 0);
|
||||
$this->assertEquals($expected->toDateString(), $period->toDateString());
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class NavigationEndOfPeriodTest extends TestCase
|
||||
$this->navigation = new Navigation();
|
||||
}
|
||||
|
||||
public static function provideDates(): array
|
||||
public static function provideDates(): iterable
|
||||
{
|
||||
return [
|
||||
'1D' => ['frequency' => '1D', 'from' => Carbon::now(), 'expected' => Carbon::now()->endOfDay()],
|
||||
@ -79,10 +79,10 @@ class NavigationEndOfPeriodTest extends TestCase
|
||||
public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected)
|
||||
{
|
||||
$period = $this->navigation->endOfPeriod($from, $frequency);
|
||||
$this->assertEquals($expected->toDateString(), $period->toDateString());
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
public static function provideUnknownFrequencies(): array
|
||||
public static function provideUnknownFrequencies(): iterable
|
||||
{
|
||||
return [
|
||||
'1day' => ['frequency' => '1day', 'from' => Carbon::now(), 'expected' => Carbon::now()],
|
||||
@ -99,7 +99,7 @@ class NavigationEndOfPeriodTest extends TestCase
|
||||
Log::spy();
|
||||
|
||||
$period = $this->navigation->endOfPeriod($from, $frequency);
|
||||
$this->assertEquals($expected->toDateString(), $period->toDateString());
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
$expectedMessage = sprintf('Cannot do endOfPeriod for $repeat_freq "%s"', $frequency);
|
||||
|
||||
Log::shouldHaveReceived('error', [$expectedMessage]);
|
||||
|
@ -42,7 +42,7 @@ class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
|
||||
$this->navigation = new Navigation();
|
||||
}
|
||||
|
||||
public static function providePeriods(): array
|
||||
public static function providePeriods(): iterable
|
||||
{
|
||||
return [
|
||||
'unknown' => ['period' => '1day', 'expected' => 'Y-m-d'],
|
||||
@ -60,6 +60,6 @@ class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
|
||||
public function testGivenAPeriodWhenCallPreferredCarbonFormatByPeriodThenReturnsExpectedFormat(string $period, string $expected)
|
||||
{
|
||||
$formatPeriod = $this->navigation->preferredCarbonFormatByPeriod($period);
|
||||
$this->assertEquals($expected, $formatPeriod);
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class NavigationPreferredCarbonFormatTest extends TestCase
|
||||
$this->navigation = new Navigation();
|
||||
}
|
||||
|
||||
public static function providePeriods(): array
|
||||
public static function providePeriods(): iterable
|
||||
{
|
||||
return [
|
||||
'1 week' => ['start' => Carbon::now(), 'end' => Carbon::now()->addWeek(), 'expected' => 'Y-m-d'],
|
||||
@ -67,6 +67,6 @@ class NavigationPreferredCarbonFormatTest extends TestCase
|
||||
public function testGivenStartAndEndDatesWhenCallPreferredCarbonFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected)
|
||||
{
|
||||
$carbonFormat = $this->navigation->preferredCarbonFormat($start, $end);
|
||||
$this->assertEquals($expected, $carbonFormat);
|
||||
self::assertSame($expected, $carbonFormat);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class NavigationPreferredEndOfPeriodTest extends TestCase
|
||||
$this->navigation = new Navigation();
|
||||
}
|
||||
|
||||
public static function providePeriods(): array
|
||||
public static function providePeriods(): iterable
|
||||
{
|
||||
return [
|
||||
'1 week' => ['start' => Carbon::now(), 'end' => Carbon::now()->addWeek(), 'expected' => 'endOfDay'],
|
||||
@ -67,6 +67,6 @@ class NavigationPreferredEndOfPeriodTest extends TestCase
|
||||
public function testGivenStartAndEndDatesWhenCallPreferredEndOfPeriodThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected)
|
||||
{
|
||||
$formatPeriod = $this->navigation->preferredEndOfPeriod($start, $end);
|
||||
$this->assertEquals($expected, $formatPeriod);
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class NavigationPreferredRangeFormatTest extends TestCase
|
||||
$this->navigation = new Navigation();
|
||||
}
|
||||
|
||||
public static function providePeriods(): array
|
||||
public static function providePeriods(): iterable
|
||||
{
|
||||
return [
|
||||
'1 week' => ['start' => Carbon::now(), 'end' => Carbon::now()->addWeek(), 'expected' => '1D'],
|
||||
@ -67,6 +67,6 @@ class NavigationPreferredRangeFormatTest extends TestCase
|
||||
public function testGivenStartAndEndDatesWhenCallPreferredRangeFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected)
|
||||
{
|
||||
$formatPeriod = $this->navigation->preferredRangeFormat($start, $end);
|
||||
$this->assertEquals($expected, $formatPeriod);
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class NavigationPreferredSqlFormatTest extends TestCase
|
||||
$this->navigation = new Navigation();
|
||||
}
|
||||
|
||||
public static function provideDates(): array
|
||||
public static function provideDates(): iterable
|
||||
{
|
||||
return [
|
||||
'1 week' => ['start' => Carbon::now(), 'end' => Carbon::now()->addWeek(), 'expected' => '%Y-%m-%d'],
|
||||
@ -67,6 +67,6 @@ class NavigationPreferredSqlFormatTest extends TestCase
|
||||
public function testGivenStartAndEndDatesWhenCallPreferredSqlFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected)
|
||||
{
|
||||
$formatPeriod = $this->navigation->preferredSqlFormat($start, $end);
|
||||
$this->assertEquals($expected, $formatPeriod);
|
||||
self::assertSame($expected, $formatPeriod);
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class NavigationStartOfPeriodTest extends TestCase
|
||||
$this->navigation = new Navigation();
|
||||
}
|
||||
|
||||
public static function provideDates(): array
|
||||
public static function provideDates(): iterable
|
||||
{
|
||||
return [
|
||||
'custom' => ['frequency' => 'custom', 'from' => Carbon::now(), 'expected' => Carbon::now()],
|
||||
@ -74,7 +74,7 @@ class NavigationStartOfPeriodTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public static function provideUnknownFrequencies(): array
|
||||
public static function provideUnknownFrequencies(): iterable
|
||||
{
|
||||
return [
|
||||
'1day' => ['frequency' => '1day', 'from' => Carbon::now(), 'expected' => Carbon::now()],
|
||||
@ -89,7 +89,7 @@ class NavigationStartOfPeriodTest extends TestCase
|
||||
public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected)
|
||||
{
|
||||
$period = $this->navigation->startOfPeriod($from, $frequency);
|
||||
$this->assertEquals($expected->toDateString(), $period->toDateString());
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -102,6 +102,6 @@ class NavigationStartOfPeriodTest extends TestCase
|
||||
->andReturnNull();
|
||||
|
||||
$period = $this->navigation->startOfPeriod($from, $frequency);
|
||||
$this->assertEquals($expected->toDateString(), $period->toDateString());
|
||||
self::assertSame($expected->toDateString(), $period->toDateString());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user