mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Fix phpunit tests
This commit is contained in:
@@ -26,6 +26,7 @@ namespace Tests\integration\Support\Models;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Models\BillDateCalculator;
|
use FireflyIII\Support\Models\BillDateCalculator;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,19 +38,21 @@ use Tests\integration\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class BillDateCalculatorTest extends TestCase
|
final class BillDateCalculatorTest extends TestCase
|
||||||
{
|
{
|
||||||
private readonly BillDateCalculator $calculator;
|
private BillDateCalculator $calculator;
|
||||||
|
|
||||||
public function __construct(string $name)
|
|
||||||
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
parent::__construct($name);
|
parent::setUp();
|
||||||
$this->calculator = new BillDateCalculator();
|
$this->calculator = new BillDateCalculator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stupid long method names I'm not going to do that.
|
* Stupid long method names I'm not going to do that.
|
||||||
*
|
*
|
||||||
* @dataProvider provideDates
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('provideDates')]
|
||||||
public function testGivenSomeDataItWorks(Carbon $earliest, Carbon $latest, Carbon $billStart, string $period, int $skip, ?Carbon $lastPaid, array $expected): void
|
public function testGivenSomeDataItWorks(Carbon $earliest, Carbon $latest, Carbon $billStart, string $period, int $skip, ?Carbon $lastPaid, array $expected): void
|
||||||
{
|
{
|
||||||
$result = $this->calculator->getPayDates($earliest, $latest, $billStart, $period, $skip, $lastPaid);
|
$result = $this->calculator->getPayDates($earliest, $latest, $billStart, $period, $skip, $lastPaid);
|
||||||
|
@@ -35,10 +35,6 @@ use Tests\integration\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class NavigationCustomEndOfPeriodTest extends TestCase
|
final class NavigationCustomEndOfPeriodTest extends TestCase
|
||||||
{
|
{
|
||||||
public function __construct(string $name)
|
|
||||||
{
|
|
||||||
parent::__construct($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @preserveGlobalState disabled
|
* @preserveGlobalState disabled
|
||||||
|
@@ -27,6 +27,7 @@ namespace Tests\unit\Support\Calendar;
|
|||||||
use FireflyIII\Exceptions\IntervalException;
|
use FireflyIII\Exceptions\IntervalException;
|
||||||
use FireflyIII\Support\Calendar\Calculator;
|
use FireflyIII\Support\Calendar\Calculator;
|
||||||
use FireflyIII\Support\Calendar\Periodicity;
|
use FireflyIII\Support\Calendar\Periodicity;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
use Tests\unit\Support\Calendar\Periodicity\BimonthlyTest;
|
use Tests\unit\Support\Calendar\Periodicity\BimonthlyTest;
|
||||||
use Tests\unit\Support\Calendar\Periodicity\DailyTest;
|
use Tests\unit\Support\Calendar\Periodicity\DailyTest;
|
||||||
@@ -65,10 +66,11 @@ final class CalculatorTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideAllPeriodicity
|
*
|
||||||
*
|
*
|
||||||
* @throws IntervalException
|
* @throws IntervalException
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('provideAllPeriodicity')]
|
||||||
public function testGivenADailyPeriodicityWhenCallTheNextDateByIntervalMethodThenReturnsTheExpectedDateSuccessful(CalculatorProvider $provider): void
|
public function testGivenADailyPeriodicityWhenCallTheNextDateByIntervalMethodThenReturnsTheExpectedDateSuccessful(CalculatorProvider $provider): void
|
||||||
{
|
{
|
||||||
$calculator = new Calculator();
|
$calculator = new Calculator();
|
||||||
@@ -95,10 +97,11 @@ final class CalculatorTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideSkippedIntervals
|
*
|
||||||
*
|
*
|
||||||
* @throws IntervalException
|
* @throws IntervalException
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('provideSkippedIntervals')]
|
||||||
public function testGivenAnEpochWithSkipIntervalNumberWhenCallTheNextDateBySkippedIntervalMethodThenReturnsTheExpectedDateSuccessful(CalculatorProvider $provider): void
|
public function testGivenAnEpochWithSkipIntervalNumberWhenCallTheNextDateBySkippedIntervalMethodThenReturnsTheExpectedDateSuccessful(CalculatorProvider $provider): void
|
||||||
{
|
{
|
||||||
$calculator = new Calculator();
|
$calculator = new Calculator();
|
||||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\unit\Support\Calendar\Periodicity;
|
namespace Tests\unit\Support\Calendar\Periodicity;
|
||||||
|
|
||||||
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
use FireflyIII\Support\Calendar\Periodicity\Interval;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
|
|
||||||
abstract class IntervalTestCase extends TestCase
|
abstract class IntervalTestCase extends TestCase
|
||||||
@@ -32,8 +33,9 @@ abstract class IntervalTestCase extends TestCase
|
|||||||
abstract public static function provideIntervals(): array;
|
abstract public static function provideIntervals(): array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provider
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('provider')]
|
||||||
public function testGivenAnEpochWhenCallTheNextDateThenReturnsTheExpectedDateSuccessful(IntervalProvider $provider): void
|
public function testGivenAnEpochWhenCallTheNextDateThenReturnsTheExpectedDateSuccessful(IntervalProvider $provider): void
|
||||||
{
|
{
|
||||||
$period = static::factory()->nextDate($provider->epoch);
|
$period = static::factory()->nextDate($provider->epoch);
|
||||||
|
@@ -27,6 +27,7 @@ namespace Tests\unit\Support;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Calendar\Periodicity;
|
use FireflyIII\Support\Calendar\Periodicity;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,17 +41,18 @@ use Tests\integration\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class NavigationAddPeriodTest extends 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();
|
$this->navigation = new Navigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providePeriodsWithSkippingParam
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('providePeriodsWithSkippingParam')]
|
||||||
public function testGivenAFrequencyAndSkipIntervalWhenCalculateTheDateThenReturnsTheSkippedDateSuccessful(int $skip, string $frequency, Carbon $from, Carbon $expected): void
|
public function testGivenAFrequencyAndSkipIntervalWhenCalculateTheDateThenReturnsTheSkippedDateSuccessful(int $skip, string $frequency, Carbon $from, Carbon $expected): void
|
||||||
{
|
{
|
||||||
$period = $this->navigation->addPeriod($from, $frequency, $skip);
|
$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
|
public function testGivenAFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
||||||
{
|
{
|
||||||
$period = $this->navigation->addPeriod($from, $frequency, 0);
|
$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
|
public function testGivenAIntervalWhenCallTheNextDateByIntervalMethodThenReturnsTheExpectedDateSuccessful(Periodicity $periodicity, Carbon $from, Carbon $expected): void
|
||||||
{
|
{
|
||||||
$period = $this->navigation->nextDateByInterval($from, $periodicity);
|
$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
|
public function testGivenAMonthFrequencyWhenCalculateTheDateThenReturnsTheLastDayOfMonthSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
||||||
{
|
{
|
||||||
$period = $this->navigation->addPeriod($from, $frequency, 0);
|
$period = $this->navigation->addPeriod($from, $frequency, 0);
|
||||||
|
@@ -26,6 +26,7 @@ namespace Tests\unit\Support;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,17 +40,18 @@ use Tests\integration\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class NavigationEndOfPeriodTest extends TestCase
|
final class NavigationEndOfPeriodTest 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();
|
$this->navigation = new Navigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideDates
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('provideDates')]
|
||||||
public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
||||||
{
|
{
|
||||||
$period = clone $this->navigation->endOfPeriod($from, $frequency);
|
$period = clone $this->navigation->endOfPeriod($from, $frequency);
|
||||||
@@ -88,8 +90,9 @@ final class NavigationEndOfPeriodTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideUnknownFrequencies
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('provideUnknownFrequencies')]
|
||||||
public function testGivenADateAndUnknownFrequencyWhenCalculateTheDateThenReturnsTheSameDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
public function testGivenADateAndUnknownFrequencyWhenCalculateTheDateThenReturnsTheSameDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
||||||
{
|
{
|
||||||
Log::spy();
|
Log::spy();
|
||||||
|
@@ -25,6 +25,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\unit\Support;
|
namespace Tests\unit\Support;
|
||||||
|
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,17 +39,18 @@ use Tests\integration\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
|
final class NavigationPreferredCarbonFormatByPeriodTest 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();
|
$this->navigation = new Navigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providePeriods
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('providePeriods')]
|
||||||
public function testGivenAPeriodWhenCallPreferredCarbonFormatByPeriodThenReturnsExpectedFormat(string $period, string $expected): void
|
public function testGivenAPeriodWhenCallPreferredCarbonFormatByPeriodThenReturnsExpectedFormat(string $period, string $expected): void
|
||||||
{
|
{
|
||||||
$formatPeriod = $this->navigation->preferredCarbonFormatByPeriod($period);
|
$formatPeriod = $this->navigation->preferredCarbonFormatByPeriod($period);
|
||||||
|
@@ -26,6 +26,7 @@ namespace Tests\unit\Support;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,17 +40,18 @@ use Tests\integration\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class NavigationPreferredCarbonFormatTest extends TestCase
|
final class NavigationPreferredCarbonFormatTest 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();
|
$this->navigation = new Navigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providePeriods
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('providePeriods')]
|
||||||
public function testGivenStartAndEndDatesWhenCallPreferredCarbonFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
public function testGivenStartAndEndDatesWhenCallPreferredCarbonFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
||||||
{
|
{
|
||||||
$carbonFormat = $this->navigation->preferredCarbonFormat($start, $end);
|
$carbonFormat = $this->navigation->preferredCarbonFormat($start, $end);
|
||||||
|
@@ -26,6 +26,7 @@ namespace Tests\unit\Support;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,17 +40,18 @@ use Tests\integration\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class NavigationPreferredEndOfPeriodTest extends TestCase
|
final class NavigationPreferredEndOfPeriodTest 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();
|
$this->navigation = new Navigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providePeriods
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('providePeriods')]
|
||||||
public function testGivenStartAndEndDatesWhenCallPreferredEndOfPeriodThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
public function testGivenStartAndEndDatesWhenCallPreferredEndOfPeriodThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
||||||
{
|
{
|
||||||
$formatPeriod = $this->navigation->preferredEndOfPeriod($start, $end);
|
$formatPeriod = $this->navigation->preferredEndOfPeriod($start, $end);
|
||||||
|
@@ -26,6 +26,7 @@ namespace Tests\unit\Support;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,17 +40,17 @@ use Tests\integration\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class NavigationPreferredRangeFormatTest extends TestCase
|
final class NavigationPreferredRangeFormatTest 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();
|
$this->navigation = new Navigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider providePeriods
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('providePeriods')]
|
||||||
public function testGivenStartAndEndDatesWhenCallPreferredRangeFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
public function testGivenStartAndEndDatesWhenCallPreferredRangeFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
||||||
{
|
{
|
||||||
$formatPeriod = $this->navigation->preferredRangeFormat($start, $end);
|
$formatPeriod = $this->navigation->preferredRangeFormat($start, $end);
|
||||||
|
@@ -26,6 +26,7 @@ namespace Tests\unit\Support;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,17 +40,18 @@ use Tests\integration\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class NavigationPreferredSqlFormatTest extends TestCase
|
final class NavigationPreferredSqlFormatTest extends TestCase
|
||||||
{
|
{
|
||||||
private readonly Navigation $navigation;
|
|
||||||
|
|
||||||
public function __construct(string $name)
|
private Navigation $navigation;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
parent::__construct($name);
|
parent::setUp();
|
||||||
$this->navigation = new Navigation();
|
$this->navigation = new Navigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideDates
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('provideDates')]
|
||||||
public function testGivenStartAndEndDatesWhenCallPreferredSqlFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
public function testGivenStartAndEndDatesWhenCallPreferredSqlFormatThenReturnsTheExpectedFormatSuccessful(Carbon $start, Carbon $end, string $expected): void
|
||||||
{
|
{
|
||||||
$formatPeriod = $this->navigation->preferredSqlFormat($start, $end);
|
$formatPeriod = $this->navigation->preferredSqlFormat($start, $end);
|
||||||
|
@@ -27,6 +27,7 @@ namespace Tests\unit\Support;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Support\Navigation;
|
use FireflyIII\Support\Navigation;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,17 +41,17 @@ use Tests\integration\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class NavigationStartOfPeriodTest extends TestCase
|
final class NavigationStartOfPeriodTest 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();
|
$this->navigation = new Navigation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideDates
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('provideDates')]
|
||||||
public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
||||||
{
|
{
|
||||||
$period = $this->navigation->startOfPeriod($from, $frequency);
|
$period = $this->navigation->startOfPeriod($from, $frequency);
|
||||||
@@ -88,8 +89,9 @@ final class NavigationStartOfPeriodTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideUnknownFrequencies
|
*
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('provideUnknownFrequencies')]
|
||||||
public function testGivenADateAndUnknownFrequencyWhenCalculateTheDateThenReturnsTheSameDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
public function testGivenADateAndUnknownFrequencyWhenCalculateTheDateThenReturnsTheSameDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
|
||||||
{
|
{
|
||||||
Log::spy();
|
Log::spy();
|
||||||
|
@@ -9,6 +9,7 @@ use FireflyIII\Support\Search\QueryParser\QueryParserInterface;
|
|||||||
use FireflyIII\Support\Search\QueryParser\StringNode;
|
use FireflyIII\Support\Search\QueryParser\StringNode;
|
||||||
use FireflyIII\Support\Search\QueryParser\NodeGroup;
|
use FireflyIII\Support\Search\QueryParser\NodeGroup;
|
||||||
use FireflyIII\Support\Search\QueryParser\Node;
|
use FireflyIII\Support\Search\QueryParser\Node;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
use Tests\integration\TestCase;
|
use Tests\integration\TestCase;
|
||||||
|
|
||||||
abstract class AbstractQueryParserInterfaceParseQueryTester extends TestCase
|
abstract class AbstractQueryParserInterfaceParseQueryTester extends TestCase
|
||||||
@@ -16,11 +17,12 @@ abstract class AbstractQueryParserInterfaceParseQueryTester extends TestCase
|
|||||||
abstract protected function createParser(): QueryParserInterface;
|
abstract protected function createParser(): QueryParserInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider queryDataProvider
|
*
|
||||||
*
|
*
|
||||||
* @param string $query The query string to parse
|
* @param string $query The query string to parse
|
||||||
* @param Node $expected The expected parse result
|
* @param Node $expected The expected parse result
|
||||||
*/
|
*/
|
||||||
|
#[DataProvider('queryDataProvider')]
|
||||||
public function testQueryParsing(string $query, Node $expected): void
|
public function testQueryParsing(string $query, Node $expected): void
|
||||||
{
|
{
|
||||||
$actual = $this->createParser()->parse($query);
|
$actual = $this->createParser()->parse($query);
|
||||||
|
Reference in New Issue
Block a user