Fix phpunit tests

This commit is contained in:
James Cole
2025-05-24 06:07:59 +02:00
parent 3716b50616
commit d26d1b4b87
13 changed files with 77 additions and 52 deletions

View File

@@ -27,6 +27,7 @@ namespace Tests\unit\Support;
use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity;
use FireflyIII\Support\Navigation;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\integration\TestCase;
/**
@@ -40,17 +41,18 @@ use Tests\integration\TestCase;
*/
final class NavigationAddPeriodTest extends TestCase
{
private readonly Navigation $navigation;
private Navigation $navigation;
public function __construct(string $name)
public function setUp(): void
{
parent::__construct($name);
parent::setUp();
$this->navigation = new Navigation();
}
/**
* @dataProvider providePeriodsWithSkippingParam
*
*/
#[DataProvider('providePeriodsWithSkippingParam')]
public function testGivenAFrequencyAndSkipIntervalWhenCalculateTheDateThenReturnsTheSkippedDateSuccessful(int $skip, string $frequency, Carbon $from, Carbon $expected): void
{
$period = $this->navigation->addPeriod($from, $frequency, $skip);
@@ -103,8 +105,9 @@ final class NavigationAddPeriodTest extends TestCase
}
/**
* @dataProvider providePeriods
*
*/
#[DataProvider('providePeriods')]
public function testGivenAFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
{
$period = $this->navigation->addPeriod($from, $frequency, 0);
@@ -138,8 +141,9 @@ final class NavigationAddPeriodTest extends TestCase
}
/**
* @dataProvider provideFrequencies
*
*/
#[DataProvider('provideFrequencies')]
public function testGivenAIntervalWhenCallTheNextDateByIntervalMethodThenReturnsTheExpectedDateSuccessful(Periodicity $periodicity, Carbon $from, Carbon $expected): void
{
$period = $this->navigation->nextDateByInterval($from, $periodicity);
@@ -175,8 +179,9 @@ final class NavigationAddPeriodTest extends TestCase
}
/**
* @dataProvider provideMonthPeriods
*
*/
#[DataProvider('provideMonthPeriods')]
public function testGivenAMonthFrequencyWhenCalculateTheDateThenReturnsTheLastDayOfMonthSuccessful(string $frequency, Carbon $from, Carbon $expected): void
{
$period = $this->navigation->addPeriod($from, $frequency, 0);