diff --git a/app/Models/Note.php b/app/Models/Note.php
index 7526f1cf24..94732a1242 100644
--- a/app/Models/Note.php
+++ b/app/Models/Note.php
@@ -86,6 +86,7 @@ class Note extends Model
/**
* @param $value
+ * @codeCoverageIgnore
*/
public function setTextAttribute($value): void
{
diff --git a/app/Models/Preference.php b/app/Models/Preference.php
index ac4c514b15..5e3853bc8f 100644
--- a/app/Models/Preference.php
+++ b/app/Models/Preference.php
@@ -38,7 +38,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property int $id
* @property User user
* @property int $user_id
- * @property-read \FireflyIII\User $user
* @method static \Illuminate\Database\Eloquent\Builder|\FireflyIII\Models\Preference newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\FireflyIII\Models\Preference newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\FireflyIII\Models\Preference query()
diff --git a/app/Models/Rule.php b/app/Models/Rule.php
index 4bbd508263..e459eb4677 100644
--- a/app/Models/Rule.php
+++ b/app/Models/Rule.php
@@ -147,6 +147,7 @@ class Rule extends Model
/**
* @param $value
+ * @codeCoverageIgnore
*/
public function setDescriptionAttribute($value): void
{
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index a599ebbb8f..8591b1f2c0 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -102,10 +102,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property Carbon updated_at
* @property string foreign_currency_code
* @SuppressWarnings (PHPMD.TooManyPublicMethods)
- * @property \Illuminate\Support\Carbon|null $created_at
- * @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
- * @property bool $reconciled
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Budget[] $budgets
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Category[] $categories
* @method static \Illuminate\Database\Eloquent\Builder|\FireflyIII\Models\Transaction after(\Carbon\Carbon $date)
@@ -185,30 +182,6 @@ class Transaction extends Model
return false;
}
- /**
- * Route binder. Converts the key in the URL to the specified object (or throw 404).
- *
- * @param string $value
- *
- * @return Transaction
- * @throws NotFoundHttpException
- */
- public static function routeBinder(string $value): Transaction
- {
- if (auth()->check()) {
- $transactionId = (int)$value;
- /** @var User $user */
- $user = auth()->user();
- /** @var Transaction $transaction */
- $transaction = $user->transactions()->where('transactions.id', $transactionId)->first(['transactions.*']);
- if (null !== $transaction) {
- return $transaction;
- }
- }
-
- throw new NotFoundHttpException;
- }
-
/**
* Get the account this object belongs to.
diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.php
index 67a2595c70..09f6188e9a 100644
--- a/app/Support/Binder/BudgetList.php
+++ b/app/Support/Binder/BudgetList.php
@@ -46,11 +46,13 @@ class BudgetList implements BinderInterface
//Log::debug(sprintf('Now in BudgetList::routeBinder("%s")', $value));
if (auth()->check()) {
$list = array_unique(array_map('\intval', explode(',', $value)));
- //Log::debug('List is now', $list);
+
+ // @codeCoverageIgnoreStart
if (0 === count($list)) {
Log::warning('Budget list count is zero, return 404.');
- throw new NotFoundHttpException; // @codeCoverageIgnore
+ throw new NotFoundHttpException;
}
+ // @codeCoverageIgnoreEnd
/** @var Collection $collection */
$collection = auth()->user()->budgets()
diff --git a/app/Support/Binder/ImportProvider.php b/app/Support/Binder/ImportProvider.php
index 4ee846d1e5..02cde65d27 100644
--- a/app/Support/Binder/ImportProvider.php
+++ b/app/Support/Binder/ImportProvider.php
@@ -44,8 +44,14 @@ class ImportProvider implements BinderInterface
{
$repository = app(UserRepositoryInterface::class);
// get and filter all import routines:
+
+ if (!auth()->check()) {
+ return [];
+ }
+
/** @var User $user */
$user = auth()->user();
+
/** @var array $config */
$providerNames = array_keys(config('import.enabled'));
$providers = [];
@@ -55,13 +61,20 @@ class ImportProvider implements BinderInterface
// only consider enabled providers
$enabled = (bool)config(sprintf('import.enabled.%s', $providerName));
$allowedForUser = (bool)config(sprintf('import.allowed_for_user.%s', $providerName));
+ $allowedForDemo = (bool)config(sprintf('import.allowed_for_demo.%s', $providerName));
if (false === $enabled) {
continue;
}
-
- if (false === $isDemoUser && false === $allowedForUser && false === $isDebug) {
- continue; // @codeCoverageIgnore
+ if (false === $allowedForUser && !$isDemoUser) {
+ continue;
}
+ if (false === $allowedForDemo && $isDemoUser) {
+ continue;
+ }
+
+// if (false === $isDemoUser && false === $allowedForUser && false === $isDebug) {
+// continue;
+// }
$providers[$providerName] = [
'has_prereq' => (bool)config('import.has_prereq.' . $providerName),
diff --git a/app/Support/Binder/TagList.php b/app/Support/Binder/TagList.php
index 150b072772..62d64dd568 100644
--- a/app/Support/Binder/TagList.php
+++ b/app/Support/Binder/TagList.php
@@ -46,17 +46,20 @@ class TagList implements BinderInterface
if (auth()->check()) {
$list = array_unique(array_map('\strtolower', explode(',', $value)));
Log::debug('List of tags is', $list);
+ // @codeCoverageIgnoreStart
if (0 === count($list)) {
Log::error('Tag list is empty.');
- throw new NotFoundHttpException; // @codeCoverageIgnore
+ throw new NotFoundHttpException;
}
+ // @codeCoverageIgnoreEnd
+
/** @var TagRepositoryInterface $repository */
$repository = app(TagRepositoryInterface::class);
$repository->setUser(auth()->user());
$allTags = $repository->get();
$collection = $allTags->filter(
- function (Tag $tag) use ($list) {
+ static function (Tag $tag) use ($list) {
if (in_array(strtolower($tag->tag), $list, true)) {
return true;
}
diff --git a/app/Support/Binder/TransactionGroup.php b/app/Support/Binder/TransactionGroup.php
deleted file mode 100644
index abe4fe05e0..0000000000
--- a/app/Support/Binder/TransactionGroup.php
+++ /dev/null
@@ -1,53 +0,0 @@
-.
- */
-declare(strict_types=1);
-
-namespace FireflyIII\Support\Binder;
-
-use FireflyIII\Models\TransactionJournal;
-use Illuminate\Routing\Route;
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
-/**
- * Class TransactionGroup.
- */
-class TransactionGroup implements BinderInterface
-{
- /**
- * @param string $value
- * @param Route $route
- *
- * @return TransactionGroup
- * @throws NotFoundHttpException
- */
- public static function routeBinder(string $value, Route $route): TransactionGroup
- {
- if (auth()->check()) {
- $group = auth()->user()->transactionGroups()
- ->find($value);
- if (null !== $group) {
- return $group;
- }
- }
-
- throw new NotFoundHttpException;
- }
-}
diff --git a/app/Support/Binder/UnfinishedJournal.php b/app/Support/Binder/UnfinishedJournal.php
deleted file mode 100644
index b255144d8a..0000000000
--- a/app/Support/Binder/UnfinishedJournal.php
+++ /dev/null
@@ -1,55 +0,0 @@
-.
- */
-declare(strict_types=1);
-
-namespace FireflyIII\Support\Binder;
-
-use FireflyIII\Models\TransactionJournal;
-use Illuminate\Routing\Route;
-use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
-/**
- * Class Date.
- */
-class UnfinishedJournal implements BinderInterface
-{
- /**
- * @param string $value
- * @param Route $route
- *
- * @return TransactionJournal
- * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
- */
- public static function routeBinder(string $value, Route $route): TransactionJournal
- {
- if (auth()->check()) {
- $journal = auth()->user()->transactionJournals()->where('transaction_journals.id', $value)
- ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
- ->where('completed', 0)
- ->where('user_id', auth()->user()->id)->first(['transaction_journals.*']);
- if (null !== $journal) {
- return $journal;
- }
- }
-
- throw new NotFoundHttpException;
- }
-}
diff --git a/config/firefly.php b/config/firefly.php
index e062578248..ad3419778e 100644
--- a/config/firefly.php
+++ b/config/firefly.php
@@ -23,7 +23,6 @@
declare(strict_types=1);
-use FireflyIII\Export\Exporter\CsvExporter;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Attachment;
@@ -32,7 +31,6 @@ use FireflyIII\Models\Bill;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\Category;
-use FireflyIII\Models\ExportJob;
use FireflyIII\Models\ImportJob;
use FireflyIII\Models\LinkType;
use FireflyIII\Models\PiggyBank;
@@ -41,7 +39,6 @@ use FireflyIII\Models\Recurrence;
use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\Tag;
-use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
@@ -60,7 +57,6 @@ use FireflyIII\Support\Binder\ImportProvider;
use FireflyIII\Support\Binder\JournalList;
use FireflyIII\Support\Binder\TagList;
use FireflyIII\Support\Binder\TagOrId;
-use FireflyIII\Support\Binder\UnfinishedJournal;
use FireflyIII\TransactionRules\Actions\AddTag;
use FireflyIII\TransactionRules\Actions\AppendDescription;
use FireflyIII\TransactionRules\Actions\AppendNotes;
@@ -377,7 +373,6 @@ return [
'rule' => Rule::class,
'ruleGroup' => RuleGroup::class,
'importJob' => ImportJob::class,
- 'transaction' => Transaction::class,
'transactionGroup' => TransactionGroup::class,
'user' => User::class,
@@ -401,7 +396,6 @@ return [
// others
'fromCurrencyCode' => CurrencyCode::class,
'toCurrencyCode' => CurrencyCode::class,
- 'unfinishedJournal' => UnfinishedJournal::class,
'cliToken' => CLIToken::class,
'tagOrId' => TagOrId::class,
'configName' => ConfigurationName::class,
diff --git a/tests/Feature/Controllers/AttachmentControllerTest.php b/tests/Feature/Controllers/AttachmentControllerTest.php
index 2bc51c5a17..9e762d2dab 100644
--- a/tests/Feature/Controllers/AttachmentControllerTest.php
+++ b/tests/Feature/Controllers/AttachmentControllerTest.php
@@ -23,9 +23,7 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
use FireflyIII\Models\Attachment;
-use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
@@ -63,7 +61,7 @@ class AttachmentControllerTest extends TestCase
// mock stuff
$this->mock(AttachmentRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
@@ -122,8 +120,8 @@ class AttachmentControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
- $attachment = $this->getRandomAttachment();
- $repository = $this->mock(AttachmentRepositoryInterface::class);
+ $attachment = $this->getRandomAttachment();
+ $repository = $this->mock(AttachmentRepositoryInterface::class);
$repository->shouldReceive('exists')->once()->andReturn(false);
@@ -207,7 +205,7 @@ class AttachmentControllerTest extends TestCase
$attachment = $this->getRandomAttachment();
$this->mockDefaultSession();
- $repository = $this->mock(AttachmentRepositoryInterface::class);
+ $repository = $this->mock(AttachmentRepositoryInterface::class);
$repository->shouldReceive('exists')->once()->andReturn(true);
$repository->shouldReceive('getContent')->once()->andReturn('This is attachment number one.');
diff --git a/tests/Feature/Controllers/BillControllerTest.php b/tests/Feature/Controllers/BillControllerTest.php
index a460ed98ee..281b6645e1 100644
--- a/tests/Feature/Controllers/BillControllerTest.php
+++ b/tests/Feature/Controllers/BillControllerTest.php
@@ -160,10 +160,10 @@ class BillControllerTest extends TestCase
// mock stuff
$this->mock(AttachmentHelperInterface::class);
- $bill = $this->getRandomBill();
- $repository = $this->mock(BillRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $transformer = $this->mock(BillTransformer::class);
+ $bill = $this->getRandomBill();
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $transformer = $this->mock(BillTransformer::class);
$pref = new Preference;
$pref->data = 50;
@@ -172,8 +172,8 @@ class BillControllerTest extends TestCase
$transformer->shouldReceive('setParameters')->atLeast()->once();
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(
- ['id' => 5, 'active' => true, 'name' => 'x', 'next_expected_match' => '2018-01-01',
- 'currency' => $this->getEuro(),
+ ['id' => 5, 'active' => true, 'name' => 'x', 'next_expected_match' => '2018-01-01',
+ 'currency' => $this->getEuro(),
]
);
@@ -201,8 +201,8 @@ class BillControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
- $rule = $this->getRandomRule();
- $repository = $this->mock(BillRepositoryInterface::class);
+ $rule = $this->getRandomRule();
+ $repository = $this->mock(BillRepositoryInterface::class);
$this->mock(AttachmentHelperInterface::class);
@@ -414,8 +414,8 @@ class BillControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
$repository->shouldReceive('store')->andReturn(new Bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');
@@ -450,8 +450,8 @@ class BillControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
- $attachHelper = $this->mock(AttachmentHelperInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
+ $attachHelper = $this->mock(AttachmentHelperInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
$repository->shouldReceive('update')->andReturn(new Bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');
diff --git a/tests/Feature/Controllers/Budget/DeleteControllerTest.php b/tests/Feature/Controllers/Budget/DeleteControllerTest.php
index 21621106d4..08fa1dd524 100644
--- a/tests/Feature/Controllers/Budget/DeleteControllerTest.php
+++ b/tests/Feature/Controllers/Budget/DeleteControllerTest.php
@@ -57,7 +57,7 @@ class DeleteControllerTest extends TestCase
// mock stuff
$this->mock(BudgetRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
@@ -77,7 +77,7 @@ class DeleteControllerTest extends TestCase
$budget = $this->getRandomBudget();
Log::debug('Now in testDestroy()');
// mock stuff
- $repository = $this->mock(BudgetRepositoryInterface::class);
+ $repository = $this->mock(BudgetRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);
diff --git a/tests/Feature/Controllers/Budget/EditControllerTest.php b/tests/Feature/Controllers/Budget/EditControllerTest.php
index 9cdfb28f5b..60082c81e5 100644
--- a/tests/Feature/Controllers/Budget/EditControllerTest.php
+++ b/tests/Feature/Controllers/Budget/EditControllerTest.php
@@ -54,7 +54,7 @@ class EditControllerTest extends TestCase
Log::debug('Now in testEdit()');
// mock stuff
$this->mock(BudgetRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$this->mockDefaultSession();
@@ -74,7 +74,7 @@ class EditControllerTest extends TestCase
Log::debug('Now in testUpdate()');
// mock stuff
$budget = $this->getRandomBudget();
- $repository = $this->mock(BudgetRepositoryInterface::class);
+ $repository = $this->mock(BudgetRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('findNull')->andReturn($budget);
diff --git a/tests/Feature/Controllers/Budget/IndexControllerTest.php b/tests/Feature/Controllers/Budget/IndexControllerTest.php
index ea01a0100e..cddfce6f07 100644
--- a/tests/Feature/Controllers/Budget/IndexControllerTest.php
+++ b/tests/Feature/Controllers/Budget/IndexControllerTest.php
@@ -65,7 +65,7 @@ class IndexControllerTest extends TestCase
public function testIndex(string $range): void
{
// mock stuff
- $budget = $this->getRandomBudget();
+ $budget = $this->getRandomBudget();
$budgetLimit = $this->getRandomBudgetLimit();
$budgetLimit->start_date = Carbon::now()->startOfMonth();
$budgetLimit->end_date = Carbon::now()->endOfMonth();
@@ -102,7 +102,7 @@ class IndexControllerTest extends TestCase
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
- $response = $this->get(route('budgets.index'));
+ $response = $this->get(route('budgets.index'));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('
');
diff --git a/tests/Feature/Controllers/Budget/ShowControllerTest.php b/tests/Feature/Controllers/Budget/ShowControllerTest.php
index e67706b927..6896ca630d 100644
--- a/tests/Feature/Controllers/Budget/ShowControllerTest.php
+++ b/tests/Feature/Controllers/Budget/ShowControllerTest.php
@@ -222,7 +222,7 @@ class ShowControllerTest extends TestCase
{
$accountRepository = $this->mock(AccountRepositoryInterface::class);
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
- $collector = $this->mock(GroupCollectorInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
diff --git a/tests/Feature/Controllers/Category/CreateControllerTest.php b/tests/Feature/Controllers/Category/CreateControllerTest.php
index b5b20bd77b..5539ccbb9f 100644
--- a/tests/Feature/Controllers/Category/CreateControllerTest.php
+++ b/tests/Feature/Controllers/Category/CreateControllerTest.php
@@ -52,7 +52,7 @@ class CreateControllerTest extends TestCase
Log::debug('TestCreate()');
// mock stuff
$this->mock(CategoryRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->mockDefaultSession();
@@ -71,7 +71,7 @@ class CreateControllerTest extends TestCase
public function testStore(): void
{
Log::debug('Test store()');
- $repository = $this->mock(CategoryRepositoryInterface::class);
+ $repository = $this->mock(CategoryRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$repository->shouldReceive('findNull')->andReturn(new Category);
diff --git a/tests/Feature/Controllers/Category/DeleteControllerTest.php b/tests/Feature/Controllers/Category/DeleteControllerTest.php
index 76d24db190..55ef0ab04f 100644
--- a/tests/Feature/Controllers/Category/DeleteControllerTest.php
+++ b/tests/Feature/Controllers/Category/DeleteControllerTest.php
@@ -53,7 +53,7 @@ class DeleteControllerTest extends TestCase
// mock stuff
$this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
diff --git a/tests/Feature/Controllers/Category/EditControllerTest.php b/tests/Feature/Controllers/Category/EditControllerTest.php
index 0f4c99a3b3..f45c813d18 100644
--- a/tests/Feature/Controllers/Category/EditControllerTest.php
+++ b/tests/Feature/Controllers/Category/EditControllerTest.php
@@ -67,7 +67,6 @@ class EditControllerTest extends TestCase
}
-
/**
* @covers \FireflyIII\Http\Controllers\Category\EditController
* @covers \FireflyIII\Http\Requests\CategoryFormRequest
@@ -75,8 +74,8 @@ class EditControllerTest extends TestCase
public function testUpdate(): void
{
Log::debug('Test update()');
- $category = Category::first();
- $repository = $this->mock(CategoryRepositoryInterface::class);
+ $category = Category::first();
+ $repository = $this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
diff --git a/tests/Feature/Controllers/Category/NoCategoryControllerTest.php b/tests/Feature/Controllers/Category/NoCategoryControllerTest.php
index 916cfaa293..4619c7b63d 100644
--- a/tests/Feature/Controllers/Category/NoCategoryControllerTest.php
+++ b/tests/Feature/Controllers/Category/NoCategoryControllerTest.php
@@ -67,10 +67,10 @@ class NoCategoryControllerTest extends TestCase
*/
public function testNoCategory(string $range): void
{
- $collector = $this->mock(GroupCollectorInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
// list size
@@ -108,11 +108,11 @@ class NoCategoryControllerTest extends TestCase
*/
public function testNoCategoryAll(string $range): void
{
- $collector = $this->mock(GroupCollectorInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $fiscalHelper = $this->mock(FiscalHelperInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $fiscalHelper = $this->mock(FiscalHelperInterface::class);
$this->mockDefaultSession();
// list size
@@ -150,12 +150,12 @@ class NoCategoryControllerTest extends TestCase
*/
public function testNoCategoryDate(string $range): void
{
- $collector = $this->mock(GroupCollectorInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $fiscalHelper = $this->mock(FiscalHelperInterface::class);
- $date = new Carbon;
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $fiscalHelper = $this->mock(FiscalHelperInterface::class);
+ $date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
diff --git a/tests/Feature/Controllers/Category/ShowControllerTest.php b/tests/Feature/Controllers/Category/ShowControllerTest.php
index 032cec1983..c6fbeaeb81 100644
--- a/tests/Feature/Controllers/Category/ShowControllerTest.php
+++ b/tests/Feature/Controllers/Category/ShowControllerTest.php
@@ -123,10 +123,10 @@ class ShowControllerTest extends TestCase
*/
public function testShowAll(string $range): void
{
- $withdrawal = $this->getRandomWithdrawalAsArray();
- $repository = $this->mock(CategoryRepositoryInterface::class);
- $collector = $this->mock(GroupCollectorInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $withdrawal = $this->getRandomWithdrawalAsArray();
+ $repository = $this->mock(CategoryRepositoryInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$pref = new Preference;
diff --git a/tests/Feature/Controllers/Chart/AccountControllerTest.php b/tests/Feature/Controllers/Chart/AccountControllerTest.php
index cbf106d1f9..68a09b58af 100644
--- a/tests/Feature/Controllers/Chart/AccountControllerTest.php
+++ b/tests/Feature/Controllers/Chart/AccountControllerTest.php
@@ -26,12 +26,9 @@ use Carbon\Carbon;
use Exception;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
-
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
-use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference;
-use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
@@ -118,14 +115,14 @@ class AccountControllerTest extends TestCase
*/
public function testExpenseBudget(string $range): void
{
- $generator = $this->mock(GeneratorInterface::class);
- $collector = $this->mock(GroupCollectorInterface::class);
- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);
+ $generator = $this->mock(GeneratorInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
+ $budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$this->mock(CurrencyRepositoryInterface::class);
- $fiscalHelper = $this->mock(FiscalHelperInterface::class);
- $withdrawal = $this->getRandomWithdrawalAsArray();
- $budget = $this->user()->budgets()->find($withdrawal['budget_id']);
+ $fiscalHelper = $this->mock(FiscalHelperInterface::class);
+ $withdrawal = $this->getRandomWithdrawalAsArray();
+ $budget = $this->user()->budgets()->find($withdrawal['budget_id']);
// mock default session
$this->mockDefaultSession();
@@ -158,14 +155,14 @@ class AccountControllerTest extends TestCase
*/
public function testExpenseBudgetAll(string $range): void
{
- $generator = $this->mock(GeneratorInterface::class);
- $collector = $this->mock(GroupCollectorInterface::class);
- $budgetRepos = $this->mock(BudgetRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $generator = $this->mock(GeneratorInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
+ $budgetRepos = $this->mock(BudgetRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
$this->mock(CurrencyRepositoryInterface::class);
$this->mock(FiscalHelperInterface::class);
- $withdrawal = $this->getRandomWithdrawalAsArray();
- $budget = $this->user()->budgets()->find($withdrawal['budget_id']);
+ $withdrawal = $this->getRandomWithdrawalAsArray();
+ $budget = $this->user()->budgets()->find($withdrawal['budget_id']);
// mock default session
$this->mockDefaultSession();
@@ -202,9 +199,9 @@ class AccountControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
$this->mock(CurrencyRepositoryInterface::class);
- $fiscalHelper = $this->mock(FiscalHelperInterface::class);
- $withdrawal = $this->getRandomWithdrawalAsArray();
- $category = $this->user()->categories()->find($withdrawal['category_id']);
+ $fiscalHelper = $this->mock(FiscalHelperInterface::class);
+ $withdrawal = $this->getRandomWithdrawalAsArray();
+ $category = $this->user()->categories()->find($withdrawal['category_id']);
// mock default session
$this->mockDefaultSession();
@@ -245,8 +242,8 @@ class AccountControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$this->mock(CurrencyRepositoryInterface::class);
- $withdrawal = $this->getRandomWithdrawalAsArray();
- $category = $this->user()->categories()->find($withdrawal['category_id']);
+ $withdrawal = $this->getRandomWithdrawalAsArray();
+ $category = $this->user()->categories()->find($withdrawal['category_id']);
// mock default session
$this->mockDefaultSession();
@@ -404,7 +401,7 @@ class AccountControllerTest extends TestCase
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
- $date = new Carbon;
+ $date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
$accountRepos->shouldReceive('oldestJournalDate')->andReturn(new Carbon);
@@ -433,7 +430,7 @@ class AccountControllerTest extends TestCase
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
- $date = new Carbon;
+ $date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
diff --git a/tests/Feature/Controllers/Chart/BudgetControllerTest.php b/tests/Feature/Controllers/Chart/BudgetControllerTest.php
index 68572aeebe..568def1fcd 100644
--- a/tests/Feature/Controllers/Chart/BudgetControllerTest.php
+++ b/tests/Feature/Controllers/Chart/BudgetControllerTest.php
@@ -27,9 +27,7 @@ use Exception;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
-use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
-use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
@@ -309,8 +307,8 @@ class BudgetControllerTest extends TestCase
public function testFrontpageNoLimits(string $range): void
{
- $repository = $this->mock(BudgetRepositoryInterface::class);
- $generator = $this->mock(GeneratorInterface::class);
+ $repository = $this->mock(BudgetRepositoryInterface::class);
+ $generator = $this->mock(GeneratorInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$budget = $this->getRandomBudget();
@@ -341,11 +339,11 @@ class BudgetControllerTest extends TestCase
*/
public function testPeriod(): void
{
- $repository = $this->mock(BudgetRepositoryInterface::class);
- $generator = $this->mock(GeneratorInterface::class);
- $budgetLimit = $this->getRandomBudgetLimit();
- $fiscalHelper = $this->mock(FiscalHelperInterface::class);
- $date = new Carbon;
+ $repository = $this->mock(BudgetRepositoryInterface::class);
+ $generator = $this->mock(GeneratorInterface::class);
+ $budgetLimit = $this->getRandomBudgetLimit();
+ $fiscalHelper = $this->mock(FiscalHelperInterface::class);
+ $date = new Carbon;
// mock default session
$this->mockDefaultSession();
diff --git a/tests/Feature/Controllers/Chart/BudgetReportControllerTest.php b/tests/Feature/Controllers/Chart/BudgetReportControllerTest.php
index dcc3a58b37..fa375a3001 100644
--- a/tests/Feature/Controllers/Chart/BudgetReportControllerTest.php
+++ b/tests/Feature/Controllers/Chart/BudgetReportControllerTest.php
@@ -26,10 +26,6 @@ use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
-
-
-
-
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\TransactionType;
@@ -39,6 +35,7 @@ use Log;
use Preferences;
use Tests\TestCase;
+
/**
* Class BudgetReportControllerTest
*/
@@ -134,7 +131,7 @@ class BudgetReportControllerTest extends TestCase
$limit3->budget_id = $budget->id;
$limit3->start_date = new Carbon('2012-01-01');
$limit3->end_date = new Carbon('2012-01-31');
- $limit3->amount = '100';
+ $limit3->amount = '100';
$limit3->save();
diff --git a/tests/Feature/Controllers/Chart/CategoryReportControllerTest.php b/tests/Feature/Controllers/Chart/CategoryReportControllerTest.php
index a121fa6035..92cb518b54 100644
--- a/tests/Feature/Controllers/Chart/CategoryReportControllerTest.php
+++ b/tests/Feature/Controllers/Chart/CategoryReportControllerTest.php
@@ -26,18 +26,13 @@ use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
-
-
-
-
-
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
-use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use Log;
use Preferences;
use Tests\TestCase;
+
/**
* Class CategoryReportControllerTest
*/
@@ -173,7 +168,7 @@ class CategoryReportControllerTest extends TestCase
$collector = $this->mock(GroupCollectorInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
- $withdrawal = $this->getRandomWithdrawalAsArray();
+ $withdrawal = $this->getRandomWithdrawalAsArray();
$this->mockDefaultSession();
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
diff --git a/tests/Feature/Controllers/Chart/ExpenseReportControllerTest.php b/tests/Feature/Controllers/Chart/ExpenseReportControllerTest.php
index 8809be65f8..eb31db4d29 100644
--- a/tests/Feature/Controllers/Chart/ExpenseReportControllerTest.php
+++ b/tests/Feature/Controllers/Chart/ExpenseReportControllerTest.php
@@ -58,7 +58,7 @@ class ExpenseReportControllerTest extends TestCase
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$expense = $this->getRandomExpense();
$date = new Carbon;
- $withdrawal = $this->getRandomWithdrawalAsArray();
+ $withdrawal = $this->getRandomWithdrawalAsArray();
$accountRepository->shouldReceive('findByName')->once()->andReturn($expense);
diff --git a/tests/Feature/Controllers/Chart/PiggyBankControllerTest.php b/tests/Feature/Controllers/Chart/PiggyBankControllerTest.php
index c784b87b12..4eeb80bf0e 100644
--- a/tests/Feature/Controllers/Chart/PiggyBankControllerTest.php
+++ b/tests/Feature/Controllers/Chart/PiggyBankControllerTest.php
@@ -52,7 +52,7 @@ class PiggyBankControllerTest extends TestCase
$generator = $this->mock(GeneratorInterface::class);
$repository = $this->mock(PiggyBankRepositoryInterface::class);
/** @var PiggyBankEvent $event */
- $event = PiggyBankEvent::inRandomOrder()->first();
+ $event = PiggyBankEvent::inRandomOrder()->first();
$piggy = $event->piggy_bank_id;
$this->mockDefaultSession();
diff --git a/tests/Feature/Controllers/Chart/TagReportControllerTest.php b/tests/Feature/Controllers/Chart/TagReportControllerTest.php
index ea1fb5b54f..45cf7fa7bb 100644
--- a/tests/Feature/Controllers/Chart/TagReportControllerTest.php
+++ b/tests/Feature/Controllers/Chart/TagReportControllerTest.php
@@ -194,9 +194,9 @@ class TagReportControllerTest extends TestCase
public function testMainChart(): void
{
$this->mock(AccountRepositoryInterface::class);
- $generator = $this->mock(GeneratorInterface::class);
- $collector = $this->mock(GroupCollectorInterface::class);
- $tagRepos = $this->mock(TagRepositoryInterface::class);
+ $generator = $this->mock(GeneratorInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
+ $tagRepos = $this->mock(TagRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$withdrawal = $this->getRandomWithdrawalAsArray();
@@ -234,11 +234,11 @@ class TagReportControllerTest extends TestCase
public function testTagExpense(): void
{
$this->mockDefaultSession();
- $generator = $this->mock(GeneratorInterface::class);
- $pieChart = $this->mock(MetaPieChartInterface::class);
- $tagRepos = $this->mock(TagRepositoryInterface::class);
+ $generator = $this->mock(GeneratorInterface::class);
+ $pieChart = $this->mock(MetaPieChartInterface::class);
+ $tagRepos = $this->mock(TagRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
- $tag = $this->user()->tags()->first();
+ $tag = $this->user()->tags()->first();
$tagRepos->shouldReceive('setUser');
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
diff --git a/tests/Feature/Controllers/CurrencyControllerTest.php b/tests/Feature/Controllers/CurrencyControllerTest.php
index 74539ebbbe..8826b663a2 100644
--- a/tests/Feature/Controllers/CurrencyControllerTest.php
+++ b/tests/Feature/Controllers/CurrencyControllerTest.php
@@ -24,9 +24,7 @@ namespace Tests\Feature\Controllers;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionCurrency;
-use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
@@ -169,9 +167,9 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
- $repository = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $euro = $this->getEuro();
+ $repository = $this->mock(CurrencyRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $euro = $this->getEuro();
$repository->shouldReceive('currencyInUse')->andReturn(false);
@@ -192,9 +190,9 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
- $repository = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $euro = $this->getEuro();
+ $repository = $this->mock(CurrencyRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $euro = $this->getEuro();
$repository->shouldReceive('currencyInUse')->andReturn(false);
$repository->shouldReceive('destroy')->andReturn(true)->once();
@@ -350,8 +348,8 @@ class CurrencyControllerTest extends TestCase
$this->mockIntroPreference('shown_demo_currencies_index');
// mock stuff
- $repository = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $repository = $this->mock(CurrencyRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$currencies = TransactionCurrency::get();
@@ -385,8 +383,8 @@ class CurrencyControllerTest extends TestCase
$this->mockIntroPreference('shown_demo_currencies_index');
// mock stuff
- $repository = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $repository = $this->mock(CurrencyRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('getCurrencyByPreference')->andReturn(new TransactionCurrency);
@@ -418,8 +416,8 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
- $repository = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $repository = $this->mock(CurrencyRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('store')->andReturn(new TransactionCurrency);
@@ -447,8 +445,8 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
- $repository = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $repository = $this->mock(CurrencyRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('store')->andReturnNull();
@@ -476,8 +474,8 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
- $repository = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $repository = $this->mock(CurrencyRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('store')->andReturn(new TransactionCurrency);
@@ -505,8 +503,8 @@ class CurrencyControllerTest extends TestCase
$this->mockDefaultSession();
// mock stuff
- $repository = $this->mock(CurrencyRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $repository = $this->mock(CurrencyRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('update')->andReturn(new TransactionCurrency);
diff --git a/tests/Feature/Controllers/DebugControllerTest.php b/tests/Feature/Controllers/DebugControllerTest.php
index cfd4569b5c..61c99b049a 100644
--- a/tests/Feature/Controllers/DebugControllerTest.php
+++ b/tests/Feature/Controllers/DebugControllerTest.php
@@ -22,8 +22,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
-use FireflyIII\Models\TransactionJournal;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
use Mockery;
@@ -55,7 +53,7 @@ class DebugControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
$this->be($this->user());
@@ -71,7 +69,7 @@ class DebugControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
Preferences::shouldReceive('mark')->atLeast()->once();
@@ -115,7 +113,7 @@ class DebugControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
diff --git a/tests/Feature/Controllers/Import/PrerequisitesControllerTest.php b/tests/Feature/Controllers/Import/PrerequisitesControllerTest.php
index 81ae5164f4..0cb79cf1b9 100644
--- a/tests/Feature/Controllers/Import/PrerequisitesControllerTest.php
+++ b/tests/Feature/Controllers/Import/PrerequisitesControllerTest.php
@@ -29,9 +29,9 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\MessageBag;
use Log;
use Mockery;
+use Preferences;
use Tests\TestCase;
-use Preferences;
/**
* Class AccountControllerTest
*
@@ -56,8 +56,8 @@ class PrerequisitesControllerTest extends TestCase
public function testIndex(): void
{
$this->mockDefaultSession();
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $prereq = $this->mock(FakePrerequisites::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $prereq = $this->mock(FakePrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
$job = new ImportJob;
@@ -69,10 +69,9 @@ class PrerequisitesControllerTest extends TestCase
$job->file_type = '';
$job->save();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
-
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
@@ -97,7 +96,7 @@ class PrerequisitesControllerTest extends TestCase
public function testIndexBadState(): void
{
$this->mockDefaultSession();
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$this->mock(ImportJobRepositoryInterface::class);
@@ -110,10 +109,10 @@ class PrerequisitesControllerTest extends TestCase
$job->file_type = '';
$job->save();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'fake_api_key',null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'fake_api_key', null])->andReturnNull();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
@@ -134,9 +133,9 @@ class PrerequisitesControllerTest extends TestCase
$prereq = $this->mock(FakePrerequisites::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
$job = new ImportJob;
$job->user_id = $this->user()->id;
@@ -171,9 +170,9 @@ class PrerequisitesControllerTest extends TestCase
$prereq = $this->mock(FakePrerequisites::class);
$repository = $this->mock(ImportJobRepositoryInterface::class);
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
//Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'fake_api_key',null])->andReturnNull();
@@ -206,13 +205,13 @@ class PrerequisitesControllerTest extends TestCase
public function testPostBadState(): void
{
$this->mockDefaultSession();
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $prereq = $this->mock(FakePrerequisites::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $prereq = $this->mock(FakePrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
$job = new ImportJob;
$job->user_id = $this->user()->id;
@@ -242,13 +241,13 @@ class PrerequisitesControllerTest extends TestCase
public function testPostNoJob(): void
{
$this->mockDefaultSession();
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $prereq = $this->mock(FakePrerequisites::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $prereq = $this->mock(FakePrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
@@ -272,13 +271,13 @@ class PrerequisitesControllerTest extends TestCase
public function testPostWithMessages(): void
{
$this->mockDefaultSession();
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $prereq = $this->mock(FakePrerequisites::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $prereq = $this->mock(FakePrerequisites::class);
$this->mock(ImportJobRepositoryInterface::class);
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_api_key',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'spectre_app_id',null])->andReturnNull();
- Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'ynab_client_id',null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'bunq_api_key', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'spectre_app_id', null])->andReturnNull();
+ Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(), 'ynab_client_id', null])->andReturnNull();
//Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'fake_api_key',null])->andReturnNull();
$job = new ImportJob;
diff --git a/tests/Feature/Controllers/JavascriptControllerTest.php b/tests/Feature/Controllers/JavascriptControllerTest.php
index c515899e1a..d713a725e7 100644
--- a/tests/Feature/Controllers/JavascriptControllerTest.php
+++ b/tests/Feature/Controllers/JavascriptControllerTest.php
@@ -62,8 +62,8 @@ class JavascriptControllerTest extends TestCase
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$account = $this->getRandomAsset();
$euro = $this->getEuro();
- $pref = new Preference;
- $pref->data = 'EUR';
+ $pref = new Preference;
+ $pref->data = 'EUR';
Preferences::shouldReceive('get')->withArgs(['currencyPreference', 'EUR'])->atLeast()->once()->andReturn($pref);
diff --git a/tests/Feature/Controllers/Json/BoxControllerTest.php b/tests/Feature/Controllers/Json/BoxControllerTest.php
index a563c7fc11..86db1fadd0 100644
--- a/tests/Feature/Controllers/Json/BoxControllerTest.php
+++ b/tests/Feature/Controllers/Json/BoxControllerTest.php
@@ -111,7 +111,8 @@ class BoxControllerTest extends TestCase
* @covers \FireflyIII\Http\Controllers\Json\BoxController
*/
public function testBalance(): void
- { $this->mockDefaultSession();
+ {
+ $this->mockDefaultSession();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
@@ -138,11 +139,11 @@ class BoxControllerTest extends TestCase
*/
public function testBalanceTransactions(): void
{
- $withdrawal = $this->getRandomWithdrawalAsArray();
+ $withdrawal = $this->getRandomWithdrawalAsArray();
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$collector = $this->mock(GroupCollectorInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
- $euro =$this->getEuro();
+ $euro = $this->getEuro();
$this->mockDefaultSession();
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
diff --git a/tests/Feature/Controllers/Json/ExchangeControllerTest.php b/tests/Feature/Controllers/Json/ExchangeControllerTest.php
index 45a0ca63bd..23bad3798c 100644
--- a/tests/Feature/Controllers/Json/ExchangeControllerTest.php
+++ b/tests/Feature/Controllers/Json/ExchangeControllerTest.php
@@ -24,7 +24,6 @@ namespace Tests\Feature\Controllers\Json;
use Carbon\Carbon;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
-use FireflyIII\Models\CurrencyExchangeRate;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Services\Currency\ExchangeRateInterface;
use Log;
@@ -58,7 +57,7 @@ class ExchangeControllerTest extends TestCase
$this->mockDefaultSession();
- $date = new Carbon;
+ $date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
$rate = $this->getRandomCer();
@@ -77,7 +76,7 @@ class ExchangeControllerTest extends TestCase
$this->mockDefaultSession();
$repository = $this->mock(CurrencyRepositoryInterface::class);
- $rate = $this->getRandomCer();
+ $rate = $this->getRandomCer();
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
diff --git a/tests/Feature/Controllers/Json/IntroControllerTest.php b/tests/Feature/Controllers/Json/IntroControllerTest.php
index 21c792b35a..6ea39464e4 100644
--- a/tests/Feature/Controllers/Json/IntroControllerTest.php
+++ b/tests/Feature/Controllers/Json/IntroControllerTest.php
@@ -23,8 +23,8 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Json;
use Log;
-use Tests\TestCase;
use Preferences;
+use Tests\TestCase;
/**
* Class IntroControllerTest
diff --git a/tests/Feature/Controllers/Json/ReconcileControllerTest.php b/tests/Feature/Controllers/Json/ReconcileControllerTest.php
index d4902ff397..37d658ac77 100644
--- a/tests/Feature/Controllers/Json/ReconcileControllerTest.php
+++ b/tests/Feature/Controllers/Json/ReconcileControllerTest.php
@@ -27,14 +27,10 @@ namespace Tests\Feature\Controllers\Json;
use Amount;
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
-
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
-use FireflyIII\Models\Transaction;
-use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
-use Illuminate\Support\Collection;
use Log;
use Mockery;
use Preferences;
@@ -110,13 +106,13 @@ class ReconcileControllerTest extends TestCase
$this->mock(RecurringRepositoryInterface::class);
$this->mockDefaultSession();
- $repository = $this->mock(CurrencyRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $fiscalHelper = $this->mock(FiscalHelperInterface::class);
- $collector = $this->mock(GroupCollectorInterface::class);
- $date = new Carbon;
- $euro =$this->getEuro();
- $withdrawal = $this->getRandomWithdrawalAsArray();
+ $repository = $this->mock(CurrencyRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $fiscalHelper = $this->mock(FiscalHelperInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
+ $date = new Carbon;
+ $euro = $this->getEuro();
+ $withdrawal = $this->getRandomWithdrawalAsArray();
$accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);
diff --git a/tests/Feature/Controllers/Json/RuleControllerTest.php b/tests/Feature/Controllers/Json/RuleControllerTest.php
index b5a45ae934..25f2d93853 100644
--- a/tests/Feature/Controllers/Json/RuleControllerTest.php
+++ b/tests/Feature/Controllers/Json/RuleControllerTest.php
@@ -22,8 +22,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
-use FireflyIII\Models\TransactionJournal;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Log;
use Tests\TestCase;
diff --git a/tests/Feature/Controllers/NewUserControllerTest.php b/tests/Feature/Controllers/NewUserControllerTest.php
index 68d5db2707..24970c89f0 100644
--- a/tests/Feature/Controllers/NewUserControllerTest.php
+++ b/tests/Feature/Controllers/NewUserControllerTest.php
@@ -22,7 +22,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
-use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
diff --git a/tests/Feature/Controllers/PiggyBankControllerTest.php b/tests/Feature/Controllers/PiggyBankControllerTest.php
index c78f7993f8..db2efd49c5 100644
--- a/tests/Feature/Controllers/PiggyBankControllerTest.php
+++ b/tests/Feature/Controllers/PiggyBankControllerTest.php
@@ -425,7 +425,7 @@ class PiggyBankControllerTest extends TestCase
$userRepos = $this->mock(UserRepositoryInterface::class);
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
$repetition = PiggyBankRepetition::first();
- $piggyBank = $this->getRandomPiggyBank();
+ $piggyBank = $this->getRandomPiggyBank();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
@@ -449,8 +449,8 @@ class PiggyBankControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
- $repository = $this->mock(PiggyBankRepositoryInterface::class);
- $piggyBank = $this->getRandomPiggyBank();
+ $repository = $this->mock(PiggyBankRepositoryInterface::class);
+ $piggyBank = $this->getRandomPiggyBank();
$this->mock(CurrencyRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
@@ -471,12 +471,12 @@ class PiggyBankControllerTest extends TestCase
$this->mockDefaultSession();
$this->mockIntroPreference('shown_demo_piggy-banks_show');
// mock stuff
- $first = $this->user()->transactionJournals()->inRandomOrder()->first();
- $repository = $this->mock(PiggyBankRepositoryInterface::class);
- $journalRepos = $this->mock(JournalRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $transformer = $this->mock(PiggyBankTransformer::class);
- $piggyBank = $this->getRandomPiggyBank();
+ $first = $this->user()->transactionJournals()->inRandomOrder()->first();
+ $repository = $this->mock(PiggyBankRepositoryInterface::class);
+ $journalRepos = $this->mock(JournalRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $transformer = $this->mock(PiggyBankTransformer::class);
+ $piggyBank = $this->getRandomPiggyBank();
$this->mock(CurrencyRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
@@ -506,7 +506,7 @@ class PiggyBankControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
- $repository = $this->mock(PiggyBankRepositoryInterface::class);
+ $repository = $this->mock(PiggyBankRepositoryInterface::class);
$this->mock(CurrencyRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
@@ -535,8 +535,8 @@ class PiggyBankControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
- $repository = $this->mock(PiggyBankRepositoryInterface::class);
- $piggyBank = $this->getRandomPiggyBank();
+ $repository = $this->mock(PiggyBankRepositoryInterface::class);
+ $piggyBank = $this->getRandomPiggyBank();
$this->mock(CurrencyRepositoryInterface::class);
$this->mock(AccountRepositoryInterface::class);
diff --git a/tests/Feature/Controllers/Popup/ReportControllerTest.php b/tests/Feature/Controllers/Popup/ReportControllerTest.php
index d6753a53d7..8987cbbb12 100644
--- a/tests/Feature/Controllers/Popup/ReportControllerTest.php
+++ b/tests/Feature/Controllers/Popup/ReportControllerTest.php
@@ -25,13 +25,10 @@ namespace Tests\Feature\Controllers\Popup;
use Amount;
use Carbon\Carbon;
use FireflyIII\Helpers\Report\PopupReportInterface;
-use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
-use FireflyIII\Models\Category;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
-use Illuminate\Support\Collection;
use Log;
use Tests\TestCase;
@@ -192,8 +189,8 @@ class ReportControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$popupReport = $this->mock(PopupReportInterface::class);
- $account = $this->getRandomAsset();
- $budget = $this->getRandomBudget();
+ $account = $this->getRandomAsset();
+ $budget = $this->getRandomBudget();
$this->mockDefaultSession();
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
@@ -227,7 +224,7 @@ class ReportControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
- $budget = $this->getRandomBudget();
+ $budget = $this->getRandomBudget();
$this->mockDefaultSession();
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
@@ -259,7 +256,7 @@ class ReportControllerTest extends TestCase
$this->mock(AccountRepositoryInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
- $category = $this->getRandomCategory();
+ $category = $this->getRandomCategory();
$this->mockDefaultSession();
$categoryRepos->shouldReceive('findNull')->andReturn($category)->once()->withArgs([1]);
@@ -292,7 +289,7 @@ class ReportControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
- $account = $this->getRandomAsset();
+ $account = $this->getRandomAsset();
$this->mockDefaultSession();
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
@@ -325,7 +322,7 @@ class ReportControllerTest extends TestCase
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$popupHelper = $this->mock(PopupReportInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
- $account = $this->getRandomAsset();
+ $account = $this->getRandomAsset();
$this->mockDefaultSession();
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
diff --git a/tests/Feature/Controllers/PreferencesControllerTest.php b/tests/Feature/Controllers/PreferencesControllerTest.php
index 7ea35f0ed5..e16a710383 100644
--- a/tests/Feature/Controllers/PreferencesControllerTest.php
+++ b/tests/Feature/Controllers/PreferencesControllerTest.php
@@ -24,9 +24,7 @@ namespace Tests\Feature\Controllers;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference;
-use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
@@ -104,7 +102,7 @@ class PreferencesControllerTest extends TestCase
{
$this->mockDefaultSession();
// mock stuff
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->andReturn(false);
diff --git a/tests/Feature/Controllers/ProfileControllerTest.php b/tests/Feature/Controllers/ProfileControllerTest.php
index d01342f264..a24643f39d 100644
--- a/tests/Feature/Controllers/ProfileControllerTest.php
+++ b/tests/Feature/Controllers/ProfileControllerTest.php
@@ -24,8 +24,6 @@ namespace Tests\Feature\Controllers;
use Amount;
use FireflyIII\Models\Preference;
-use FireflyIII\Models\TransactionJournal;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Google2FA;
@@ -33,6 +31,7 @@ use Illuminate\Support\Collection;
use Log;
use Mockery;
use Preferences;
+use stdClass;
use Tests\TestCase;
/**
@@ -133,7 +132,7 @@ class ProfileControllerTest extends TestCase
$repository->shouldReceive('unblockUser');
$preference = new Preference;
$preference->data = 'existing-token';
- /** @var \stdClass $preference */
+ /** @var stdClass $preference */
$preference->user = $this->user();
Preferences::shouldReceive('findByName')->withArgs(['email_change_confirm_token'])->andReturn(new Collection([$preference]));
// email_change_confirm_token
@@ -205,8 +204,8 @@ class ProfileControllerTest extends TestCase
{
//$this->mockDefaultSession(); // DISABLED ON PURPOSE
$this->mockDefaultConfiguration();
- $repository = $this->mock(UserRepositoryInterface::class);
- $euro = $this->getEuro();
+ $repository = $this->mock(UserRepositoryInterface::class);
+ $euro = $this->getEuro();
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->times(1)->andReturn(false);
@@ -534,12 +533,12 @@ class ProfileControllerTest extends TestCase
$hash = hash('sha256', 'previous@example.com');
$tokenPreference = new Preference;
$tokenPreference->data = 'token';
- /** @var \stdClass $tokenPreference */
+ /** @var stdClass $tokenPreference */
$tokenPreference->user = $this->user();
$hashPreference = new Preference;
$hashPreference->data = 'previous@example.com';
- /** @var \stdClass $hashPreference */
+ /** @var stdClass $hashPreference */
$hashPreference->user = $this->user();
Preferences::shouldReceive('findByName')->once()->andReturn(new Collection([$tokenPreference]));
@@ -567,12 +566,12 @@ class ProfileControllerTest extends TestCase
$hash = hash('sha256', 'previous@example.comX');
$tokenPreference = new Preference;
$tokenPreference->data = 'token';
- /** @var \stdClass $tokenPreference */
+ /** @var stdClass $tokenPreference */
$tokenPreference->user = $this->user();
$hashPreference = new Preference;
$hashPreference->data = 'previous@example.com';
- /** @var \stdClass $hashPreference */
+ /** @var stdClass $hashPreference */
$hashPreference->user = $this->user();
Preferences::shouldReceive('findByName')->once()->andReturn(new Collection([$tokenPreference]));
diff --git a/tests/Feature/Controllers/Recurring/CreateControllerTest.php b/tests/Feature/Controllers/Recurring/CreateControllerTest.php
index f1d58d61ee..7b01332f31 100644
--- a/tests/Feature/Controllers/Recurring/CreateControllerTest.php
+++ b/tests/Feature/Controllers/Recurring/CreateControllerTest.php
@@ -29,7 +29,6 @@ use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
-use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
diff --git a/tests/Feature/Controllers/Recurring/IndexControllerTest.php b/tests/Feature/Controllers/Recurring/IndexControllerTest.php
index ee9912fc67..2be12cb775 100644
--- a/tests/Feature/Controllers/Recurring/IndexControllerTest.php
+++ b/tests/Feature/Controllers/Recurring/IndexControllerTest.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Recurring;
+use FireflyConfig;
use FireflyIII\Factory\CategoryFactory;
use FireflyIII\Models\Configuration;
use FireflyIII\Models\Preference;
@@ -91,7 +92,7 @@ class IndexControllerTest extends TestCase
$collection = $this->user()->recurrences()->take(2)->get();
// mock cron job config:
- \FireflyConfig::shouldReceive('get')->withArgs(['last_rt_job', 0])->once()->andReturn($config);
+ FireflyConfig::shouldReceive('get')->withArgs(['last_rt_job', 0])->once()->andReturn($config);
$repository->shouldReceive('get')->andReturn($collection)->once();
@@ -125,9 +126,9 @@ class IndexControllerTest extends TestCase
'recurrence_repetitions' => [
[
'occurrences' => [
- '2019-01-01'
- ]
- ]
+ '2019-01-01',
+ ],
+ ],
],
]
);
diff --git a/tests/Feature/Controllers/ReportControllerTest.php b/tests/Feature/Controllers/ReportControllerTest.php
index 6d3369c1ba..6776d7d829 100644
--- a/tests/Feature/Controllers/ReportControllerTest.php
+++ b/tests/Feature/Controllers/ReportControllerTest.php
@@ -295,7 +295,7 @@ class ReportControllerTest extends TestCase
$this->mockDefaultSession();
$this->mock(BudgetRepositoryInterface::class);
$this->mock(ReportHelperInterface::class);
- $repository = $this->mock(AccountRepositoryInterface::class);
+ $repository = $this->mock(AccountRepositoryInterface::class);
$account = new Account();
$account->name = 'Something';
@@ -338,7 +338,7 @@ class ReportControllerTest extends TestCase
{
Log::debug(sprintf('Now in test %s', __METHOD__));
$this->mockDefaultSession();
- $categoryRepos = $this->mock(CategoryRepositoryInterface::class);
+ $categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$this->mock(BudgetRepositoryInterface::class);
$this->mock(ReportHelperInterface::class);
$category = $this->getRandomCategory();
@@ -383,8 +383,8 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $asset = $this->getRandomAsset();
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $asset = $this->getRandomAsset();
// find the user's asset account
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($asset)->atLeast()->once();
@@ -414,7 +414,7 @@ class ReportControllerTest extends TestCase
{
Log::debug(sprintf('Now in test %s', __METHOD__));
$this->mockDefaultSession();
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
$this->mock(BudgetRepositoryInterface::class);
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
@@ -446,7 +446,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
$data = [
@@ -472,7 +472,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
$data = [
@@ -530,7 +530,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
@@ -558,8 +558,8 @@ class ReportControllerTest extends TestCase
$this->mock(BudgetRepositoryInterface::class);
$this->mock(ReportHelperInterface::class);
$this->mock(TagRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $categoryRepos = $this->mock(CategoryRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$categoryRepos->shouldReceive('findNull')->andReturn($this->user()->categories()->find(1))->twice();
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
@@ -588,7 +588,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
@@ -615,7 +615,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
@@ -642,7 +642,7 @@ class ReportControllerTest extends TestCase
$this->mock(ReportHelperInterface::class);
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
@@ -672,8 +672,8 @@ class ReportControllerTest extends TestCase
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
Log::debug(sprintf('Now in test %s', __METHOD__));
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $tagRepos = $this->mock(TagRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $tagRepos = $this->mock(TagRepositoryInterface::class);
/** @var Tag $tag */
$tag = $this->user()->tags()->find(1);
@@ -710,8 +710,8 @@ class ReportControllerTest extends TestCase
$this->mock(CategoryRepositoryInterface::class);
$this->mock(TagRepositoryInterface::class);
Log::debug(sprintf('Now in test %s', __METHOD__));
- $accountRepos = $this->mock(AccountRepositoryInterface::class);
- $tagRepos = $this->mock(TagRepositoryInterface::class);
+ $accountRepos = $this->mock(AccountRepositoryInterface::class);
+ $tagRepos = $this->mock(TagRepositoryInterface::class);
$tag2 = $this->user()->tags()->find(3);
diff --git a/tests/Feature/Controllers/Rule/CreateControllerTest.php b/tests/Feature/Controllers/Rule/CreateControllerTest.php
index 3a92054183..a50544fe69 100644
--- a/tests/Feature/Controllers/Rule/CreateControllerTest.php
+++ b/tests/Feature/Controllers/Rule/CreateControllerTest.php
@@ -25,9 +25,7 @@ namespace tests\Feature\Controllers\Rule;
use FireflyIII\Models\Rule;
-use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
diff --git a/tests/Feature/Controllers/Rule/DeleteControllerTest.php b/tests/Feature/Controllers/Rule/DeleteControllerTest.php
index 5f2cde8962..6abeb626dd 100644
--- a/tests/Feature/Controllers/Rule/DeleteControllerTest.php
+++ b/tests/Feature/Controllers/Rule/DeleteControllerTest.php
@@ -24,8 +24,6 @@ declare(strict_types=1);
namespace tests\Feature\Controllers\Rule;
-use FireflyIII\Models\TransactionJournal;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
@@ -55,15 +53,14 @@ class DeleteControllerTest extends TestCase
public function testDelete(): void
{
// mock stuff
- $ruleRepos = $this->mock(RuleRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $ruleRepos = $this->mock(RuleRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
-
$this->be($this->user());
$response = $this->get(route('rules.delete', [1]));
$response->assertStatus(200);
@@ -76,7 +73,7 @@ class DeleteControllerTest extends TestCase
public function testDestroy(): void
{
// mock stuff
- $repository = $this->mock(RuleRepositoryInterface::class);
+ $repository = $this->mock(RuleRepositoryInterface::class);
$repository->shouldReceive('destroy');
$this->mockDefaultSession();
diff --git a/tests/Feature/Controllers/Rule/EditControllerTest.php b/tests/Feature/Controllers/Rule/EditControllerTest.php
index dc9e96cf6f..35d67bb4a6 100644
--- a/tests/Feature/Controllers/Rule/EditControllerTest.php
+++ b/tests/Feature/Controllers/Rule/EditControllerTest.php
@@ -25,8 +25,6 @@ namespace tests\Feature\Controllers\Rule;
use FireflyIII\Models\Rule;
-use FireflyIII\Models\TransactionJournal;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
@@ -56,9 +54,9 @@ class EditControllerTest extends TestCase
public function testEdit(): void
{
// mock stuff
- $groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
- $repository = $this->mock(RuleRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
+ $repository = $this->mock(RuleRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
@@ -88,9 +86,9 @@ class EditControllerTest extends TestCase
$this->session(['_old_input' => $old]);
// mock stuff
- $groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
- $repository = $this->mock(RuleRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
+ $repository = $this->mock(RuleRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->mockDefaultSession();
@@ -111,8 +109,8 @@ class EditControllerTest extends TestCase
public function testUpdate(): void
{
// mock stuff
- $repository = $this->mock(RuleRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $repository = $this->mock(RuleRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$this->mockDefaultSession();
diff --git a/tests/Feature/Controllers/Rule/IndexControllerTest.php b/tests/Feature/Controllers/Rule/IndexControllerTest.php
index 0d8850cc97..379cacb139 100644
--- a/tests/Feature/Controllers/Rule/IndexControllerTest.php
+++ b/tests/Feature/Controllers/Rule/IndexControllerTest.php
@@ -23,8 +23,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Rule;
use FireflyIII\Models\RuleGroup;
-use FireflyIII\Models\TransactionJournal;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
diff --git a/tests/Feature/Controllers/Rule/SelectControllerTest.php b/tests/Feature/Controllers/Rule/SelectControllerTest.php
index 8603a0e9d1..2e5655cd89 100644
--- a/tests/Feature/Controllers/Rule/SelectControllerTest.php
+++ b/tests/Feature/Controllers/Rule/SelectControllerTest.php
@@ -26,10 +26,7 @@ namespace tests\Feature\Controllers\Rule;
use Carbon\Carbon;
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
use FireflyIII\Jobs\Job;
-use FireflyIII\Models\Transaction;
-use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\TransactionRules\TransactionMatcher;
@@ -82,7 +79,7 @@ class SelectControllerTest extends TestCase
Queue::assertPushed(
ExecuteRuleOnExistingTransactions::class, function (Job $job) {
- return 1=== $job->getRule()->id;
+ return 1 === $job->getRule()->id;
}
);
}
@@ -193,7 +190,6 @@ class SelectControllerTest extends TestCase
$accountRepos = $this->mock(AccountRepositoryInterface::class);
-
$matcher->shouldReceive('setStrict')->once()->withArgs([false]);
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
diff --git a/tests/Feature/Controllers/RuleGroup/CreateControllerTest.php b/tests/Feature/Controllers/RuleGroup/CreateControllerTest.php
index 9f8ba888f1..3a08c15886 100644
--- a/tests/Feature/Controllers/RuleGroup/CreateControllerTest.php
+++ b/tests/Feature/Controllers/RuleGroup/CreateControllerTest.php
@@ -52,7 +52,7 @@ class CreateControllerTest extends TestCase
{
$this->mockDefaultSession();
$this->mock(RuleGroupRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->be($this->user());
@@ -69,7 +69,7 @@ class CreateControllerTest extends TestCase
public function testStore(): void
{
$this->mockDefaultSession();
- $repository = $this->mock(RuleGroupRepositoryInterface::class);
+ $repository = $this->mock(RuleGroupRepositoryInterface::class);
Preferences::shouldReceive('mark')->atLeast()->once();
diff --git a/tests/Feature/Controllers/RuleGroup/ExecutionControllerTest.php b/tests/Feature/Controllers/RuleGroup/ExecutionControllerTest.php
index bd3dcfd5cb..4b620b4a46 100644
--- a/tests/Feature/Controllers/RuleGroup/ExecutionControllerTest.php
+++ b/tests/Feature/Controllers/RuleGroup/ExecutionControllerTest.php
@@ -24,9 +24,7 @@ namespace Tests\Feature\Controllers\RuleGroup;
use Carbon\Carbon;
use FireflyIII\Jobs\ExecuteRuleGroupOnExistingTransactions;
-use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
diff --git a/tests/Feature/Controllers/SearchControllerTest.php b/tests/Feature/Controllers/SearchControllerTest.php
index 6c50030354..36926ab9ba 100644
--- a/tests/Feature/Controllers/SearchControllerTest.php
+++ b/tests/Feature/Controllers/SearchControllerTest.php
@@ -75,7 +75,7 @@ class SearchControllerTest extends TestCase
public function testSearch(): void
{
$this->mockDefaultSession();
- $search = $this->mock(SearchInterface::class);
+ $search = $this->mock(SearchInterface::class);
$search->shouldReceive('parseQuery')->once();
$search->shouldReceive('setLimit')->withArgs([50])->once();
diff --git a/tests/Feature/Controllers/System/CronControllerTest.php b/tests/Feature/Controllers/System/CronControllerTest.php
index 5055812752..4b4c106b55 100644
--- a/tests/Feature/Controllers/System/CronControllerTest.php
+++ b/tests/Feature/Controllers/System/CronControllerTest.php
@@ -30,6 +30,7 @@ use FireflyIII\Support\Cronjobs\RecurringCronjob;
use Illuminate\Support\Collection;
use Log;
use Mockery;
+use Preferences;
use Tests\TestCase;
/**
@@ -61,7 +62,7 @@ class CronControllerTest extends TestCase
$job->shouldReceive('fire')->once()->andReturn(true);
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('all')->andReturn($users);
- \Preferences::shouldReceive('getForUser')
+ Preferences::shouldReceive('getForUser')
->withArgs([Mockery::any(), 'access_token', null])
->andReturn($preference)->once();
$response = $this->get(route('cron.cron', ['token']));
@@ -83,7 +84,7 @@ class CronControllerTest extends TestCase
$job->shouldReceive('fire')->once()->andThrow(new FireflyException('Exception noted.'));
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('all')->andReturn($users);
- \Preferences::shouldReceive('getForUser')
+ Preferences::shouldReceive('getForUser')
->withArgs([Mockery::any(), 'access_token', null])
->andReturn($preference)->once();
$response = $this->get(route('cron.cron', ['token']));
@@ -105,7 +106,7 @@ class CronControllerTest extends TestCase
$job->shouldReceive('fire')->once()->andReturn(false);
$repository = $this->mock(UserRepositoryInterface::class);
$repository->shouldReceive('all')->andReturn($users);
- \Preferences::shouldReceive('getForUser')
+ Preferences::shouldReceive('getForUser')
->withArgs([Mockery::any(), 'access_token', null])
->andReturn($preference)->once();
$response = $this->get(route('cron.cron', ['token']));
diff --git a/tests/Feature/Controllers/TagControllerTest.php b/tests/Feature/Controllers/TagControllerTest.php
index 02242aacfc..ad867e2da2 100644
--- a/tests/Feature/Controllers/TagControllerTest.php
+++ b/tests/Feature/Controllers/TagControllerTest.php
@@ -29,11 +29,9 @@ use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionType;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Pagination\LengthAwarePaginator;
-use Illuminate\Support\Collection;
use Log;
use Mockery;
use Preferences;
@@ -65,8 +63,8 @@ class TagControllerTest extends TestCase
{
$this->mockDefaultSession();
$this->mock(TagRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
-
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->be($this->user());
@@ -82,9 +80,9 @@ class TagControllerTest extends TestCase
{
$this->mockDefaultSession();
$this->mock(TagRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+
-
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->be($this->user());
@@ -99,7 +97,7 @@ class TagControllerTest extends TestCase
public function testDestroy(): void
{
$this->mockDefaultSession();
- $repository = $this->mock(TagRepositoryInterface::class);
+ $repository = $this->mock(TagRepositoryInterface::class);
$repository->shouldReceive('destroy');
Preferences::shouldReceive('mark')->atLeast()->once();
@@ -117,8 +115,8 @@ class TagControllerTest extends TestCase
{
$this->mockDefaultSession();
$this->mock(TagRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
-
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->be($this->user());
@@ -133,11 +131,11 @@ class TagControllerTest extends TestCase
public function testIndex(): void
{
$this->mockDefaultSession();
- $repository = $this->mock(TagRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $repository = $this->mock(TagRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
-
+
$repository->shouldReceive('count')->andReturn(0);
$repository->shouldReceive('tagCloud')->andReturn([]);
$repository->shouldReceive('oldestTag')->andReturn(null)->once();
@@ -315,7 +313,7 @@ class TagControllerTest extends TestCase
public function testStore(): void
{
$this->mockDefaultSession();
- $repository = $this->mock(TagRepositoryInterface::class);
+ $repository = $this->mock(TagRepositoryInterface::class);
Preferences::shouldReceive('mark')->atLeast()->once();
$repository->shouldReceive('findNull')->andReturn(null);
@@ -341,8 +339,8 @@ class TagControllerTest extends TestCase
public function testUpdate(): void
{
$this->mockDefaultSession();
- $repository = $this->mock(TagRepositoryInterface::class);
- $userRepos = $this->mock(UserRepositoryInterface::class);
+ $repository = $this->mock(TagRepositoryInterface::class);
+ $userRepos = $this->mock(UserRepositoryInterface::class);
Preferences::shouldReceive('mark')->atLeast()->once();
diff --git a/tests/Feature/Controllers/Transaction/ConvertControllerTest.php b/tests/Feature/Controllers/Transaction/ConvertControllerTest.php
index 9b42f8bfc1..03aadb530f 100644
--- a/tests/Feature/Controllers/Transaction/ConvertControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/ConvertControllerTest.php
@@ -24,10 +24,8 @@ namespace Tests\Feature\Controllers\Transaction;
use Amount;
use FireflyIII\Models\AccountType;
-use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
@@ -193,8 +191,6 @@ class ConvertControllerTest extends TestCase
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
-
-
$data = ['source_account_id' => 1];
$this->be($this->user());
$response = $this->post(route('transactions.convert.index.post', ['transfer', $deposit->id]), $data);
diff --git a/tests/Feature/Controllers/Transaction/CreateControllerTest.php b/tests/Feature/Controllers/Transaction/CreateControllerTest.php
index 0d2cbd92dc..55d091a564 100644
--- a/tests/Feature/Controllers/Transaction/CreateControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/CreateControllerTest.php
@@ -26,9 +26,9 @@ use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Log;
+use Mockery;
use Preferences;
use Tests\TestCase;
-use Mockery;
/**
* Class CreateControllerTest
@@ -56,7 +56,7 @@ class CreateControllerTest extends TestCase
$empty = new Preference;
$empty->data = [];
- $userRepos->shouldReceive('hasRole')->atLeast()->once()->withArgs([Mockery::any(),'owner'])->andReturn(true);
+ $userRepos->shouldReceive('hasRole')->atLeast()->once()->withArgs([Mockery::any(), 'owner'])->andReturn(true);
$accountRepos->shouldReceive('getCashAccount')->atLeast()->once()->andReturn($cash);
Preferences::shouldReceive('get')->withArgs(['transaction_journal_optional_fields', []])->atLeast()->once()->andReturn($empty);
diff --git a/tests/Feature/Controllers/Transaction/IndexControllerTest.php b/tests/Feature/Controllers/Transaction/IndexControllerTest.php
index b08f6a4ec8..1d6ba48f07 100644
--- a/tests/Feature/Controllers/Transaction/IndexControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/IndexControllerTest.php
@@ -53,9 +53,9 @@ class IndexControllerTest extends TestCase
public function testIndex(): void
{
$this->mockDefaultSession();
- $group = $this->getRandomWithdrawalGroup();
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $collector = $this->mock(GroupCollectorInterface::class);
+ $group = $this->getRandomWithdrawalGroup();
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
// generic set for the info blocks:
$groupArray = [$this->getRandomWithdrawalAsArray()];
@@ -95,9 +95,9 @@ class IndexControllerTest extends TestCase
public function testIndexAll(): void
{
$this->mockDefaultSession();
- $group = $this->getRandomWithdrawalGroup();
- $userRepos = $this->mock(UserRepositoryInterface::class);
- $collector = $this->mock(GroupCollectorInterface::class);
+ $group = $this->getRandomWithdrawalGroup();
+ $userRepos = $this->mock(UserRepositoryInterface::class);
+ $collector = $this->mock(GroupCollectorInterface::class);
// role?
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true);
diff --git a/tests/Feature/Controllers/Transaction/LinkControllerTest.php b/tests/Feature/Controllers/Transaction/LinkControllerTest.php
index a7ae5845be..1db52da8a7 100644
--- a/tests/Feature/Controllers/Transaction/LinkControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/LinkControllerTest.php
@@ -25,7 +25,6 @@ namespace Tests\Feature\Controllers\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionJournalLink;
-use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
@@ -60,8 +59,6 @@ class LinkControllerTest extends TestCase
$userRepos = $this->mock(UserRepositoryInterface::class);
-
-
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
$this->be($this->user());
@@ -80,7 +77,6 @@ class LinkControllerTest extends TestCase
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
-
$linkRepos->shouldReceive('get')->atLeast()->once()->andReturn(new Collection);
$this->be($this->user());
@@ -94,8 +90,8 @@ class LinkControllerTest extends TestCase
public function testDestroy(): void
{
$this->mockDefaultSession();
- $link = $this->getRandomLink();
- $repository = $this->mock(LinkTypeRepositoryInterface::class);
+ $link = $this->getRandomLink();
+ $repository = $this->mock(LinkTypeRepositoryInterface::class);
Preferences::shouldReceive('mark')->once();
@@ -203,7 +199,7 @@ class LinkControllerTest extends TestCase
$repository = $this->mock(LinkTypeRepositoryInterface::class);
$journalRepos = $this->mockDefaultSession();
- $data = [
+ $data = [
'link_other' => $withdrawal->id,
'link_type' => '1_inward',
];
@@ -224,8 +220,8 @@ class LinkControllerTest extends TestCase
public function testSwitchLink(): void
{
$this->mockDefaultSession();
- $link = $this->getRandomLink();
- $repository = $this->mock(LinkTypeRepositoryInterface::class);
+ $link = $this->getRandomLink();
+ $repository = $this->mock(LinkTypeRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);
diff --git a/tests/Feature/Controllers/Transaction/MassControllerTest.php b/tests/Feature/Controllers/Transaction/MassControllerTest.php
index 7b03e8ec87..905a35d054 100644
--- a/tests/Feature/Controllers/Transaction/MassControllerTest.php
+++ b/tests/Feature/Controllers/Transaction/MassControllerTest.php
@@ -172,13 +172,13 @@ class MassControllerTest extends TestCase
$this->session(['transactions.mass-edit.uri' => 'http://localhost']);
$data = [
- 'journals' => [$deposit->id],
- 'description' => [$deposit->id => 'Updated salary thing'],
- 'amount' => [$deposit->id => 1600],
- 'date' => [$deposit->id => '2014-07-24'],
- 'source_name' => [$deposit->id => 'Job'],
- 'destination_id' => [$deposit->id => 1],
- 'category' => [$deposit->id => 'Salary'],
+ 'journals' => [$deposit->id],
+ 'description' => [$deposit->id => 'Updated salary thing'],
+ 'amount' => [$deposit->id => 1600],
+ 'date' => [$deposit->id => '2014-07-24'],
+ 'source_name' => [$deposit->id => 'Job'],
+ 'destination_id' => [$deposit->id => 1],
+ 'category' => [$deposit->id => 'Salary'],
];
$this->be($this->user());
diff --git a/tests/Unit/Middleware/BinderTest.php b/tests/Unit/Middleware/BinderTest.php
index 9fd7937093..5d4fca3fe6 100644
--- a/tests/Unit/Middleware/BinderTest.php
+++ b/tests/Unit/Middleware/BinderTest.php
@@ -25,15 +25,26 @@ namespace Tests\Unit\Middleware;
use Carbon\Carbon;
-use FireflyIII\Helpers\FiscalHelperInterface;
+use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
use FireflyIII\Http\Middleware\Binder;
+use FireflyIII\Import\Prerequisites\PrerequisitesInterface;
+use FireflyIII\Models\AccountType;
+use FireflyIII\Models\AvailableBudget;
+use FireflyIII\Models\Preference;
+use FireflyIII\Models\Recurrence;
+use FireflyIII\Models\Tag;
+use FireflyIII\Models\TransactionGroup;
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
+use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
+use Mockery;
+use Preferences;
use Route;
use Symfony\Component\HttpFoundation\Response;
use Tests\TestCase;
+
/**
* Class BinderTest
* Per object: works, not existing, not logged in + existing
@@ -76,6 +87,28 @@ class BinderTest extends TestCase
$response->assertSee('count: 2');
}
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\AccountList
+ */
+ public function testAccountListAllAssets(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{accountList}', function (Collection $accounts) {
+ return 'count: ' . $accounts->count();
+ }
+ );
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/allAssetAccounts');
+ $count = $this->user()->accounts()
+ ->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
+ ->where('account_types.type', AccountType::ASSET)
+ ->orderBy('accounts.name', 'ASC')
+ ->count();
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+ $response->assertSee(sprintf('count: %d', $count));
+ }
+
/**
* @covers \FireflyIII\Http\Middleware\Binder
* @covers \FireflyIII\Support\Binder\AccountList
@@ -357,6 +390,223 @@ class BinderTest extends TestCase
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
}
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\BudgetList
+ */
+ public function testBudgetListEmpty(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{budgetList}', function (Collection $budgets) {
+ return 'count: ' . $budgets->count();
+ }
+ );
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\CLIToken
+ */
+ public function testCLIToken(): void
+ {
+ $repos = $this->mock(UserRepositoryInterface::class);
+ $repos->shouldReceive('all')->andReturn(new Collection([$this->user()]))->atLeast()->once();
+
+ $token = new Preference;
+ $token->data = 'token';
+
+ Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token', null])->atLeast()->once()->andReturn($token);
+
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{cliToken}', static function (string $token) {
+ return sprintf('token: %s', $token);
+ }
+ );
+
+ $response = $this->get('/_test/binder/token');
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+ $response->assertSee('token');
+
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\CLIToken
+ */
+ public function testCLITokenNotFound(): void
+ {
+ $repos = $this->mock(UserRepositoryInterface::class);
+ $repos->shouldReceive('all')->andReturn(new Collection([$this->user()]))->atLeast()->once();
+
+ $token = new Preference;
+ $token->data = 'token';
+
+ Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token', null])->atLeast()->once()->andReturn($token);
+
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{cliToken}', static function (string $token) {
+ return sprintf('token: %s', $token);
+ }
+ );
+
+ $response = $this->get('/_test/binder/tokenX');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\ConfigurationName
+ */
+ public function testConfigName(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{configName}', static function (string $name) {
+ return sprintf('configName: %s', $name);
+ }
+ );
+
+ $response = $this->get('/_test/binder/is_demo_site');
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+ $response->assertSee('is_demo_site');
+ }
+
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\ConfigurationName
+ */
+ public function testConfigNameNotFOund(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{configName}', static function (string $name) {
+ return sprintf('configName: %s', $name);
+ }
+ );
+
+ $response = $this->get('/_test/binder/is_demoX_site');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
+ /**
+ * Normal user can access file routine
+ *
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\ImportProvider
+ */
+ public function testImportProvider(): void
+ {
+ $repository = $this->mock(UserRepositoryInterface::class);
+ $this->mock(PrerequisitesInterface::class);
+
+ $repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
+
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{import_provider}', static function (string $name) {
+ return sprintf('import_provider: %s', $name);
+ }
+ );
+
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/file');
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+ $response->assertSee('file');
+ }
+
+ /**
+ * Normal user cannot access fake import routine.
+ *
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\ImportProvider
+ */
+ public function testImportProviderFake(): void
+ {
+ $repository = $this->mock(UserRepositoryInterface::class);
+ $this->mock(PrerequisitesInterface::class);
+
+ $repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
+
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{import_provider}', static function (string $name) {
+ return sprintf('import_provider: %s', $name);
+ }
+ );
+
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/fake');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
+ /**
+ * Nobody can access "bad" import routine.
+ *
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\ImportProvider
+ */
+ public function testImportProviderBad(): void
+ {
+ $repository = $this->mock(UserRepositoryInterface::class);
+ $this->mock(PrerequisitesInterface::class);
+
+ $repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
+
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{import_provider}', static function (string $name) {
+ return sprintf('import_provider: %s', $name);
+ }
+ );
+
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/bad');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
+ /**
+ * Demo user cannot access file import routine.
+ *
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\ImportProvider
+ */
+ public function testImportProviderDemoFile(): void
+ {
+ $repository = $this->mock(UserRepositoryInterface::class);
+ $this->mock(PrerequisitesInterface::class);
+
+ $repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(true)->atLeast()->once();
+
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{import_provider}', static function (string $name) {
+ return sprintf('import_provider: %s', $name);
+ }
+ );
+
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/file');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\ImportProvider
+ */
+ public function testImportProviderNotLoggedIn(): void
+ {
+ $this->mock(UserRepositoryInterface::class);
+ $this->mock(PrerequisitesInterface::class);
+
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{import_provider}', static function (string $name) {
+ return sprintf('import_provider: %s', $name);
+ }
+ );
+
+ $response = $this->get('/_test/binder/file');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
+
/**
* @covers \FireflyIII\Http\Middleware\Binder
* @covers \FireflyIII\Models\Budget
@@ -730,56 +980,6 @@ class BinderTest extends TestCase
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
}
- /**
- * @covers \FireflyIII\Http\Middleware\Binder
- * @covers \FireflyIII\Models\ExportJob
- */
- public function testExportJob(): void
- {
- Route::middleware(Binder::class)->any(
- '/_test/binder/{exportJob}', function () {
- return 'OK';
- }
- );
-
- $this->be($this->user());
- $response = $this->get('/_test/binder/testExport');
- $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
- }
-
- /**
- * @covers \FireflyIII\Http\Middleware\Binder
- * @covers \FireflyIII\Models\ExportJob
- */
- public function testExportJobNotFound(): void
- {
- Route::middleware(Binder::class)->any(
- '/_test/binder/{exportJob}', function () {
- return 'OK';
- }
- );
-
- $this->be($this->user());
- $response = $this->get('/_test/binder/0');
- $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
- }
-
- /**
- * @covers \FireflyIII\Http\Middleware\Binder
- * @covers \FireflyIII\Models\ExportJob
- */
- public function testExportJobNotLoggedIn(): void
- {
- Route::middleware(Binder::class)->any(
- '/_test/binder/{exportJob}', function () {
- return 'OK';
- }
- );
-
- $response = $this->get('/_test/binder/testExport');
- $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
- }
-
/**
* @covers \FireflyIII\Http\Middleware\Binder
* @covers \FireflyIII\Models\ImportJob
@@ -836,16 +1036,15 @@ class BinderTest extends TestCase
*/
public function testJournalList(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
Route::middleware(Binder::class)->any(
- '/_test/binder/{journalList}', function (Collection $journals) {
- return 'count: ' . $journals->count();
+ '/_test/binder/{journalList}', static function (array $journals) {
+ return 'count: ' . count($journals);
}
);
$this->be($this->user());
- $response = $this->get('/_test/binder/1,2');
+ $withdrawal = $this->getRandomWithdrawal();
+ $deposit = $this->getRandomDeposit();
+ $response = $this->get(sprintf('/_test/binder/%d,%d', $withdrawal->id, $deposit->id));
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
$response->assertSee('count: 2');
}
@@ -856,19 +1055,33 @@ class BinderTest extends TestCase
*/
public function testJournalListEmpty(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
Route::middleware(Binder::class)->any(
- '/_test/binder/{journalList}', function (Collection $journals) {
- return 'count: ' . $journals->count();
- }
- );
+ '/_test/binder/{journalList}', static function (array $journals) {
+ return 'count: ' . count($journals);
+ });
+
$this->be($this->user());
$response = $this->get('/_test/binder/-1');
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
}
+ /**
+ * Not logged in.
+ *
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\JournalList
+ */
+ public function testJournalListNotLoggedIn(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{journalList}', static function (array $journals) {
+ return 'count: ' . count($journals);
+ });
+
+ $response = $this->get('/_test/binder/-1');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
/**
* @covers \FireflyIII\Http\Middleware\Binder
* @covers \FireflyIII\Models\LinkType
@@ -936,6 +1149,141 @@ class BinderTest extends TestCase
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
}
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Models\Preference
+ */
+ public function testPreference(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{preference}', static function (?Preference $preference) {
+ return $preference->name ?? 'unknown';
+ }
+ );
+
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/frontPageAccounts');
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+ $response->assertSee('frontPageAccounts');
+ }
+
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Models\Recurrence
+ */
+ public function testRecurrence(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{recurrence}', static function (?Recurrence $recurrence) {
+ return $recurrence->description ?? 'unknown';
+ }
+ );
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/1');
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Models\Recurrence
+ */
+ public function testRecurrenceNotFound(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{recurrence}', static function (?Recurrence $recurrence) {
+ return $recurrence->description ?? 'unknown';
+ }
+ );
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/-1');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Models\TransactionGroup
+ */
+ public function testTransactionGroup(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{transactionGroup}', static function (?TransactionGroup $transactionGroup) {
+ return $transactionGroup->title ?? 'unknown';
+ }
+ );
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/1');
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Models\TransactionGroup
+ */
+ public function testTransactionGroupNotFound(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{transactionGroup}', static function (?TransactionGroup $transactionGroup) {
+ return $transactionGroup->title ?? 'unknown';
+ }
+ );
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/-1');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Models\AvailableBudget
+ */
+ public function testAvailableBudget(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{availableBudget}', static function (?AvailableBudget $availableBudget) {
+ return $availableBudget->id ?? 0;
+ }
+ );
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/1');
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Models\AvailableBudget
+ */
+ public function testAvailableBudgetNotFound(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{availableBudget}', static function (?AvailableBudget $availableBudget) {
+ return $availableBudget->id ?? 0;
+ }
+ );
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/-1');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Models\Preference
+ */
+ public function testPreferenceNotFound(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{preference}', static function (?Preference $preference) {
+ return $preference->name ?? 'unknown';
+ }
+ );
+
+ $this->be($this->user());
+ $response = $this->get('/_test/binder/frontPageAccountsX');
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
/**
* @covers \FireflyIII\Http\Middleware\Binder
* @covers \FireflyIII\Models\PiggyBank
@@ -1075,9 +1423,6 @@ class BinderTest extends TestCase
*/
public function testTJ(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
Route::middleware(Binder::class)->any(
'/_test/binder/{tj}', function () {
return 'OK';
@@ -1095,9 +1440,6 @@ class BinderTest extends TestCase
*/
public function testTJNotFound(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
Route::middleware(Binder::class)->any(
'/_test/binder/{tj}', function () {
return 'OK';
@@ -1115,9 +1457,6 @@ class BinderTest extends TestCase
*/
public function testTJNotLoggedIn(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
Route::middleware(Binder::class)->any(
'/_test/binder/{tj}', function () {
return 'OK';
@@ -1171,6 +1510,139 @@ class BinderTest extends TestCase
$response->assertSee('count: 2');
}
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\TagList
+ */
+ public function testTagListWithId(): void
+ {
+ $tagRepos = $this->mock(TagRepositoryInterface::class);
+ $tagRepos->shouldReceive('setUser');
+ $tags = $this->user()->tags()->whereIn('id', [1, 2, 3])->get(['tags.*']);
+ $tagRepos->shouldReceive('get')->once()->andReturn($tags);
+
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{tagList}', function (Collection $tags) {
+ return 'count: ' . $tags->count();
+ }
+ );
+ $first = $tags->get(0);
+ $second = $tags->get(1);
+
+
+ $this->be($this->user());
+ $response = $this->get(sprintf('/_test/binder/%s,%d,bleep', $first->tag, $second->id));
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+ $response->assertSee('count: 2');
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\TagOrId
+ */
+ public function testTagOrIdByTag(): void
+ {
+ $tagRepos = $this->mock(TagRepositoryInterface::class);
+ $tag = $this->getRandomTag();
+
+ $tagRepos->shouldReceive('setUser');
+ $tagRepos->shouldReceive('findByTag')->withArgs([$tag->tag])->andReturn($tag)->atLeast()->once();
+
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{tagOrId}', static function (?Tag $tag) {
+ if ($tag) {
+ return $tag->tag;
+ }
+
+ return 'unfound';
+ }
+ );
+
+ $this->be($this->user());
+ $response = $this->get(sprintf('/_test/binder/%s', $tag->tag));
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+
+ $response->assertSee($tag->tag);
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\TagOrId
+ */
+ public function testTagOrIdById(): void
+ {
+ $tagRepos = $this->mock(TagRepositoryInterface::class);
+ $tag = $this->getRandomTag();
+
+ $tagRepos->shouldReceive('setUser');
+ $tagRepos->shouldReceive('findByTag')->withArgs([(string)$tag->id])->andReturnNull()->atLeast()->once();
+ $tagRepos->shouldReceive('findNull')->withArgs([$tag->id])->andReturn($tag)->atLeast()->once();
+
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{tagOrId}', static function (?Tag $tag) {
+ if ($tag) {
+ return $tag->tag;
+ }
+
+ return 'unfound';
+ }
+ );
+
+ $this->be($this->user());
+ $response = $this->get(sprintf('/_test/binder/%d', $tag->id));
+ $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
+
+ $response->assertSee($tag->tag);
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\TagOrId
+ */
+ public function testTagOrIdBothNull(): void
+ {
+ $tagRepos = $this->mock(TagRepositoryInterface::class);
+ $tag = $this->getRandomTag();
+
+ $tagRepos->shouldReceive('setUser');
+ $tagRepos->shouldReceive('findByTag')->withArgs([(string)$tag->id])->andReturnNull()->atLeast()->once();
+ $tagRepos->shouldReceive('findNull')->withArgs([$tag->id])->andReturnNull()->atLeast()->once();
+
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{tagOrId}', static function (?Tag $tag) {
+ if ($tag) {
+ return $tag->tag;
+ }
+
+ return 'unfound';
+ }
+ );
+
+ $this->be($this->user());
+ $response = $this->get(sprintf('/_test/binder/%d', $tag->id));
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
+ /**
+ * @covers \FireflyIII\Http\Middleware\Binder
+ * @covers \FireflyIII\Support\Binder\TagOrId
+ */
+ public function testTagOrIdNotLoggedIn(): void
+ {
+ Route::middleware(Binder::class)->any(
+ '/_test/binder/{tagOrId}', static function (?Tag $tag) {
+ if ($tag) {
+ return $tag->tag;
+ }
+
+ return 'unfound';
+ }
+ );
+
+ $response = $this->get(sprintf('/_test/binder/%d', 4));
+ $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
+ }
+
/**
* @covers \FireflyIII\Http\Middleware\Binder
* @covers \FireflyIII\Support\Binder\TagList
@@ -1280,9 +1752,6 @@ class BinderTest extends TestCase
*/
public function testTransactionJournalLink(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
Route::middleware(Binder::class)->any(
'/_test/binder/{journalLink}', function () {
return 'OK';
@@ -1300,9 +1769,6 @@ class BinderTest extends TestCase
*/
public function testTransactionJournalLinkNotFound(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
Route::middleware(Binder::class)->any(
'/_test/binder/{journalLink}', function () {
return 'OK';
@@ -1320,9 +1786,6 @@ class BinderTest extends TestCase
*/
public function testTransactionJournalLinkNotLoggedIn(): void
{
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
Route::middleware(Binder::class)->any(
'/_test/binder/{journalLink}', function () {
return 'OK';
@@ -1382,64 +1845,4 @@ class BinderTest extends TestCase
$response = $this->get('/_test/binder/withdrawal');
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
}
-
- /**
- * @covers \FireflyIII\Http\Middleware\Binder
- * @covers \FireflyIII\Support\Binder\UnfinishedJournal
- */
- public function testUnfinishedJournal(): void
- {
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
- $journal = $this->user()->transactionJournals()->where('completed', 0)->first();
- Route::middleware(Binder::class)->any(
- '/_test/binder/{unfinishedJournal}', function () {
- return 'OK';
- }
- );
- $this->be($this->user());
- $response = $this->get('/_test/binder/' . $journal->id);
- $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
- }
-
- /**
- * @covers \FireflyIII\Http\Middleware\Binder
- * @covers \FireflyIII\Support\Binder\UnfinishedJournal
- */
- public function testUnfinishedJournalFinished(): void
- {
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
- $journal = $this->user()->transactionJournals()->where('completed', 1)->first();
- Route::middleware(Binder::class)->any(
- '/_test/binder/{unfinishedJournal}', function () {
- return 'OK';
- }
- );
- $response = $this->get('/_test/binder/' . $journal->id);
- $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
- }
-
- /**
- * @covers \FireflyIII\Http\Middleware\Binder
- * @covers \FireflyIII\Support\Binder\UnfinishedJournal
- */
- public function testUnfinishedJournalNotLoggedIn(): void
- {
- $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
-
- return;
- $journal = $this->user()->transactionJournals()->where('completed', 0)->first();
- Route::middleware(Binder::class)->any(
- '/_test/binder/{unfinishedJournal}', function () {
- return 'OK';
- }
- );
- $response = $this->get('/_test/binder/' . $journal->id);
- $this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
- }
-
-
}