Skip to content

Firefly III: a personal finances manager

Code cleanup and realign.

James Cole5908c0ce8c9b
diff --git a/app/Api/V1/Controllers/BudgetLimitController.php b/app/Api/V1/Controllers/BudgetLimitController.php
index 16cf1d095a..99127989cb 100644
--- a/app/Api/V1/Controllers/BudgetLimitController.php
+++ b/app/Api/V1/Controllers/BudgetLimitController.php
@@ -34,7 +34,6 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
-
use League\Fractal\Manager;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
diff --git a/app/Api/V1/Controllers/ConfigurationController.php b/app/Api/V1/Controllers/ConfigurationController.php
index aee513f7cb..c21b430b0c 100644
--- a/app/Api/V1/Controllers/ConfigurationController.php
+++ b/app/Api/V1/Controllers/ConfigurationController.php
@@ -54,6 +54,7 @@ class ConfigurationController extends Controller
$admin = auth()->user();
if (!$this->repository->hasRole($admin, 'owner')) {
+ /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
throw new FireflyException('No access to method.'); // @codeCoverageIgnore
}
diff --git a/app/Console/Commands/Import.php b/app/Console/Commands/Import.php
index 0f952e6af3..b7572cf061 100644
--- a/app/Console/Commands/Import.php
+++ b/app/Console/Commands/Import.php
@@ -64,7 +64,7 @@ class Import extends Command
Log::debug('Start start-import command');
$jobKey = (string)$this->argument('key');
/** @var ImportJob $job */
- $job = ImportJob::where('key', $jobKey)->first();
+ $job = ImportJob::where('key', $jobKey)->first();
if (null === $job) {
$this->errorLine(sprintf('No job found with key "%s"', $jobKey));
diff --git a/app/Console/Commands/ScanAttachments.php b/app/Console/Commands/ScanAttachments.php
index 0a77363a0a..cd76aa9377 100644
--- a/app/Console/Commands/ScanAttachments.php
+++ b/app/Console/Commands/ScanAttachments.php
@@ -82,6 +82,7 @@ class ScanAttachments extends Command
$attachment->save();
$this->line(sprintf('Fixed attachment #%d', $attachment->id));
}
+
return 0;
}
}
diff --git a/app/Console/Commands/UpgradeFireflyInstructions.php b/app/Console/Commands/UpgradeFireflyInstructions.php
index d2e4730204..9aa8f33a1e 100644
--- a/app/Console/Commands/UpgradeFireflyInstructions.php
+++ b/app/Console/Commands/UpgradeFireflyInstructions.php
@@ -54,6 +54,7 @@ class UpgradeFireflyInstructions extends Command
if ('install' === (string)$this->argument('task')) {
$this->installInstructions();
}
+
return 0;
}
diff --git a/app/Console/Commands/UseEncryption.php b/app/Console/Commands/UseEncryption.php
index bfc04db91c..7a67d71cf6 100644
--- a/app/Console/Commands/UseEncryption.php
+++ b/app/Console/Commands/UseEncryption.php
@@ -62,6 +62,7 @@ class UseEncryption extends Command
$this->handleObjects('Category', 'name', 'encrypted');
$this->handleObjects('PiggyBank', 'name', 'encrypted');
$this->handleObjects('TransactionJournal', 'description', 'encrypted');
+
return 0;
}
diff --git a/app/Events/RequestedNewPassword.php b/app/Events/RequestedNewPassword.php
index 4452a8dfeb..ffd13ee344 100644
--- a/app/Events/RequestedNewPassword.php
+++ b/app/Events/RequestedNewPassword.php
@@ -36,10 +36,10 @@ class RequestedNewPassword extends Event
/** @var string The users IP address */
public $ipAddress;
- /** @var User The user */
- public $user;
/** @var string The token */
public $token;
+ /** @var User The user */
+ public $user;
/**
* Create a new event instance. This event is triggered when a users tries to reset his or her password.
diff --git a/app/Export/Collector/AttachmentCollector.php b/app/Export/Collector/AttachmentCollector.php
index 9eecde245b..49e8b1e20a 100644
--- a/app/Export/Collector/AttachmentCollector.php
+++ b/app/Export/Collector/AttachmentCollector.php
@@ -28,7 +28,6 @@ use Crypt;
use FireflyIII\Models\Attachment;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
use Illuminate\Contracts\Encryption\DecryptException;
-use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Collection;
use Log;
use Storage;
@@ -108,7 +107,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface
if ($this->uploadDisk->exists($file)) {
try {
$decrypted = Crypt::decrypt($this->uploadDisk->get($file));
- } catch (FileNotFoundException|DecryptException $e) {
+ } catch (DecryptException $e) {
Log::error('Catchable error: could not decrypt attachment #' . $attachment->id . ' because: ' . $e->getMessage());
return false;
diff --git a/app/Export/ExpandedProcessor.php b/app/Export/ExpandedProcessor.php
index 27fdc83822..2c15573719 100644
--- a/app/Export/ExpandedProcessor.php
+++ b/app/Export/ExpandedProcessor.php
@@ -54,7 +54,7 @@ class ExpandedProcessor implements ProcessorInterface
{
/** @var Collection All accounts */
public $accounts;
- /** @var string The export format*/
+ /** @var string The export format */
public $exportFormat;
/** @var bool Should include attachments */
public $includeAttachments;
@@ -62,7 +62,7 @@ class ExpandedProcessor implements ProcessorInterface
public $includeOldUploads;
/** @var ExportJob The export job itself */
public $job;
- /** @var array The settings*/
+ /** @var array The settings */
public $settings;
/** @var Collection The entries to export. */
private $exportEntries;
@@ -222,7 +222,7 @@ class ExpandedProcessor implements ProcessorInterface
{
$exporterClass = config('firefly.export_formats.' . $this->exportFormat);
/** @var ExporterInterface $exporter */
- $exporter = app($exporterClass);
+ $exporter = app($exporterClass);
$exporter->setJob($this->job);
$exporter->setEntries($this->exportEntries);
$exporter->run();
@@ -260,7 +260,7 @@ class ExpandedProcessor implements ProcessorInterface
/**
* Delete files.
*/
- private function deleteFiles():void
+ private function deleteFiles(): void
{
$disk = Storage::disk('export');
foreach ($this->getFiles() as $file) {
diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php
index 9096d8099d..1dbd565934 100644
--- a/app/Factory/TransactionJournalFactory.php
+++ b/app/Factory/TransactionJournalFactory.php
@@ -104,7 +104,7 @@ class TransactionJournalFactory
// store date meta fields (if present):
$fields = ['sepa-cc', 'sepa-ct-op', 'sepa-ct-id', 'sepa-db', 'sepa-country', 'sepa-ep', 'sepa-ci', 'interest_date', 'book_date', 'process_date',
'due_date', 'recurrence_id', 'payment_date', 'invoice_date', 'internal_reference', 'bunq_payment_id', 'importHash', 'importHashV2',
- 'external_id','sepa-batch-id'];
+ 'external_id', 'sepa-batch-id'];
foreach ($fields as $field) {
$this->storeMeta($journal, $data, $field);
diff --git a/app/Generator/Report/Budget/MonthReportGenerator.php b/app/Generator/Report/Budget/MonthReportGenerator.php
index 39aaf1696e..f613fd8f84 100644
--- a/app/Generator/Report/Budget/MonthReportGenerator.php
+++ b/app/Generator/Report/Budget/MonthReportGenerator.php
@@ -78,15 +78,16 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
// render!
try {
- $result= view('reports.budget.month', compact('accountIds', 'budgetIds', 'accountSummary', 'budgetSummary', 'averageExpenses', 'topExpenses'))
- ->with('start', $this->start)->with('end', $this->end)
- ->with('budgets', $this->budgets)
- ->with('accounts', $this->accounts)
- ->render();
+ $result = view('reports.budget.month', compact('accountIds', 'budgetIds', 'accountSummary', 'budgetSummary', 'averageExpenses', 'topExpenses'))
+ ->with('start', $this->start)->with('end', $this->end)
+ ->with('budgets', $this->budgets)
+ ->with('accounts', $this->accounts)
+ ->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.account.report: %s', $e->getMessage()));
$result = 'Could not render report view.';
}
+
return $result;
}
diff --git a/app/Generator/Report/Tag/MonthReportGenerator.php b/app/Generator/Report/Tag/MonthReportGenerator.php
index 84532e19f1..1b1294583c 100644
--- a/app/Generator/Report/Tag/MonthReportGenerator.php
+++ b/app/Generator/Report/Tag/MonthReportGenerator.php
@@ -90,8 +90,9 @@ class MonthReportGenerator extends Support implements ReportGeneratorInterface
try {
$result = view(
'reports.tag.month', compact(
- 'accountIds', 'tagTags', 'reportType', 'accountSummary', 'tagSummary', 'averageExpenses', 'averageIncome', 'topIncome', 'topExpenses'
- )
+ 'accountIds', 'tagTags', 'reportType', 'accountSummary', 'tagSummary', 'averageExpenses', 'averageIncome', 'topIncome',
+ 'topExpenses'
+ )
)->with('start', $this->start)->with('end', $this->end)->with('tags', $this->tags)->with('accounts', $this->accounts)->render();
} catch (Throwable $e) {
Log::error(sprintf('Cannot render reports.tag.month: %s', $e->getMessage()));
diff --git a/app/Handlers/Events/VersionCheckEventHandler.php b/app/Handlers/Events/VersionCheckEventHandler.php
index 46b371772e..6213a10f8c 100644
--- a/app/Handlers/Events/VersionCheckEventHandler.php
+++ b/app/Handlers/Events/VersionCheckEventHandler.php
@@ -27,14 +27,12 @@ namespace FireflyIII\Handlers\Events;
use FireflyConfig;
use FireflyIII\Events\RequestedVersionCheckStatus;
-
use FireflyIII\Helpers\Update\UpdateTrait;
use FireflyIII\Repositories\User\UserRepositoryInterface;
-
-
use FireflyIII\User;
use Log;
+
/**
* Class VersionCheckEventHandler
*/
@@ -81,7 +79,7 @@ class VersionCheckEventHandler
$latestRelease = $this->getLatestRelease();
$versionCheck = $this->versionCheck($latestRelease);
- $resultString = $this->parseResult($versionCheck, $latestRelease);
+ $resultString = $this->parseResult($versionCheck, $latestRelease);
if (0 !== $versionCheck && '' !== $resultString) {
// flash info
session()->flash('info', $resultString);
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index d840a2a812..8714dfec07 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -25,7 +25,6 @@ namespace FireflyIII\Helpers\Attachments;
use Crypt;
use FireflyIII\Models\Attachment;
use Illuminate\Contracts\Encryption\DecryptException;
-use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
@@ -80,7 +79,7 @@ class AttachmentHelper implements AttachmentHelperInterface
try {
$content = Crypt::decrypt($this->uploadDisk->get(sprintf('at-%d.data', $attachment->id)));
- } catch (DecryptException|FileNotFoundException $e) {
+ } catch (DecryptException $e) {
Log::error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
$content = '';
}
diff --git a/app/Helpers/Report/BalanceReportHelper.php b/app/Helpers/Report/BalanceReportHelper.php
index 1daec53c1c..c2d807f530 100644
--- a/app/Helpers/Report/BalanceReportHelper.php
+++ b/app/Helpers/Report/BalanceReportHelper.php
@@ -160,6 +160,7 @@ class BalanceReportHelper implements BalanceReportHelperInterface
{
$set = $balance->getBalanceLines();
$newSet = new Collection;
+ /** @var BalanceLine $entry */
foreach ($set as $entry) {
if (null !== $entry->getBudget()->id) {
$sum = '0';
diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.php
index f78ac9e166..38feabb864 100644
--- a/app/Http/Controllers/Account/CreateController.php
+++ b/app/Http/Controllers/Account/CreateController.php
@@ -107,7 +107,7 @@ class CreateController extends Controller
}
$request->session()->forget('accounts.create.fromStore');
- return view('accounts.create', compact('subTitleIcon', 'what','interestPeriods', 'subTitle', 'roles', 'liabilityTypes'));
+ return view('accounts.create', compact('subTitleIcon', 'what', 'interestPeriods', 'subTitle', 'roles', 'liabilityTypes'));
}
diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.php
index 99c3ab623c..6e2e04fd09 100644
--- a/app/Http/Controllers/Account/ReconcileController.php
+++ b/app/Http/Controllers/Account/ReconcileController.php
@@ -147,7 +147,7 @@ class ReconcileController extends Controller
/** @var Carbon $start */
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon, $range));
/** @var Carbon $end */
- $end = clone session('end', app('navigation')->endOfPeriod(new Carbon, $range));
+ $end = clone session('end', app('navigation')->endOfPeriod(new Carbon, $range));
}
if (null === $end) {
/** @var Carbon $end */
diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php
index a5273323c4..e5a08761c9 100644
--- a/app/Http/Controllers/Account/ShowController.php
+++ b/app/Http/Controllers/Account/ShowController.php
@@ -93,7 +93,7 @@ class ShowController extends Controller
/** @var Carbon $start */
$start = $start ?? session('start');
/** @var Carbon $end */
- $end = $end ?? session('end');
+ $end = $end ?? session('end');
if ($end < $start) {
throw new FireflyException('End is after start!'); // @codeCoverageIgnore
}
diff --git a/app/Http/Controllers/Admin/LinkController.php b/app/Http/Controllers/Admin/LinkController.php
index fd877c1e5d..b16db6a4de 100644
--- a/app/Http/Controllers/Admin/LinkController.php
+++ b/app/Http/Controllers/Admin/LinkController.php
@@ -55,6 +55,7 @@ class LinkController extends Controller
/**
* Make a new link form.
+ *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function create()
diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php
index efc6dfb0b5..767d9cea49 100644
--- a/app/Http/Controllers/BillController.php
+++ b/app/Http/Controllers/BillController.php
@@ -28,7 +28,6 @@ use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Requests\BillFormRequest;
use FireflyIII\Models\Bill;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
-use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\TransactionRules\TransactionMatcher;
use FireflyIII\Transformers\BillTransformer;
use Illuminate\Http\RedirectResponse;
@@ -51,8 +50,6 @@ class BillController extends Controller
private $attachments;
/** @var BillRepositoryInterface Bill repository */
private $billRepository;
- /** @var RuleGroupRepositoryInterface Rule group repository */
- private $ruleGroupRepos;
/**
* BillController constructor.
@@ -72,7 +69,6 @@ class BillController extends Controller
app('view')->share('mainTitleIcon', 'fa-calendar-o');
$this->attachments = app(AttachmentHelperInterface::class);
$this->billRepository = app(BillRepositoryInterface::class);
- $this->ruleGroupRepos = app(RuleGroupRepositoryInterface::class);
return $next($request);
}
diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php
index f23cd4f159..726a730356 100644
--- a/app/Http/Controllers/Budget/IndexController.php
+++ b/app/Http/Controllers/Budget/IndexController.php
@@ -78,9 +78,9 @@ class IndexController extends Controller
public function index(Request $request, string $moment = null)
{
/** @var string $range */
- $range = app('preferences')->get('viewRange', '1M')->data;
+ $range = app('preferences')->get('viewRange', '1M')->data;
/** @var Carbon $start */
- $start = session('start', new Carbon);
+ $start = session('start', new Carbon);
/** @var Carbon $end */
$end = session('end', new Carbon);
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
@@ -92,7 +92,7 @@ class IndexController extends Controller
try {
$start = new Carbon($moment);
/** @var Carbon $end */
- $end = app('navigation')->endOfPeriod($start, $range);
+ $end = app('navigation')->endOfPeriod($start, $range);
} catch (Exception $e) {
// start and end are already defined.
Log::debug(sprintf('start and end are already defined: %s', $e->getMessage()));
diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.php
index 3e81b43390..d9ff4999f5 100644
--- a/app/Http/Controllers/Budget/ShowController.php
+++ b/app/Http/Controllers/Budget/ShowController.php
@@ -127,7 +127,7 @@ class ShowController extends Controller
$transactions = $collector->getPaginatedJournals();
$transactions->setPath(route('budgets.no-budget'));
- return view('budgets.no-budget', compact('transactions', 'subTitle', 'moment', 'start', 'end'));
+ return view('budgets.no-budget', compact('transactions', 'subTitle', 'moment', 'start', 'end'));
}
diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.php
index 59b03f4a1f..720befb907 100644
--- a/app/Http/Controllers/Category/NoCategoryController.php
+++ b/app/Http/Controllers/Category/NoCategoryController.php
@@ -29,7 +29,6 @@ use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Helpers\Filter\InternalTransferFilter;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\TransactionType;
-
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Http\Request;
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index 124cc00da6..d05ca1dc5e 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -129,6 +129,7 @@ class AccountController extends Controller
if ($cache->has()) {
return response()->json($cache->get()); // @codeCoverageIgnore
}
+ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withBudgetInformation()->setTypes([TransactionType::WITHDRAWAL]);
$transactions = $collector->getJournals();
@@ -192,6 +193,7 @@ class AccountController extends Controller
return response()->json($cache->get()); // @codeCoverageIgnore
}
+ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::WITHDRAWAL]);
$transactions = $collector->getJournals();
@@ -283,6 +285,7 @@ class AccountController extends Controller
}
// grab all journals:
+ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionType::DEPOSIT]);
$transactions = $collector->getJournals();
diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php
index ab4fb05f79..55ea1819ff 100644
--- a/app/Http/Controllers/Chart/BillController.php
+++ b/app/Http/Controllers/Chart/BillController.php
@@ -102,7 +102,8 @@ class BillController extends Controller
}
$results = $collector->setAllAssetAccounts()->setBills(new Collection([$bill]))->getJournals();
- $results = $results->sortBy(
+ /** @var Collection $results */
+ $results = $results->sortBy(
function (Transaction $transaction) {
return $transaction->date->format('U');
}
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index 801be0814c..644b761bd6 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -325,12 +325,12 @@ class BudgetController extends Controller
/**
* Shows a budget list with spent/left/overspent.
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return JsonResponse
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function frontpage(): \Symfony\Component\HttpFoundation\Response
+ public function frontpage(): JsonResponse
{
$start = session('start', Carbon::now()->startOfMonth());
$end = session('end', Carbon::now()->endOfMonth());
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index a90a31dc8f..e3b70c6cc8 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -168,6 +168,7 @@ class Controller extends BaseController
/**
* Get user's language.
+ *
* @return string
*/
private function getLanguage(): string
diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php
index 102a10dbb3..379702255c 100644
--- a/app/Http/Controllers/ExportController.php
+++ b/app/Http/Controllers/ExportController.php
@@ -78,7 +78,7 @@ class ExportController extends Controller
}
$content = $repository->getContent($job);
- $job->change('export_downloaded');
+ $repository->changeStatus($job, 'export_downloaded');
/** @var LaravelResponse $response */
$response = response($content, 200);
$response
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index cf2b749385..c087184932 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -108,7 +108,9 @@ class HomeController extends Controller
}
$subTitle = (string)trans('firefly.welcomeBack');
$transactions = [];
- $frontPage = app('preferences')->get('frontPageAccounts', $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray());
+ $frontPage = app('preferences')->get(
+ 'frontPageAccounts', $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray()
+ );
/** @var Carbon $start */
$start = session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php
index d9432135bf..a3b962cfc5 100644
--- a/app/Http/Controllers/JavascriptController.php
+++ b/app/Http/Controllers/JavascriptController.php
@@ -150,15 +150,15 @@ class JavascriptController extends Controller
{
$viewRange = app('preferences')->get('viewRange', '1M')->data;
/** @var Carbon $start */
- $start = session('start');
+ $start = session('start');
/** @var Carbon $end */
- $end = session('end');
+ $end = session('end');
/** @var Carbon $first */
- $first = session('first');
- $title = sprintf('%s - %s', $start->formatLocalized($this->monthAndDayFormat), $end->formatLocalized($this->monthAndDayFormat));
- $isCustom = true === session('is_custom_range', false);
- $today = new Carbon;
- $ranges = [
+ $first = session('first');
+ $title = sprintf('%s - %s', $start->formatLocalized($this->monthAndDayFormat), $end->formatLocalized($this->monthAndDayFormat));
+ $isCustom = true === session('is_custom_range', false);
+ $today = new Carbon;
+ $ranges = [
// first range is the current range:
$title => [$start, $end],
];
diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php
index f059036100..94903a7010 100644
--- a/app/Http/Controllers/Json/BoxController.php
+++ b/app/Http/Controllers/Json/BoxController.php
@@ -202,7 +202,7 @@ class BoxController extends Controller
/** @var Carbon $start */
$start = session('start', Carbon::now()->startOfMonth());
/** @var Carbon $end */
- $end = session('end', Carbon::now()->endOfMonth());
+ $end = session('end', Carbon::now()->endOfMonth());
$cache = new CacheProperties;
$cache->addProperty($start);
diff --git a/app/Http/Controllers/Popup/ReportController.php b/app/Http/Controllers/Popup/ReportController.php
index 8e7d3e3cb6..d6c5fef0c0 100644
--- a/app/Http/Controllers/Popup/ReportController.php
+++ b/app/Http/Controllers/Popup/ReportController.php
@@ -80,6 +80,7 @@ class ReportController extends Controller
/**
* Generate popup view.
+ *
* @param Request $request
*
* @return JsonResponse
@@ -274,7 +275,7 @@ class ReportController extends Controller
$attributes['startDate'] = Carbon::createFromFormat('Ymd', $attributes['startDate']);
} catch (InvalidArgumentException $e) {
Log::debug(sprintf('Not important error message: %s', $e->getMessage()));
- $date = Carbon::now()->startOfMonth();
+ $date = Carbon::now()->startOfMonth();
$attributes['startDate'] = $date;
}
@@ -282,7 +283,7 @@ class ReportController extends Controller
$attributes['endDate'] = Carbon::createFromFormat('Ymd', $attributes['endDate']);
} catch (InvalidArgumentException $e) {
Log::debug(sprintf('Not important error message: %s', $e->getMessage()));
- $date = Carbon::now()->startOfMonth();
+ $date = Carbon::now()->startOfMonth();
$attributes['endDate'] = $date;
}
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index 944a221915..2edae12e66 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -340,6 +340,7 @@ class ProfileController extends Controller
session()->flash('success', (string)trans('firefly.saved_preferences'));
app('preferences')->mark();
+
return redirect(route('profile.index'));
}
@@ -371,6 +372,7 @@ class ProfileController extends Controller
/**
* Regenerate access token.
+ *
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function regenerate()
diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.php
index 38bde82fe2..88e5abd5a4 100644
--- a/app/Http/Controllers/Recurring/CreateController.php
+++ b/app/Http/Controllers/Recurring/CreateController.php
@@ -86,7 +86,7 @@ class CreateController extends Controller
$this->rememberPreviousUri('recurring.create.uri');
}
$request->session()->forget('recurring.create.fromStore');
- $repetitionEnds = [
+ $repetitionEnds = [
'forever' => (string)trans('firefly.repeat_forever'),
'until_date' => (string)trans('firefly.repeat_until_date'),
'times' => (string)trans('firefly.repeat_times'),
diff --git a/app/Http/Controllers/Recurring/EditController.php b/app/Http/Controllers/Recurring/EditController.php
index 400bd07a5b..ebae84cf4d 100644
--- a/app/Http/Controllers/Recurring/EditController.php
+++ b/app/Http/Controllers/Recurring/EditController.php
@@ -86,7 +86,7 @@ class EditController extends Controller
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());
/** @var RecurrenceRepetition $repetition */
- $repetition = $recurrence->recurrenceRepetitions()->first();
+ $repetition = $recurrence->recurrenceRepetitions()->first();
$currentRepType = $repetition->repetition_type;
if ('' !== $repetition->repetition_moment) {
$currentRepType .= ',' . $repetition->repetition_moment;
diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.php
index e475de3551..4bb1aeb807 100644
--- a/app/Http/Controllers/Rule/CreateController.php
+++ b/app/Http/Controllers/Rule/CreateController.php
@@ -28,7 +28,6 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\RuleFormRequest;
use FireflyIII\Models\Bill;
use FireflyIII\Models\RuleGroup;
-use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Support\Http\Controllers\RuleManagement;
use Illuminate\Http\RedirectResponse;
@@ -42,8 +41,6 @@ use Throwable;
class CreateController extends Controller
{
use RuleManagement;
- /** @var BillRepositoryInterface Bill repository */
- private $billRepos;
/** @var RuleRepositoryInterface Rule repository */
private $ruleRepos;
@@ -59,7 +56,6 @@ class CreateController extends Controller
app('view')->share('title', (string)trans('firefly.rules'));
app('view')->share('mainTitleIcon', 'fa-random');
- $this->billRepos = app(BillRepositoryInterface::class);
$this->ruleRepos = app(RuleRepositoryInterface::class);
return $next($request);
diff --git a/app/Http/Controllers/Rule/IndexController.php b/app/Http/Controllers/Rule/IndexController.php
index 5de05fc9a8..13a6d21978 100644
--- a/app/Http/Controllers/Rule/IndexController.php
+++ b/app/Http/Controllers/Rule/IndexController.php
@@ -130,7 +130,7 @@ class IndexController extends Controller
/**
* Move rule ip.
- *
+ *
* @param Rule $rule
*
* @return RedirectResponse|\Illuminate\Routing\Redirector
diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.php
index 23056a5642..d19adf6500 100644
--- a/app/Http/Controllers/System/InstallController.php
+++ b/app/Http/Controllers/System/InstallController.php
@@ -34,6 +34,7 @@ use phpseclib\Crypt\RSA;
/**
* Class InstallController
+ *
* @codeCoverageIgnore
*/
class InstallController extends Controller
diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.php
index ed11993a1e..ab938ff166 100644
--- a/app/Http/Controllers/Transaction/LinkController.php
+++ b/app/Http/Controllers/Transaction/LinkController.php
@@ -136,6 +136,7 @@ class LinkController extends Controller
/**
* Switch link from A <> B to B <> A.
+ *
* @param TransactionJournalLink $link
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index a989dda208..6bc490a5de 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -260,9 +260,9 @@ class TransactionController extends Controller
*/
private function getPeriodOverview(string $what, Carbon $date): Collection
{
- $range = app('preferences')->get('viewRange', '1M')->data;
- $first = $this->repository->firstNull();
- $start = Carbon::now()->subYear();
+ $range = app('preferences')->get('viewRange', '1M')->data;
+ $first = $this->repository->firstNull();
+ $start = Carbon::now()->subYear();
$types = config('firefly.transactionTypesByWhat.' . $what);
$entries = new Collection;
if (null !== $first) {
@@ -289,9 +289,9 @@ class TransactionController extends Controller
/** @noinspection PhpUndefinedMethodInspection */
$entries->push(
[
- 'name' => $dateName,
- 'sums' => $sums,
- 'sum' => $sum,
+ 'name' => $dateName,
+ 'sums' => $sums,
+ 'sum' => $sum,
'start' => $currentDate['start']->format('Y-m-d'),
'end' => $currentDate['end']->format('Y-m-d'),
]
diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php
index 3377dd6720..59900edc22 100644
--- a/app/Http/Middleware/TrustProxies.php
+++ b/app/Http/Middleware/TrustProxies.php
@@ -45,7 +45,7 @@ class TrustProxies extends Middleware
{
$trustedProxies = (string)env('TRUSTED_PROXIES', null);
$this->proxies = explode(',', $trustedProxies);
- if ($trustedProxies === '**') {
+ if ('**' === $trustedProxies) {
$this->proxies = '**';
}
parent::__construct($config);
diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php
index d347aa7a9e..5aa3b47519 100644
--- a/app/Http/Requests/AccountFormRequest.php
+++ b/app/Http/Requests/AccountFormRequest.php
@@ -70,7 +70,7 @@ class AccountFormRequest extends Request
// if the account type is "liabilities" there are actually four types of liability
// that could have been selected.
- if ($data['accountType'] === 'liabilities') {
+ if ('liabilities' === $data['accountType']) {
$data['accountType'] = null;
$data['account_type_id'] = $this->integer('liability_type_id');
// also reverse the opening balance:
diff --git a/app/Http/Requests/JournalFormRequest.php b/app/Http/Requests/JournalFormRequest.php
index e63b041a1f..ee45cfe6ce 100644
--- a/app/Http/Requests/JournalFormRequest.php
+++ b/app/Http/Requests/JournalFormRequest.php
@@ -270,7 +270,7 @@ class JournalFormRequest extends Request
*/
private function validateDeposit(Validator $validator): void
{
- $data = $validator->getData();
+ $data = $validator->getData();
$selectedCurrency = (int)($data['amount_currency_id_amount'] ?? 0);
$accountCurrency = (int)($data['destination_account_currency'] ?? 0);
$nativeAmount = (string)($data['native_amount'] ?? '');
@@ -290,7 +290,7 @@ class JournalFormRequest extends Request
*/
private function validateTransfer(Validator $validator): void
{
- $data = $validator->getData();
+ $data = $validator->getData();
$sourceCurrency = (int)($data['source_account_currency'] ?? 0);
$destinationCurrency = (int)($data['destination_account_currency'] ?? 0);
$sourceAmount = (string)($data['source_amount'] ?? '');
diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.php
index 7f2fba4f03..a20ffccbe1 100644
--- a/app/Http/Requests/RecurrenceFormRequest.php
+++ b/app/Http/Requests/RecurrenceFormRequest.php
@@ -150,7 +150,7 @@ class RecurrenceFormRequest extends Request
{
$today = new Carbon;
$tomorrow = Carbon::now()->addDay();
- $rules = [
+ $rules = [
// mandatory info for recurrence.
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
'first_date' => 'required|date|after:' . $today->format('Y-m-d'),
diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php
index f03a05093d..9a1873fbdd 100644
--- a/app/Http/Requests/Request.php
+++ b/app/Http/Requests/Request.php
@@ -61,9 +61,10 @@ class Request extends FormRequest
public function float(string $field): ?float
{
$res = $this->get($field);
- if(null === $res) {
+ if (null === $res) {
return null;
}
+
return (float)$res;
}
diff --git a/app/Http/Requests/RuleFormRequest.php b/app/Http/Requests/RuleFormRequest.php
index de1e104185..b9bc3dcbdb 100644
--- a/app/Http/Requests/RuleFormRequest.php
+++ b/app/Http/Requests/RuleFormRequest.php
@@ -61,6 +61,7 @@ class RuleFormRequest extends Request
'rule_triggers' => $this->getRuleTriggerData(),
'rule_actions' => $this->getRuleActionData(),
];
+
return $data;
}
@@ -109,8 +110,8 @@ class RuleFormRequest extends Request
*/
private function getRuleActionData(): array
{
- $return = [];
- $actionData= $this->get('rule_actions');
+ $return = [];
+ $actionData = $this->get('rule_actions');
if (\is_array($actionData)) {
foreach ($actionData as $action) {
$stopProcessing = $action['stop_processing'] ?? '0';
diff --git a/app/Import/Mapper/OpposingAccountIbans.php b/app/Import/Mapper/OpposingAccountIbans.php
index ad15bf94e6..d11a75323a 100644
--- a/app/Import/Mapper/OpposingAccountIbans.php
+++ b/app/Import/Mapper/OpposingAccountIbans.php
@@ -33,6 +33,7 @@ class OpposingAccountIbans implements MapperInterface
{
/**
* Get map of opposing accounts.
+ *
* @return array
*/
public function getMap(): array
diff --git a/app/Import/Prerequisites/BunqPrerequisites.php b/app/Import/Prerequisites/BunqPrerequisites.php
index 1aeecf1499..55f07df71d 100644
--- a/app/Import/Prerequisites/BunqPrerequisites.php
+++ b/app/Import/Prerequisites/BunqPrerequisites.php
@@ -22,8 +22,8 @@ declare(strict_types=1);
namespace FireflyIII\Import\Prerequisites;
-use bunq\Exception\BunqException;
use bunq\Util\BunqEnumApiEnvironmentType;
+use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Services\Bunq\ApiContext;
use FireflyIII\Services\IP\IPRetrievalInterface;
@@ -134,7 +134,7 @@ class BunqPrerequisites implements PrerequisitesInterface
try {
$json = $apiContext->toJson();
// @codeCoverageIgnoreStart
- } catch (BunqException $e) {
+ } catch (Exception $e) {
$messages = new MessageBag();
$messages->add('bunq_error', $e->getMessage());
diff --git a/app/Import/Routine/YnabRoutine.php b/app/Import/Routine/YnabRoutine.php
index 7a7fe731b6..6540d36c19 100644
--- a/app/Import/Routine/YnabRoutine.php
+++ b/app/Import/Routine/YnabRoutine.php
@@ -86,17 +86,18 @@ class YnabRoutine implements RoutineInterface
if (\count($budgets) > 1) {
$this->repository->setStage($this->importJob, 'select_budgets');
$this->repository->setStatus($this->importJob, 'need_job_config');
+
return;
}
- if (\count($budgets) === 1) {
+ if (1 === \count($budgets)) {
$this->repository->setStatus($this->importJob, 'ready_to_run');
$this->repository->setStage($this->importJob, 'get_accounts');
}
return;
}
- if('get_accounts' === $this->importJob->stage) {
+ if ('get_accounts' === $this->importJob->stage) {
$this->repository->setStatus($this->importJob, 'running');
/** @var GetAccountsHandler $handler */
@@ -106,9 +107,10 @@ class YnabRoutine implements RoutineInterface
$this->repository->setStage($this->importJob, 'select_accounts');
$this->repository->setStatus($this->importJob, 'need_job_config');
+
return;
}
- if('go-for-import' === $this->importJob->stage) {
+ if ('go-for-import' === $this->importJob->stage) {
$this->repository->setStatus($this->importJob, 'running');
$this->repository->setStage($this->importJob, 'do_import');
/** @var ImportDataHandler $handler */
@@ -117,26 +119,27 @@ class YnabRoutine implements RoutineInterface
$handler->run();
$this->repository->setStatus($this->importJob, 'provider_finished');
$this->repository->setStage($this->importJob, 'final');
+
return;
}
-// if ('match_accounts' === $this->importJob->stage) {
-// // $this->repository->setStatus($this->importJob, 'running');
-// /** @var StageGetBudgetsHandler $handler */
-// $handler = app(StageGetBudgetsHandler::class);
-// $handler->setImportJob($this->importJob);
-// $handler->run();
-// $this->repository->setStage($this->importJob, 'get_transactions');
-// }
-//
-// if ('get_transactions' === $this->importJob->stage) {
-// // $this->repository->setStatus($this->importJob, 'running');
-// /** @var StageGetBudgetsHandler $handler */
-// $handler = app(StageGetBudgetsHandler::class);
-// $handler->setImportJob($this->importJob);
-// $handler->run();
-// $this->repository->setStage($this->importJob, 'get_transactions');
-// }
+ // if ('match_accounts' === $this->importJob->stage) {
+ // // $this->repository->setStatus($this->importJob, 'running');
+ // /** @var StageGetBudgetsHandler $handler */
+ // $handler = app(StageGetBudgetsHandler::class);
+ // $handler->setImportJob($this->importJob);
+ // $handler->run();
+ // $this->repository->setStage($this->importJob, 'get_transactions');
+ // }
+ //
+ // if ('get_transactions' === $this->importJob->stage) {
+ // // $this->repository->setStatus($this->importJob, 'running');
+ // /** @var StageGetBudgetsHandler $handler */
+ // $handler = app(StageGetBudgetsHandler::class);
+ // $handler->setImportJob($this->importJob);
+ // $handler->run();
+ // $this->repository->setStage($this->importJob, 'get_transactions');
+ // }
throw new FireflyException(sprintf('YNAB import routine cannot handle stage "%s"', $this->importJob->stage));
}
}
diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.php
index 16c0bcd15d..b5f9ec9e12 100644
--- a/app/Jobs/CreateRecurringTransactions.php
+++ b/app/Jobs/CreateRecurringTransactions.php
@@ -55,7 +55,7 @@ class CreateRecurringTransactions implements ShouldQueue
/** @var Carbon The current date */
private $date;
- /** @var JournalRepositoryInterface Journal repository */
+ /** @var JournalRepositoryInterface Journal repository */
private $journalRepository;
/** @var RecurringRepositoryInterface Recurring transactions repository. */
private $repository;
@@ -155,6 +155,7 @@ class CreateRecurringTransactions implements ShouldQueue
function (Rule $rule) use ($journal) {
Log::debug(sprintf('Going to apply rule #%d to journal %d.', $rule->id, $journal->id));
$processor = Processor::make($rule);
+ /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
$processor->handleTransactionJournal($journal);
if ($rule->stop_processing) {
return;
diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php
index 2faad2e91a..ae4fd5369d 100644
--- a/app/Models/AccountType.php
+++ b/app/Models/AccountType.php
@@ -35,32 +35,32 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
*/
class AccountType extends Model
{
- /** @var string */
- public const DEFAULT = 'Default account';
- /** @var string */
- public const CASH = 'Cash account';
- /** @var string */
- public const ASSET = 'Asset account';
- /** @var string */
- public const EXPENSE = 'Expense account';
- /** @var string */
- public const REVENUE = 'Revenue account';
- /** @var string */
+ /** @var string */
+ public const DEFAULT = 'Default account';
+ /** @var string */
+ public const CASH = 'Cash account';
+ /** @var string */
+ public const ASSET = 'Asset account';
+ /** @var string */
+ public const EXPENSE = 'Expense account';
+ /** @var string */
+ public const REVENUE = 'Revenue account';
+ /** @var string */
public const INITIAL_BALANCE = 'Initial balance account';
- /** @var string */
- public const BENEFICIARY = 'Beneficiary account';
- /** @var string */
- public const IMPORT = 'Import account';
- /** @var string */
- public const RECONCILIATION = 'Reconciliation account';
- /** @var string */
- public const LOAN = 'Loan';
- /** @var string */
- public const DEBT = 'Debt';
- /** @var string */
- public const MORTGAGE = 'Mortgage';
- /** @var string */
- public const CREDITCARD = 'Credit card';
+ /** @var string */
+ public const BENEFICIARY = 'Beneficiary account';
+ /** @var string */
+ public const IMPORT = 'Import account';
+ /** @var string */
+ public const RECONCILIATION = 'Reconciliation account';
+ /** @var string */
+ public const LOAN = 'Loan';
+ /** @var string */
+ public const DEBT = 'Debt';
+ /** @var string */
+ public const MORTGAGE = 'Mortgage';
+ /** @var string */
+ public const CREDITCARD = 'Credit card';
/**
* The attributes that should be casted to native types.
*
diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php
index 967316202b..8c700089e7 100644
--- a/app/Models/Attachment.php
+++ b/app/Models/Attachment.php
@@ -84,7 +84,7 @@ class Attachment extends Model
/** @var User $user */
$user = auth()->user();
/** @var Attachment $attachment */
- $attachment = $user->attachments()->find($attachmentId);
+ $attachment = $user->attachments()->find($attachmentId);
if (null !== $attachment) {
return $attachment;
}
diff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.php
index 0e41aaf521..0276ba7084 100644
--- a/app/Models/AvailableBudget.php
+++ b/app/Models/AvailableBudget.php
@@ -76,7 +76,7 @@ class AvailableBudget extends Model
/** @var User $user */
$user = auth()->user();
/** @var AvailableBudget $availableBudget */
- $availableBudget = $user->availableBudgets()->find($availableBudgetId);
+ $availableBudget = $user->availableBudgets()->find($availableBudgetId);
if (null !== $availableBudget) {
return $availableBudget;
}
diff --git a/app/Models/Bill.php b/app/Models/Bill.php
index 2354c460f0..610d2695ce 100644
--- a/app/Models/Bill.php
+++ b/app/Models/Bill.php
@@ -110,9 +110,9 @@ class Bill extends Model
/**
* @codeCoverageIgnore
- * @return \Illuminate\Database\Eloquent\Relations\MorphMany
+ * @return MorphMany
*/
- public function attachments(): \Illuminate\Database\Eloquent\Relations\MorphMany
+ public function attachments(): MorphMany
{
return $this->morphMany(Attachment::class, 'attachable');
}
diff --git a/app/Models/Budget.php b/app/Models/Budget.php
index 106739fcec..0ef5142e05 100644
--- a/app/Models/Budget.php
+++ b/app/Models/Budget.php
@@ -41,7 +41,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property int $user_id
* @property-read string $email
* @property bool encrypted
- * @property Collection budgetlimits
+ * @property Collection budgetlimits
*/
class Budget extends Model
{
@@ -80,7 +80,7 @@ class Budget extends Model
/** @var User $user */
$user = auth()->user();
/** @var Budget $budget */
- $budget = $user->budgets()->find($budgetId);
+ $budget = $user->budgets()->find($budgetId);
if (null !== $budget) {
return $budget;
}
diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php
index 2306e375de..f0d975d3c8 100644
--- a/app/Models/BudgetLimit.php
+++ b/app/Models/BudgetLimit.php
@@ -48,7 +48,7 @@ class BudgetLimit extends Model
* @var array
*/
protected $casts
- = [
+ = [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'start_date' => 'date',
diff --git a/app/Models/Category.php b/app/Models/Category.php
index 92e657d78f..67459e3a24 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -39,7 +39,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property int $id
* @property float $spent // used in category reports
* @property Carbon|null lastActivity
- * @property bool encrypted
+ * @property bool encrypted
*/
class Category extends Model
{
@@ -77,7 +77,7 @@ class Category extends Model
/** @var User $user */
$user = auth()->user();
/** @var Category $category */
- $category = $user->categories()->find($categoryId);
+ $category = $user->categories()->find($categoryId);
if (null !== $category) {
return $category;
}
diff --git a/app/Models/CurrencyExchangeRate.php b/app/Models/CurrencyExchangeRate.php
index 203b4d6bd2..6a50c0d874 100644
--- a/app/Models/CurrencyExchangeRate.php
+++ b/app/Models/CurrencyExchangeRate.php
@@ -46,8 +46,8 @@ class CurrencyExchangeRate extends Model
/** @var array Convert these fields to other data types */
protected $casts
= [
- 'created_at' => 'datetime',
- 'updated_at' => 'datetime',
+ 'created_at' => 'datetime',
+ 'updated_at' => 'datetime',
'user_id' => 'int',
'from_currency_id' => 'int',
'to_currency_id' => 'int',
diff --git a/app/Models/ImportJob.php b/app/Models/ImportJob.php
index ab8392a1f7..aebbf35b45 100644
--- a/app/Models/ImportJob.php
+++ b/app/Models/ImportJob.php
@@ -25,6 +25,7 @@ namespace FireflyIII\Models;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\Relations\MorphMany;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
@@ -43,7 +44,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property Tag $tag
* @property array $errors
* @property array extended_status
- * @property int id
+ * @property int id
*/
class ImportJob extends Model
{
@@ -77,7 +78,7 @@ class ImportJob extends Model
public static function routeBinder(string $value): ImportJob
{
if (auth()->check()) {
- $key = trim($value);
+ $key = trim($value);
/** @var User $user */
$user = auth()->user();
/** @var ImportJob $importJob */
@@ -91,9 +92,9 @@ class ImportJob extends Model
/**
* @codeCoverageIgnore
- * @return \Illuminate\Database\Eloquent\Relations\MorphMany
+ * @return MorphMany
*/
- public function attachments(): \Illuminate\Database\Eloquent\Relations\MorphMany
+ public function attachments(): MorphMany
{
return $this->morphMany(Attachment::class, 'attachable');
}
diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php
index 360d4b7c01..289e7f79b3 100644
--- a/app/Models/PiggyBank.php
+++ b/app/Models/PiggyBank.php
@@ -45,7 +45,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property int $order
* @property bool $active
* @property int $account_id
- * @property bool encrypted
+ * @property bool encrypted
*
*/
class PiggyBank extends Model
diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php
index 3cb7541896..6cc3042832 100644
--- a/app/Models/PiggyBankEvent.php
+++ b/app/Models/PiggyBankEvent.php
@@ -33,7 +33,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
* @property int $transaction_journal_id
* @property int $piggy_bank_id
* @property int $id
- * @property Carbon date
+ * @property Carbon date
*/
class PiggyBankEvent extends Model
{
diff --git a/app/Models/Preference.php b/app/Models/Preference.php
index a7e28d2bad..f24effcfe1 100644
--- a/app/Models/Preference.php
+++ b/app/Models/Preference.php
@@ -41,7 +41,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property Carbon $updated_at
* @property Carbon $created_at
* @property int $id
- * @property User user
+ * @property User user
*/
class Preference extends Model
{
@@ -74,7 +74,7 @@ class Preference extends Model
/** @var User $user */
$user = auth()->user();
/** @var Preference $preference */
- $preference = $user->preferences()->find($preferenceId);
+ $preference = $user->preferences()->find($preferenceId);
if (null !== $preference) {
return $preference;
}
diff --git a/app/Models/Recurrence.php b/app/Models/Recurrence.php
index 0c4ac5a9c0..3bdcc2c58d 100644
--- a/app/Models/Recurrence.php
+++ b/app/Models/Recurrence.php
@@ -103,7 +103,7 @@ class Recurrence extends Model
/** @var User $user */
$user = auth()->user();
/** @var Recurrence $recurrence */
- $recurrence = $user->recurrences()->find($recurrenceId);
+ $recurrence = $user->recurrences()->find($recurrenceId);
if (null !== $recurrence) {
return $recurrence;
}
diff --git a/app/Models/RecurrenceRepetition.php b/app/Models/RecurrenceRepetition.php
index cc26a97378..fc72034c92 100644
--- a/app/Models/RecurrenceRepetition.php
+++ b/app/Models/RecurrenceRepetition.php
@@ -57,7 +57,7 @@ class RecurrenceRepetition extends Model
* @var array
*/
protected $casts
- = [
+ = [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
diff --git a/app/Models/RecurrenceTransactionMeta.php b/app/Models/RecurrenceTransactionMeta.php
index 1f283ad0db..9f96b0fb5b 100644
--- a/app/Models/RecurrenceTransactionMeta.php
+++ b/app/Models/RecurrenceTransactionMeta.php
@@ -43,7 +43,7 @@ class RecurrenceTransactionMeta extends Model
* @var array
*/
protected $casts
- = [
+ = [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'deleted_at' => 'datetime',
diff --git a/app/Models/Rule.php b/app/Models/Rule.php
index 328ac6039d..58fe37ac10 100644
--- a/app/Models/Rule.php
+++ b/app/Models/Rule.php
@@ -88,7 +88,7 @@ class Rule extends Model
/** @var User $user */
$user = auth()->user();
/** @var Rule $rule */
- $rule = $user->rules()->find($ruleId);
+ $rule = $user->rules()->find($ruleId);
if (null !== $rule) {
return $rule;
}
diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php
index 233ef34165..14f85f5491 100644
--- a/app/Models/RuleGroup.php
+++ b/app/Models/RuleGroup.php
@@ -43,7 +43,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property int $id
* @property int $order
* @property Collection $rules
- * @property string description
+ * @property string description
*/
class RuleGroup extends Model
{
@@ -80,7 +80,7 @@ class RuleGroup extends Model
/** @var User $user */
$user = auth()->user();
/** @var RuleGroup $ruleGroup */
- $ruleGroup = $user->ruleGroups()->find($ruleGroupId);
+ $ruleGroup = $user->ruleGroups()->find($ruleGroupId);
if (null !== $ruleGroup) {
return $ruleGroup;
}
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index d20fbf8778..bc52be8698 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -237,6 +237,7 @@ class Transaction extends Model
/**
* Check for transactions BEFORE the specified date.
+ *
* @codeCoverageIgnore
*
* @param Builder $query
diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php
index 08358b492d..5f85ace223 100644
--- a/app/Models/TransactionCurrency.php
+++ b/app/Models/TransactionCurrency.php
@@ -34,7 +34,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $symbol
* @property int $decimal_places
* @property int $id
- * @property string name
+ * @property string name
*
*/
class TransactionCurrency extends Model
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index ccdb49fa4c..266974a4b5 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -150,9 +150,9 @@ class TransactionJournal extends Model
/**
* @codeCoverageIgnore
- * @return \Illuminate\Database\Eloquent\Relations\MorphMany
+ * @return MorphMany
*/
- public function attachments(): \Illuminate\Database\Eloquent\Relations\MorphMany
+ public function attachments(): MorphMany
{
return $this->morphMany(Attachment::class, 'attachable');
}
diff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.php
index 92e5920f7a..8107ce07a0 100644
--- a/app/Models/TransactionJournalLink.php
+++ b/app/Models/TransactionJournalLink.php
@@ -45,9 +45,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class TransactionJournalLink extends Model
{
- /** @var string The table to store the data in */
- protected $table = 'journal_links';
-
/**
* The attributes that should be casted to native types.
*
@@ -55,9 +52,11 @@ class TransactionJournalLink extends Model
*/
protected $casts
= [
- 'created_at' => 'datetime',
- 'updated_at' => 'datetime',
+ 'created_at' => 'datetime',
+ 'updated_at' => 'datetime',
];
+ /** @var string The table to store the data in */
+ protected $table = 'journal_links';
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index d91edc80e3..f426485c0f 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -26,6 +26,7 @@ use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Laravel\Passport\Passport;
use URL;
+
/**
* @codeCoverageIgnore
* Class AppServiceProvider.
@@ -38,7 +39,7 @@ class AppServiceProvider extends ServiceProvider
public function boot(): void
{
Schema::defaultStringLength(191);
- if('heroku' === env('APP_ENV')) {
+ if ('heroku' === env('APP_ENV')) {
URL::forceScheme('https');
}
}
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 8489a62a80..0961ba3f9b 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -303,6 +303,7 @@ class AccountRepository implements AccountRepositoryInterface
if (null === $note) {
return null;
}
+
return $note->text;
}
@@ -450,6 +451,9 @@ class AccountRepository implements AccountRepositoryInterface
* @param array $data
*
* @return Account
+ * @throws \FireflyIII\Exceptions\FireflyException
+ * @throws FireflyException
+ * @throws FireflyException
*/
public function update(Account $account, array $data): Account
{
diff --git a/app/Repositories/Attachment/AttachmentRepositoryInterface.php b/app/Repositories/Attachment/AttachmentRepositoryInterface.php
index 527d00f88e..b59378c58d 100644
--- a/app/Repositories/Attachment/AttachmentRepositoryInterface.php
+++ b/app/Repositories/Attachment/AttachmentRepositoryInterface.php
@@ -50,6 +50,7 @@ interface AttachmentRepositoryInterface
/**
* @param int $attachmentId
+ *
* @return Attachment|null
*/
public function findWithoutUser(int $attachmentId): ?Attachment;
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index 390916ce24..a7587fff83 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -323,7 +323,7 @@ class BillRepository implements BillRepositoryInterface
*/
public function getPayDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection
{
- $set = new Collection;
+ $set = new Collection;
$currentStart = clone $start;
Log::debug(sprintf('Now at bill "%s" (%s)', $bill->name, $bill->repeat_freq));
Log::debug(sprintf('First currentstart is %s', $currentStart->format('Y-m-d')));
diff --git a/app/Repositories/ExportJob/ExportJobRepository.php b/app/Repositories/ExportJob/ExportJobRepository.php
index a74f7f6628..756af68450 100644
--- a/app/Repositories/ExportJob/ExportJobRepository.php
+++ b/app/Repositories/ExportJob/ExportJobRepository.php
@@ -48,7 +48,8 @@ class ExportJobRepository implements ExportJobRepositoryInterface
public function changeStatus(ExportJob $job, string $status): bool
{
Log::debug(sprintf('Change status of job #%d to "%s"', $job->id, $status));
- $job->change($status);
+ $job->status = $status;
+ $job->save();
return true;
}
diff --git a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php
index 65d51523a4..d1a35f47a9 100644
--- a/app/Repositories/ExportJob/ExportJobRepositoryInterface.php
+++ b/app/Repositories/ExportJob/ExportJobRepositoryInterface.php
@@ -57,6 +57,7 @@ interface ExportJobRepositoryInterface
/**
* @param string $key
+ *
* @return ExportJob|null
*/
public function findByKey(string $key): ?ExportJob;
diff --git a/app/Repositories/ImportJob/ImportJobRepository.php b/app/Repositories/ImportJob/ImportJobRepository.php
index 43efe32767..120e612f40 100644
--- a/app/Repositories/ImportJob/ImportJobRepository.php
+++ b/app/Repositories/ImportJob/ImportJobRepository.php
@@ -184,6 +184,7 @@ class ImportJobRepository implements ImportJobRepositoryInterface
$newConfig = array_merge($currentConfig, $configuration);
$job->configuration = $newConfig;
$job->save();
+
//Log::debug(sprintf('Set config of job "%s" to: ', $job->key), $newConfig);
return $job;
diff --git a/app/Repositories/ImportJob/ImportJobRepositoryInterface.php b/app/Repositories/ImportJob/ImportJobRepositoryInterface.php
index 6d151a4588..42248dd461 100644
--- a/app/Repositories/ImportJob/ImportJobRepositoryInterface.php
+++ b/app/Repositories/ImportJob/ImportJobRepositoryInterface.php
@@ -54,6 +54,7 @@ interface ImportJobRepositoryInterface
/**
* @param string $key
+ *
* @return ImportJob|null
*/
public function findByKey(string $key): ?ImportJob;
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index 64715c42af..c89d31e2fd 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -707,6 +707,8 @@ class JournalRepository implements JournalRepositoryInterface
*
* @return TransactionJournal
*
+ * @throws FireflyException
+ * @throws FireflyException
*/
public function update(TransactionJournal $journal, array $data): TransactionJournal
{
diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php
index 6b26aaa30a..0b38323d41 100644
--- a/app/Repositories/Journal/JournalRepositoryInterface.php
+++ b/app/Repositories/Journal/JournalRepositoryInterface.php
@@ -25,7 +25,6 @@ namespace FireflyIII\Repositories\Journal;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
-
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalMeta;
diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.php
index c85b819de3..bedfef3cb7 100644
--- a/app/Repositories/Tag/TagRepositoryInterface.php
+++ b/app/Repositories/Tag/TagRepositoryInterface.php
@@ -60,7 +60,7 @@ interface TagRepositoryInterface
*
* @return Tag|null
*/
- public function findByTag(string $tag):?Tag;
+ public function findByTag(string $tag): ?Tag;
/**
* @param int $tagId
diff --git a/app/Services/Currency/FixerIOv2.php b/app/Services/Currency/FixerIOv2.php
index 2d5f250f8a..0bbfbc556d 100644
--- a/app/Services/Currency/FixerIOv2.php
+++ b/app/Services/Currency/FixerIOv2.php
@@ -68,7 +68,7 @@ class FixerIOv2 implements ExchangeRateInterface
}
// build URI
- $uri = sprintf(
+ $uri = sprintf(
'http://data.fixer.io/api/%s?access_key=%s&base=%s&symbols=%s',
$date->format('Y-m-d'), $apiKey, $fromCurrency->code, $toCurrency->code
);
diff --git a/app/Services/Github/Request/UpdateRequest.php b/app/Services/Github/Request/UpdateRequest.php
index 44a0bc17b7..1616db8701 100644
--- a/app/Services/Github/Request/UpdateRequest.php
+++ b/app/Services/Github/Request/UpdateRequest.php
@@ -60,7 +60,7 @@ class UpdateRequest implements GithubRequest
}
try {
$releaseXml = new SimpleXMLElement($res->getBody()->getContents(), LIBXML_NOCDATA);
- } catch (RunTimeException $e) {
+ } catch (RuntimeException $e) {
Log::error(sprintf('Could not get body from github updat result: %s', $e->getMessage()));
$releaseXml = new SimpleXMLElement('');
}
diff --git a/app/Services/IP/IpifyOrg.php b/app/Services/IP/IpifyOrg.php
index a171b3f8eb..f5abb40d5e 100644
--- a/app/Services/IP/IpifyOrg.php
+++ b/app/Services/IP/IpifyOrg.php
@@ -27,7 +27,7 @@ use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Log;
-use RunTimeException;
+use RuntimeException;
/**
* Class IpifyOrg
@@ -58,7 +58,7 @@ class IpifyOrg implements IPRetrievalInterface
}
try {
$body = (string)$res->getBody()->getContents();
- } catch (RunTimeException $e) {
+ } catch (RuntimeException $e) {
Log::error(sprintf('Could not get body from ipify.org result: %s', $e->getMessage()));
$body = null;
}
diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.php
index 6877ba13bb..8d4e2f3e33 100644
--- a/app/Services/Internal/Support/AccountServiceTrait.php
+++ b/app/Services/Internal/Support/AccountServiceTrait.php
@@ -49,7 +49,7 @@ trait AccountServiceTrait
/** @var array */
public $validCCFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber', 'currency_id', 'BIC'];
/** @var array */
- public $validFields = ['accountNumber', 'currency_id', 'BIC','interest','interest_period'];
+ public $validFields = ['accountNumber', 'currency_id', 'BIC', 'interest', 'interest_period'];
/**
* @param Account $account
diff --git a/app/Services/Internal/Support/TransactionTypeTrait.php b/app/Services/Internal/Support/TransactionTypeTrait.php
index 4372c736d8..e877e3be76 100644
--- a/app/Services/Internal/Support/TransactionTypeTrait.php
+++ b/app/Services/Internal/Support/TransactionTypeTrait.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Services\Internal\Support;
+
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\TransactionTypeFactory;
use FireflyIII\Models\TransactionType;
diff --git a/app/Services/Internal/Update/BillUpdateService.php b/app/Services/Internal/Update/BillUpdateService.php
index 72c811bee2..1c849d4fb4 100644
--- a/app/Services/Internal/Update/BillUpdateService.php
+++ b/app/Services/Internal/Update/BillUpdateService.php
@@ -51,7 +51,7 @@ class BillUpdateService
$bill->repeat_freq = $data['repeat_freq'];
$bill->skip = $data['skip'];
$bill->automatch = true;
- $bill->active = $data['active']??true;
+ $bill->active = $data['active'] ?? true;
$bill->save();
// update note:
diff --git a/app/Services/Internal/Update/RecurrenceUpdateService.php b/app/Services/Internal/Update/RecurrenceUpdateService.php
index b33a8b2297..7205b4c9ff 100644
--- a/app/Services/Internal/Update/RecurrenceUpdateService.php
+++ b/app/Services/Internal/Update/RecurrenceUpdateService.php
@@ -25,7 +25,6 @@ namespace FireflyIII\Services\Internal\Update;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Recurrence;
-
use FireflyIII\Services\Internal\Support\RecurringTransactionTrait;
use FireflyIII\Services\Internal\Support\TransactionServiceTrait;
use FireflyIII\Services\Internal\Support\TransactionTypeTrait;
@@ -65,7 +64,7 @@ class RecurrenceUpdateService
$recurrence->apply_rules = $data['recurrence']['apply_rules'] ?? $recurrence->apply_rules;
$recurrence->active = $data['recurrence']['active'] ?? $recurrence->active;
- if(isset($data['recurrence']['repetition_end'])) {
+ if (isset($data['recurrence']['repetition_end'])) {
if (\in_array($data['recurrence']['repetition_end'], ['forever ', 'until_date'])) {
$recurrence->repetitions = 0;
}
diff --git a/app/Services/Password/PwndVerifierV2.php b/app/Services/Password/PwndVerifierV2.php
index 87e936b846..b78fdeb67b 100644
--- a/app/Services/Password/PwndVerifierV2.php
+++ b/app/Services/Password/PwndVerifierV2.php
@@ -67,7 +67,7 @@ class PwndVerifierV2 implements Verifier
}
try {
$strpos = stripos($res->getBody()->getContents(), $rest);
- } catch (RunTimeException $e) {
+ } catch (RuntimeException $e) {
Log::error(sprintf('Could not get body from Pwnd result: %s', $e->getMessage()));
$strpos = false;
}
diff --git a/app/Services/Spectre/Object/Attempt.php b/app/Services/Spectre/Object/Attempt.php
index 53aff5124a..210ad00088 100644
--- a/app/Services/Spectre/Object/Attempt.php
+++ b/app/Services/Spectre/Object/Attempt.php
@@ -28,6 +28,7 @@ use Carbon\Carbon;
/**
*
* Class Attempt
+ *
* @codeCoverageIgnore
* @SuppressWarnings(PHPMD.ShortVariable)
* @SuppressWarnings(PHPMD.TooManyFields)
diff --git a/app/Services/Spectre/Object/Login.php b/app/Services/Spectre/Object/Login.php
index 6d536ac7ce..23b120e0a9 100644
--- a/app/Services/Spectre/Object/Login.php
+++ b/app/Services/Spectre/Object/Login.php
@@ -28,6 +28,7 @@ use Carbon\Carbon;
/**
* Class Login
+ *
* @codeCoverageIgnore
* @SuppressWarnings(PHPMD.ShortVariable)
* @SuppressWarnings(PHPMD.TooManyFields)
diff --git a/app/Services/Spectre/Object/Transaction.php b/app/Services/Spectre/Object/Transaction.php
index 866ffddbb2..974bf01cc6 100644
--- a/app/Services/Spectre/Object/Transaction.php
+++ b/app/Services/Spectre/Object/Transaction.php
@@ -27,6 +27,7 @@ use Carbon\Carbon;
/**
* Class Transaction
+ *
* @codeCoverageIgnore
*
* @SuppressWarnings(PHPMD.ShortVariable)
diff --git a/app/Services/Spectre/Request/NewCustomerRequest.php b/app/Services/Spectre/Request/NewCustomerRequest.php
index 099a40cfd9..36e4946387 100644
--- a/app/Services/Spectre/Request/NewCustomerRequest.php
+++ b/app/Services/Spectre/Request/NewCustomerRequest.php
@@ -24,6 +24,7 @@ namespace FireflyIII\Services\Spectre\Request;
use FireflyIII\Services\Spectre\Object\Customer;
use Log;
+
/**
* Class NewCustomerRequest
*/
@@ -37,12 +38,12 @@ class NewCustomerRequest extends SpectreRequest
*/
public function call(): void
{
- $data = [
+ $data = [
'data' => [
'identifier' => 'default_ff3_customer',
],
];
- $uri = '/api/v4/customers/';
+ $uri = '/api/v4/customers/';
Log::debug(sprintf('Going to call %s with info:', $uri), $data);
$response = $this->sendSignedSpectrePost($uri, $data);
// create customer:
diff --git a/app/Services/Spectre/Request/SpectreRequest.php b/app/Services/Spectre/Request/SpectreRequest.php
index cbf62ebe71..d392fad037 100644
--- a/app/Services/Spectre/Request/SpectreRequest.php
+++ b/app/Services/Spectre/Request/SpectreRequest.php
@@ -211,7 +211,7 @@ abstract class SpectreRequest
$statusCode = $res->getStatusCode();
try {
$returnBody = $res->getBody()->getContents();
- } catch (RunTimeException $e) {
+ } catch (RuntimeException $e) {
Log::error(sprintf('Could not get body from SpectreRequest::GET result: %s', $e->getMessage()));
$returnBody = '';
}
@@ -261,7 +261,7 @@ abstract class SpectreRequest
try {
$body = $res->getBody()->getContents();
- } catch (RunTimeException $e) {
+ } catch (RuntimeException $e) {
Log::error(sprintf('Could not get body from SpectreRequest::POST result: %s', $e->getMessage()));
$body = '';
}
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index 48c98cc177..e2fa4c17c0 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -56,7 +56,7 @@ class Amount
$space = ' ';
// require space between symbol and amount?
- if ($sepBySpace === false) {
+ if (false === $sepBySpace) {
$space = ''; // no
}
@@ -134,8 +134,8 @@ class Amount
// some complicated switches to format the amount correctly:
$precedes = $amount < 0 ? $info['n_cs_precedes'] : $info['p_cs_precedes'];
$separated = $amount < 0 ? $info['n_sep_by_space'] : $info['p_sep_by_space'];
- $space = $separated === true ? ' ' : '';
- $result = $precedes === false ? $formatted . $space . $format->symbol : $format->symbol . $space . $formatted;
+ $space = true === $separated ? ' ' : '';
+ $result = false === $precedes ? $formatted . $space . $format->symbol : $format->symbol . $space . $formatted;
if (true === $coloured) {
if ($amount > 0) {
diff --git a/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php b/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php
index a65d7be089..92a14d57c1 100644
--- a/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php
+++ b/app/Support/Import/JobConfiguration/Ynab/SelectBudgetHandler.php
@@ -59,7 +59,7 @@ class SelectBudgetHandler implements YnabJobConfigurationInterface
Log::debug('Now in SelectBudgetHandler::configComplete');
$configuration = $this->repository->getConfiguration($this->importJob);
$selectedBudget = $configuration['selected_budget'] ?? '';
- if ($selectedBudget !== '') {
+ if ('' !== $selectedBudget) {
Log::debug(sprintf('Selected budget is %s, config is complete. Return true.', $selectedBudget));
$this->repository->setStage($this->importJob, 'get_accounts');
diff --git a/app/Support/Import/JobConfiguration/Ynab/YnabJobConfigurationInterface.php b/app/Support/Import/JobConfiguration/Ynab/YnabJobConfigurationInterface.php
index 5458d1ef53..bc9bcc3d2e 100644
--- a/app/Support/Import/JobConfiguration/Ynab/YnabJobConfigurationInterface.php
+++ b/app/Support/Import/JobConfiguration/Ynab/YnabJobConfigurationInterface.php
@@ -22,6 +22,7 @@
declare(strict_types=1);
namespace FireflyIII\Support\Import\JobConfiguration\Ynab;
+
use FireflyIII\Models\ImportJob;
use Illuminate\Support\MessageBag;
diff --git a/app/Support/Import/Routine/File/ImportableConverter.php b/app/Support/Import/Routine/File/ImportableConverter.php
index d4a90fc9d8..b12cb52216 100644
--- a/app/Support/Import/Routine/File/ImportableConverter.php
+++ b/app/Support/Import/Routine/File/ImportableConverter.php
@@ -147,6 +147,7 @@ class ImportableConverter
Log::error($e->getTraceAsString());
}
}
+
return $result;
}
diff --git a/app/Support/Import/Routine/Ynab/ImportDataHandler.php b/app/Support/Import/Routine/Ynab/ImportDataHandler.php
index c6e4c0976c..0e97b2f5ea 100644
--- a/app/Support/Import/Routine/Ynab/ImportDataHandler.php
+++ b/app/Support/Import/Routine/Ynab/ImportDataHandler.php
@@ -150,7 +150,7 @@ class ImportDataHandler
$destination = $this->mapper->map($possibleDestinationId, $amount, $destinationData);
if (1 === bccomp($amount, '0')) {
[$source, $destination] = [$destination, $source];
- $type = $type === 'transfer' ? 'transfer' : 'deposit';
+ $type = 'transfer' === $type ? 'transfer' : 'deposit';
Log::debug(sprintf('Amount is %s, so switch source/dest and make this a %s', $amount, $type));
}
diff --git a/app/Support/Import/Routine/Ynab/StageGetAccessHandler.php b/app/Support/Import/Routine/Ynab/StageGetAccessHandler.php
index 4c91d1abac..c155a4e0ca 100644
--- a/app/Support/Import/Routine/Ynab/StageGetAccessHandler.php
+++ b/app/Support/Import/Routine/Ynab/StageGetAccessHandler.php
@@ -70,14 +70,14 @@ class StageGetAccessHandler
}
$statusCode = $res->getStatusCode();
try {
- $content = trim($res->getBody()->getContents());
- } catch(RuntimeException $e) {
+ $content = trim($res->getBody()->getContents());
+ } catch (RuntimeException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
throw new FireflyException($e->getMessage());
}
- $json = json_decode($content, true) ?? [];
+ $json = json_decode($content, true) ?? [];
Log::debug(sprintf('Status code from YNAB is %d', $statusCode));
Log::debug(sprintf('Body of result is %s', $content), $json);
diff --git a/app/Support/Import/Routine/Ynab/StageGetBudgetsHandler.php b/app/Support/Import/Routine/Ynab/StageGetBudgetsHandler.php
index 642298d4bb..fd8c3dbeb6 100644
--- a/app/Support/Import/Routine/Ynab/StageGetBudgetsHandler.php
+++ b/app/Support/Import/Routine/Ynab/StageGetBudgetsHandler.php
@@ -58,7 +58,7 @@ class StageGetBudgetsHandler
$configuration['budgets'] = $request->budgets;
$this->repository->setConfiguration($this->importJob, $configuration);
Log::debug(sprintf('Found %d budgets', \count($request->budgets)));
- if (\count($request->budgets) === 0) {
+ if (0 === \count($request->budgets)) {
throw new FireflyException('It seems this user has zero budgets or an error prevented Firefly III from reading them.');
}
}
diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php
index b94901dcd1..c1a097efc6 100644
--- a/app/Support/Preferences.php
+++ b/app/Support/Preferences.php
@@ -171,6 +171,7 @@ class Preferences
if (\is_array($lastActivity)) {
$lastActivity = implode(',', $lastActivity);
}
+
return md5($lastActivity);
}
diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php
index 804378ffe2..e26f79374d 100644
--- a/app/Support/Twig/General.php
+++ b/app/Support/Twig/General.php
@@ -46,7 +46,7 @@ class General extends Twig_Extension
$this->balance(),
$this->formatFilesize(),
$this->mimeIcon(),
- $this->markdown()
+ $this->markdown(),
];
}
@@ -249,6 +249,7 @@ class General extends Twig_Extension
if ($repository->hasRole(auth()->user(), $role)) {
return true;
}
+
return false;
}
);
diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.php
index e00093a7c9..6aa55ceec3 100644
--- a/app/Support/Twig/Translation.php
+++ b/app/Support/Twig/Translation.php
@@ -69,7 +69,6 @@ class Translation extends Twig_Extension
'journalLinkTranslation',
function (string $direction, string $original) {
$key = sprintf('firefly.%s_%s', $original, $direction);
- return $key;
$translation = trans($key);
if ($key === $translation) {
diff --git a/app/TransactionRules/Processor.php b/app/TransactionRules/Processor.php
index a3de4387f0..6acf0fcd64 100644
--- a/app/TransactionRules/Processor.php
+++ b/app/TransactionRules/Processor.php
@@ -86,7 +86,7 @@ final class Processor
Log::debug(sprintf('Push trigger %d', $trigger->id));
$self->triggers->push(TriggerFactory::getTrigger($trigger));
}
- if ($includeActions === true) {
+ if (true === $includeActions) {
$self->actions = $rule->ruleActions()->orderBy('order', 'ASC')->get();
}
diff --git a/app/TransactionRules/TransactionMatcher.php b/app/TransactionRules/TransactionMatcher.php
index b417311aae..3d1ba9d317 100644
--- a/app/TransactionRules/TransactionMatcher.php
+++ b/app/TransactionRules/TransactionMatcher.php
@@ -195,15 +195,15 @@ class TransactionMatcher
$allTriggers = $this->rule->ruleTriggers()->whereIn('trigger_type', $valid)->get();
/** @var RuleTrigger $trigger */
foreach ($allTriggers as $trigger) {
- if ($trigger->trigger_type === 'amount_less') {
+ if ('amount_less' === $trigger->trigger_type) {
$this->maxAmount = $trigger->trigger_value;
Log::debug(sprintf('Set max amount to be %s', $trigger->trigger_value));
}
- if ($trigger->trigger_type === 'amount_more') {
+ if ('amount_more' === $trigger->trigger_type) {
$this->minAmount = $trigger->trigger_value;
Log::debug(sprintf('Set min amount to be %s', $trigger->trigger_value));
}
- if ($trigger->trigger_type === 'amount_exactly') {
+ if ('amount_exactly' === $trigger->trigger_type) {
$this->exactAmount = $trigger->trigger_value;
Log::debug(sprintf('Set exact amount to be %s', $trigger->trigger_value));
}
diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php
index 64ec626911..c6cc0e3af2 100644
--- a/app/Transformers/AccountTransformer.php
+++ b/app/Transformers/AccountTransformer.php
@@ -148,7 +148,7 @@ class AccountTransformer extends TransformerAbstract
$type = $account->accountType->type;
$role = $this->repository->getMetaValue($account, 'accountRole');
- if ($type !== AccountType::ASSET || (string)$role === '') {
+ if ($type !== AccountType::ASSET || '' === (string)$role) {
$role = null;
}
$currencyId = (int)$this->repository->getMetaValue($account, 'currency_id');
@@ -167,13 +167,13 @@ class AccountTransformer extends TransformerAbstract
$date = $this->parameters->get('date');
}
- if ($currencyId === 0) {
+ if (0 === $currencyId) {
$currencyId = null;
}
$monthlyPaymentDate = null;
$creditCardType = null;
- if ($role === 'ccAsset' && $type === AccountType::ASSET) {
+ if ('ccAsset' === $role && $type === AccountType::ASSET) {
$creditCardType = $this->repository->getMetaValue($account, 'ccType');
$monthlyPaymentDate = $this->repository->getMetaValue($account, 'ccMonthlyPaymentDate');
}
@@ -194,7 +194,7 @@ class AccountTransformer extends TransformerAbstract
'updated_at' => $account->updated_at->toAtomString(),
'created_at' => $account->created_at->toAtomString(),
'name' => $account->name,
- 'active' => (int)$account->active === 1,
+ 'active' => 1 === (int)$account->active,
'type' => $type,
'currency_id' => $currencyId,
'currency_code' => $currencyCode,
diff --git a/app/Transformers/BudgetTransformer.php b/app/Transformers/BudgetTransformer.php
index 4b9562292a..e09170a54a 100644
--- a/app/Transformers/BudgetTransformer.php
+++ b/app/Transformers/BudgetTransformer.php
@@ -118,7 +118,7 @@ class BudgetTransformer extends TransformerAbstract
'id' => (int)$budget->id,
'updated_at' => $budget->updated_at->toAtomString(),
'created_at' => $budget->created_at->toAtomString(),
- 'active' => (int)$budget->active === 1,
+ 'active' => 1 === (int)$budget->active,
'name' => $budget->name,
'links' => [
[
diff --git a/app/Transformers/CurrencyExchangeRateTransformer.php b/app/Transformers/CurrencyExchangeRateTransformer.php
index e1c8ebc0e6..e9dbd007dc 100644
--- a/app/Transformers/CurrencyExchangeRateTransformer.php
+++ b/app/Transformers/CurrencyExchangeRateTransformer.php
@@ -29,6 +29,9 @@ use League\Fractal\Resource\Item;
use League\Fractal\TransformerAbstract;
use Symfony\Component\HttpFoundation\ParameterBag;
+/**
+ * Class CurrencyExchangeRateTransformer
+ */
class CurrencyExchangeRateTransformer extends TransformerAbstract
{
/**
@@ -79,6 +82,11 @@ class CurrencyExchangeRateTransformer extends TransformerAbstract
return $this->item($rate->toCurrency, new CurrencyTransformer($this->parameters), 'transaction_currencies');
}
+ /**
+ * @param CurrencyExchangeRate $rate
+ *
+ * @return array
+ */
public function transform(CurrencyExchangeRate $rate): array
{
$data = [
diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.php
index 44b60aad55..420a761899 100644
--- a/app/Transformers/PiggyBankEventTransformer.php
+++ b/app/Transformers/PiggyBankEventTransformer.php
@@ -95,6 +95,7 @@ class PiggyBankEventTransformer extends TransformerAbstract
$pageSize = (int)app('preferences')->getForUser($journal->user, 'listPageSize', 50)->data;
// journals always use collector and limited using URL parameters.
+ /** @var JournalCollectorInterface $collector */
$collector = app(JournalCollectorInterface::class);
$collector->setUser($journal->user);
$collector->withOpposingAccount()->withCategoryInformation()->withCategoryInformation();
@@ -129,7 +130,8 @@ class PiggyBankEventTransformer extends TransformerAbstract
/** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class);
$repository->setUser($account->user);
- $currency = $repository->findNull($currencyId);
+ $currency = $repository->findNull($currencyId);
+ /** @noinspection NullPointerExceptionInspection */
$decimalPlaces = $currency->decimal_places;
}
diff --git a/app/Transformers/PiggyBankTransformer.php b/app/Transformers/PiggyBankTransformer.php
index 897e969b7e..b3bd7f91da 100644
--- a/app/Transformers/PiggyBankTransformer.php
+++ b/app/Transformers/PiggyBankTransformer.php
@@ -170,7 +170,7 @@ class PiggyBankTransformer extends TransformerAbstract
'start_date' => $startDate,
'target_date' => $targetDate,
'order' => (int)$piggyBank->order,
- 'active' => (int)$piggyBank->active === 1,
+ 'active' => 1 === (int)$piggyBank->active,
'notes' => null,
'links' => [
[
diff --git a/app/Transformers/PreferenceTransformer.php b/app/Transformers/PreferenceTransformer.php
index 033b682050..254c11bf3c 100644
--- a/app/Transformers/PreferenceTransformer.php
+++ b/app/Transformers/PreferenceTransformer.php
@@ -28,6 +28,9 @@ use FireflyIII\Models\Preference;
use League\Fractal\TransformerAbstract;
use Symfony\Component\HttpFoundation\ParameterBag;
+/**
+ * Class PreferenceTransformer
+ */
class PreferenceTransformer extends TransformerAbstract
{
/**
@@ -45,6 +48,11 @@ class PreferenceTransformer extends TransformerAbstract
/** @var ParameterBag */
protected $parameters;
+ /**
+ * PreferenceTransformer constructor.
+ *
+ * @param ParameterBag $parameters
+ */
public function __construct(ParameterBag $parameters)
{
$this->parameters = $parameters;
diff --git a/app/Transformers/TagTransformer.php b/app/Transformers/TagTransformer.php
index 19ce472453..3b926de80a 100644
--- a/app/Transformers/TagTransformer.php
+++ b/app/Transformers/TagTransformer.php
@@ -121,7 +121,7 @@ class TagTransformer extends TransformerAbstract
'tag' => $tag->tag,
'tag_mode' => $tag->tagMode,
'date' => $date,
- 'description' => $tag->description === '' ? null : $tag->description,
+ 'description' => '' === $tag->description ? null : $tag->description,
'latitude' => (float)$tag->latitude,
'longitude' => (float)$tag->longitude,
'zoom_level' => (int)$tag->zoomLevel,
diff --git a/app/Transformers/UserTransformer.php b/app/Transformers/UserTransformer.php
index dadb23fb94..cca96ecedd 100644
--- a/app/Transformers/UserTransformer.php
+++ b/app/Transformers/UserTransformer.php
@@ -193,7 +193,7 @@ class UserTransformer extends TransformerAbstract
'updated_at' => $user->updated_at->toAtomString(),
'created_at' => $user->created_at->toAtomString(),
'email' => $user->email,
- 'blocked' => (int)$user->blocked === 1,
+ 'blocked' => 1 === (int)$user->blocked,
'blocked_code' => $user->blocked_code,
'role' => $role,
'links' => [
diff --git a/app/User.php b/app/User.php
index 442c9fb290..17a64c29c9 100644
--- a/app/User.php
+++ b/app/User.php
@@ -61,7 +61,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property bool $isAdmin used in admin user controller.
* @property bool $has2FA used in admin user controller.
* @property array $prefs used in admin user controller.
- * @property string password
+ * @property string password
* @property Collection roles
* @property string blocked_code
* @property bool blocked
@@ -216,7 +216,7 @@ class User extends Authenticatable
{
$bytes = random_bytes(16);
- return (string)bin2hex($bytes);
+ return bin2hex($bytes);
}
/**
diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php
index 5125bb6a90..c16c7430ba 100644
--- a/app/Validation/FireflyValidator.php
+++ b/app/Validation/FireflyValidator.php
@@ -243,7 +243,9 @@ class FireflyValidator extends Validator
}
/**
- * @param $attribute
+ * @param string $attribute
+ *
+ * @param string $value
*
* @return bool
*/
@@ -338,7 +340,7 @@ class FireflyValidator extends Validator
$classes = app('config')->get('firefly.rule-triggers');
/** @var TriggerInterface $class */
$class = $classes[$triggerType] ?? false;
- if(false === $class) {
+ if (false === $class) {
return false;
}
@@ -412,7 +414,7 @@ class FireflyValidator extends Validator
public function validateUniqueAccountNumberForUser($attribute, $value, $parameters): bool
{
$accountId = (int)($this->data['id'] ?? 0.0);
- if ($accountId === 0) {
+ if (0 === $accountId) {
$accountId = (int)($parameters[0] ?? 0.0);
}
@@ -421,7 +423,7 @@ class FireflyValidator extends Validator
->where('accounts.user_id', auth()->user()->id)
->where('account_meta.name', 'accountNumber');
- if ((int)$accountId > 0) {
+ if ($accountId > 0) {
// exclude current account from check.
$query->where('account_meta.account_id', '!=', $accountId);
}
@@ -513,66 +515,6 @@ class FireflyValidator extends Validator
return true;
}
- /**
- * @param int $index
- *
- * @return string
- */
- private function getRuleActionName(int $index): string
- {
- $name = $this->data['rule-action'][$index] ?? 'invalid';
- if (!isset($this->data['rule-action'][$index])) {
- $name = $this->data['rule-actions'][$index]['name'] ?? 'invalid';
- }
-
- return $name;
- }
-
- /**
- * @param int $index
- *
- * @return string
- */
- private function getRuleActionValue(int $index): string
- {
- $value = $this->data['rule-action-value'][$index] ?? '';
- if (!isset($this->data['rule-action-value'][$index])) {
- $value = $this->data['rule-actions'][$index]['value'] ?? '';
- }
-
- return $value;
- }
-
- /**
- * @param int $index
- *
- * @return string
- */
- private function getRuleTriggerName(int $index): string
- {
- $name = $this->data['rule-trigger'][$index] ?? 'invalid';
- if (!isset($this->data['rule-trigger'][$index])) {
- $name = $this->data['rule-triggers'][$index]['name'] ?? 'invalid';
- }
-
- return $name;
- }
-
- /**
- * @param int $index
- *
- * @return string
- */
- private function getRuleTriggerValue(int $index): string
- {
- $value = $this->data['rule-trigger-value'][$index] ?? '';
- if (!isset($this->data['rule-trigger-value'][$index])) {
- $value = $this->data['rule-triggers'][$index]['value'] ?? '';
- }
-
- return $value;
- }
-
/**
* @param $value
*
@@ -627,6 +569,7 @@ class FireflyValidator extends Validator
$ignore = $existingAccount->id;
$value = $this->tryDecrypt($value);
+ /** @var Collection $set */
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
/** @var Account $entry */
foreach ($set as $entry) {
@@ -650,6 +593,7 @@ class FireflyValidator extends Validator
$ignore = (int)($parameters[0] ?? 0.0);
$value = $this->tryDecrypt($value);
+ /** @var Collection $set */
$set = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
/** @var Account $entry */
foreach ($set as $entry) {
diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.php
index ad6614a0db..91e4cc47de 100644
--- a/app/Validation/RecurrenceValidation.php
+++ b/app/Validation/RecurrenceValidation.php
@@ -37,6 +37,39 @@ use Log;
*/
trait RecurrenceValidation
{
+ /**
+ * Adds an error to the validator when there are no repetitions in the array of data.
+ *
+ * @param Validator $validator
+ */
+ public function validateOneRepetition(Validator $validator): void
+ {
+ $data = $validator->getData();
+ $repetitions = $data['repetitions'] ?? [];
+ // need at least one transaction
+ if (0 === \count($repetitions)) {
+ $validator->errors()->add('description', (string)trans('validation.at_least_one_repetition'));
+ }
+ }
+
+ /**
+ * Validates that the recurrence has valid repetition information. It either doesn't stop,
+ * or stops after X times or at X date. Not both of them.,
+ *
+ * @param Validator $validator
+ */
+ public function validateRecurrenceRepetition(Validator $validator): void
+ {
+ $data = $validator->getData();
+ $repetitions = $data['nr_of_repetitions'] ?? null;
+ $repeatUntil = $data['repeat_until'] ?? null;
+ if (null !== $repetitions && null !== $repeatUntil) {
+ // expect a date OR count:
+ $validator->errors()->add('repeat_until', (string)trans('validation.require_repeat_until'));
+ $validator->errors()->add('nr_of_repetitions', (string)trans('validation.require_repeat_until'));
+ }
+ }
+
/**
* @param Validator $validator
*/
@@ -73,39 +106,6 @@ trait RecurrenceValidation
}
}
- /**
- * Adds an error to the validator when there are no repetitions in the array of data.
- *
- * @param Validator $validator
- */
- public function validateOneRepetition(Validator $validator): void
- {
- $data = $validator->getData();
- $repetitions = $data['repetitions'] ?? [];
- // need at least one transaction
- if (\count($repetitions) === 0) {
- $validator->errors()->add('description', (string)trans('validation.at_least_one_repetition'));
- }
- }
-
- /**
- * Validates that the recurrence has valid repetition information. It either doesn't stop,
- * or stops after X times or at X date. Not both of them.,
- *
- * @param Validator $validator
- */
- public function validateRecurrenceRepetition(Validator $validator): void
- {
- $data = $validator->getData();
- $repetitions = $data['nr_of_repetitions'] ?? null;
- $repeatUntil = $data['repeat_until'] ?? null;
- if (null !== $repetitions && null !== $repeatUntil) {
- // expect a date OR count:
- $validator->errors()->add('repeat_until', (string)trans('validation.require_repeat_until'));
- $validator->errors()->add('nr_of_repetitions', (string)trans('validation.require_repeat_until'));
- }
- }
-
/**
* If the repetition type is daily, the moment should be empty.
*
@@ -145,7 +145,7 @@ trait RecurrenceValidation
protected function validateNdom(Validator $validator, int $index, string $moment): void
{
$parameters = explode(',', $moment);
- if (\count($parameters) !== 2) {
+ if (2 !== \count($parameters)) {
$validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));
return;
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php
index 1d42ead1bf..cac645acdd 100644
--- a/app/Validation/TransactionValidation.php
+++ b/app/Validation/TransactionValidation.php
@@ -338,13 +338,13 @@ trait TransactionValidation
if ($accountId < 1 && '' === $accountName) {
return null;
}
- if ($accountId !== 0) {
+ if (0 !== $accountId) {
// ID belongs to user and is $type account:
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$repository->setUser($admin);
$set = $repository->getAccountsById([$accountId]);
- if ($set->count() === 1) {
+ if (1 === $set->count()) {
/** @var Account $first */
$first = $set->first();
if ($first->accountType->type !== $type) {
diff --git a/routes/web.php b/routes/web.php
index d68ca517c6..4627af911e 100755
--- a/routes/web.php
+++ b/routes/web.php
@@ -806,7 +806,6 @@ Route::group(
Route::post('update/{rule}', ['uses' => 'Rule\EditController@update', 'as' => 'update']);
-
}
);
diff --git a/tests/Api/V1/Controllers/AvailableBudgetControllerTest.php b/tests/Api/V1/Controllers/AvailableBudgetControllerTest.php
index 2e2f3dd750..cf1d849e7e 100644
--- a/tests/Api/V1/Controllers/AvailableBudgetControllerTest.php
+++ b/tests/Api/V1/Controllers/AvailableBudgetControllerTest.php
@@ -174,7 +174,7 @@ class AvailableBudgetControllerTest extends TestCase
// test API
- $response = $this->post('/api/v1/available_budgets', $data,['Accept' => 'application/json']);
+ $response = $this->post('/api/v1/available_budgets', $data, ['Accept' => 'application/json']);
$response->assertStatus(500);
$response->assertSee('Could not find the indicated currency.');
$response->assertHeader('Content-Type', 'application/json');
diff --git a/tests/Api/V1/Controllers/BillControllerTest.php b/tests/Api/V1/Controllers/BillControllerTest.php
index 8621d3779b..774037d255 100644
--- a/tests/Api/V1/Controllers/BillControllerTest.php
+++ b/tests/Api/V1/Controllers/BillControllerTest.php
@@ -127,6 +127,7 @@ class BillControllerTest extends TestCase
/**
* Store with minimum amount more than maximum amount
+ *
* @covers \FireflyIII\Api\V1\Controllers\BillController
* @covers \FireflyIII\Api\V1\Requests\BillRequest
*/
diff --git a/tests/Api/V1/Controllers/BudgetLimitControllerTest.php b/tests/Api/V1/Controllers/BudgetLimitControllerTest.php
index 5935f47301..d20d9296c5 100644
--- a/tests/Api/V1/Controllers/BudgetLimitControllerTest.php
+++ b/tests/Api/V1/Controllers/BudgetLimitControllerTest.php
@@ -124,7 +124,7 @@ class BudgetLimitControllerTest extends TestCase
'start' => '2018-01-01',
'end' => '2018-01-31',
];
- $uri = '/api/v1/budget_limits?' . http_build_query($params);
+ $uri = '/api/v1/budget_limits?' . http_build_query($params);
$response = $this->get($uri);
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/vnd.api+json');
@@ -149,9 +149,9 @@ class BudgetLimitControllerTest extends TestCase
// call API
$params = [
- 'budget_id' => $budget->id,
- 'start' => '2018-01-01',
- 'end' => '2018-01-31',
+ 'budget_id' => $budget->id,
+ 'start' => '2018-01-01',
+ 'end' => '2018-01-31',
];
$response = $this->get('/api/v1/budget_limits?' . http_build_query($params));
$response->assertStatus(200);
diff --git a/tests/Api/V1/Controllers/CurrencyControllerTest.php b/tests/Api/V1/Controllers/CurrencyControllerTest.php
index b9f0f64fb6..a72d2d3aa1 100644
--- a/tests/Api/V1/Controllers/CurrencyControllerTest.php
+++ b/tests/Api/V1/Controllers/CurrencyControllerTest.php
@@ -97,7 +97,8 @@ class CurrencyControllerTest extends TestCase
$response = $this->get('/api/v1/currencies');
$response->assertStatus(200);
$response->assertJson(['data' => [],]);
- $response->assertJson([
+ $response->assertJson(
+ [
'meta' => [
'pagination' => [
'total' => $collection->count(),
diff --git a/tests/Api/V1/Controllers/CurrencyExchangeRateControllerTest.php b/tests/Api/V1/Controllers/CurrencyExchangeRateControllerTest.php
index d246883ef1..09da194a12 100644
--- a/tests/Api/V1/Controllers/CurrencyExchangeRateControllerTest.php
+++ b/tests/Api/V1/Controllers/CurrencyExchangeRateControllerTest.php
@@ -106,7 +106,7 @@ class CurrencyExchangeRateControllerTest extends TestCase
/**
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
*/
- public function testIndexBadSource(): void
+ public function testIndexBadDestination(): void
{
// mock repository
$repository = $this->mock(CurrencyRepositoryInterface::class);
@@ -122,8 +122,8 @@ class CurrencyExchangeRateControllerTest extends TestCase
// mock calls:
$repository->shouldReceive('setUser')->once();
- $repository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
- $repository->shouldReceive('findByCodeNull')->withArgs(['USD'])->andReturn(TransactionCurrency::whereCode('USD')->first())->once();
+ $repository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(TransactionCurrency::whereCode('USD')->first())->once();
+ $repository->shouldReceive('findByCodeNull')->withArgs(['USD'])->andReturn(null)->once();
// test API
$params = [
@@ -133,14 +133,14 @@ class CurrencyExchangeRateControllerTest extends TestCase
];
$response = $this->get('/api/v1/cer?' . http_build_query($params), ['Accept' => 'application/json']);
$response->assertStatus(500);
- $response->assertSee('Unknown source currency.');
+ $response->assertSee('Unknown destination currency.');
$response->assertHeader('Content-Type', 'application/json');
}
/**
* @covers \FireflyIII\Api\V1\Controllers\CurrencyExchangeRateController
*/
- public function testIndexBadDestination(): void
+ public function testIndexBadSource(): void
{
// mock repository
$repository = $this->mock(CurrencyRepositoryInterface::class);
@@ -156,8 +156,8 @@ class CurrencyExchangeRateControllerTest extends TestCase
// mock calls:
$repository->shouldReceive('setUser')->once();
- $repository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(TransactionCurrency::whereCode('USD')->first())->once();
- $repository->shouldReceive('findByCodeNull')->withArgs(['USD'])->andReturn(null)->once();
+ $repository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
+ $repository->shouldReceive('findByCodeNull')->withArgs(['USD'])->andReturn(TransactionCurrency::whereCode('USD')->first())->once();
// test API
$params = [
@@ -167,7 +167,7 @@ class CurrencyExchangeRateControllerTest extends TestCase
];
$response = $this->get('/api/v1/cer?' . http_build_query($params), ['Accept' => 'application/json']);
$response->assertStatus(500);
- $response->assertSee('Unknown destination currency.');
+ $response->assertSee('Unknown source currency.');
$response->assertHeader('Content-Type', 'application/json');
}
}
diff --git a/tests/Api/V1/Controllers/RecurrenceControllerTest.php b/tests/Api/V1/Controllers/RecurrenceControllerTest.php
index 83ab310195..ac41bf1309 100644
--- a/tests/Api/V1/Controllers/RecurrenceControllerTest.php
+++ b/tests/Api/V1/Controllers/RecurrenceControllerTest.php
@@ -749,12 +749,12 @@ class RecurrenceControllerTest extends TestCase
}
/**
- * Submit the minimum amount to store a recurring transaction (using source ID field).
+ * Add a recurring but refer to an asset as destination.
*
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
*/
- public function testStoreFailInvalidWeekly(): void
+ public function testStoreFailInvalidDestinationId(): void
{
/** @var Recurrence $recurrence */
$recurrence = $this->user()->recurrences()->first();
@@ -776,6 +776,19 @@ class RecurrenceControllerTest extends TestCase
// used by the validator to find the source_id:
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
->andReturn(new Collection([$assetAccount]));
+ $accountRepos->shouldReceive('getAccountsById')->withArgs([[$assetAccount->id]])->once()
+ ->andReturn(new Collection([$assetAccount]));
+
+
+ // entries used by the transformer
+ $repository->shouldReceive('getNoteText')->andReturn('Note text');
+ $repository->shouldReceive('repetitionDescription')->andReturn('Some description.');
+ $repository->shouldReceive('getXOccurrences')->andReturn([]);
+
+ // entries used by the transformer (the fake entry has a category + a budget):
+ $factory->shouldReceive('findOrCreate')->andReturn(null);
+ $budgetRepos->shouldReceive('findNull')->andReturn(null);
+
// data to submit
$firstDate = new Carbon;
@@ -788,16 +801,17 @@ class RecurrenceControllerTest extends TestCase
'active' => 1,
'transactions' => [
[
- 'amount' => '100',
- 'currency_id' => '1',
- 'description' => 'Test description',
- 'source_id' => '1',
+ 'amount' => '100',
+ 'currency_id' => '1',
+ 'description' => 'Test description',
+ 'source_id' => '1',
+ 'destination_id' => $assetAccount->id,
],
],
'repetitions' => [
[
- 'type' => 'weekly',
- 'moment' => '8',
+ 'type' => 'daily',
+ 'moment' => '',
'skip' => '0',
'weekend' => '1',
@@ -811,8 +825,8 @@ class RecurrenceControllerTest extends TestCase
[
'message' => 'The given data was invalid.',
'errors' => [
- 'repetitions.0.moment' => [
- 'Invalid repetition moment for this type of repetition.',
+ 'transactions.0.destination_id' => [
+ 'This value is invalid for this field.',
],
],
]
@@ -973,7 +987,7 @@ class RecurrenceControllerTest extends TestCase
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
*/
- public function testStoreFailInvalidNdomHigh(): void
+ public function testStoreFailInvalidNdomCount(): void
{
/** @var Recurrence $recurrence */
$recurrence = $this->user()->recurrences()->first();
@@ -1016,7 +1030,7 @@ class RecurrenceControllerTest extends TestCase
'repetitions' => [
[
'type' => 'ndom',
- 'moment' => '4,9',
+ 'moment' => '9',
'skip' => '0',
'weekend' => '1',
@@ -1046,7 +1060,7 @@ class RecurrenceControllerTest extends TestCase
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
*/
- public function testStoreFailInvalidNdomCount(): void
+ public function testStoreFailInvalidNdomHigh(): void
{
/** @var Recurrence $recurrence */
$recurrence = $this->user()->recurrences()->first();
@@ -1089,7 +1103,7 @@ class RecurrenceControllerTest extends TestCase
'repetitions' => [
[
'type' => 'ndom',
- 'moment' => '9',
+ 'moment' => '4,9',
'skip' => '0',
'weekend' => '1',
@@ -1114,12 +1128,12 @@ class RecurrenceControllerTest extends TestCase
}
/**
- * Add a recurring but refer to an asset as destination.
+ * Submit the minimum amount to store a recurring transaction (using source ID field).
*
* @covers \FireflyIII\Api\V1\Controllers\RecurrenceController
* @covers \FireflyIII\Api\V1\Requests\RecurrenceRequest
*/
- public function testStoreFailInvalidDestinationId(): void
+ public function testStoreFailInvalidWeekly(): void
{
/** @var Recurrence $recurrence */
$recurrence = $this->user()->recurrences()->first();
@@ -1141,19 +1155,6 @@ class RecurrenceControllerTest extends TestCase
// used by the validator to find the source_id:
$accountRepos->shouldReceive('getAccountsById')->withArgs([[1]])->once()
->andReturn(new Collection([$assetAccount]));
- $accountRepos->shouldReceive('getAccountsById')->withArgs([[$assetAccount->id]])->once()
- ->andReturn(new Collection([$assetAccount]));
-
-
- // entries used by the transformer
- $repository->shouldReceive('getNoteText')->andReturn('Note text');
- $repository->shouldReceive('repetitionDescription')->andReturn('Some description.');
- $repository->shouldReceive('getXOccurrences')->andReturn([]);
-
- // entries used by the transformer (the fake entry has a category + a budget):
- $factory->shouldReceive('findOrCreate')->andReturn(null);
- $budgetRepos->shouldReceive('findNull')->andReturn(null);
-
// data to submit
$firstDate = new Carbon;
@@ -1166,17 +1167,16 @@ class RecurrenceControllerTest extends TestCase
'active' => 1,
'transactions' => [
[
- 'amount' => '100',
- 'currency_id' => '1',
- 'description' => 'Test description',
- 'source_id' => '1',
- 'destination_id' => $assetAccount->id,
+ 'amount' => '100',
+ 'currency_id' => '1',
+ 'description' => 'Test description',
+ 'source_id' => '1',
],
],
'repetitions' => [
[
- 'type' => 'daily',
- 'moment' => '',
+ 'type' => 'weekly',
+ 'moment' => '8',
'skip' => '0',
'weekend' => '1',
@@ -1190,8 +1190,8 @@ class RecurrenceControllerTest extends TestCase
[
'message' => 'The given data was invalid.',
'errors' => [
- 'transactions.0.destination_id' => [
- 'This value is invalid for this field.',
+ 'repetitions.0.moment' => [
+ 'Invalid repetition moment for this type of repetition.',
],
],
]
diff --git a/tests/Feature/Controllers/Account/CreateControllerTest.php b/tests/Feature/Controllers/Account/CreateControllerTest.php
index 8746bbba6e..a378f1bf6a 100644
--- a/tests/Feature/Controllers/Account/CreateControllerTest.php
+++ b/tests/Feature/Controllers/Account/CreateControllerTest.php
@@ -27,7 +27,6 @@ namespace Tests\Feature\Controllers\Account;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionJournal;
-use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
diff --git a/tests/Feature/Controllers/Account/DeleteControllerTest.php b/tests/Feature/Controllers/Account/DeleteControllerTest.php
index 572b4872f1..482df158d7 100644
--- a/tests/Feature/Controllers/Account/DeleteControllerTest.php
+++ b/tests/Feature/Controllers/Account/DeleteControllerTest.php
@@ -30,8 +30,9 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection;
-use Tests\TestCase;
use Log;
+use Tests\TestCase;
+
/**
*
* Class DeleteControllerTest
@@ -46,6 +47,7 @@ class DeleteControllerTest extends TestCase
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
}
+
/**
* @covers \FireflyIII\Http\Controllers\Account\DeleteController
* @covers \FireflyIII\Http\Controllers\Controller
diff --git a/tests/Feature/Controllers/Account/EditControllerTest.php b/tests/Feature/Controllers/Account/EditControllerTest.php
index 2dd3cbcde3..ef9951d705 100644
--- a/tests/Feature/Controllers/Account/EditControllerTest.php
+++ b/tests/Feature/Controllers/Account/EditControllerTest.php
@@ -26,16 +26,16 @@ namespace Tests\Feature\Controllers\Account;
use Amount;
use FireflyIII\Models\AccountType;
-use FireflyIII\Models\Note;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection;
+use Log;
use Mockery;
use Tests\TestCase;
-use Log;
+
/**
*
* Class EditControllerTest
@@ -50,6 +50,7 @@ class EditControllerTest extends TestCase
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
}
+
/**
* @covers \FireflyIII\Http\Controllers\Account\EditController
*/
diff --git a/tests/Feature/Controllers/Account/ReconcileControllerTest.php b/tests/Feature/Controllers/Account/ReconcileControllerTest.php
index 93fded7b6e..16e6883de9 100644
--- a/tests/Feature/Controllers/Account/ReconcileControllerTest.php
+++ b/tests/Feature/Controllers/Account/ReconcileControllerTest.php
@@ -32,8 +32,8 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
-use Tests\TestCase;
use Mockery;
+use Tests\TestCase;
/**
* Class ConfigurationControllerTest
@@ -217,7 +217,7 @@ class ReconcileControllerTest extends TestCase
$journalRepos->shouldReceive('store')->andReturn(new TransactionJournal);
$repository->shouldReceive('getReconciliation')->andReturn(new Account);
$repository->shouldReceive('findNull')->andReturn(new Account);
- $repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(),'currency_id'])->andReturn('1');
+ $repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$data = [
'transactions' => [1, 2, 3],
diff --git a/tests/Feature/Controllers/Account/ShowControllerTest.php b/tests/Feature/Controllers/Account/ShowControllerTest.php
index 3268405a40..355e3973b4 100644
--- a/tests/Feature/Controllers/Account/ShowControllerTest.php
+++ b/tests/Feature/Controllers/Account/ShowControllerTest.php
@@ -147,7 +147,7 @@ class ShowControllerTest extends TestCase
}
/**
- * @covers \FireflyIII\Http\Controllers\Account\ShowController
+ * @covers \FireflyIII\Http\Controllers\Account\ShowController
* @expectedExceptionMessage End is after start!
*/
public function testShowBrokenBadDates(): void
@@ -165,7 +165,7 @@ class ShowControllerTest extends TestCase
}
/**
- * @covers \FireflyIII\Http\Controllers\Account\ShowController
+ * @covers \FireflyIII\Http\Controllers\Account\ShowController
* @expectedExceptionMessage Expected a transaction
*/
public function testShowBrokenInitial(): void
diff --git a/tests/Feature/Controllers/Admin/UpdateControllerTest.php b/tests/Feature/Controllers/Admin/UpdateControllerTest.php
index 0d9212bb35..8b9b0a2d33 100644
--- a/tests/Feature/Controllers/Admin/UpdateControllerTest.php
+++ b/tests/Feature/Controllers/Admin/UpdateControllerTest.php
@@ -97,8 +97,8 @@ class UpdateControllerTest extends TestCase
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
FireflyConfig::shouldReceive('set')->withArgs(['last_update_check', Mockery::any()])->once()->andReturn(new Configuration);
- $version = config('firefly.version');
- $date = new Carbon;
+ $version = config('firefly.version');
+ $date = new Carbon;
$date->subDays(5);
$releases = [
new Release(['id' => 'x', 'title' => $version . '.1', 'content' => '', 'updated' => $date]),
diff --git a/tests/Feature/Controllers/Admin/UserControllerTest.php b/tests/Feature/Controllers/Admin/UserControllerTest.php
index 70d559ff56..298061386e 100644
--- a/tests/Feature/Controllers/Admin/UserControllerTest.php
+++ b/tests/Feature/Controllers/Admin/UserControllerTest.php
@@ -96,7 +96,7 @@ class UserControllerTest extends TestCase
$repository = $this->mock(UserRepositoryInterface::class);
//$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->once()->andReturn(false);
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->times(3)->andReturn(true);
- $user = $this->user();
+ $user = $this->user();
$repository->shouldReceive('all')->andReturn(new Collection([$user]));
$this->be($user);
diff --git a/tests/Feature/Controllers/AttachmentControllerTest.php b/tests/Feature/Controllers/AttachmentControllerTest.php
index 8b96a9ab78..d7d1d9ef32 100644
--- a/tests/Feature/Controllers/AttachmentControllerTest.php
+++ b/tests/Feature/Controllers/AttachmentControllerTest.php
@@ -139,7 +139,7 @@ class AttachmentControllerTest extends TestCase
*/
public function testIndex()
{
- $repository = $this->mock(AttachmentRepositoryInterface::class);
+ $repository = $this->mock(AttachmentRepositoryInterface::class);
$repository->shouldReceive('get')->andReturn(new Collection([Attachment::first()]))->once();
$repository->shouldReceive('exists')->andReturn(true)->once();
diff --git a/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php b/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php
index a7bd6e1f9f..ab9be7b766 100644
--- a/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php
+++ b/tests/Feature/Controllers/Auth/TwoFactorControllerTest.php
@@ -74,8 +74,8 @@ class TwoFactorControllerTest extends TestCase
$falsePreference = new Preference;
$falsePreference->data = false;
- $langPreference = new Preference;
- $langPreference->data = 'en_US';
+ $langPreference = new Preference;
+ $langPreference->data = 'en_US';
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthEnabled', false])->andReturn($falsePreference)->twice();
Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret', null])->andReturn(null)->once();
diff --git a/tests/Feature/Controllers/BillControllerTest.php b/tests/Feature/Controllers/BillControllerTest.php
index 8a29efb42a..5f7d22cb33 100644
--- a/tests/Feature/Controllers/BillControllerTest.php
+++ b/tests/Feature/Controllers/BillControllerTest.php
@@ -27,7 +27,6 @@ use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Rule;
-use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
@@ -65,9 +64,9 @@ class BillControllerTest extends TestCase
public function testCreate(): void
{
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@@ -83,9 +82,9 @@ class BillControllerTest extends TestCase
public function testDelete(): void
{
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@@ -101,10 +100,10 @@ class BillControllerTest extends TestCase
public function testDestroy(): void
{
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$repository->shouldReceive('destroy')->andReturn(true);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
@@ -121,9 +120,9 @@ class BillControllerTest extends TestCase
public function testEdit(): void
{
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@@ -140,11 +139,11 @@ class BillControllerTest extends TestCase
public function testIndex(): void
{
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $bill = factory(Bill::class)->make();
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $bill = factory(Bill::class)->make();
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$collection = new Collection([$bill]);
$repository->shouldReceive('getPaginator')->andReturn(new LengthAwarePaginator($collection, 1, 50))->once();
@@ -166,12 +165,12 @@ class BillControllerTest extends TestCase
public function testRescan(): void
{
// mock stuff
- $rule = Rule::first();
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journal = factory(TransactionJournal::class)->make();
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $rule = Rule::first();
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journal = factory(TransactionJournal::class)->make();
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('getRulesForBill')->andReturn(new Collection([$rule]));
@@ -196,10 +195,10 @@ class BillControllerTest extends TestCase
public function testRescanInactive(): void
{
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@@ -214,11 +213,11 @@ class BillControllerTest extends TestCase
public function testShow(): void
{
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $collector = $this->mock(JournalCollectorInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $collector = $this->mock(JournalCollectorInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$repository->shouldReceive('getYearAverage')->andReturn('0');
$repository->shouldReceive('getOverallAverage')->andReturn('0');
$repository->shouldReceive('nextExpectedMatch')->andReturn(new Carbon);
@@ -252,10 +251,10 @@ class BillControllerTest extends TestCase
$this->be($this->user());
$bill = $this->user()->bills()->first();
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('store')->andReturn($bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');
@@ -286,11 +285,11 @@ class BillControllerTest extends TestCase
public function testStoreCreateAnother(): void
{
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
- $bill = $this->user()->bills()->first();
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
+ $bill = $this->user()->bills()->first();
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('store')->andReturn($bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');
@@ -319,34 +318,31 @@ class BillControllerTest extends TestCase
* @covers \FireflyIII\Http\Requests\BillFormRequest
* @covers \FireflyIII\Http\Requests\Request
*/
- public function testStoreNoGroup(): void
+ public function testStoreError(): void
{
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
- $repository->shouldReceive('store')->andReturn(new Bill);
- $attachHelper->shouldReceive('saveAttachmentsForModel');
- $attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
+ $repository->shouldReceive('store')->andReturn(null);
$data = [
'name' => 'New Bill ' . random_int(1000, 9999),
'amount_min' => '100',
'transaction_currency_id' => 1,
'skip' => 0,
- 'create_another' => '1',
'strict' => 1,
'amount_max' => '100',
'date' => '2016-01-01',
'repeat_freq' => 'monthly',
];
- $this->session(['bills.create.uri' => 'http://localhost']);
$this->be($this->user());
$response = $this->post(route('bills.store'), $data);
$response->assertStatus(302);
- $response->assertSessionHas('success');
+ $response->assertSessionHas('error');
+ $response->assertRedirect(route('bills.create'));
}
/**
@@ -354,31 +350,34 @@ class BillControllerTest extends TestCase
* @covers \FireflyIII\Http\Requests\BillFormRequest
* @covers \FireflyIII\Http\Requests\Request
*/
- public function testStoreError(): void
+ public function testStoreNoGroup(): void
{
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
- $repository->shouldReceive('store')->andReturn(null);
+ $repository->shouldReceive('store')->andReturn(new Bill);
+ $attachHelper->shouldReceive('saveAttachmentsForModel');
+ $attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
$data = [
'name' => 'New Bill ' . random_int(1000, 9999),
'amount_min' => '100',
'transaction_currency_id' => 1,
'skip' => 0,
+ 'create_another' => '1',
'strict' => 1,
'amount_max' => '100',
'date' => '2016-01-01',
'repeat_freq' => 'monthly',
];
+ $this->session(['bills.create.uri' => 'http://localhost']);
$this->be($this->user());
$response = $this->post(route('bills.store'), $data);
$response->assertStatus(302);
- $response->assertSessionHas('error');
- $response->assertRedirect(route('bills.create'));
+ $response->assertSessionHas('success');
}
/**
@@ -389,10 +388,10 @@ class BillControllerTest extends TestCase
public function testUpdate(): void
{
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
- $ruleGroupRepos =$this->mock(RuleGroupRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('update')->andReturn(new Bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');
diff --git a/tests/Feature/Controllers/Category/ShowControllerTest.php b/tests/Feature/Controllers/Category/ShowControllerTest.php
index f6a4eacf11..6e6e1551d2 100644
--- a/tests/Feature/Controllers/Category/ShowControllerTest.php
+++ b/tests/Feature/Controllers/Category/ShowControllerTest.php
@@ -24,13 +24,9 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Category;
-use Tests\TestCase;
-use Log;
-
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Helpers\Filter\InternalTransferFilter;
-use FireflyIII\Models\Category;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -38,7 +34,10 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
+use Log;
use Navigation;
+use Tests\TestCase;
+
/**
*
* Class ShowControllerTest
@@ -200,7 +199,7 @@ class ShowControllerTest extends TestCase
public function testShowEmpty(string $range): void
{
$latestJournal = $this->user()->transactionJournals()
- ->orderBy('date','DESC')->first();
+ ->orderBy('date', 'DESC')->first();
Log::debug(sprintf('Test testShowEmpty(%s)', $range));
$journalRepos = $this->mock(JournalRepositoryInterface::class);
diff --git a/tests/Feature/Controllers/CurrencyControllerTest.php b/tests/Feature/Controllers/CurrencyControllerTest.php
index e39225964d..c2f2dd9a54 100644
--- a/tests/Feature/Controllers/CurrencyControllerTest.php
+++ b/tests/Feature/Controllers/CurrencyControllerTest.php
@@ -29,8 +29,9 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
-use Tests\TestCase;
use Mockery;
+use Tests\TestCase;
+
/**
* Class CurrencyControllerTest
*
diff --git a/tests/Feature/Controllers/HomeControllerTest.php b/tests/Feature/Controllers/HomeControllerTest.php
index a2b68c59b8..73705a6df3 100644
--- a/tests/Feature/Controllers/HomeControllerTest.php
+++ b/tests/Feature/Controllers/HomeControllerTest.php
@@ -22,11 +22,10 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
-use FireflyIII\Models\TransactionCurrency;
-use Mockery;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
+use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
@@ -34,6 +33,7 @@ use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
+use Mockery;
use Tests\TestCase;
/**
@@ -111,11 +111,11 @@ class HomeControllerTest extends TestCase
public function testIndex(string $range): void
{
// mock stuff
- $account = factory(Account::class)->make();
- $collector = $this->mock(JournalCollectorInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $billRepos = $this->mock(BillRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $account = factory(Account::class)->make();
+ $collector = $this->mock(JournalCollectorInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $billRepos = $this->mock(BillRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
$accountRepos->shouldReceive('count')->andReturn(1);
diff --git a/tests/Feature/Controllers/Import/IndexControllerTest.php b/tests/Feature/Controllers/Import/IndexControllerTest.php
index 5a9e2931a0..4e9a0852c1 100644
--- a/tests/Feature/Controllers/Import/IndexControllerTest.php
+++ b/tests/Feature/Controllers/Import/IndexControllerTest.php
@@ -167,7 +167,6 @@ class IndexControllerTest extends TestCase
$ynabPrerequisites->shouldReceive('setUser')->times(2);
-
$repository->shouldReceive('create')->withArgs(['fake'])->andReturn($importJob);
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'has_prereq'])->andReturn($importJob)->once();
diff --git a/tests/Feature/Controllers/JavascriptControllerTest.php b/tests/Feature/Controllers/JavascriptControllerTest.php
index b4f0b30905..b44738fbc3 100644
--- a/tests/Feature/Controllers/JavascriptControllerTest.php
+++ b/tests/Feature/Controllers/JavascriptControllerTest.php
@@ -107,7 +107,6 @@ class JavascriptControllerTest extends TestCase
$response->assertStatus(200);
}
-
/**
* @covers \FireflyIII\Http\Controllers\JavascriptController::variables
* @covers \FireflyIII\Http\Controllers\JavascriptController::getDateRangeConfig
@@ -116,19 +115,17 @@ class JavascriptControllerTest extends TestCase
*
* @dataProvider dateRangeProvider
*/
- public function testVariablesNull(string $range): void
+ public function testVariablesCustom(string $range): void
{
- Amount::shouldReceive('getDefaultCurrency')->andReturn(TransactionCurrency::find(1))->times(2);
- Amount::shouldReceive('getJsConfig')->andReturn([])->once();
-
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn(new Account);
- $currencyRepos->shouldReceive('findNull')->andReturn(null);
-
+ $currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
+
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
+ $this->session(['is_custom_range' => true]);
$response = $this->get(route('javascript.variables'));
$response->assertStatus(200);
}
@@ -141,17 +138,19 @@ class JavascriptControllerTest extends TestCase
*
* @dataProvider dateRangeProvider
*/
- public function testVariablesCustom(string $range): void
+ public function testVariablesNull(string $range): void
{
+ Amount::shouldReceive('getDefaultCurrency')->andReturn(TransactionCurrency::find(1))->times(2);
+ Amount::shouldReceive('getJsConfig')->andReturn([])->once();
+
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn(new Account);
- $currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
- $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
+ $currencyRepos->shouldReceive('findNull')->andReturn(null);
+ $accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
- $this->session(['is_custom_range' => true]);
$response = $this->get(route('javascript.variables'));
$response->assertStatus(200);
}
diff --git a/tests/Feature/Controllers/Json/AutoCompleteControllerTest.php b/tests/Feature/Controllers/Json/AutoCompleteControllerTest.php
index d35cbe837c..6013a992f2 100644
--- a/tests/Feature/Controllers/Json/AutoCompleteControllerTest.php
+++ b/tests/Feature/Controllers/Json/AutoCompleteControllerTest.php
@@ -108,23 +108,6 @@ class AutoCompleteControllerTest extends TestCase
$response->assertStatus(200);
}
-
- /**
- * @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
- */
- public function testCurrencyNames(): void
- {
- $repository = $this->mock(CurrencyRepositoryInterface::class);
-
- $currency = TransactionCurrency::find(1);
- $repository->shouldReceive('get')->andReturn(new Collection([$currency]))->once();
-
- $this->be($this->user());
- $response = $this->get(route('json.currency-names'));
- $response->assertStatus(200);
- $response->assertExactJson(['Euro']);
- }
-
/**
* @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
*/
@@ -159,6 +142,22 @@ class AutoCompleteControllerTest extends TestCase
$response->assertExactJson([$category->name]);
}
+ /**
+ * @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
+ */
+ public function testCurrencyNames(): void
+ {
+ $repository = $this->mock(CurrencyRepositoryInterface::class);
+
+ $currency = TransactionCurrency::find(1);
+ $repository->shouldReceive('get')->andReturn(new Collection([$currency]))->once();
+
+ $this->be($this->user());
+ $response = $this->get(route('json.currency-names'));
+ $response->assertStatus(200);
+ $response->assertExactJson(['Euro']);
+ }
+
/**
* @covers \FireflyIII\Http\Controllers\Json\AutoCompleteController
*/
diff --git a/tests/Feature/Controllers/Json/BoxControllerTest.php b/tests/Feature/Controllers/Json/BoxControllerTest.php
index 377d139d50..23031ea22d 100644
--- a/tests/Feature/Controllers/Json/BoxControllerTest.php
+++ b/tests/Feature/Controllers/Json/BoxControllerTest.php
@@ -117,9 +117,9 @@ class BoxControllerTest extends TestCase
*/
public function testBalanceTransactions(): void
{
- $transaction = new Transaction;
+ $transaction = new Transaction;
$transaction->transaction_currency_id = 1;
- $transaction->transaction_amount ='5';
+ $transaction->transaction_amount = '5';
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
@@ -171,17 +171,20 @@ class BoxControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Json\BoxController::netWorth()
*/
- public function testNetWorthVirtual(): void
+ public function testNetWorthFuture(): void
{
- $account = $this->user()->accounts()->first();
- $account->virtual_balance = '1000';
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
- $accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$account]));
+ $accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
+ $start = new Carbon;
+ $start->addMonths(6)->startOfMonth();
+ $end = clone $start;
+ $end->endOfMonth();
+ $this->session(['start' => $start, 'end' => $end]);
$this->be($this->user());
$response = $this->get(route('json.box.net-worth'));
$response->assertStatus(200);
@@ -207,20 +210,17 @@ class BoxControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Json\BoxController::netWorth()
*/
- public function testNetWorthFuture(): void
+ public function testNetWorthVirtual(): void
{
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
- $accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
+ $account = $this->user()->accounts()->first();
+ $account->virtual_balance = '1000';
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
+ $accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$account]));
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
- $start = new Carbon;
- $start->addMonths(6)->startOfMonth();
- $end = clone $start;
- $end->endOfMonth();
- $this->session(['start' => $start, 'end' => $end]);
$this->be($this->user());
$response = $this->get(route('json.box.net-worth'));
$response->assertStatus(200);
diff --git a/tests/Feature/Controllers/ProfileControllerTest.php b/tests/Feature/Controllers/ProfileControllerTest.php
index 6f157eb889..376e59fa44 100644
--- a/tests/Feature/Controllers/ProfileControllerTest.php
+++ b/tests/Feature/Controllers/ProfileControllerTest.php
@@ -228,9 +228,9 @@ class ProfileControllerTest extends TestCase
$listPref->data = '50';
Preferences::shouldReceive('get')->withArgs(['list-length', '10'])->andReturn($listPref)->once();
- $secretPref= new Preference;
+ $secretPref = new Preference;
$secretPref->data = 'X';
- Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->twice()->andReturn(null,$secretPref);
+ Preferences::shouldReceive('get')->withArgs(['twoFactorAuthSecret'])->twice()->andReturn(null, $secretPref);
// set pref
Preferences::shouldReceive('set')->once()->withArgs(['twoFactorAuthEnabled', 1]);
@@ -313,7 +313,7 @@ class ProfileControllerTest extends TestCase
{
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->once()->andReturn(false);
- $data = [
+ $data = [
'email' => $this->user()->email,
];
$this->be($this->user());
@@ -467,7 +467,7 @@ class ProfileControllerTest extends TestCase
*/
public function testRegenerate(): void
{
- $repository = $this->mock(UserRepositoryInterface::class);
+ $repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->once()->andReturn(false);
$token = '';
$currentToken = Preference::where('user_id', $this->user()->id)->where('name', 'access_token')->first();
diff --git a/tests/Feature/Controllers/Rule/CreateControllerTest.php b/tests/Feature/Controllers/Rule/CreateControllerTest.php
index 87f54a9436..6d29c4db2e 100644
--- a/tests/Feature/Controllers/Rule/CreateControllerTest.php
+++ b/tests/Feature/Controllers/Rule/CreateControllerTest.php
@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace tests\Feature\Controllers\Rule;
-use FireflyIII\Models\Bill;
use FireflyIII\Models\Rule;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
diff --git a/tests/Feature/Controllers/Transaction/BulkControllerTest.php b/tests/Feature/Controllers/Transaction/BulkControllerTest.php
index d8133c1b41..fa6dfaa31a 100644
--- a/tests/Feature/Controllers/Transaction/BulkControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/BulkControllerTest.php
@@ -75,32 +75,6 @@ class BulkControllerTest extends TestCase
$response->assertSee('<ol class="breadcrumb">');
}
- /**
- * @covers \FireflyIII\Http\Controllers\Transaction\BulkController
- * @covers \FireflyIII\Http\Controllers\Transaction\BulkController
- */
- public function testEditNull(): void
- {
- // mock stuff:
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);
- $budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
- $journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
- $journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal, null);
- $journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer');
- $journalRepos->shouldReceive('isJournalReconciled')->andReturn(false);
-
- $transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(4)->get()->pluck('id')->toArray();
-
- $this->be($this->user());
- $response = $this->get(route('transactions.bulk.edit', $transfers));
- $response->assertStatus(200);
- $response->assertSee('Bulk edit a number of transactions');
- // has bread crumb
- $response->assertSee('<ol class="breadcrumb">');
- }
-
/**
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::edit
*/
@@ -136,6 +110,32 @@ class BulkControllerTest extends TestCase
$response->assertSee('multiple destination accounts');
}
+ /**
+ * @covers \FireflyIII\Http\Controllers\Transaction\BulkController
+ * @covers \FireflyIII\Http\Controllers\Transaction\BulkController
+ */
+ public function testEditNull(): void
+ {
+ // mock stuff:
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $budgetRepos = $this->mock(BudgetRepositoryInterface::class);
+ $budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
+ $journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
+ $journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
+ $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal, null);
+ $journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer');
+ $journalRepos->shouldReceive('isJournalReconciled')->andReturn(false);
+
+ $transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(4)->get()->pluck('id')->toArray();
+
+ $this->be($this->user());
+ $response = $this->get(route('transactions.bulk.edit', $transfers));
+ $response->assertStatus(200);
+ $response->assertSee('Bulk edit a number of transactions');
+ // has bread crumb
+ $response->assertSee('<ol class="breadcrumb">');
+ }
+
/**
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::update
* @covers \FireflyIII\Http\Requests\BulkEditJournalRequest
diff --git a/tests/Feature/Controllers/Transaction/LinkControllerTest.php b/tests/Feature/Controllers/Transaction/LinkControllerTest.php
index b11003c189..c19738c74e 100644
--- a/tests/Feature/Controllers/Transaction/LinkControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/LinkControllerTest.php
@@ -107,12 +107,11 @@ class LinkControllerTest extends TestCase
$response->assertRedirect(route('transactions.show', [1]));
}
-
/**
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
*/
- public function testStoreSame(): void
+ public function testStoreAlreadyLinked(): void
{
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
@@ -120,42 +119,36 @@ class LinkControllerTest extends TestCase
'link_other' => 8,
'link_type' => '1_inward',
];
- $journal = $this->user()->transactionJournals()->first();
- $journalRepos->shouldReceive('firstNull')->andReturn($journal);
- $journalRepos->shouldReceive('findNull')->andReturn($journal);
- $repository->shouldReceive('findLink')->andReturn(false);
- $repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
+ $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
+ $journalRepos->shouldReceive('findNull')->andReturn(new TransactionJournal);
+ $repository->shouldReceive('findLink')->andReturn(true);
$this->be($this->user());
- $response = $this->post(route('transactions.link.store', [$journal->id]), $data);
+ $response = $this->post(route('transactions.link.store', [1]), $data);
$response->assertStatus(302);
$response->assertSessionHas('error');
$response->assertRedirect(route('transactions.show', [1]));
}
-
/**
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
*/
- public function testStoreAlreadyLinked(): void
+ public function testStoreInvalid(): void
{
- $repository = $this->mock(LinkTypeRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $data = [
- 'link_other' => 8,
+ $data = [
+ 'link_other' => 0,
'link_type' => '1_inward',
];
- $journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
- $journalRepos->shouldReceive('findNull')->andReturn(new TransactionJournal);
- $repository->shouldReceive('findLink')->andReturn(true);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $journalRepos->shouldReceive('firstNull')->andReturn(null);
+ $journalRepos->shouldReceive('findNull')->andReturn(null);
$this->be($this->user());
$response = $this->post(route('transactions.link.store', [1]), $data);
-
$response->assertStatus(302);
$response->assertSessionHas('error');
$response->assertRedirect(route('transactions.show', [1]));
@@ -165,19 +158,24 @@ class LinkControllerTest extends TestCase
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
*/
- public function testStoreInvalid(): void
+ public function testStoreSame(): void
{
+ $repository = $this->mock(LinkTypeRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
$data = [
- 'link_other' => 0,
+ 'link_other' => 8,
'link_type' => '1_inward',
];
+ $journal = $this->user()->transactionJournals()->first();
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $journalRepos->shouldReceive('firstNull')->andReturn(null);
- $journalRepos->shouldReceive('findNull')->andReturn(null);
+ $journalRepos->shouldReceive('firstNull')->andReturn($journal);
+ $journalRepos->shouldReceive('findNull')->andReturn($journal);
+ $repository->shouldReceive('findLink')->andReturn(false);
+ $repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
$this->be($this->user());
- $response = $this->post(route('transactions.link.store', [1]), $data);
+ $response = $this->post(route('transactions.link.store', [$journal->id]), $data);
+
$response->assertStatus(302);
$response->assertSessionHas('error');
$response->assertRedirect(route('transactions.show', [1]));
diff --git a/tests/Feature/Controllers/Transaction/MassControllerTest.php b/tests/Feature/Controllers/Transaction/MassControllerTest.php
index f722727516..c5f10c2b5b 100644
--- a/tests/Feature/Controllers/Transaction/MassControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/MassControllerTest.php
@@ -202,8 +202,8 @@ class MassControllerTest extends TestCase
'amount' => [$deposit->id => 1600],
'amount_currency_id_amount_' . $deposit->id => 1,
'date' => [$deposit->id => '2014-07-24'],
- 'source_name' => [$deposit->id => 'Job'],
- 'destination_id' => [$deposit->id => 1],
+ 'source_name' => [$deposit->id => 'Job'],
+ 'destination_id' => [$deposit->id => 1],
'category' => [$deposit->id => 'Salary'],
];
diff --git a/tests/Feature/Controllers/Transaction/SingleControllerTest.php b/tests/Feature/Controllers/Transaction/SingleControllerTest.php
index d785a5a5a2..fcb0189be7 100644
--- a/tests/Feature/Controllers/Transaction/SingleControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/SingleControllerTest.php
@@ -29,7 +29,6 @@ use FireflyIII\Events\StoredTransactionJournal;
use FireflyIII\Events\UpdatedTransactionJournal;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Models\AccountType;
-use FireflyIII\Models\Note;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
@@ -849,7 +848,6 @@ class SingleControllerTest extends TestCase
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
-
$linkRepos->shouldReceive('get')->andReturn(new Collection);
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
$attRepos->shouldReceive('saveAttachmentsForModel');
diff --git a/tests/Feature/Controllers/Transaction/SplitControllerTest.php b/tests/Feature/Controllers/Transaction/SplitControllerTest.php
index 6a00a72925..3f0b64ddae 100644
--- a/tests/Feature/Controllers/Transaction/SplitControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/SplitControllerTest.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Transaction;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
-use FireflyIII\Models\AccountType;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
@@ -77,7 +76,6 @@ class SplitControllerTest extends TestCase
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
-
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
$account = $destination->account;
@@ -131,7 +129,6 @@ class SplitControllerTest extends TestCase
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
-
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
@@ -292,15 +289,15 @@ class SplitControllerTest extends TestCase
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
$deposit = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();
$data = [
- 'id' => $deposit->id,
- 'what' => 'deposit',
- 'journal_description' => 'Updated salary',
- 'journal_currency_id' => 1,
+ 'id' => $deposit->id,
+ 'what' => 'deposit',
+ 'journal_description' => 'Updated salary',
+ 'journal_currency_id' => 1,
'journal_destination_id' => 1,
- 'journal_amount' => 1591,
- 'date' => '2014-01-24',
- 'tags' => '',
- 'transactions' => [
+ 'journal_amount' => 1591,
+ 'date' => '2014-01-24',
+ 'tags' => '',
+ 'transactions' => [
[
'transaction_description' => 'Split #1',
'source_name' => 'Job',
@@ -342,15 +339,15 @@ class SplitControllerTest extends TestCase
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
$data = [
- 'id' => $opening->id,
- 'what' => 'opening balance',
- 'journal_description' => 'Updated salary',
- 'journal_currency_id' => 1,
+ 'id' => $opening->id,
+ 'what' => 'opening balance',
+ 'journal_description' => 'Updated salary',
+ 'journal_currency_id' => 1,
'journal_destination_id' => 1,
- 'journal_amount' => 1591,
- 'date' => '2014-01-24',
- 'tags' => '',
- 'transactions' => [
+ 'journal_amount' => 1591,
+ 'date' => '2014-01-24',
+ 'tags' => '',
+ 'transactions' => [
[
'transaction_description' => 'Split #1',
'source_name' => 'Job',
@@ -390,18 +387,18 @@ class SplitControllerTest extends TestCase
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
$data = [
- 'id' => $transfer->id,
- 'what' => 'transfer',
- 'journal_description' => 'Some updated withdrawal',
- 'journal_currency_id' => 1,
- 'journal_source_id' => 1,
- 'journal_amount' => 1591,
- 'date' => '2014-01-24',
- 'tags' => '',
- 'transactions' => [
+ 'id' => $transfer->id,
+ 'what' => 'transfer',
+ 'journal_description' => 'Some updated withdrawal',
+ 'journal_currency_id' => 1,
+ 'journal_source_id' => 1,
+ 'journal_amount' => 1591,
+ 'date' => '2014-01-24',
+ 'tags' => '',
+ 'transactions' => [
[
'transaction_description' => 'Split #1',
- 'source_id' => '1',
+ 'source_id' => '1',
'destination_id' => '2',
'transaction_currency_id' => 1,
'amount' => 1591,
@@ -446,15 +443,15 @@ class SplitControllerTest extends TestCase
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
$withdrawal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 1)->first();
$data = [
- 'id' => $withdrawal->id,
- 'what' => 'withdrawal',
- 'journal_description' => 'Some updated withdrawal',
- 'journal_currency_id' => 1,
- 'journal_source_id' => 1,
- 'journal_amount' => 1591,
- 'date' => '2014-01-24',
- 'tags' => '',
- 'transactions' => [
+ 'id' => $withdrawal->id,
+ 'what' => 'withdrawal',
+ 'journal_description' => 'Some updated withdrawal',
+ 'journal_currency_id' => 1,
+ 'journal_source_id' => 1,
+ 'journal_amount' => 1591,
+ 'date' => '2014-01-24',
+ 'tags' => '',
+ 'transactions' => [
[
'transaction_description' => 'Split #1',
'source_id' => '1',
diff --git a/tests/Feature/Controllers/TransactionControllerTest.php b/tests/Feature/Controllers/TransactionControllerTest.php
index 73cb4f7d6b..8659944402 100644
--- a/tests/Feature/Controllers/TransactionControllerTest.php
+++ b/tests/Feature/Controllers/TransactionControllerTest.php
@@ -65,7 +65,7 @@ class TransactionControllerTest extends TestCase
$this->session(['start' => $date, 'end' => clone $date]);
// mock stuff
- $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
+ $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
$repository->shouldReceive('firstNull')->twice()->andReturn($transfer);
@@ -99,7 +99,7 @@ class TransactionControllerTest extends TestCase
$this->session(['start' => $date, 'end' => clone $date]);
// mock stuff
- $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
+ $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
$repository->shouldReceive('firstNull')->twice()->andReturn($transfer);
@@ -143,7 +143,7 @@ class TransactionControllerTest extends TestCase
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
- $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
+ $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
@@ -186,7 +186,7 @@ class TransactionControllerTest extends TestCase
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
- $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
+ $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
@@ -204,7 +204,7 @@ class TransactionControllerTest extends TestCase
$collector->shouldReceive('getJournals')->andReturn($collection);
$this->be($this->user());
- $response = $this->get(route('transactions.index', ['transfer', '2016-01-01','2015-12-31']));
+ $response = $this->get(route('transactions.index', ['transfer', '2016-01-01', '2015-12-31']));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
@@ -229,7 +229,7 @@ class TransactionControllerTest extends TestCase
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
- $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
+ $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
@@ -272,7 +272,7 @@ class TransactionControllerTest extends TestCase
// mock stuff
$repository = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
- $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
+ $transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
$repository->shouldReceive('firstNull')->once()->andReturn($transfer);
diff --git a/tests/Object/FakeApiContext.php b/tests/Object/FakeApiContext.php
index 7157692db4..a929bbac42 100644
--- a/tests/Object/FakeApiContext.php
+++ b/tests/Object/FakeApiContext.php
@@ -31,7 +31,8 @@ class FakeApiContext
/**
* @return string
*/
- public function toJson(): string{
+ public function toJson(): string
+ {
return json_encode(['a' => 'b']);
}
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 8dcba3a554..e9d9b35d3e 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -42,7 +42,6 @@ abstract class TestCase extends BaseTestCase
{
-
/**
* @param User $user
* @param string $range
diff --git a/tests/Unit/Factory/AccountFactoryTest.php b/tests/Unit/Factory/AccountFactoryTest.php
index 58068f4cc9..8e8bd86452 100644
--- a/tests/Unit/Factory/AccountFactoryTest.php
+++ b/tests/Unit/Factory/AccountFactoryTest.php
@@ -69,29 +69,30 @@ class AccountFactoryTest extends TestCase
// get the role:
/** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','accountRole')->first();
+ $meta = $account->accountMeta()->where('name', 'accountRole')->first();
$this->assertNotNull($meta);
$this->assertEquals('defaultAsset', $meta->data);
}
/**
- * Test minimal set of data to make factory work (asset account).
+ * Test creation of CC asset.
*
* @covers \FireflyIII\Factory\AccountFactory
* @covers \FireflyIII\Factory\AccountMetaFactory
* @covers \FireflyIII\Services\Internal\Support\AccountServiceTrait
*/
- public function testCreateBasicEmptyVb(): void
+ public function testCreateBasicCC(): void
{
$data = [
- 'account_type_id' => null,
- 'accountType' => 'asset',
- 'iban' => null,
- 'name' => 'Basic asset account #' . random_int(1, 10000),
- 'virtualBalance' => '',
- 'active' => true,
- 'accountRole' => 'defaultAsset',
+ 'account_type_id' => null,
+ 'accountType' => 'asset',
+ 'iban' => null,
+ 'name' => 'Basic CC account #' . random_int(1, 10000),
+ 'virtualBalance' => null,
+ 'active' => true,
+ 'accountRole' => 'ccAsset',
+ 'ccMonthlyPaymentDate' => '2018-01-01',
];
/** @var AccountFactory $factory */
@@ -108,30 +109,35 @@ class AccountFactoryTest extends TestCase
// get the role:
/** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','accountRole')->first();
+ $meta = $account->accountMeta()->where('name', 'accountRole')->first();
$this->assertNotNull($meta);
- $this->assertEquals('defaultAsset', $meta->data);
+ $this->assertEquals('ccAsset', $meta->data);
+
+ // get the date:
+ /** @var AccountMeta $meta */
+ $meta = $account->accountMeta()->where('name', 'ccMonthlyPaymentDate')->first();
+ $this->assertNotNull($meta);
+ $this->assertEquals('2018-01-01', $meta->data);
}
/**
- * Test creation of CC asset.
+ * Test minimal set of data to make factory work (asset account).
*
* @covers \FireflyIII\Factory\AccountFactory
* @covers \FireflyIII\Factory\AccountMetaFactory
* @covers \FireflyIII\Services\Internal\Support\AccountServiceTrait
*/
- public function testCreateBasicCC(): void
+ public function testCreateBasicEmptyVb(): void
{
$data = [
- 'account_type_id' => null,
- 'accountType' => 'asset',
- 'iban' => null,
- 'name' => 'Basic CC account #' . random_int(1, 10000),
- 'virtualBalance' => null,
- 'active' => true,
- 'accountRole' => 'ccAsset',
- 'ccMonthlyPaymentDate' => '2018-01-01',
+ 'account_type_id' => null,
+ 'accountType' => 'asset',
+ 'iban' => null,
+ 'name' => 'Basic asset account #' . random_int(1, 10000),
+ 'virtualBalance' => '',
+ 'active' => true,
+ 'accountRole' => 'defaultAsset',
];
/** @var AccountFactory $factory */
@@ -148,15 +154,9 @@ class AccountFactoryTest extends TestCase
// get the role:
/** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','accountRole')->first();
+ $meta = $account->accountMeta()->where('name', 'accountRole')->first();
$this->assertNotNull($meta);
- $this->assertEquals('ccAsset', $meta->data);
-
- // get the date:
- /** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','ccMonthlyPaymentDate')->first();
- $this->assertNotNull($meta);
- $this->assertEquals('2018-01-01', $meta->data);
+ $this->assertEquals('defaultAsset', $meta->data);
}
/**
@@ -194,7 +194,7 @@ class AccountFactoryTest extends TestCase
// get the role:
/** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','accountRole')->first();
+ $meta = $account->accountMeta()->where('name', 'accountRole')->first();
$this->assertNull($meta);
}
@@ -233,7 +233,7 @@ class AccountFactoryTest extends TestCase
// get the role:
/** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','accountRole')->first();
+ $meta = $account->accountMeta()->where('name', 'accountRole')->first();
$this->assertNull($meta);
}
@@ -274,7 +274,7 @@ class AccountFactoryTest extends TestCase
// get the role:
/** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','accountRole')->first();
+ $meta = $account->accountMeta()->where('name', 'accountRole')->first();
$this->assertNotNull($meta);
$this->assertEquals('defaultAsset', $meta->data);
@@ -320,7 +320,7 @@ class AccountFactoryTest extends TestCase
// get the role:
/** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','accountRole')->first();
+ $meta = $account->accountMeta()->where('name', 'accountRole')->first();
$this->assertNotNull($meta);
$this->assertEquals('defaultAsset', $meta->data);
@@ -362,7 +362,7 @@ class AccountFactoryTest extends TestCase
// get the role:
/** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','accountRole')->first();
+ $meta = $account->accountMeta()->where('name', 'accountRole')->first();
$this->assertNotNull($meta);
$this->assertEquals('defaultAsset', $meta->data);
}
@@ -401,7 +401,7 @@ class AccountFactoryTest extends TestCase
// get the role:
/** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','accountRole')->first();
+ $meta = $account->accountMeta()->where('name', 'accountRole')->first();
$this->assertNotNull($meta);
$this->assertEquals('defaultAsset', $meta->data);
}
@@ -443,7 +443,7 @@ class AccountFactoryTest extends TestCase
// get the role:
/** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','accountRole')->first();
+ $meta = $account->accountMeta()->where('name', 'accountRole')->first();
$this->assertNotNull($meta);
$this->assertEquals('defaultAsset', $meta->data);
@@ -487,7 +487,7 @@ class AccountFactoryTest extends TestCase
// get the role:
/** @var AccountMeta $meta */
- $meta = $account->accountMeta()->where('name','accountRole')->first();
+ $meta = $account->accountMeta()->where('name', 'accountRole')->first();
$this->assertNotNull($meta);
$this->assertEquals('defaultAsset', $meta->data);
diff --git a/tests/Unit/Factory/TransactionCurrencyFactoryTest.php b/tests/Unit/Factory/TransactionCurrencyFactoryTest.php
index 2805aba8cc..3172100117 100644
--- a/tests/Unit/Factory/TransactionCurrencyFactoryTest.php
+++ b/tests/Unit/Factory/TransactionCurrencyFactoryTest.php
@@ -68,41 +68,41 @@ class TransactionCurrencyFactoryTest extends TestCase
}
/**
+ * submit ID = 1000
+ *
* @covers \FireflyIII\Factory\TransactionCurrencyFactory
*/
- public function testFindByCode(): void
+ public function testFindByBadID(): void
{
- // ;
$currency = TransactionCurrency::inRandomOrder()->whereNull('deleted_at')->first();
/** @var TransactionCurrencyFactory $factory */
$factory = app(TransactionCurrencyFactory::class);
- $result = $factory->find(null, $currency->code);
+ $result = $factory->find(1000, $currency->code);
$this->assertEquals($currency->id, $result->id);
}
/**
* @covers \FireflyIII\Factory\TransactionCurrencyFactory
*/
- public function testFindByID(): void
+ public function testFindByCode(): void
{
+ // ;
$currency = TransactionCurrency::inRandomOrder()->whereNull('deleted_at')->first();
/** @var TransactionCurrencyFactory $factory */
$factory = app(TransactionCurrencyFactory::class);
- $result = $factory->find($currency->id, null);
+ $result = $factory->find(null, $currency->code);
$this->assertEquals($currency->id, $result->id);
}
/**
- * submit ID = 1000
- *
* @covers \FireflyIII\Factory\TransactionCurrencyFactory
*/
- public function testFindByBadID(): void
+ public function testFindByID(): void
{
$currency = TransactionCurrency::inRandomOrder()->whereNull('deleted_at')->first();
/** @var TransactionCurrencyFactory $factory */
$factory = app(TransactionCurrencyFactory::class);
- $result = $factory->find(1000, $currency->code);
+ $result = $factory->find($currency->id, null);
$this->assertEquals($currency->id, $result->id);
}
diff --git a/tests/Unit/Factory/TransactionFactoryTest.php b/tests/Unit/Factory/TransactionFactoryTest.php
index f34ad9524c..af7cb0b039 100644
--- a/tests/Unit/Factory/TransactionFactoryTest.php
+++ b/tests/Unit/Factory/TransactionFactoryTest.php
@@ -704,11 +704,11 @@ class TransactionFactoryTest extends TestCase
public function testCreatePairReconciliation(): void
{
// objects:
- $asset = $this->user()->accounts()->where('account_type_id', 3)->first();
+ $asset = $this->user()->accounts()->where('account_type_id', 3)->first();
$reconAccount = $this->user()->accounts()->where('account_type_id', 10)->first();
//$opposing = $this->user()->accounts()->where('id', '!=', $asset->id)->where('account_type_id', 3)->first();
- $euro = TransactionCurrency::first();
- $foreign = TransactionCurrency::where('id', '!=', $euro->id)->first();
+ $euro = TransactionCurrency::first();
+ $foreign = TransactionCurrency::where('id', '!=', $euro->id)->first();
// mocked classes
$accountRepos = $this->mock(AccountRepositoryInterface::class);
diff --git a/tests/Unit/Factory/TransactionJournalMetaFactoryTest.php b/tests/Unit/Factory/TransactionJournalMetaFactoryTest.php
index e17427694a..748308c763 100644
--- a/tests/Unit/Factory/TransactionJournalMetaFactoryTest.php
+++ b/tests/Unit/Factory/TransactionJournalMetaFactoryTest.php
@@ -90,7 +90,7 @@ class TransactionJournalMetaFactoryTest extends TestCase
'data' => 'bye!',
]
);
- $count = $journal->transactionJournalMeta()->count();
+ $count = $journal->transactionJournalMeta()->count();
$set = [
'journal' => $journal,
@@ -101,7 +101,7 @@ class TransactionJournalMetaFactoryTest extends TestCase
$factory = app(TransactionJournalMetaFactory::class);
$factory->updateOrCreate($set);
- $this->assertEquals($count-1, $journal->transactionJournalMeta()->count());
+ $this->assertEquals($count - 1, $journal->transactionJournalMeta()->count());
}
/**
diff --git a/tests/Unit/Import/Converter/AmountCreditTest.php b/tests/Unit/Import/Converter/AmountCreditTest.php
index 7bcde6b83a..955c78c25e 100644
--- a/tests/Unit/Import/Converter/AmountCreditTest.php
+++ b/tests/Unit/Import/Converter/AmountCreditTest.php
@@ -169,7 +169,7 @@ class AmountCreditTest extends TestCase
foreach ($values as $value => $expected) {
$converter = new AmountCredit;
$result = $converter->convert($value);
- //$this->assertEquals($expected, $result, sprintf('The original value was %s, expected was %s', $value, $expected));
+ //$this->assertEquals($expected, $result, sprintf('The original value was %s, expected was %s', $value, $expected));
}
}
diff --git a/tests/Unit/Import/Routine/SpectreRoutineTest.php b/tests/Unit/Import/Routine/SpectreRoutineTest.php
index 7883f257ba..722f704d3c 100644
--- a/tests/Unit/Import/Routine/SpectreRoutineTest.php
+++ b/tests/Unit/Import/Routine/SpectreRoutineTest.php
@@ -28,8 +28,8 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Import\Routine\SpectreRoutine;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
-use FireflyIII\Support\Import\Routine\Spectre\StageImportDataHandler;
use FireflyIII\Support\Import\Routine\Spectre\StageAuthenticatedHandler;
+use FireflyIII\Support\Import\Routine\Spectre\StageImportDataHandler;
use FireflyIII\Support\Import\Routine\Spectre\StageNewHandler;
use Mockery;
use Tests\TestCase;
@@ -42,24 +42,31 @@ class SpectreRoutineTest extends TestCase
/**
* @covers \FireflyIII\Import\Routine\SpectreRoutine
*/
- public function testRunDoAuthenticate(): void
+ public function testRunAuthenticated(): void
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
- $job->key = 'SR1A' . random_int(1, 10000);
+ $job->key = 'SR2b' . random_int(1, 10000);
$job->status = 'ready_to_run';
- $job->stage = 'do-authenticate';
+ $job->stage = 'authenticated';
$job->provider = 'spectre';
$job->file_type = '';
$job->configuration = [];
$job->save();
// mock handler and repository
+ $handler = $this->mock(StageAuthenticatedHandler::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
// mock calls for repository
$repository->shouldReceive('setUser')->once();
+ $repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'running'])->once();
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'need_job_config'])->once();
+ $repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'choose-accounts'])->once();
+
+ // mock calls for handler
+ $handler->shouldReceive('setImportJob')->once();
+ $handler->shouldReceive('run')->once();
$routine = new SpectreRoutine;
$routine->setImportJob($job);
@@ -73,31 +80,24 @@ class SpectreRoutineTest extends TestCase
/**
* @covers \FireflyIII\Import\Routine\SpectreRoutine
*/
- public function testRunAuthenticated(): void
+ public function testRunDoAuthenticate(): void
{
$job = new ImportJob;
$job->user_id = $this->user()->id;
- $job->key = 'SR2b' . random_int(1, 10000);
+ $job->key = 'SR1A' . random_int(1, 10000);
$job->status = 'ready_to_run';
- $job->stage = 'authenticated';
+ $job->stage = 'do-authenticate';
$job->provider = 'spectre';
$job->file_type = '';
$job->configuration = [];
$job->save();
// mock handler and repository
- $handler = $this->mock(StageAuthenticatedHandler::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
// mock calls for repository
$repository->shouldReceive('setUser')->once();
- $repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'running'])->once();
$repository->shouldReceive('setStatus')->withArgs([Mockery::any(), 'need_job_config'])->once();
- $repository->shouldReceive('setStage')->withArgs([Mockery::any(), 'choose-accounts'])->once();
-
- // mock calls for handler
- $handler->shouldReceive('setImportJob')->once();
- $handler->shouldReceive('run')->once();
$routine = new SpectreRoutine;
$routine->setImportJob($job);
diff --git a/tests/Unit/Import/Specifics/AbnAmroDescriptionTest.php b/tests/Unit/Import/Specifics/AbnAmroDescriptionTest.php
index 0e37954d12..6d5f6e2cd4 100644
--- a/tests/Unit/Import/Specifics/AbnAmroDescriptionTest.php
+++ b/tests/Unit/Import/Specifics/AbnAmroDescriptionTest.php
@@ -112,7 +112,9 @@ class AbnAmroDescriptionTest extends TestCase
*/
public function testSepaBasic(): void
{
- $row = [0, 1, 2, 3, 4, 5, 6, 'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: 1232138 1232131233 412321 iBOOD.com iBOOD.com B.V. Kenmerk: 12-12-2014 21:03 002000 0213123238', '',''];
+ $row = [0, 1, 2, 3, 4, 5, 6,
+ 'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: 1232138 1232131233 412321 iBOOD.com iBOOD.com B.V. Kenmerk: 12-12-2014 21:03 002000 0213123238',
+ '', ''];
$parser = new AbnAmroDescription;
$result = $parser->run($row);
$this->assertEquals('1232138 1232131233 412321 iBOOD.com iBOOD.com B.V.', $result[7]);
@@ -127,7 +129,9 @@ class AbnAmroDescriptionTest extends TestCase
*/
public function testSepaBasicNoDescription(): void
{
- $row = [0, 1, 2, 3, 4, 5, 6, 'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: Kenmerk: 12-12-2014 21:03 002000 0213123238', '',''];
+ $row = [0, 1, 2, 3, 4, 5, 6,
+ 'SEPA PLAIN: SEPA iDEAL IBAN: NL12RABO0121212212 BIC: RABONL2U Naam: Silver Ocean B.V. Omschrijving: Kenmerk: 12-12-2014 21:03 002000 0213123238',
+ '', ''];
$parser = new AbnAmroDescription;
$result = $parser->run($row);
$this->assertEquals(' PLAIN: SEPA iDEAL - Silver Ocean B.V. (12-12-2014)', $result[7]);
@@ -140,23 +144,27 @@ class AbnAmroDescriptionTest extends TestCase
*
* @covers \FireflyIII\Import\Specifics\AbnAmroDescription
*/
- public function testTRTPBasic(): void {
+ public function testTRTPBasic(): void
+ {
- $row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI/Nullijn/EREF/NOTPROVIDED', '',''];
+ $row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI/Nullijn/EREF/NOTPROVIDED', '',
+ ''];
$parser = new AbnAmroDescription;
$result = $parser->run($row);
$this->assertEquals('Nullijn', $result[7]);
$this->assertEquals('baasd dsdsT CJ', $result[8]);
$this->assertEquals('NL23ABNA0000000000', $result[9]);
}
+
/**
* Basic TRTP data with empty description
*
* @covers \FireflyIII\Import\Specifics\AbnAmroDescription
*/
- public function testTRTPEmptyDescr(): void {
+ public function testTRTPEmptyDescr(): void
+ {
- $row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI//EREF/NOTPROVIDED', '',''];
+ $row = [0, 1, 2, 3, 4, 5, 6, '/TRTP/SEPA OVERBOEKING/IBAN/NL23ABNA0000000000/BIC/ABNANL2A/NAME/baasd dsdsT CJ/REMI//EREF/NOTPROVIDED', '', ''];
$parser = new AbnAmroDescription;
$result = $parser->run($row);
$this->assertEquals('SEPA OVERBOEKING - (NOTPROVIDED)', $result[7]);
diff --git a/tests/Unit/Import/Specifics/IngDescriptionTest.php b/tests/Unit/Import/Specifics/IngDescriptionTest.php
index f9e142f773..d068516ddf 100644
--- a/tests/Unit/Import/Specifics/IngDescriptionTest.php
+++ b/tests/Unit/Import/Specifics/IngDescriptionTest.php
@@ -33,44 +33,45 @@ use Tests\TestCase;
class IngDescriptionTest extends TestCase
{
/**
- * Try if the IBAN is removed in GT transactions
+ * Test changes to BA row.
+ *
+ * Remove specific fields.
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
- public function testRunGTRemoveIban(): void
+ public function testRunBABasic(): void
{
- $iban = 'NL66INGB0665877351';
- $row = [0, 1, 2, $iban, 'GT', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
+ $row = [0, 'XX', 2, '', 'BA', 5, 6, 7, 'XX', 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
- $this->assertEquals('Should be removed', $result[8]);
+ $this->assertEquals('XX XX', $result[8]);
}
/**
- * Try if the IBAN is removed in OV transactions
+ * Empty description? Use "tegenrekening".
+ * Remove specific fields.
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
- public function testRunOVRemoveIban(): void
+ public function testRunEmptyDescr(): void
{
- $iban = 'NL66INGB0665877351';
- $row = [0, 1, 2, $iban, 'OV', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
+ $row = [0, 1, 2, '', 'GT', 5, 6, 7, 'Naar Oranje Spaarrekening Bla bla', 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
- $this->assertEquals('Should be removed', $result[8]);
+ $this->assertEquals('Bla bla', $result[3]);
}
/**
- * Try if the IBAN is removed in IC transactions
+ * See if the description is removed
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
- public function testRunICRemoveIban(): void
+ public function testRunGTRemoveDescr(): void
{
$iban = 'NL66INGB0665877351';
- $row = [0, 1, 2, $iban, 'IC', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
+ $row = [0, 1, 2, $iban, 'GT', 5, 6, 7, 'Bla bla bla Omschrijving: Should be removed IBAN: ' . $iban, 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
@@ -78,44 +79,44 @@ class IngDescriptionTest extends TestCase
}
/**
- * Empty description? Use "tegenrekening".
- * Remove specific fields.
+ * Try if the IBAN is removed in GT transactions
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
- public function testRunEmptyDescr(): void
+ public function testRunGTRemoveIban(): void
{
- $row = [0, 1, 2, '', 'GT', 5, 6, 7, 'Naar Oranje Spaarrekening Bla bla', 9, 10];
+ $iban = 'NL66INGB0665877351';
+ $row = [0, 1, 2, $iban, 'GT', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
- $this->assertEquals('Bla bla', $result[3]);
+ $this->assertEquals('Should be removed', $result[8]);
}
/**
- * Test changes to BA row.
- *
- * Remove specific fields.
+ * Try if the IBAN is removed in IC transactions
*
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
- public function testRunBABasic(): void
+ public function testRunICRemoveIban(): void
{
- $row = [0, 'XX', 2, '', 'BA', 5, 6, 7, 'XX', 9, 10];
+ $iban = 'NL66INGB0665877351';
+ $row = [0, 1, 2, $iban, 'IC', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
- $this->assertEquals('XX XX', $result[8]);
+ $this->assertEquals('Should be removed', $result[8]);
}
/**
- * See if the description is removed
+ * Try if the IBAN is removed in OV transactions
+ *
* @covers \FireflyIII\Import\Specifics\IngDescription
*/
- public function testRunGTRemoveDescr(): void
+ public function testRunOVRemoveIban(): void
{
$iban = 'NL66INGB0665877351';
- $row = [0, 1, 2, $iban, 'GT', 5, 6, 7, 'Bla bla bla Omschrijving: Should be removed IBAN: ' . $iban, 9, 10];
+ $row = [0, 1, 2, $iban, 'OV', 5, 6, 7, 'Should be removed IBAN: ' . $iban, 9, 10];
$parser = new IngDescription;
$result = $parser->run($row);
diff --git a/tests/Unit/Import/Specifics/PresidentsChoiceTest.php b/tests/Unit/Import/Specifics/PresidentsChoiceTest.php
index e2ba5bd6e6..09bcb96393 100644
--- a/tests/Unit/Import/Specifics/PresidentsChoiceTest.php
+++ b/tests/Unit/Import/Specifics/PresidentsChoiceTest.php
@@ -36,25 +36,27 @@ class PresidentsChoiceTest extends TestCase
/**
* @covers \FireflyIII\Import\Specifics\PresidentsChoice
*/
- public function testRunBasic():void {
- $row = [''];
+ public function testRunAmount(): void
+ {
+ $row = ['', 'Descr', '12.34', '', ''];
$parser = new PresidentsChoice;
$result = $parser->run($row);
- $this->assertEquals($row, $result);
+ $this->assertEquals('-12.34', $result[3]);
+ $this->assertEquals('Descr', $result[2]);
}
/**
* @covers \FireflyIII\Import\Specifics\PresidentsChoice
*/
- public function testRunAmount():void {
- $row = ['','Descr','12.34','',''];
+ public function testRunBasic(): void
+ {
+ $row = [''];
$parser = new PresidentsChoice;
$result = $parser->run($row);
- $this->assertEquals('-12.34', $result[3]);
- $this->assertEquals('Descr', $result[2]);
+ $this->assertEquals($row, $result);
}
diff --git a/tests/Unit/Import/Storage/ImportArrayStorageTest.php b/tests/Unit/Import/Storage/ImportArrayStorageTest.php
index 396fa42acb..2bb21582cf 100644
--- a/tests/Unit/Import/Storage/ImportArrayStorageTest.php
+++ b/tests/Unit/Import/Storage/ImportArrayStorageTest.php
@@ -155,8 +155,6 @@ class ImportArrayStorageTest extends TestCase
$collector->shouldReceive('addFilter')->andReturnSelf();
-
-
$storage = new ImportArrayStorage;
$storage->setImportJob($job);
$result = new Collection;
@@ -409,7 +407,6 @@ class ImportArrayStorageTest extends TestCase
$journalRepos->shouldReceive('findByHash')->andReturn(null)->times(2);
-
$storage = new ImportArrayStorage;
$storage->setImportJob($job);
$result = new Collection;
diff --git a/tests/Unit/Middleware/AuthenticateTest.php b/tests/Unit/Middleware/AuthenticateTest.php
index ad316d6194..844b5e6b1d 100644
--- a/tests/Unit/Middleware/AuthenticateTest.php
+++ b/tests/Unit/Middleware/AuthenticateTest.php
@@ -23,10 +23,11 @@ declare(strict_types=1);
namespace Tests\Unit\Middleware;
+use Log;
use Route;
use Symfony\Component\HttpFoundation\Response;
use Tests\TestCase;
-use Log;
+
/**
* Class AuthenticateTest
*/
diff --git a/tests/Unit/Middleware/BinderTest.php b/tests/Unit/Middleware/BinderTest.php
index 1558a05b9c..584c33a6bb 100644
--- a/tests/Unit/Middleware/BinderTest.php
+++ b/tests/Unit/Middleware/BinderTest.php
@@ -534,7 +534,7 @@ class BinderTest extends TestCase
);
// mock fiscal helper:
- $date = new Carbon;
+ $date = new Carbon;
$helper = $this->mock(FiscalHelperInterface::class);
$helper->shouldReceive('endOfFiscalYear')->andReturn($date)->once();
$helper->shouldReceive('startOfFiscalYear')->andReturn($date)->once();
diff --git a/tests/Unit/Middleware/IsDemoUserTest.php b/tests/Unit/Middleware/IsDemoUserTest.php
index c2d0ad4f5f..2a56a6c7fa 100644
--- a/tests/Unit/Middleware/IsDemoUserTest.php
+++ b/tests/Unit/Middleware/IsDemoUserTest.php
@@ -47,21 +47,21 @@ class IsDemoUserTest extends TestCase
/**
* @covers \FireflyIII\Http\Middleware\IsDemoUser
*/
- public function testMiddlewareNotAuthenticated(): void
+ public function testMiddlewareIsDemoUser(): void
{
+ $this->be($this->demoUser());
$response = $this->get('/_test/is-demo');
- $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+ $this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode());
+ $response->assertSessionHas('info');
}
/**
* @covers \FireflyIII\Http\Middleware\IsDemoUser
*/
- public function testMiddlewareIsDemoUser(): void
+ public function testMiddlewareNotAuthenticated(): void
{
- $this->be($this->demoUser());
$response = $this->get('/_test/is-demo');
- $this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode());
- $response->assertSessionHas('info');
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
}
/**
diff --git a/tests/Unit/Middleware/SandstormTest.php b/tests/Unit/Middleware/SandstormTest.php
index a367e101e9..09a05a5911 100644
--- a/tests/Unit/Middleware/SandstormTest.php
+++ b/tests/Unit/Middleware/SandstormTest.php
@@ -25,10 +25,10 @@ namespace Tests\Unit\Middleware;
use FireflyIII\Http\Middleware\Sandstorm;
use FireflyIII\Repositories\User\UserRepositoryInterface;
+use Mockery;
use Route;
use Symfony\Component\HttpFoundation\Response;
use Tests\TestCase;
-use Mockery;
/**
* Class RangeTest
diff --git a/tests/Unit/Services/Internal/Update/TransactionUpdateServiceTest.php b/tests/Unit/Services/Internal/Update/TransactionUpdateServiceTest.php
index 1c9b88a109..ae20ba3a19 100644
--- a/tests/Unit/Services/Internal/Update/TransactionUpdateServiceTest.php
+++ b/tests/Unit/Services/Internal/Update/TransactionUpdateServiceTest.php
@@ -159,7 +159,7 @@ class TransactionUpdateServiceTest extends TestCase
{
/** @var Transaction $source */
$source = $this->user()->transactions()->where('amount', '>', 0)->inRandomOrder()->first();
- $data = [
+ $data = [
'currency_id' => 1,
'currency_code' => null,
'description' => 'Some new description',
@@ -187,7 +187,6 @@ class TransactionUpdateServiceTest extends TestCase
$result = $service->update($source, $data);
-
$this->assertEquals($source->id, $result->id);
$this->assertEquals($result->description, $data['description']);
$this->assertEquals($data['foreign_amount'], $result->foreign_amount);
@@ -202,7 +201,7 @@ class TransactionUpdateServiceTest extends TestCase
{
/** @var Transaction $source */
$source = $this->user()->transactions()->where('amount', '<', 0)->inRandomOrder()->first();
- $data = [
+ $data = [
'currency_id' => 1,
'currency_code' => null,
'description' => 'Some new description',
diff --git a/tests/Unit/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandlerTest.php b/tests/Unit/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandlerTest.php
index 2af6e0ac06..ba705646fa 100644
--- a/tests/Unit/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandlerTest.php
+++ b/tests/Unit/Support/Import/JobConfiguration/Bunq/ChooseAccountsHandlerTest.php
@@ -287,10 +287,10 @@ class ChooseAccountsHandlerTest extends TestCase
// data:
$data = ['account_mapping' => [], 'apply_rules' => true,];
$config = [
- 'accounts' => [
+ 'accounts' => [
0 => ['id' => 1234, 'name' => 'bunq'],
],
- 'apply-rules' => true,
+ 'apply-rules' => true,
];
diff --git a/tests/Unit/Support/Import/JobConfiguration/Bunq/NewBunqJobHandlerTest.php b/tests/Unit/Support/Import/JobConfiguration/Bunq/NewBunqJobHandlerTest.php
index 2865cd0382..164775517b 100644
--- a/tests/Unit/Support/Import/JobConfiguration/Bunq/NewBunqJobHandlerTest.php
+++ b/tests/Unit/Support/Import/JobConfiguration/Bunq/NewBunqJobHandlerTest.php
@@ -27,7 +27,6 @@ namespace Tests\Unit\Support\Import\JobConfiguration\Bunq;
use FireflyIII\Models\ImportJob;
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
use FireflyIII\Support\Import\JobConfiguration\Bunq\NewBunqJobHandler;
-use Mockery;
use Tests\TestCase;
class NewBunqJobHandlerTest extends TestCase
diff --git a/tests/Unit/Support/Import/JobConfiguration/Spectre/DoAuthenticateHandlerTest.php b/tests/Unit/Support/Import/JobConfiguration/Spectre/DoAuthenticateHandlerTest.php
index a92319f105..91ef0280d8 100644
--- a/tests/Unit/Support/Import/JobConfiguration/Spectre/DoAuthenticateHandlerTest.php
+++ b/tests/Unit/Support/Import/JobConfiguration/Spectre/DoAuthenticateHandlerTest.php
@@ -43,6 +43,7 @@ class DoAuthenticateHandlerTest extends TestCase
{
/**
* No token in config, but grab it from users preferences.
+ *
* @covers \FireflyIII\Support\Import\Information\GetSpectreTokenTrait
* @covers \FireflyIII\Support\Import\JobConfiguration\Spectre\DoAuthenticateHandler
*/
diff --git a/tests/Unit/Support/Import/Routine/File/CurrencyMapperTest.php b/tests/Unit/Support/Import/Routine/File/CurrencyMapperTest.php
index c067873630..3a516cbc5f 100644
--- a/tests/Unit/Support/Import/Routine/File/CurrencyMapperTest.php
+++ b/tests/Unit/Support/Import/Routine/File/CurrencyMapperTest.php
@@ -72,100 +72,100 @@ class CurrencyMapperTest extends TestCase
/**
* @covers \FireflyIII\Support\Import\Routine\File\CurrencyMapper
*/
- public function testFindByCode(): void
+ public function testEmpty(): void
{
- $currency = TransactionCurrency::inRandomOrder()->first();
+
// mock data
$repository = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('setUser')->once();
- $repository->shouldReceive('findByCodeNull')->withArgs([$currency->code])
- ->andReturn($currency)->once();
$mapper = new CurrencyMapper();
$mapper->setUser($this->user());
- $result = $mapper->map(null, ['code' => $currency->code]);
- $this->assertEquals($currency->id, $result->id);
+ $result = $mapper->map(null, []);
+ $this->assertNull($result);
}
/**
* @covers \FireflyIII\Support\Import\Routine\File\CurrencyMapper
*/
- public function testFindByName(): void
+ public function testFindAndCreate(): void
{
$currency = TransactionCurrency::inRandomOrder()->first();
// mock data
$repository = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('setUser')->once();
- $repository->shouldReceive('findByNameNull')->withArgs([$currency->name])
- ->andReturn($currency)->once();
+ $repository->shouldReceive('findBySymbolNull')->withArgs([$currency->symbol])->andReturn(null)->once();
+ $repository->shouldReceive('findByCodeNull')->withArgs([$currency->code])->andReturn(null)->once();
+ $repository->shouldReceive('findByNameNull')->withArgs([$currency->name])->andReturn(null)->once();
+
+ // nothing found, mapper will try to create it.
+ $repository->shouldReceive('store')
+ ->withArgs([['code' => $currency->code, 'name' => $currency->name, 'symbol' => $currency->symbol, 'decimal_places' => 2]])
+ ->once()->andReturn($currency);
$mapper = new CurrencyMapper();
$mapper->setUser($this->user());
- $result = $mapper->map(null, ['name' => $currency->name]);
+ $result = $mapper->map(null, ['name' => $currency->name, 'code' => $currency->code, 'symbol' => $currency->symbol]);
$this->assertEquals($currency->id, $result->id);
}
/**
* @covers \FireflyIII\Support\Import\Routine\File\CurrencyMapper
*/
- public function testFindBySymbol(): void
+ public function testFindByCode(): void
{
$currency = TransactionCurrency::inRandomOrder()->first();
// mock data
$repository = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('setUser')->once();
- $repository->shouldReceive('findBySymbolNull')->withArgs([$currency->symbol])
+ $repository->shouldReceive('findByCodeNull')->withArgs([$currency->code])
->andReturn($currency)->once();
$mapper = new CurrencyMapper();
$mapper->setUser($this->user());
- $result = $mapper->map(null, ['symbol' => $currency->symbol]);
+ $result = $mapper->map(null, ['code' => $currency->code]);
$this->assertEquals($currency->id, $result->id);
}
/**
* @covers \FireflyIII\Support\Import\Routine\File\CurrencyMapper
*/
- public function testFindAndCreate(): void
+ public function testFindByName(): void
{
$currency = TransactionCurrency::inRandomOrder()->first();
// mock data
$repository = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('setUser')->once();
- $repository->shouldReceive('findBySymbolNull')->withArgs([$currency->symbol])->andReturn(null)->once();
- $repository->shouldReceive('findByCodeNull')->withArgs([$currency->code])->andReturn(null)->once();
- $repository->shouldReceive('findByNameNull')->withArgs([$currency->name])->andReturn(null)->once();
-
- // nothing found, mapper will try to create it.
- $repository->shouldReceive('store')
- ->withArgs([['code' => $currency->code, 'name' => $currency->name, 'symbol' => $currency->symbol,'decimal_places'=>2]])
- ->once()->andReturn($currency);
+ $repository->shouldReceive('findByNameNull')->withArgs([$currency->name])
+ ->andReturn($currency)->once();
$mapper = new CurrencyMapper();
$mapper->setUser($this->user());
- $result = $mapper->map(null, ['name' => $currency->name, 'code' => $currency->code, 'symbol' => $currency->symbol]);
+ $result = $mapper->map(null, ['name' => $currency->name]);
$this->assertEquals($currency->id, $result->id);
}
/**
* @covers \FireflyIII\Support\Import\Routine\File\CurrencyMapper
*/
- public function testEmpty(): void
+ public function testFindBySymbol(): void
{
-
+ $currency = TransactionCurrency::inRandomOrder()->first();
// mock data
$repository = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('setUser')->once();
+ $repository->shouldReceive('findBySymbolNull')->withArgs([$currency->symbol])
+ ->andReturn($currency)->once();
$mapper = new CurrencyMapper();
$mapper->setUser($this->user());
- $result = $mapper->map(null, []);
- $this->assertNull($result);
+ $result = $mapper->map(null, ['symbol' => $currency->symbol]);
+ $this->assertEquals($currency->id, $result->id);
}
}
diff --git a/tests/Unit/Support/Import/Routine/File/ImportableCreatorTest.php b/tests/Unit/Support/Import/Routine/File/ImportableCreatorTest.php
index 7e71bb71e1..0c893def63 100644
--- a/tests/Unit/Support/Import/Routine/File/ImportableCreatorTest.php
+++ b/tests/Unit/Support/Import/Routine/File/ImportableCreatorTest.php
@@ -39,7 +39,7 @@ class ImportableCreatorTest extends TestCase
*/
public function testConvertSets(): void
{
- $columnValue =new ColumnValue();
+ $columnValue = new ColumnValue();
$columnValue->setOriginalRole('account-name');
$columnValue->setRole('account-id');
$columnValue->setValue('Checking Account');
@@ -47,13 +47,13 @@ class ImportableCreatorTest extends TestCase
$input = [
[
- $columnValue
- ]
+ $columnValue,
+ ],
];
$creator = new ImportableCreator;
- $result = $creator->convertSets($input);
+ $result = $creator->convertSets($input);
$this->assertCount(1, $result);
$this->assertInstanceOf(ImportTransaction::class, $result[0]);
diff --git a/tests/Unit/Support/Import/Routine/File/MappingConvergerTest.php b/tests/Unit/Support/Import/Routine/File/MappingConvergerTest.php
index cea0ebf80c..fef417afad 100644
--- a/tests/Unit/Support/Import/Routine/File/MappingConvergerTest.php
+++ b/tests/Unit/Support/Import/Routine/File/MappingConvergerTest.php
@@ -103,7 +103,7 @@ class MappingConvergerTest extends TestCase
5 => 'USD',
6 => 'SomeNumber',
7 => 'I am a description',
- 8 => 'IBANX'
+ 8 => 'IBANX',
],
[
0 => 'CheckingX Account',
@@ -114,7 +114,7 @@ class MappingConvergerTest extends TestCase
5 => 'USA',
6 => 'SomeANumber',
7 => 'I am X description',
- 8 => 'IBANXX'
+ 8 => 'IBANXX',
],
];
diff --git a/tests/Unit/Support/Import/Routine/File/OpposingAccountMapperTest.php b/tests/Unit/Support/Import/Routine/File/OpposingAccountMapperTest.php
index 86e3fab70a..adde7738a9 100644
--- a/tests/Unit/Support/Import/Routine/File/OpposingAccountMapperTest.php
+++ b/tests/Unit/Support/Import/Routine/File/OpposingAccountMapperTest.php
@@ -62,7 +62,7 @@ class OpposingAccountMapperTest extends TestCase
*/
public function testAccountIdBadType(): void
{
- $expected = $this->user()->accounts()->where('account_type_id', 5)->inRandomOrder()->first();
+ $expected = $this->user()->accounts()->where('account_type_id', 5)->inRandomOrder()->first();
$expected->iban = null;
$expected->save();
$amount = '-12.34';
@@ -160,30 +160,6 @@ class OpposingAccountMapperTest extends TestCase
$mapper->map(null, $amount, []);
}
- /**
- * Amount = negative
- * ID = null
- * other data = null
- * Should call store() with "(no name") for expense account
- *
- * @covers \FireflyIII\Support\Import\Routine\File\OpposingAccountMapper
- */
- public function testFindByAccountNumber(): void
- {
- $expected = $this->user()->accounts()->where('account_type_id', 4)->inRandomOrder()->first();
- $amount = '-12.34';
- $repository = $this->mock(AccountRepositoryInterface::class);
- $repository->shouldReceive('setUser')->once();
- $repository->shouldReceive('findByAccountNumber')->withArgs(['12345', [AccountType::EXPENSE]])
- ->andReturn($expected)->once();
-
-
- $mapper = new OpposingAccountMapper;
- $mapper->setUser($this->user());
- $result = $mapper->map(null, $amount, ['number' => '12345']);
- $this->assertEquals($result->id, $expected->id);
- }
-
/**
* Amount = positive
* ID = null
@@ -216,4 +192,28 @@ class OpposingAccountMapperTest extends TestCase
$mapper->map(null, $amount, []);
}
+ /**
+ * Amount = negative
+ * ID = null
+ * other data = null
+ * Should call store() with "(no name") for expense account
+ *
+ * @covers \FireflyIII\Support\Import\Routine\File\OpposingAccountMapper
+ */
+ public function testFindByAccountNumber(): void
+ {
+ $expected = $this->user()->accounts()->where('account_type_id', 4)->inRandomOrder()->first();
+ $amount = '-12.34';
+ $repository = $this->mock(AccountRepositoryInterface::class);
+ $repository->shouldReceive('setUser')->once();
+ $repository->shouldReceive('findByAccountNumber')->withArgs(['12345', [AccountType::EXPENSE]])
+ ->andReturn($expected)->once();
+
+
+ $mapper = new OpposingAccountMapper;
+ $mapper->setUser($this->user());
+ $result = $mapper->map(null, $amount, ['number' => '12345']);
+ $this->assertEquals($result->id, $expected->id);
+ }
+
}
diff --git a/tests/Unit/TransactionRules/Actions/ClearBudgetTest.php b/tests/Unit/TransactionRules/Actions/ClearBudgetTest.php
index 97f6e456e8..e90d827650 100644
--- a/tests/Unit/TransactionRules/Actions/ClearBudgetTest.php
+++ b/tests/Unit/TransactionRules/Actions/ClearBudgetTest.php
@@ -56,7 +56,7 @@ class ClearBudgetTest extends TestCase
$this->assertEquals(0, $journal->budgets()->count());
/** @var Transaction $transaction */
- foreach($journal->transactions as $transaction) {
+ foreach ($journal->transactions as $transaction) {
$this->assertEquals(0, $transaction->budgets()->count());
}
diff --git a/tests/Unit/TransactionRules/Actions/ClearCategoryTest.php b/tests/Unit/TransactionRules/Actions/ClearCategoryTest.php
index e9b43a7d6d..705b783e7b 100644
--- a/tests/Unit/TransactionRules/Actions/ClearCategoryTest.php
+++ b/tests/Unit/TransactionRules/Actions/ClearCategoryTest.php
@@ -56,7 +56,7 @@ class ClearCategoryTest extends TestCase
$this->assertEquals(0, $journal->categories()->count());
/** @var Transaction $transaction */
- foreach($journal->transactions as $transaction) {
+ foreach ($journal->transactions as $transaction) {
$this->assertEquals(0, $transaction->categories()->count());
}
}
diff --git a/tests/Unit/TransactionRules/Triggers/BudgetIsTest.php b/tests/Unit/TransactionRules/Triggers/BudgetIsTest.php
index 54380e8da4..fd5851303d 100644
--- a/tests/Unit/TransactionRules/Triggers/BudgetIsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/BudgetIsTest.php
@@ -86,11 +86,11 @@ class BudgetIsTest extends TestCase
/** @var Collection $transactions */
$transactions = $journal->transactions()->get();
- $budget = $journal->user->budgets()->first();
+ $budget = $journal->user->budgets()->first();
$journal->budgets()->detach();
/** @var Transaction $transaction */
- foreach($transactions as $transaction) {
+ foreach ($transactions as $transaction) {
$transaction->budgets()->detach();
$transaction->budgets()->save($budget);
$this->assertEquals(1, $transaction->budgets()->count());
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
index e945255556..cdbd9211b7 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountEndsTest.php
@@ -92,8 +92,8 @@ class FromAccountEndsTest extends TestCase
public function testWillMatchEverythingEmpty(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = '';
- $result = FromAccountEnds::willMatchEverything($value);
+ $value = '';
+ $result = FromAccountEnds::willMatchEverything($value);
$this->assertTrue($result);
}
@@ -103,8 +103,8 @@ class FromAccountEndsTest extends TestCase
public function testWillMatchEverythingNotNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = 'x';
- $result = FromAccountEnds::willMatchEverything($value);
+ $value = 'x';
+ $result = FromAccountEnds::willMatchEverything($value);
$this->assertFalse($result);
}
@@ -114,8 +114,8 @@ class FromAccountEndsTest extends TestCase
public function testWillMatchEverythingNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = null;
- $result = FromAccountEnds::willMatchEverything($value);
+ $value = null;
+ $result = FromAccountEnds::willMatchEverything($value);
$this->assertTrue($result);
}
}
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
index 280c3459df..d3fd6eb3f6 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountIsTest.php
@@ -27,7 +27,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\FromAccountIs;
use Illuminate\Support\Collection;
use Tests\TestCase;
-use Log;
+
/**
* Class FromAccountIsTest
*/
@@ -76,8 +76,8 @@ class FromAccountIsTest extends TestCase
public function testWillMatchEverythingEmpty(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = '';
- $result = FromAccountIs::willMatchEverything($value);
+ $value = '';
+ $result = FromAccountIs::willMatchEverything($value);
$this->assertTrue($result);
}
@@ -87,8 +87,8 @@ class FromAccountIsTest extends TestCase
public function testWillMatchEverythingNotNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = 'x';
- $result = FromAccountIs::willMatchEverything($value);
+ $value = 'x';
+ $result = FromAccountIs::willMatchEverything($value);
$this->assertFalse($result);
}
@@ -98,8 +98,8 @@ class FromAccountIsTest extends TestCase
public function testWillMatchEverythingNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = null;
- $result = FromAccountIs::willMatchEverything($value);
+ $value = null;
+ $result = FromAccountIs::willMatchEverything($value);
$this->assertTrue($result);
}
}
diff --git a/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php
index 3527b1547d..f4de28c471 100644
--- a/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/FromAccountStartsTest.php
@@ -103,8 +103,8 @@ class FromAccountStartsTest extends TestCase
public function testWillMatchEverythingEmpty(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = '';
- $result = FromAccountStarts::willMatchEverything($value);
+ $value = '';
+ $result = FromAccountStarts::willMatchEverything($value);
$this->assertTrue($result);
}
@@ -114,8 +114,8 @@ class FromAccountStartsTest extends TestCase
public function testWillMatchEverythingNotNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = 'x';
- $result = FromAccountStarts::willMatchEverything($value);
+ $value = 'x';
+ $result = FromAccountStarts::willMatchEverything($value);
$this->assertFalse($result);
}
@@ -125,8 +125,8 @@ class FromAccountStartsTest extends TestCase
public function testWillMatchEverythingNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = null;
- $result = FromAccountStarts::willMatchEverything($value);
+ $value = null;
+ $result = FromAccountStarts::willMatchEverything($value);
$this->assertTrue($result);
}
}
diff --git a/tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php b/tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php
index 841261bb6d..18537be953 100644
--- a/tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php
+++ b/tests/Unit/TransactionRules/Triggers/HasAttachmentTest.php
@@ -38,9 +38,9 @@ class HasAttachmentTest extends TestCase
{
do {
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
- $count = $journal->attachments()->count();
- } while($count !== 0);
-
+ $count = $journal->attachments()->count();
+ } while ($count !== 0);
+
$attachment = $journal->user->attachments()->first();
$journal->attachments()->save($attachment);
$this->assertEquals(1, $journal->attachments()->count());
@@ -58,8 +58,8 @@ class HasAttachmentTest extends TestCase
do {
// this is kind of cheating but OK.
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
- $count = $journal->attachments()->count();
- } while($count !== 0);
+ $count = $journal->attachments()->count();
+ } while ($count !== 0);
$this->assertEquals(0, $journal->attachments()->count());
diff --git a/tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php b/tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php
index 7ede15cd6b..e902deace8 100644
--- a/tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php
+++ b/tests/Unit/TransactionRules/Triggers/HasNoBudgetTest.php
@@ -74,8 +74,8 @@ class HasNoBudgetTest extends TestCase
{
$loopCount = 0;
do {
- $journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
- $count = $journal->transactions()->count();
+ $journal = $this->user()->transactionJournals()->inRandomOrder()->whereNull('deleted_at')->first();
+ $count = $journal->transactions()->count();
} while ($loopCount < 30 && $count !== 2);
$transactions = $journal->transactions()->get();
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php
index 9974e65e03..e1f03e2594 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountContainsTest.php
@@ -77,8 +77,8 @@ class ToAccountContainsTest extends TestCase
public function testWillMatchEverythingEmpty(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = '';
- $result = ToAccountContains::willMatchEverything($value);
+ $value = '';
+ $result = ToAccountContains::willMatchEverything($value);
$this->assertTrue($result);
}
@@ -88,8 +88,8 @@ class ToAccountContainsTest extends TestCase
public function testWillMatchEverythingNotNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = 'x';
- $result = ToAccountContains::willMatchEverything($value);
+ $value = 'x';
+ $result = ToAccountContains::willMatchEverything($value);
$this->assertFalse($result);
}
@@ -99,8 +99,8 @@ class ToAccountContainsTest extends TestCase
public function testWillMatchEverythingNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = null;
- $result = ToAccountContains::willMatchEverything($value);
+ $value = null;
+ $result = ToAccountContains::willMatchEverything($value);
$this->assertTrue($result);
}
}
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
index bf78a467ed..f8b1fbc46d 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountEndsTest.php
@@ -26,7 +26,6 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\ToAccountEnds;
use Illuminate\Support\Collection;
-use Log;
use Tests\TestCase;
/**
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
index 4a8ff271d1..db6dea9d87 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountIsTest.php
@@ -27,7 +27,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\ToAccountIs;
use Illuminate\Support\Collection;
use Tests\TestCase;
-use Log;
/**
* Class ToAccountIsTest
@@ -48,7 +47,6 @@ class ToAccountIsTest extends TestCase
$repository->shouldReceive('getJournalDestinationAccounts')->once()->andReturn($collection);
-
$trigger = ToAccountIs::makeFromStrings($account->name, false);
$result = $trigger->triggered($journal);
$this->assertTrue($result);
@@ -78,8 +76,8 @@ class ToAccountIsTest extends TestCase
public function testWillMatchEverythingEmpty(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = '';
- $result = ToAccountIs::willMatchEverything($value);
+ $value = '';
+ $result = ToAccountIs::willMatchEverything($value);
$this->assertTrue($result);
}
@@ -89,8 +87,8 @@ class ToAccountIsTest extends TestCase
public function testWillMatchEverythingNotNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = 'x';
- $result = ToAccountIs::willMatchEverything($value);
+ $value = 'x';
+ $result = ToAccountIs::willMatchEverything($value);
$this->assertFalse($result);
}
@@ -100,8 +98,8 @@ class ToAccountIsTest extends TestCase
public function testWillMatchEverythingNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
- $value = null;
- $result = ToAccountIs::willMatchEverything($value);
+ $value = null;
+ $result = ToAccountIs::willMatchEverything($value);
$this->assertTrue($result);
}
}
diff --git a/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php b/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
index 9ed3017438..15dc45106b 100644
--- a/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
+++ b/tests/Unit/TransactionRules/Triggers/ToAccountStartsTest.php
@@ -26,7 +26,6 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\ToAccountStarts;
use Illuminate\Support\Collection;
-use Log;
use Tests\TestCase;
/**
diff --git a/tests/Unit/Transformers/BillTransformerTest.php b/tests/Unit/Transformers/BillTransformerTest.php
index 4b64833ba8..7abe4689de 100644
--- a/tests/Unit/Transformers/BillTransformerTest.php
+++ b/tests/Unit/Transformers/BillTransformerTest.php
@@ -25,7 +25,6 @@ namespace Tests\Unit\Transformers;
use Carbon\Carbon;
use FireflyIII\Models\Bill;
-use FireflyIII\Models\Note;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Transformers\BillTransformer;
use Illuminate\Support\Collection;