More code cleanup

This commit is contained in:
James Cole
2023-12-20 19:45:12 +01:00
parent 4961b1f715
commit c9d5d74662
30 changed files with 420 additions and 422 deletions

View File

@@ -25,9 +25,9 @@ $paths = [
$current . '/../../app', $current . '/../../app',
$current . '/../../config', $current . '/../../config',
$current . '/../../database', $current . '/../../database',
// $current . '/../../routes', $current . '/../../routes',
// $current . '/../../tests', $current . '/../../tests',
// $current . '/../../resources/lang', $current . '/../../resources/lang',
]; ];
$finder = PhpCsFixer\Finder::create() $finder = PhpCsFixer\Finder::create()

View File

@@ -22,9 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
/** // V2 API route for Summary boxes
* V2 API route for Summary boxes
*/
// BASIC // BASIC
Route::group( Route::group(
[ [
@@ -36,9 +34,7 @@ Route::group(
Route::get('basic', ['uses' => 'BasicController@basic', 'as' => 'basic']); Route::get('basic', ['uses' => 'BasicController@basic', 'as' => 'basic']);
} }
); );
/** // V2 API route for TransactionList API endpoints
* V2 API route for TransactionList API endpoints
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\Transaction\List', 'namespace' => 'FireflyIII\Api\V2\Controllers\Transaction\List',
@@ -51,9 +47,7 @@ Route::group(
} }
); );
/** // V2 API routes for auto complete
* V2 API routes for auto complete
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\Autocomplete', 'namespace' => 'FireflyIII\Api\V2\Controllers\Autocomplete',
@@ -67,9 +61,7 @@ Route::group(
} }
); );
/** // V2 API route for net worth endpoint(s);
* V2 API route for net worth endpoint(s);
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\Summary', 'namespace' => 'FireflyIII\Api\V2\Controllers\Summary',
@@ -81,9 +73,7 @@ Route::group(
} }
); );
/** // V2 API routes for charts
* V2 API routes for charts
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\Chart', 'namespace' => 'FireflyIII\Api\V2\Controllers\Chart',
@@ -98,9 +88,7 @@ Route::group(
} }
); );
/** // V2 API route for accounts.
* V2 API route for accounts.
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\Model\Account', 'namespace' => 'FireflyIII\Api\V2\Controllers\Model\Account',
@@ -112,9 +100,7 @@ Route::group(
} }
); );
/** // V2 API route for subscriptions.
* V2 API route for subscriptions.
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\Model\Bill', 'namespace' => 'FireflyIII\Api\V2\Controllers\Model\Bill',
@@ -129,9 +115,7 @@ Route::group(
} }
); );
/** // V2 API route for piggy banks.
* V2 API route for piggy banks.
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\Model\PiggyBank', 'namespace' => 'FireflyIII\Api\V2\Controllers\Model\PiggyBank',
@@ -143,9 +127,7 @@ Route::group(
} }
); );
/** // V2 API route for transaction currencies
* V2 API route for transaction currencies
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\Model\Currency', 'namespace' => 'FireflyIII\Api\V2\Controllers\Model\Currency',
@@ -157,9 +139,7 @@ Route::group(
} }
); );
/** // V2 API route for transactions
* V2 API route for transactions
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\Model\Transaction', 'namespace' => 'FireflyIII\Api\V2\Controllers\Model\Transaction',
@@ -171,9 +151,7 @@ Route::group(
} }
); );
/** // V2 API route for budgets and budget limits:
* V2 API route for budgets and budget limits:
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\Model', 'namespace' => 'FireflyIII\Api\V2\Controllers\Model',
@@ -186,14 +164,12 @@ Route::group(
Route::get('{budget}/limits', ['uses' => 'BudgetLimit\IndexController@index', 'as' => 'budget-limits.index']); Route::get('{budget}/limits', ['uses' => 'BudgetLimit\IndexController@index', 'as' => 'budget-limits.index']);
Route::get('sum/budgeted', ['uses' => 'Budget\IndexController@budgeted', 'as' => 'sum.budgeted']); Route::get('sum/budgeted', ['uses' => 'Budget\IndexController@budgeted', 'as' => 'sum.budgeted']);
Route::get('sum/spent', ['uses' => 'Budget\IndexController@spent', 'as' => 'sum.spent']); Route::get('sum/spent', ['uses' => 'Budget\IndexController@spent', 'as' => 'sum.spent']);
//Route::get('{budget}/budgeted', ['uses' => 'Budget\ShowController@budgeted', 'as' => 'budget.budgeted']); // Route::get('{budget}/budgeted', ['uses' => 'Budget\ShowController@budgeted', 'as' => 'budget.budgeted']);
//Route::get('{budget}/spent', ['uses' => 'Budget\ShowController@spent', 'as' => 'budget.spent']); // Route::get('{budget}/spent', ['uses' => 'Budget\ShowController@spent', 'as' => 'budget.spent']);
} }
); );
/** // V2 API route for system
* V2 API route for system
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\System', 'namespace' => 'FireflyIII\Api\V2\Controllers\System',
@@ -205,9 +181,7 @@ Route::group(
} }
); );
/** // V2 API route for user groups (administrations).
* V2 API route for user groups (administrations).
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V2\Controllers\UserGroup', 'namespace' => 'FireflyIII\Api\V2\Controllers\UserGroup',
@@ -226,9 +200,7 @@ Route::group(
// down here is v1 // down here is v1
/** // Autocomplete controllers
* Autocomplete controllers
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V1\Controllers\Autocomplete', 'namespace' => 'FireflyIII\Api\V1\Controllers\Autocomplete',
@@ -256,9 +228,7 @@ Route::group(
} }
); );
/** // CHART ROUTES.
* CHART ROUTES.
*/
// Accounts // Accounts
Route::group( Route::group(
[ [
@@ -271,9 +241,7 @@ Route::group(
} }
); );
/** // DATA ROUTES
* DATA ROUTES
*/
// Export data API routes // Export data API routes
Route::group( Route::group(
[ [
@@ -327,9 +295,7 @@ Route::group(
} }
); );
/** // INSIGHTS ROUTES
* INSIGHTS ROUTES
*/
// Insight in expenses: // Insight in expenses:
Route::group( Route::group(
@@ -401,9 +367,7 @@ Route::group(
// TODO Transfers for piggies // TODO Transfers for piggies
} }
); );
/** // SUMMARY CONTROLLER
* SUMMARY CONTROLLER
*/
// BASIC // BASIC
Route::group( Route::group(
[ [
@@ -416,9 +380,7 @@ Route::group(
} }
); );
/** // MODELS
* MODELS
*/
// Accounts API routes: // Accounts API routes:
Route::group( Route::group(
[ [
@@ -486,10 +448,10 @@ Route::group(
], ],
static function () { static function () {
Route::get('', ['uses' => 'ShowController@index', 'as' => 'index']); Route::get('', ['uses' => 'ShowController@index', 'as' => 'index']);
//Route::post('', ['uses' => 'StoreController@store', 'as' => 'store']); // Route::post('', ['uses' => 'StoreController@store', 'as' => 'store']);
Route::get('{availableBudget}', ['uses' => 'ShowController@show', 'as' => 'show']); Route::get('{availableBudget}', ['uses' => 'ShowController@show', 'as' => 'show']);
//Route::put('{availableBudget}', ['uses' => 'UpdateController@update', 'as' => 'update']); // Route::put('{availableBudget}', ['uses' => 'UpdateController@update', 'as' => 'update']);
//Route::delete('{availableBudget}', ['uses' => 'DestroyController@destroy', 'as' => 'delete']); // Route::delete('{availableBudget}', ['uses' => 'DestroyController@destroy', 'as' => 'delete']);
} }
); );
@@ -763,9 +725,7 @@ Route::group(
} }
); );
/** // SEARCH ENDPOINTS
* SEARCH ENDPOINTS
*/
Route::group( Route::group(
[ [
'namespace' => 'FireflyIII\Api\V1\Controllers\Search', 'namespace' => 'FireflyIII\Api\V1\Controllers\Search',
@@ -778,9 +738,7 @@ Route::group(
} }
); );
/** // SYSTEM END POINTS
* SYSTEM END POINTS
*/
// About Firefly III API routes: // About Firefly III API routes:
Route::group( Route::group(
[ [
@@ -823,9 +781,7 @@ Route::group(
} }
); );
/** // USER
* USER
*/
// Preference API routes: // Preference API routes:
Route::group( Route::group(

View File

@@ -48,10 +48,6 @@ use Illuminate\Support\Arr;
if (!function_exists('limitStringLength')) { if (!function_exists('limitStringLength')) {
/** /**
* Cuts away the middle of a string when it's very long. * Cuts away the middle of a string when it's very long.
*
* @param string $string
*
* @return string
*/ */
function limitStringLength(string $string): string function limitStringLength(string $string): string
{ {
@@ -86,14 +82,14 @@ Breadcrumbs::for(
'accounts.index', 'accounts.index',
static function (Generator $breadcrumbs, string $what) { static function (Generator $breadcrumbs, string $what) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('firefly.' . strtolower(e($what)) . '_accounts'), route('accounts.index', [$what])); $breadcrumbs->push(trans('firefly.'.strtolower(e($what)).'_accounts'), route('accounts.index', [$what]));
} }
); );
Breadcrumbs::for( // inactive Breadcrumbs::for( // inactive
'accounts.inactive.index', 'accounts.inactive.index',
static function (Generator $breadcrumbs, string $what) { static function (Generator $breadcrumbs, string $what) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('firefly.' . strtolower(e($what)) . '_accounts_inactive'), route('accounts.inactive.index', [$what])); $breadcrumbs->push(trans('firefly.'.strtolower(e($what)).'_accounts_inactive'), route('accounts.inactive.index', [$what]));
} }
); );
@@ -101,14 +97,14 @@ Breadcrumbs::for(
'accounts.create', 'accounts.create',
static function (Generator $breadcrumbs, string $what) { static function (Generator $breadcrumbs, string $what) {
$breadcrumbs->parent('accounts.index', $what); $breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push(trans('firefly.new_' . strtolower(e($what)) . '_account'), route('accounts.create', [$what])); $breadcrumbs->push(trans('firefly.new_'.strtolower(e($what)).'_account'), route('accounts.create', [$what]));
} }
); );
Breadcrumbs::for( Breadcrumbs::for(
'accounts.show', 'accounts.show',
static function (Generator $breadcrumbs, Account $account, Carbon $start = null, Carbon $end = null) { static function (Generator $breadcrumbs, Account $account, Carbon $start = null, Carbon $end = null) {
$what = config('firefly.shortNamesByFullName.' . $account->accountType->type); $what = config('firefly.shortNamesByFullName.'.$account->accountType->type);
$breadcrumbs->parent('accounts.index', $what); $breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push(limitStringLength($account->name), route('accounts.show.all', [$account->id])); $breadcrumbs->push(limitStringLength($account->name), route('accounts.show.all', [$account->id]));
@@ -128,7 +124,7 @@ Breadcrumbs::for(
Breadcrumbs::for( Breadcrumbs::for(
'accounts.show.all', 'accounts.show.all',
static function (Generator $breadcrumbs, Account $account) { static function (Generator $breadcrumbs, Account $account) {
$what = config('firefly.shortNamesByFullName.' . $account->accountType->type); $what = config('firefly.shortNamesByFullName.'.$account->accountType->type);
$breadcrumbs->parent('accounts.index', $what); $breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push(limitStringLength($account->name), route('accounts.show', [$account->id])); $breadcrumbs->push(limitStringLength($account->name), route('accounts.show', [$account->id]));
@@ -147,7 +143,7 @@ Breadcrumbs::for(
'accounts.reconcile.show', 'accounts.reconcile.show',
static function (Generator $breadcrumbs, Account $account, TransactionJournal $journal) { static function (Generator $breadcrumbs, Account $account, TransactionJournal $journal) {
$breadcrumbs->parent('accounts.show', $account); $breadcrumbs->parent('accounts.show', $account);
$title = trans('firefly.reconciliation') . ' "' . $journal->description . '"'; $title = trans('firefly.reconciliation').' "'.$journal->description.'"';
$breadcrumbs->push($title, route('accounts.reconcile.show', [$journal->id])); $breadcrumbs->push($title, route('accounts.reconcile.show', [$journal->id]));
} }
); );
@@ -164,10 +160,10 @@ Breadcrumbs::for(
'accounts.edit', 'accounts.edit',
static function (Generator $breadcrumbs, Account $account) { static function (Generator $breadcrumbs, Account $account) {
$breadcrumbs->parent('accounts.show', $account); $breadcrumbs->parent('accounts.show', $account);
$what = config('firefly.shortNamesByFullName.' . $account->accountType->type); $what = config('firefly.shortNamesByFullName.'.$account->accountType->type);
$breadcrumbs->push( $breadcrumbs->push(
trans('firefly.edit_' . $what . '_account', ['name' => limitStringLength($account->name)]), trans('firefly.edit_'.$what.'_account', ['name' => limitStringLength($account->name)]),
route('accounts.edit', [$account->id]) route('accounts.edit', [$account->id])
); );
} }
@@ -1066,7 +1062,7 @@ Breadcrumbs::for(
'transactions.index', 'transactions.index',
static function (Generator $breadcrumbs, string $what, Carbon $start = null, Carbon $end = null) { static function (Generator $breadcrumbs, string $what, Carbon $start = null, Carbon $end = null) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what])); $breadcrumbs->push(trans('breadcrumbs.'.$what.'_list'), route('transactions.index', [$what]));
if (null !== $start && null !== $end) { if (null !== $start && null !== $end) {
// add date range: // add date range:
@@ -1086,7 +1082,7 @@ Breadcrumbs::for(
'transactions.index.all', 'transactions.index.all',
static function (Generator $breadcrumbs, string $what) { static function (Generator $breadcrumbs, string $what) {
$breadcrumbs->parent('home'); $breadcrumbs->parent('home');
$breadcrumbs->push(trans('breadcrumbs.' . $what . '_list'), route('transactions.index', [$what])); $breadcrumbs->push(trans('breadcrumbs.'.$what.'_list'), route('transactions.index', [$what]));
} }
); );

File diff suppressed because it is too large Load Diff

View File

@@ -27,8 +27,12 @@ use Tests\integration\TestCase;
/** /**
* Class AccountControllerTest * Class AccountControllerTest
*
* @internal
*
* @coversNothing
*/ */
class AccountControllerTest extends TestCase final class AccountControllerTest extends TestCase
{ {
/** /**
* @covers \FireflyIII\Api\V1\Controllers\Autocomplete\AccountController * @covers \FireflyIII\Api\V1\Controllers\Autocomplete\AccountController

View File

@@ -27,7 +27,6 @@ use Illuminate\Foundation\Application;
/** /**
* Trait CreatesApplication * Trait CreatesApplication
*
*/ */
trait CreatesApplication trait CreatesApplication
{ {
@@ -38,7 +37,7 @@ trait CreatesApplication
*/ */
public function createApplication() public function createApplication()
{ {
$app = require __DIR__ . '/../../bootstrap/app.php'; $app = require __DIR__.'/../../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap(); $app->make(Kernel::class)->bootstrap();

View File

@@ -29,8 +29,12 @@ use Tests\integration\TestCase;
/** /**
* Class BillDateCalculatorTest * Class BillDateCalculatorTest
*
* @internal
*
* @coversNothing
*/ */
class BillDateCalculatorTest extends TestCase final class BillDateCalculatorTest extends TestCase
{ {
private BillDateCalculator $calculator; private BillDateCalculator $calculator;

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* NavigationCustomEndOfPeriodTest.php * NavigationCustomEndOfPeriodTest.php
* Copyright (c) 2023 james@firefly-iii.org * Copyright (c) 2023 james@firefly-iii.org
@@ -29,7 +28,12 @@ use Carbon\Carbon;
use FireflyIII\Support\Navigation; use FireflyIII\Support\Navigation;
use Tests\integration\TestCase; use Tests\integration\TestCase;
class NavigationCustomEndOfPeriodTest extends TestCase /**
* @internal
*
* @coversNothing
*/
final class NavigationCustomEndOfPeriodTest extends TestCase
{ {
/** /**
* @preserveGlobalState disabled * @preserveGlobalState disabled

View File

@@ -36,9 +36,6 @@ abstract class TestCase extends BaseTestCase
protected const MAX_ITERATIONS = 2; protected const MAX_ITERATIONS = 2;
/**
* @return array
*/
public function dateRangeProvider(): array public function dateRangeProvider(): array
{ {
return [ return [

View File

@@ -30,9 +30,6 @@ use FireflyIII\User;
*/ */
trait CollectsValues trait CollectsValues
{ {
/**
* @return User
*/
public function user(): User public function user(): User
{ {
return User::where('email', 'james@firefly')->first(); return User::where('email', 'james@firefly')->first();

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* CalculatorProvider.php * CalculatorProvider.php
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli> * Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
@@ -27,7 +26,6 @@ namespace Tests\unit\Support\Calendar;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Support\Calendar\Periodicity; use FireflyIII\Support\Calendar\Periodicity;
use Generator;
use Tests\unit\Support\Calendar\Periodicity\IntervalProvider; use Tests\unit\Support\Calendar\Periodicity\IntervalProvider;
readonly class CalculatorProvider readonly class CalculatorProvider
@@ -45,7 +43,7 @@ readonly class CalculatorProvider
$this->label = "{$periodicity->name} {$intervalProvider->label}"; $this->label = "{$periodicity->name} {$intervalProvider->label}";
} }
public static function providePeriodicityWithSkippedIntervals(): Generator public static function providePeriodicityWithSkippedIntervals(): \Generator
{ {
$intervals = [ $intervals = [
self::from(Periodicity::Daily, new IntervalProvider(Carbon::now(), Carbon::now()->addDays(2)), 1), self::from(Periodicity::Daily, new IntervalProvider(Carbon::now(), Carbon::now()->addDays(2)), 1),

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* CalculatorTest.php * CalculatorTest.php
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli> * Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
@@ -44,8 +43,12 @@ use Tests\unit\Support\Calendar\Periodicity\YearlyTest;
* @group support * @group support
* @group calendar * @group calendar
* @group calculator * @group calculator
*
* @internal
*
* @coversNothing
*/ */
class CalculatorTest extends TestCase final class CalculatorTest extends TestCase
{ {
public static function provideAllPeriodicity(): iterable 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 public static function provideSkippedIntervals(): iterable
{ {
return CalculatorProvider::providePeriodicityWithSkippedIntervals(); return CalculatorProvider::providePeriodicityWithSkippedIntervals();
@@ -84,6 +75,7 @@ class CalculatorTest extends TestCase
/** /**
* @dataProvider provideAllPeriodicity * @dataProvider provideAllPeriodicity
*
* @throws IntervalException * @throws IntervalException
*/ */
public function testGivenADailyPeriodicityWhenCallTheNextDateByIntervalMethodThenReturnsTheExpectedDateSuccessful(CalculatorProvider $provider) public function testGivenADailyPeriodicityWhenCallTheNextDateByIntervalMethodThenReturnsTheExpectedDateSuccessful(CalculatorProvider $provider)
@@ -95,6 +87,7 @@ class CalculatorTest extends TestCase
/** /**
* @dataProvider provideSkippedIntervals * @dataProvider provideSkippedIntervals
*
* @throws IntervalException * @throws IntervalException
*/ */
public function testGivenAnEpochWithSkipIntervalNumberWhenCallTheNextDateBySkippedIntervalMethodThenReturnsTheExpectedDateSuccessful(CalculatorProvider $provider) public function testGivenAnEpochWithSkipIntervalNumberWhenCallTheNextDateBySkippedIntervalMethodThenReturnsTheExpectedDateSuccessful(CalculatorProvider $provider)
@@ -103,4 +96,18 @@ class CalculatorTest extends TestCase
$period = $calculator->nextDateByInterval($provider->epoch(), $provider->periodicity, $provider->skip); $period = $calculator->nextDateByInterval($provider->epoch(), $provider->periodicity, $provider->skip);
self::assertSame($provider->expected()->toDateString(), $period->toDateString()); 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;
}
} }

View File

@@ -33,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
* @group support * @group support
* @group calendar * @group calendar
* @group periodicity * @group periodicity
*
* @internal
*
* @coversNothing
*/ */
class BimonthlyTest extends IntervalTestCase final class BimonthlyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval
{ {

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* DailyTest.php * DailyTest.php
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli> * Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
* @group support * @group support
* @group calendar * @group calendar
* @group periodicity * @group periodicity
*
* @internal
*
* @coversNothing
*/ */
class DailyTest extends IntervalTestCase final class DailyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval
{ {

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* FortnightlyTest.php * FortnightlyTest.php
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli> * Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
* @group support * @group support
* @group calendar * @group calendar
* @group periodicity * @group periodicity
*
* @internal
*
* @coversNothing
*/ */
class FortnightlyTest extends IntervalTestCase final class FortnightlyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval
{ {

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* HalfYearlyTest.php * HalfYearlyTest.php
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli> * Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
* @group support * @group support
* @group calendar * @group calendar
* @group periodicity * @group periodicity
*
* @internal
*
* @coversNothing
*/ */
class HalfYearlyTest extends IntervalTestCase final class HalfYearlyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval
{ {

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* IntervalProvider.php * IntervalProvider.php
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli> * Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* IntervalTestCase.php * IntervalTestCase.php
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli> * Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
@@ -33,6 +32,7 @@ abstract class IntervalTestCase extends TestCase
public static function provider(): iterable public static function provider(): iterable
{ {
$intervals = static::provideIntervals(); $intervals = static::provideIntervals();
/** @var IntervalProvider $interval */ /** @var IntervalProvider $interval */
foreach ($intervals as $interval) { foreach ($intervals as $interval) {
yield "{$interval->label}" => [$interval]; yield "{$interval->label}" => [$interval];
@@ -43,10 +43,6 @@ abstract class IntervalTestCase extends TestCase
/** /**
* @dataProvider provider * @dataProvider provider
*
* @param IntervalProvider $provider
*
* @return void
*/ */
public function testGivenAnEpochWhenCallTheNextDateThenReturnsTheExpectedDateSuccessful(IntervalProvider $provider): void public function testGivenAnEpochWhenCallTheNextDateThenReturnsTheExpectedDateSuccessful(IntervalProvider $provider): void
{ {

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* MonthlyTest.php * MonthlyTest.php
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli> * Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
* @group support * @group support
* @group calendar * @group calendar
* @group periodicity * @group periodicity
*
* @internal
*
* @coversNothing
*/ */
class MonthlyTest extends IntervalTestCase final class MonthlyTest extends IntervalTestCase
{ {
public static function factory(): Interval 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('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-03-31'), Carbon::parse('2023-04-30')),
new IntervalProvider(Carbon::parse('2023-05-31'), Carbon::parse('2023-06-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')), new IntervalProvider(Carbon::parse('2023-10-31'), Carbon::parse('2023-11-30')),
]; ];
} }

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* QuarterlyTest.php * QuarterlyTest.php
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli> * Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
* @group support * @group support
* @group calendar * @group calendar
* @group periodicity * @group periodicity
*
* @internal
*
* @coversNothing
*/ */
class QuarterlyTest extends IntervalTestCase final class QuarterlyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval
{ {

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* WeeklyTest.php * WeeklyTest.php
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli> * Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
* @group support * @group support
* @group calendar * @group calendar
* @group periodicity * @group periodicity
*
* @internal
*
* @coversNothing
*/ */
class WeeklyTest extends IntervalTestCase final class WeeklyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval
{ {

View File

@@ -1,6 +1,5 @@
<?php <?php
/* /*
* YearlyTest.php * YearlyTest.php
* Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli> * Copyright (c) 2023 Antonio Spinelli <https://github.com/tonicospinelli>
@@ -34,8 +33,12 @@ use FireflyIII\Support\Calendar\Periodicity\Interval;
* @group support * @group support
* @group calendar * @group calendar
* @group periodicity * @group periodicity
*
* @internal
*
* @coversNothing
*/ */
class YearlyTest extends IntervalTestCase final class YearlyTest extends IntervalTestCase
{ {
public static function factory(): Interval public static function factory(): Interval
{ {

View File

@@ -27,15 +27,18 @@ 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 Generator;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
/** /**
* @group unit-test * @group unit-test
* @group support * @group support
* @group navigation * @group navigation
*
* @internal
*
* @coversNothing
*/ */
class NavigationAddPeriodTest extends TestCase final class NavigationAddPeriodTest extends TestCase
{ {
private Navigation $navigation; private Navigation $navigation;

View File

@@ -32,8 +32,12 @@ use PHPUnit\Framework\TestCase;
* @group unit-test * @group unit-test
* @group support * @group support
* @group navigation * @group navigation
*
* @internal
*
* @coversNothing
*/ */
class NavigationEndOfPeriodTest extends TestCase final class NavigationEndOfPeriodTest extends TestCase
{ {
private Navigation $navigation; private Navigation $navigation;
@@ -43,9 +47,6 @@ class NavigationEndOfPeriodTest extends TestCase
$this->navigation = new Navigation(); $this->navigation = new Navigation();
} }
/**
* @return iterable
*/
public static function provideDates(): iterable public static function provideDates(): iterable
{ {
return [ return [

View File

@@ -31,8 +31,12 @@ use PHPUnit\Framework\TestCase;
* @group unit-test * @group unit-test
* @group support * @group support
* @group navigation * @group navigation
*
* @internal
*
* @coversNothing
*/ */
class NavigationPreferredCarbonFormatByPeriodTest extends TestCase final class NavigationPreferredCarbonFormatByPeriodTest extends TestCase
{ {
private Navigation $navigation; private Navigation $navigation;

View File

@@ -32,8 +32,12 @@ use PHPUnit\Framework\TestCase;
* @group unit-test * @group unit-test
* @group support * @group support
* @group navigation * @group navigation
*
* @internal
*
* @coversNothing
*/ */
class NavigationPreferredCarbonFormatTest extends TestCase final class NavigationPreferredCarbonFormatTest extends TestCase
{ {
private Navigation $navigation; private Navigation $navigation;

View File

@@ -32,8 +32,12 @@ use PHPUnit\Framework\TestCase;
* @group unit-test * @group unit-test
* @group support * @group support
* @group navigation * @group navigation
*
* @internal
*
* @coversNothing
*/ */
class NavigationPreferredEndOfPeriodTest extends TestCase final class NavigationPreferredEndOfPeriodTest extends TestCase
{ {
private Navigation $navigation; private Navigation $navigation;

View File

@@ -32,8 +32,12 @@ use PHPUnit\Framework\TestCase;
* @group unit-test * @group unit-test
* @group support * @group support
* @group navigation * @group navigation
*
* @internal
*
* @coversNothing
*/ */
class NavigationPreferredRangeFormatTest extends TestCase final class NavigationPreferredRangeFormatTest extends TestCase
{ {
private Navigation $navigation; private Navigation $navigation;

View File

@@ -32,8 +32,12 @@ use PHPUnit\Framework\TestCase;
* @group unit-test * @group unit-test
* @group support * @group support
* @group navigation * @group navigation
*
* @internal
*
* @coversNothing
*/ */
class NavigationPreferredSqlFormatTest extends TestCase final class NavigationPreferredSqlFormatTest extends TestCase
{ {
private Navigation $navigation; private Navigation $navigation;

View File

@@ -33,8 +33,12 @@ use PHPUnit\Framework\TestCase;
* @group unit-test * @group unit-test
* @group support * @group support
* @group navigation * @group navigation
*
* @internal
*
* @coversNothing
*/ */
class NavigationStartOfPeriodTest extends TestCase final class NavigationStartOfPeriodTest extends TestCase
{ {
private Navigation $navigation; private Navigation $navigation;
@@ -98,8 +102,9 @@ class NavigationStartOfPeriodTest extends TestCase
public function testGivenADateAndUnknownFrequencyWhenCalculateTheDateThenReturnsTheSameDateSuccessful(string $frequency, Carbon $from, Carbon $expected) public function testGivenADateAndUnknownFrequencyWhenCalculateTheDateThenReturnsTheSameDateSuccessful(string $frequency, Carbon $from, Carbon $expected)
{ {
Log::shouldReceive('error') Log::shouldReceive('error')
->with(sprintf('Cannot do startOfPeriod for $repeat_freq "%s"', $frequency)) ->with(sprintf('Cannot do startOfPeriod for $repeat_freq "%s"', $frequency))
->andReturnNull(); ->andReturnNull()
;
$period = $this->navigation->startOfPeriod($from, $frequency); $period = $this->navigation->startOfPeriod($from, $frequency);
self::assertSame($expected->toDateString(), $period->toDateString()); self::assertSame($expected->toDateString(), $period->toDateString());