Skip to content

Firefly III: a personal finances manager

Various code cleanup.

James Cole95648c37b34b
diff --git a/app/Api/V1/Controllers/BillController.php b/app/Api/V1/Controllers/BillController.php
index 0038163a0c..876ffa2f85 100644
--- a/app/Api/V1/Controllers/BillController.php
+++ b/app/Api/V1/Controllers/BillController.php
@@ -74,6 +74,7 @@ class BillController extends Controller
public function destroy(Bill $bill)
{
$this->repository->destroy($bill);
+
return response()->json(null, 204);
}
diff --git a/app/Console/Commands/Import.php b/app/Console/Commands/Import.php
index 65ae256332..7d7a735c82 100644
--- a/app/Console/Commands/Import.php
+++ b/app/Console/Commands/Import.php
@@ -85,8 +85,8 @@ class Import extends Command
$monolog->pushHandler($handler);
// actually start job:
- $type = 'csv' === $job->file_type ? 'file' : $job->file_type;
- $key = sprintf('import.routine.%s', $type);
+ $type = 'csv' === $job->file_type ? 'file' : $job->file_type;
+ $key = sprintf('import.routine.%s', $type);
$className = config($key);
if (null === $className || !class_exists($className)) {
throw new FireflyException(sprintf('Cannot find import routine class for job of type "%s".', $type)); // @codeCoverageIgnore
diff --git a/app/Helpers/Collector/JournalCollector.php b/app/Helpers/Collector/JournalCollector.php
index ac5243a7a3..c731ff0b2a 100644
--- a/app/Helpers/Collector/JournalCollector.php
+++ b/app/Helpers/Collector/JournalCollector.php
@@ -252,6 +252,7 @@ class JournalCollector implements JournalCollectorInterface
$cache->addProperty($key);
if ($cache->has()) {
Log::debug(sprintf('Return cache of query with ID "%s".', $key));
+
return $cache->get(); // @codeCoverageIgnore
}
diff --git a/app/Helpers/Collector/JournalCollectorInterface.php b/app/Helpers/Collector/JournalCollectorInterface.php
index 30243ac6db..ce0def29a7 100644
--- a/app/Helpers/Collector/JournalCollectorInterface.php
+++ b/app/Helpers/Collector/JournalCollectorInterface.php
@@ -27,7 +27,6 @@ use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\Tag;
use FireflyIII\User;
-use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index ff5d743662..25a02e8457 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -290,9 +290,6 @@ class AccountController extends Controller
if (AccountType::INITIAL_BALANCE === $account->accountType->type) {
return $this->redirectToOriginalAccount($account);
}
- if ($end < $start) {
- throw new FireflyException('End is after start!');
- }
$range = Preferences::get('viewRange', '1M')->data;
if (null === $start) {
$start = session('start');
@@ -300,6 +297,9 @@ class AccountController extends Controller
if (null === $end) {
$end = app('navigation')->endOfPeriod($start, $range);
}
+ if ($end < $start) {
+ throw new FireflyException('End is after start!');
+ }
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
$page = intval($request->get('page'));
diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php
index 1231fc749d..fe0040156d 100644
--- a/app/Http/Controllers/Auth/ResetPasswordController.php
+++ b/app/Http/Controllers/Auth/ResetPasswordController.php
@@ -75,6 +75,7 @@ class ResetPasswordController extends Controller
if (true === $singleUserMode && $userCount > 0) {
$allowRegistration = false;
}
+
return view('auth.passwords.reset')->with(
['token' => $token, 'email' => $request->email, 'allowRegistration' => $allowRegistration]
);
diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.php
index 2dfecca07b..86e2151ef3 100644
--- a/app/Http/Controllers/Transaction/BulkController.php
+++ b/app/Http/Controllers/Transaction/BulkController.php
@@ -35,7 +35,6 @@ use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Log;
use Preferences;
-use Session;
use View;
/**
@@ -142,7 +141,7 @@ class BulkController extends Controller
$ignoreCategory = intval($request->get('ignore_category')) === 1;
$ignoreBudget = intval($request->get('ignore_budget')) === 1;
$ignoreTags = intval($request->get('ignore_tags')) === 1;
- $count = 0;
+ $count = 0;
if (is_array($journalIds)) {
foreach ($journalIds as $journalId) {
$journal = $repository->find(intval($journalId));
diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.php
index e1fe464f18..5bd8c3ae20 100644
--- a/app/Http/Controllers/Transaction/LinkController.php
+++ b/app/Http/Controllers/Transaction/LinkController.php
@@ -78,7 +78,7 @@ class LinkController extends Controller
}
/**
- * @param TransactionJournalLink $link
+ * @param TransactionJournalLink $link
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
@@ -93,8 +93,8 @@ class LinkController extends Controller
}
/**
- * @param JournalLinkRequest $request
- * @param TransactionJournal $journal
+ * @param JournalLinkRequest $request
+ * @param TransactionJournal $journal
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
@@ -123,7 +123,7 @@ class LinkController extends Controller
}
/**
- * @param TransactionJournalLink $link
+ * @param TransactionJournalLink $link
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php
index cbae31b26c..407cd24229 100644
--- a/app/Http/Controllers/Transaction/MassController.php
+++ b/app/Http/Controllers/Transaction/MassController.php
@@ -25,8 +25,8 @@ namespace FireflyIII\Http\Controllers\Transaction;
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\MassDeleteJournalRequest;
-use FireflyIII\Http\Requests\MassEditJournalRequest;
use FireflyIII\Http\Requests\MassEditBulkJournalRequest;
+use FireflyIII\Http\Requests\MassEditJournalRequest;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
index 07e4e8e29d..35d914499d 100644
--- a/app/Http/Kernel.php
+++ b/app/Http/Kernel.php
@@ -24,8 +24,8 @@ namespace FireflyIII\Http;
use FireflyIII\Http\Middleware\Authenticate;
use FireflyIII\Http\Middleware\AuthenticateTwoFactor;
-use FireflyIII\Http\Middleware\EncryptCookies;
use FireflyIII\Http\Middleware\Binder;
+use FireflyIII\Http\Middleware\EncryptCookies;
use FireflyIII\Http\Middleware\IsAdmin;
use FireflyIII\Http\Middleware\Range;
use FireflyIII\Http\Middleware\RedirectIfAuthenticated;
diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php
index dca2d3f774..2dedbbe794 100644
--- a/app/Http/Requests/Request.php
+++ b/app/Http/Requests/Request.php
@@ -40,6 +40,16 @@ class Request extends FormRequest
return 1 === intval($this->input($field));
}
+ /**
+ * @param string $field
+ *
+ * @return int
+ */
+ public function integer(string $field): int
+ {
+ return intval($this->get($field));
+ }
+
/**
* @param string $field
*
@@ -137,14 +147,4 @@ class Request extends FormRequest
return $return;
}
-
- /**
- * @param string $field
- *
- * @return int
- */
- public function integer(string $field): int
- {
- return intval($this->get($field));
- }
}
diff --git a/app/Import/Configuration/FileConfigurator.php b/app/Import/Configuration/FileConfigurator.php
index 1cde0e8015..c5070e5f73 100644
--- a/app/Import/Configuration/FileConfigurator.php
+++ b/app/Import/Configuration/FileConfigurator.php
@@ -263,6 +263,7 @@ class FileConfigurator implements ConfiguratorInterface
* Shorthand method to set the extended status.
*
* @codeCoverageIgnore
+ *
* @param array $extended
*/
private function setExtendedStatus(array $extended): void
diff --git a/app/Import/FileProcessor/CsvProcessor.php b/app/Import/FileProcessor/CsvProcessor.php
index a0de8ca0ff..79de2ec118 100644
--- a/app/Import/FileProcessor/CsvProcessor.php
+++ b/app/Import/FileProcessor/CsvProcessor.php
@@ -125,6 +125,7 @@ class CsvProcessor implements FileProcessorInterface
* Shorthand method to set the extended status.
*
* @codeCoverageIgnore
+ *
* @param array $array
*/
public function setExtendedStatus(array $array)
diff --git a/app/Import/Prerequisites/FilePrerequisites.php b/app/Import/Prerequisites/FilePrerequisites.php
index e47bb4c797..e0a9219218 100644
--- a/app/Import/Prerequisites/FilePrerequisites.php
+++ b/app/Import/Prerequisites/FilePrerequisites.php
@@ -67,9 +67,10 @@ class FilePrerequisites implements PrerequisitesInterface
*/
public function hasPrerequisites(): bool
{
- if($this->user->hasRole('demo')) {
+ if ($this->user->hasRole('demo')) {
throw new FireflyException('Apologies, the demo user cannot import files.');
}
+
return false;
}
diff --git a/app/Import/Routine/FileRoutine.php b/app/Import/Routine/FileRoutine.php
index 828dbd5d0f..121651660f 100644
--- a/app/Import/Routine/FileRoutine.php
+++ b/app/Import/Routine/FileRoutine.php
@@ -114,7 +114,6 @@ class FileRoutine implements RoutineInterface
Log::debug('Back in run()');
-
Log::debug('Updated job...');
Log::debug(sprintf('%d journals in $storage->journals', $storage->journals->count()));
$this->journals = $storage->journals;
@@ -177,6 +176,16 @@ class FileRoutine implements RoutineInterface
$this->repository->addStepsDone($this->job, 1);
}
+ /**
+ * Shorthand
+ *
+ * @param int $steps
+ */
+ private function addTotalSteps(int $steps)
+ {
+ $this->repository->addTotalSteps($this->job, $steps);
+ }
+
/**
*
*/
@@ -194,7 +203,7 @@ class FileRoutine implements RoutineInterface
/** @var TagRepositoryInterface $repository */
$repository = app(TagRepositoryInterface::class);
$repository->setUser($this->job->user);
- $data = [
+ $data = [
'tag' => trans('import.import_with_key', ['key' => $this->job->key]),
'date' => new Carbon,
'description' => null,
@@ -203,7 +212,7 @@ class FileRoutine implements RoutineInterface
'zoomLevel' => null,
'tagMode' => 'nothing',
];
- $tag = $repository->store($data);
+ $tag = $repository->store($data);
$this->addStep();
$extended = $this->getExtendedStatus();
$extended['tag'] = $tag->id;
@@ -220,6 +229,7 @@ class FileRoutine implements RoutineInterface
}
Log::info(sprintf('Linked %d journals to tag #%d ("%s")', $this->journals->count(), $tag->id, $tag->tag));
$this->addStep();
+
return $tag;
}
@@ -281,16 +291,6 @@ class FileRoutine implements RoutineInterface
$this->repository->setTotalSteps($this->job, $steps);
}
- /**
- * Shorthand
- *
- * @param int $steps
- */
- private function addTotalSteps(int $steps)
- {
- $this->repository->addTotalSteps($this->job, $steps);
- }
-
/**
* @param Collection $objects
*
diff --git a/app/Import/Storage/ImportStorage.php b/app/Import/Storage/ImportStorage.php
index 8990aab387..728cce920e 100644
--- a/app/Import/Storage/ImportStorage.php
+++ b/app/Import/Storage/ImportStorage.php
@@ -308,8 +308,8 @@ class ImportStorage
return false;
}
- $amount = app('steam')->positive($parameters['amount']);
- $names = [$parameters['asset'], $parameters['opposing']];
+ $amount = app('steam')->positive($parameters['amount']);
+ $names = [$parameters['asset'], $parameters['opposing']];
sort($names);
diff --git a/app/Models/Bill.php b/app/Models/Bill.php
index 9214b60c37..9b3a94af90 100644
--- a/app/Models/Bill.php
+++ b/app/Models/Bill.php
@@ -29,7 +29,7 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Watson\Validating\ValidatingTrait;
-use Illuminate\Contracts\Auth\Factory as Auth;
+
/**
* Class Bill.
*/
diff --git a/app/Repositories/Journal/UpdateJournalsTrait.php b/app/Repositories/Journal/UpdateJournalsTrait.php
index eb16eaeda3..cd2c3991af 100644
--- a/app/Repositories/Journal/UpdateJournalsTrait.php
+++ b/app/Repositories/Journal/UpdateJournalsTrait.php
@@ -22,15 +22,11 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Journal;
-use DB;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
-use FireflyIII\Models\Tag;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
-use FireflyIII\Repositories\Tag\TagRepositoryInterface;
-use Log;
/**
* Trait UpdateJournalsTrait.
diff --git a/app/Repositories/User/UserRepositoryInterface.php b/app/Repositories/User/UserRepositoryInterface.php
index 13568f754b..01810c451c 100644
--- a/app/Repositories/User/UserRepositoryInterface.php
+++ b/app/Repositories/User/UserRepositoryInterface.php
@@ -32,14 +32,6 @@ use Illuminate\Support\Collection;
interface UserRepositoryInterface
{
- /**
- * @param string $name
- * @param string $displayName
- * @param string $description
- *
- * @return Role
- */
- public function createRole(string $name, string $displayName, string $description): Role;
/**
* Returns a collection of all users.
*
@@ -47,13 +39,6 @@ interface UserRepositoryInterface
*/
public function all(): Collection;
- /**
- * @param string $role
- *
- * @return Role|null
- */
- public function getRole(string $role): ?Role;
-
/**
* Gives a user a role.
*
@@ -101,6 +86,15 @@ interface UserRepositoryInterface
*/
public function count(): int;
+ /**
+ * @param string $name
+ * @param string $displayName
+ * @param string $description
+ *
+ * @return Role
+ */
+ public function createRole(string $name, string $displayName, string $description): Role;
+
/**
* @param User $user
*
@@ -129,6 +123,13 @@ interface UserRepositoryInterface
*/
public function first(): ?User;
+ /**
+ * @param string $role
+ *
+ * @return Role|null
+ */
+ public function getRole(string $role): ?Role;
+
/**
* Return basic user information.
*
diff --git a/app/Services/Spectre/Object/Transaction.php b/app/Services/Spectre/Object/Transaction.php
index 5aa7cd5052..edf5768b64 100644
--- a/app/Services/Spectre/Object/Transaction.php
+++ b/app/Services/Spectre/Object/Transaction.php
@@ -57,14 +57,6 @@ class Transaction extends SpectreObject
/** @var Carbon */
private $updatedAt;
- /**
- * @return int
- */
- public function getId(): int
- {
- return $this->id;
- }
-
/**
* Transaction constructor.
*
@@ -87,39 +79,6 @@ class Transaction extends SpectreObject
$this->updatedAt = new Carbon($data['updated_at']);
}
- /**
- * @return string
- */
- public function getMode(): string
- {
- return $this->mode;
- }
-
- /**
- * @return string
- */
- public function getStatus(): string
- {
- return $this->status;
- }
-
- /**
- * @return bool
- */
- public function isDuplicated(): bool
- {
- return $this->duplicated;
- }
-
- /**
- * @return TransactionExtra
- */
- public function getExtra(): TransactionExtra
- {
- return $this->extra;
- }
-
-
/**
* @return string
*/
@@ -152,6 +111,14 @@ class Transaction extends SpectreObject
return $this->description;
}
+ /**
+ * @return TransactionExtra
+ */
+ public function getExtra(): TransactionExtra
+ {
+ return $this->extra;
+ }
+
/**
* @return string
*/
@@ -177,6 +144,14 @@ class Transaction extends SpectreObject
return $hashed;
}
+ /**
+ * @return int
+ */
+ public function getId(): int
+ {
+ return $this->id;
+ }
+
/**
* @return Carbon
*/
@@ -185,5 +160,29 @@ class Transaction extends SpectreObject
return $this->madeOn;
}
+ /**
+ * @return string
+ */
+ public function getMode(): string
+ {
+ return $this->mode;
+ }
+
+ /**
+ * @return string
+ */
+ public function getStatus(): string
+ {
+ return $this->status;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isDuplicated(): bool
+ {
+ return $this->duplicated;
+ }
+
}
\ No newline at end of file
diff --git a/app/Services/Spectre/Request/ListLoginsRequest.php b/app/Services/Spectre/Request/ListLoginsRequest.php
index c6444ec514..a7ebd89afe 100644
--- a/app/Services/Spectre/Request/ListLoginsRequest.php
+++ b/app/Services/Spectre/Request/ListLoginsRequest.php
@@ -26,6 +26,7 @@ namespace FireflyIII\Services\Spectre\Request;
use FireflyIII\Services\Spectre\Object\Customer;
use FireflyIII\Services\Spectre\Object\Login;
use Log;
+
/**
* Class ListLoginsRequest
*/
@@ -37,14 +38,6 @@ class ListLoginsRequest extends SpectreRequest
/** @var array */
private $logins = [];
- /**
- * @return array
- */
- public function getLogins(): array
- {
- return $this->logins;
- }
-
/**
*
*/
@@ -79,6 +72,14 @@ class ListLoginsRequest extends SpectreRequest
}
}
+ /**
+ * @return array
+ */
+ public function getLogins(): array
+ {
+ return $this->logins;
+ }
+
/**
* @param Customer $customer
*/
diff --git a/app/Services/Spectre/Request/SpectreRequest.php b/app/Services/Spectre/Request/SpectreRequest.php
index b7e129ca0f..5f00a09200 100644
--- a/app/Services/Spectre/Request/SpectreRequest.php
+++ b/app/Services/Spectre/Request/SpectreRequest.php
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Services\Spectre\Request;
use FireflyIII\Exceptions\FireflyException;
-use FireflyIII\Services\Spectre\Exception\DuplicatedCustomerException;
use FireflyIII\Services\Spectre\Exception\SpectreException;
use FireflyIII\User;
use Log;
diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php
index 3ac57bc625..b04e92b11d 100644
--- a/app/Support/ExpandedForm.php
+++ b/app/Support/ExpandedForm.php
@@ -25,7 +25,6 @@ namespace FireflyIII\Support;
use Amount as Amt;
use Carbon\Carbon;
use Eloquent;
-use FireflyIII\Exceptions\FireflyException;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use RuntimeException;
diff --git a/app/Support/Twig/Extension/Transaction.php b/app/Support/Twig/Extension/Transaction.php
index bd87af5b36..8d4ca0e84d 100644
--- a/app/Support/Twig/Extension/Transaction.php
+++ b/app/Support/Twig/Extension/Transaction.php
@@ -88,6 +88,7 @@ class Transaction extends Twig_Extension
$currency->decimal_places = $transaction->foreign_currency_dp;
$str .= ' (' . sprintf($format, app('amount')->formatAnything($currency, $amount, $coloured)) . ')';
}
+
return $str;
}
@@ -115,6 +116,7 @@ class Transaction extends Twig_Extension
$fakeCurrency->symbol = $transaction['foreign_currency_symbol'];
$string .= ' (' . app('amount')->formatAnything($fakeCurrency, $amount, true) . ')';
}
+
return $string;
}
@@ -201,6 +203,7 @@ class Transaction extends Twig_Extension
}
$txt = '';
+
return $txt;
}
@@ -350,10 +353,12 @@ class Transaction extends Twig_Extension
$count = TransactionModel::where('transaction_journal_id', $journalId)->whereNull('deleted_at')->count();
if ($count > 2) {
$res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
+
return $res;
}
$res = '';
+
return $res;
}
@@ -403,6 +408,7 @@ class Transaction extends Twig_Extension
}
$txt = sprintf('<a title="%1$s" href="%2$s">%1$s</a>', e($name), route('accounts.show', [$transactionId]));
+
return $txt;
}
}
diff --git a/app/Transformers/AttachmentTransformer.php b/app/Transformers/AttachmentTransformer.php
index 740b06ffbf..86b6685b4c 100644
--- a/app/Transformers/AttachmentTransformer.php
+++ b/app/Transformers/AttachmentTransformer.php
@@ -54,7 +54,7 @@ class AttachmentTransformer extends TransformerAbstract
'rel' => 'self',
'uri' => '/attachment/' . $attachment->id,
],
- ]
+ ],
];
}
diff --git a/app/Transformers/NoteTransformer.php b/app/Transformers/NoteTransformer.php
index 41c621215a..0a89959600 100644
--- a/app/Transformers/NoteTransformer.php
+++ b/app/Transformers/NoteTransformer.php
@@ -48,12 +48,12 @@ class NoteTransformer extends TransformerAbstract
'title' => $note->title,
'text' => $note->text,
'markdown' => $converter->convertToHtml($note->text),
- 'links' => [
+ 'links' => [
[
'rel' => 'self',
'uri' => '/note/' . $note->id,
],
- ]
+ ],
];
}
diff --git a/routes/breadcrumbs.php b/routes/breadcrumbs.php
index bb03bd83cb..15b91f1d13 100644
--- a/routes/breadcrumbs.php
+++ b/routes/breadcrumbs.php
@@ -76,33 +76,33 @@ Breadcrumbs::register(
Breadcrumbs::register(
'accounts.show',
- function (BreadCrumbsGenerator $breadcrumbs, Account $account, Carbon $start, Carbon $end) {
+ function (BreadCrumbsGenerator $breadcrumbs, Account $account, Carbon $start = null, Carbon $end = null) {
$what = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push($account->name, route('accounts.show', [$account->id]));
- $title = trans(
- 'firefly.between_dates_breadcrumb',
- ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
- 'end' => $end->formatLocalized(strval(trans('config.month_and_day'))),]
- );
- $breadcrumbs->push($title, route('accounts.show', [$account->id, $start, $end]));
+ $title = trans(
+ 'firefly.between_dates_breadcrumb',
+ ['start' => $start ? $start->formatLocalized(strval(trans('config.month_and_day'))) : '',
+ 'end' => $end ? $end->formatLocalized(strval(trans('config.month_and_day'))) : '',]
+ );
+ $breadcrumbs->push($title, route('accounts.show', $account));
}
);
Breadcrumbs::register(
'accounts.reconcile',
function (BreadCrumbsGenerator $breadcrumbs, Account $account) {
- $breadcrumbs->parent('accounts.show', $account, '(nothing)', new Carbon, new Carbon);
- $breadcrumbs->push(trans('firefly.reconcile_account', ['account' =>$account->name]), route('accounts.reconcile', [$account->id]));
+ $breadcrumbs->parent('accounts.show', $account);
+ $breadcrumbs->push(trans('firefly.reconcile_account', ['account' => $account->name]), route('accounts.reconcile', [$account->id]));
}
);
Breadcrumbs::register(
'accounts.reconcile.show',
function (BreadCrumbsGenerator $breadcrumbs, Account $account, TransactionJournal $journal) {
- $breadcrumbs->parent('accounts.show', $account, '(nothing)', new Carbon, new Carbon);
+ $breadcrumbs->parent('accounts.show', $account);
$title = trans('firefly.reconciliation') . ' "' . $journal->description . '"';
$breadcrumbs->push($title, route('accounts.reconcile.show', [$journal->id]));
}
@@ -111,7 +111,7 @@ Breadcrumbs::register(
Breadcrumbs::register(
'accounts.delete',
function (BreadCrumbsGenerator $breadcrumbs, Account $account) {
- $breadcrumbs->parent('accounts.show', $account, '(nothing)', new Carbon, new Carbon);
+ $breadcrumbs->parent('accounts.show', $account);
$breadcrumbs->push(trans('firefly.delete_account', ['name' => $account->name]), route('accounts.delete', [$account->id]));
}
);
@@ -119,7 +119,7 @@ Breadcrumbs::register(
Breadcrumbs::register(
'accounts.edit',
function (BreadCrumbsGenerator $breadcrumbs, Account $account) {
- $breadcrumbs->parent('accounts.show', $account, '(nothing)', new Carbon, new Carbon);
+ $breadcrumbs->parent('accounts.show', $account);
$what = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$breadcrumbs->push(trans('firefly.edit_' . $what . '_account', ['name' => $account->name]), route('accounts.edit', [$account->id]));
diff --git a/tests/Feature/Controllers/AccountControllerTest.php b/tests/Feature/Controllers/AccountControllerTest.php
index 058918f408..6b4777af1c 100644
--- a/tests/Feature/Controllers/AccountControllerTest.php
+++ b/tests/Feature/Controllers/AccountControllerTest.php
@@ -203,40 +203,6 @@ class AccountControllerTest extends TestCase
$response->assertSee('<ol class="breadcrumb">');
}
- /**
- * @covers \FireflyIII\Http\Controllers\AccountController::show
- * @dataProvider dateRangeProvider
- *
- * @param string $range
- */
- public function testShowAll(string $range)
- {
- // mock stuff
- $transaction = factory(Transaction::class)->make();
- $collector = $this->mock(JournalCollectorInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
- $collector->shouldReceive('setAccounts')->andReturnSelf();
- $collector->shouldReceive('setRange')->andReturnSelf();
- $collector->shouldReceive('setLimit')->andReturnSelf();
- $collector->shouldReceive('setPage')->andReturnSelf();
-
- $collector->shouldReceive('setTypes')->andReturnSelf();
-
- $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10));
-
- $tasker = $this->mock(AccountTaskerInterface::class);
- $tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1');
- $tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1');
-
- $this->be($this->user());
- $this->changeDateRange($this->user(), $range);
- $response = $this->get(route('accounts.show', [1, 'all']));
- $response->assertStatus(200);
- // has bread crumb
- $response->assertSee('<ol class="breadcrumb">');
- }
-
/**
* @covers \FireflyIII\Http\Controllers\AccountController::show
* @covers \FireflyIII\Http\Controllers\AccountController::redirectToOriginalAccount
@@ -256,39 +222,6 @@ class AccountControllerTest extends TestCase
$response->assertStatus(500);
}
- /**
- * @covers \FireflyIII\Http\Controllers\AccountController::show
- * @dataProvider dateRangeProvider
- *
- * @param string $range
- */
- public function testShowByDate(string $range)
- {
- // mock stuff
- $transaction = factory(Transaction::class)->make();
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
- $collector = $this->mock(JournalCollectorInterface::class);
- $collector->shouldReceive('setAccounts')->andReturnSelf();
- $collector->shouldReceive('setRange')->andReturnSelf();
- $collector->shouldReceive('setLimit')->andReturnSelf();
- $collector->shouldReceive('setPage')->andReturnSelf();
-
- $collector->shouldReceive('setTypes')->andReturnSelf();
- $collector->shouldReceive('withOpposingAccount')->andReturnSelf();
- $collector->shouldReceive('getJournals')->andReturn(new Collection([$transaction]));
- $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10));
-
- $repository = $this->mock(AccountRepositoryInterface::class);
- $repository->shouldReceive('oldestJournalDate')->andReturn(new Carbon)->once();
-
- $this->be($this->user());
- $this->changeDateRange($this->user(), $range);
- $response = $this->get(route('accounts.show', [1, '2016-01-01']));
- $response->assertStatus(200);
- // has bread crumb
- $response->assertSee('<ol class="breadcrumb">');
- }
/**
* @covers \FireflyIII\Http\Controllers\AccountController::show
diff --git a/tests/Feature/Controllers/CategoryControllerTest.php b/tests/Feature/Controllers/CategoryControllerTest.php
index 19991eca10..fcf776a7c6 100644
--- a/tests/Feature/Controllers/CategoryControllerTest.php
+++ b/tests/Feature/Controllers/CategoryControllerTest.php
@@ -398,15 +398,17 @@ class CategoryControllerTest extends TestCase
$collector = $this->mock(JournalCollectorInterface::class);
$collector->shouldReceive('setPage')->andReturnSelf()->once();
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
- $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
- $collector->shouldReceive('setRange')->andReturnSelf()->once();
- $collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->once();
- $collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
- $collector->shouldReceive('withCategoryInformation')->andReturnSelf()->once();
- $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once();
- $collector->shouldReceive('setCategory')->andReturnSelf()->once();
+ $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->atLeast(1);
+ $collector->shouldReceive('setRange')->andReturnSelf()->atLeast(1);
+ $collector->shouldReceive('removeFilter')->withArgs([InternalTransferFilter::class])->andReturnSelf()->atLeast(1);
+ $collector->shouldReceive('withBudgetInformation')->andReturnSelf()->atLeast(1);
+ $collector->shouldReceive('withCategoryInformation')->andReturnSelf()->atLeast(1);
+ $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->atLeast(1);
+ $collector->shouldReceive('setCategory')->andReturnSelf()->atLeast(1);
+ $collector->shouldReceive('setTypes')->andReturnSelf()->atLeast(1);
+ $collector->shouldReceive('getJournals')->andReturn(new Collection)->atLeast(1);
- $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once();
+ $collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->atLeast(1);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
diff --git a/tests/Feature/Controllers/Chart/AccountControllerTest.php b/tests/Feature/Controllers/Chart/AccountControllerTest.php
index ebe56a380f..3d9ff59899 100644
--- a/tests/Feature/Controllers/Chart/AccountControllerTest.php
+++ b/tests/Feature/Controllers/Chart/AccountControllerTest.php
@@ -47,42 +47,6 @@ use Tests\TestCase;
*/
class AccountControllerTest extends TestCase
{
- /**
- * @covers \FireflyIII\Http\Controllers\Chart\AccountController::all
- */
- public function testAll()
- {
- $generator = $this->mock(GeneratorInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
-
- $accountRepos->shouldReceive('oldestJournalDate')->once()->andReturn(Carbon::now()->subMonth());
- Steam::shouldReceive('balanceInRange')->andReturn(['2012-01-01' => '0']);
- $generator->shouldReceive('singleSet')->andReturn([]);
-
- $this->be($this->user());
- $response = $this->get(route('chart.account.all', [1]));
- $response->assertStatus(200);
- }
-
- /**
- * @covers \FireflyIII\Http\Controllers\Chart\AccountController::all
- */
- public function testAllLongRange()
- {
- $generator = $this->mock(GeneratorInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
-
- $carbon = new Carbon;
- $carbon->subMonths(5);
- $accountRepos->shouldReceive('oldestJournalDate')->once()->andReturn($carbon);
- Steam::shouldReceive('balance')->andReturn('0');
-
- $generator->shouldReceive('singleSet')->andReturn([]);
-
- $this->be($this->user());
- $response = $this->get(route('chart.account.all', [1]));
- $response->assertStatus(200);
- }
/**
* @covers \FireflyIII\Http\Controllers\Chart\AccountController::expenseAccounts
@@ -328,7 +292,7 @@ class AccountControllerTest extends TestCase
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
- $response = $this->get(route('chart.account.period', [1, '2012-01-01']));
+ $response = $this->get(route('chart.account.period', [1, '2012-01-01','2012-01-31']));
$response->assertStatus(200);
}
@@ -369,22 +333,4 @@ class AccountControllerTest extends TestCase
$response->assertStatus(200);
}
- /**
- * @covers \FireflyIII\Http\Controllers\Chart\AccountController::single
- * @dataProvider dateRangeProvider
- *
- * @param string $range
- */
- public function testSingle(string $range)
- {
- $generator = $this->mock(GeneratorInterface::class);
-
- Steam::shouldReceive('balanceInRange')->andReturn(['2012-01-01' => '0']);
- $generator->shouldReceive('singleSet')->andReturn([]);
-
- $this->be($this->user());
- $this->changeDateRange($this->user(), $range);
- $response = $this->get(route('chart.account.single', [1]));
- $response->assertStatus(200);
- }
}