mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Improve test coverage.
This commit is contained in:
parent
ee95606ec0
commit
6ff4a0b45c
@ -86,6 +86,7 @@ class Note extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $value
|
* @param $value
|
||||||
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function setTextAttribute($value): void
|
public function setTextAttribute($value): void
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,6 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||||||
* @property int $id
|
* @property int $id
|
||||||
* @property User user
|
* @property User user
|
||||||
* @property int $user_id
|
* @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 newModelQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\FireflyIII\Models\Preference newQuery()
|
* @method static \Illuminate\Database\Eloquent\Builder|\FireflyIII\Models\Preference newQuery()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\FireflyIII\Models\Preference query()
|
* @method static \Illuminate\Database\Eloquent\Builder|\FireflyIII\Models\Preference query()
|
||||||
|
@ -147,6 +147,7 @@ class Rule extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $value
|
* @param $value
|
||||||
|
* @codeCoverageIgnore
|
||||||
*/
|
*/
|
||||||
public function setDescriptionAttribute($value): void
|
public function setDescriptionAttribute($value): void
|
||||||
{
|
{
|
||||||
|
@ -102,10 +102,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||||||
* @property Carbon updated_at
|
* @property Carbon updated_at
|
||||||
* @property string foreign_currency_code
|
* @property string foreign_currency_code
|
||||||
* @SuppressWarnings (PHPMD.TooManyPublicMethods)
|
* @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 \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\Budget[] $budgets
|
||||||
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Category[] $categories
|
* @property-read \Illuminate\Database\Eloquent\Collection|\FireflyIII\Models\Category[] $categories
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|\FireflyIII\Models\Transaction after(\Carbon\Carbon $date)
|
* @method static \Illuminate\Database\Eloquent\Builder|\FireflyIII\Models\Transaction after(\Carbon\Carbon $date)
|
||||||
@ -185,30 +182,6 @@ class Transaction extends Model
|
|||||||
return false;
|
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.
|
* Get the account this object belongs to.
|
||||||
|
@ -46,11 +46,13 @@ class BudgetList implements BinderInterface
|
|||||||
//Log::debug(sprintf('Now in BudgetList::routeBinder("%s")', $value));
|
//Log::debug(sprintf('Now in BudgetList::routeBinder("%s")', $value));
|
||||||
if (auth()->check()) {
|
if (auth()->check()) {
|
||||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||||
//Log::debug('List is now', $list);
|
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
if (0 === count($list)) {
|
if (0 === count($list)) {
|
||||||
Log::warning('Budget list count is zero, return 404.');
|
Log::warning('Budget list count is zero, return 404.');
|
||||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
/** @var Collection $collection */
|
/** @var Collection $collection */
|
||||||
$collection = auth()->user()->budgets()
|
$collection = auth()->user()->budgets()
|
||||||
|
@ -44,8 +44,14 @@ class ImportProvider implements BinderInterface
|
|||||||
{
|
{
|
||||||
$repository = app(UserRepositoryInterface::class);
|
$repository = app(UserRepositoryInterface::class);
|
||||||
// get and filter all import routines:
|
// get and filter all import routines:
|
||||||
|
|
||||||
|
if (!auth()->check()) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
|
||||||
/** @var array $config */
|
/** @var array $config */
|
||||||
$providerNames = array_keys(config('import.enabled'));
|
$providerNames = array_keys(config('import.enabled'));
|
||||||
$providers = [];
|
$providers = [];
|
||||||
@ -55,13 +61,20 @@ class ImportProvider implements BinderInterface
|
|||||||
// only consider enabled providers
|
// only consider enabled providers
|
||||||
$enabled = (bool)config(sprintf('import.enabled.%s', $providerName));
|
$enabled = (bool)config(sprintf('import.enabled.%s', $providerName));
|
||||||
$allowedForUser = (bool)config(sprintf('import.allowed_for_user.%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) {
|
if (false === $enabled) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (false === $allowedForUser && !$isDemoUser) {
|
||||||
if (false === $isDemoUser && false === $allowedForUser && false === $isDebug) {
|
continue;
|
||||||
continue; // @codeCoverageIgnore
|
|
||||||
}
|
}
|
||||||
|
if (false === $allowedForDemo && $isDemoUser) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (false === $isDemoUser && false === $allowedForUser && false === $isDebug) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
$providers[$providerName] = [
|
$providers[$providerName] = [
|
||||||
'has_prereq' => (bool)config('import.has_prereq.' . $providerName),
|
'has_prereq' => (bool)config('import.has_prereq.' . $providerName),
|
||||||
|
@ -46,17 +46,20 @@ class TagList implements BinderInterface
|
|||||||
if (auth()->check()) {
|
if (auth()->check()) {
|
||||||
$list = array_unique(array_map('\strtolower', explode(',', $value)));
|
$list = array_unique(array_map('\strtolower', explode(',', $value)));
|
||||||
Log::debug('List of tags is', $list);
|
Log::debug('List of tags is', $list);
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
if (0 === count($list)) {
|
if (0 === count($list)) {
|
||||||
Log::error('Tag list is empty.');
|
Log::error('Tag list is empty.');
|
||||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
throw new NotFoundHttpException;
|
||||||
}
|
}
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
|
||||||
/** @var TagRepositoryInterface $repository */
|
/** @var TagRepositoryInterface $repository */
|
||||||
$repository = app(TagRepositoryInterface::class);
|
$repository = app(TagRepositoryInterface::class);
|
||||||
$repository->setUser(auth()->user());
|
$repository->setUser(auth()->user());
|
||||||
$allTags = $repository->get();
|
$allTags = $repository->get();
|
||||||
|
|
||||||
$collection = $allTags->filter(
|
$collection = $allTags->filter(
|
||||||
function (Tag $tag) use ($list) {
|
static function (Tag $tag) use ($list) {
|
||||||
if (in_array(strtolower($tag->tag), $list, true)) {
|
if (in_array(strtolower($tag->tag), $list, true)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* TransactionGroup.php
|
|
||||||
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This file is part of Firefly III.
|
|
||||||
*
|
|
||||||
* Firefly III is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Firefly III is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* UnfinishedJournal.php
|
|
||||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
||||||
*
|
|
||||||
* This file is part of Firefly III.
|
|
||||||
*
|
|
||||||
* Firefly III is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Firefly III is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use FireflyIII\Export\Exporter\CsvExporter;
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
@ -32,7 +31,6 @@ use FireflyIII\Models\Bill;
|
|||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Models\BudgetLimit;
|
use FireflyIII\Models\BudgetLimit;
|
||||||
use FireflyIII\Models\Category;
|
use FireflyIII\Models\Category;
|
||||||
use FireflyIII\Models\ExportJob;
|
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Models\LinkType;
|
use FireflyIII\Models\LinkType;
|
||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
@ -41,7 +39,6 @@ use FireflyIII\Models\Recurrence;
|
|||||||
use FireflyIII\Models\Rule;
|
use FireflyIII\Models\Rule;
|
||||||
use FireflyIII\Models\RuleGroup;
|
use FireflyIII\Models\RuleGroup;
|
||||||
use FireflyIII\Models\Tag;
|
use FireflyIII\Models\Tag;
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
use FireflyIII\Models\TransactionGroup;
|
use FireflyIII\Models\TransactionGroup;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
@ -60,7 +57,6 @@ use FireflyIII\Support\Binder\ImportProvider;
|
|||||||
use FireflyIII\Support\Binder\JournalList;
|
use FireflyIII\Support\Binder\JournalList;
|
||||||
use FireflyIII\Support\Binder\TagList;
|
use FireflyIII\Support\Binder\TagList;
|
||||||
use FireflyIII\Support\Binder\TagOrId;
|
use FireflyIII\Support\Binder\TagOrId;
|
||||||
use FireflyIII\Support\Binder\UnfinishedJournal;
|
|
||||||
use FireflyIII\TransactionRules\Actions\AddTag;
|
use FireflyIII\TransactionRules\Actions\AddTag;
|
||||||
use FireflyIII\TransactionRules\Actions\AppendDescription;
|
use FireflyIII\TransactionRules\Actions\AppendDescription;
|
||||||
use FireflyIII\TransactionRules\Actions\AppendNotes;
|
use FireflyIII\TransactionRules\Actions\AppendNotes;
|
||||||
@ -377,7 +373,6 @@ return [
|
|||||||
'rule' => Rule::class,
|
'rule' => Rule::class,
|
||||||
'ruleGroup' => RuleGroup::class,
|
'ruleGroup' => RuleGroup::class,
|
||||||
'importJob' => ImportJob::class,
|
'importJob' => ImportJob::class,
|
||||||
'transaction' => Transaction::class,
|
|
||||||
'transactionGroup' => TransactionGroup::class,
|
'transactionGroup' => TransactionGroup::class,
|
||||||
'user' => User::class,
|
'user' => User::class,
|
||||||
|
|
||||||
@ -401,7 +396,6 @@ return [
|
|||||||
// others
|
// others
|
||||||
'fromCurrencyCode' => CurrencyCode::class,
|
'fromCurrencyCode' => CurrencyCode::class,
|
||||||
'toCurrencyCode' => CurrencyCode::class,
|
'toCurrencyCode' => CurrencyCode::class,
|
||||||
'unfinishedJournal' => UnfinishedJournal::class,
|
|
||||||
'cliToken' => CLIToken::class,
|
'cliToken' => CLIToken::class,
|
||||||
'tagOrId' => TagOrId::class,
|
'tagOrId' => TagOrId::class,
|
||||||
'configName' => ConfigurationName::class,
|
'configName' => ConfigurationName::class,
|
||||||
|
@ -23,9 +23,7 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Feature\Controllers;
|
namespace Tests\Feature\Controllers;
|
||||||
|
|
||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
@ -63,7 +61,7 @@ class AttachmentControllerTest extends TestCase
|
|||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$this->mock(AttachmentRepositoryInterface::class);
|
$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();
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
@ -122,8 +120,8 @@ class AttachmentControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$attachment = $this->getRandomAttachment();
|
$attachment = $this->getRandomAttachment();
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
|
|
||||||
$repository->shouldReceive('exists')->once()->andReturn(false);
|
$repository->shouldReceive('exists')->once()->andReturn(false);
|
||||||
|
|
||||||
@ -207,7 +205,7 @@ class AttachmentControllerTest extends TestCase
|
|||||||
$attachment = $this->getRandomAttachment();
|
$attachment = $this->getRandomAttachment();
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
|
|
||||||
$repository->shouldReceive('exists')->once()->andReturn(true);
|
$repository->shouldReceive('exists')->once()->andReturn(true);
|
||||||
$repository->shouldReceive('getContent')->once()->andReturn('This is attachment number one.');
|
$repository->shouldReceive('getContent')->once()->andReturn('This is attachment number one.');
|
||||||
|
@ -160,10 +160,10 @@ class BillControllerTest extends TestCase
|
|||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$this->mock(AttachmentHelperInterface::class);
|
$this->mock(AttachmentHelperInterface::class);
|
||||||
$bill = $this->getRandomBill();
|
$bill = $this->getRandomBill();
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$transformer = $this->mock(BillTransformer::class);
|
$transformer = $this->mock(BillTransformer::class);
|
||||||
|
|
||||||
$pref = new Preference;
|
$pref = new Preference;
|
||||||
$pref->data = 50;
|
$pref->data = 50;
|
||||||
@ -172,8 +172,8 @@ class BillControllerTest extends TestCase
|
|||||||
|
|
||||||
$transformer->shouldReceive('setParameters')->atLeast()->once();
|
$transformer->shouldReceive('setParameters')->atLeast()->once();
|
||||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(
|
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(
|
||||||
['id' => 5, 'active' => true, 'name' => 'x', 'next_expected_match' => '2018-01-01',
|
['id' => 5, 'active' => true, 'name' => 'x', 'next_expected_match' => '2018-01-01',
|
||||||
'currency' => $this->getEuro(),
|
'currency' => $this->getEuro(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -201,8 +201,8 @@ class BillControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$rule = $this->getRandomRule();
|
$rule = $this->getRandomRule();
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
$this->mock(AttachmentHelperInterface::class);
|
$this->mock(AttachmentHelperInterface::class);
|
||||||
|
|
||||||
|
|
||||||
@ -414,8 +414,8 @@ class BillControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
|
|
||||||
$repository->shouldReceive('store')->andReturn(new Bill);
|
$repository->shouldReceive('store')->andReturn(new Bill);
|
||||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||||
@ -450,8 +450,8 @@ class BillControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
$attachHelper = $this->mock(AttachmentHelperInterface::class);
|
||||||
$repository = $this->mock(BillRepositoryInterface::class);
|
$repository = $this->mock(BillRepositoryInterface::class);
|
||||||
|
|
||||||
$repository->shouldReceive('update')->andReturn(new Bill);
|
$repository->shouldReceive('update')->andReturn(new Bill);
|
||||||
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
$attachHelper->shouldReceive('saveAttachmentsForModel');
|
||||||
|
@ -57,7 +57,7 @@ class DeleteControllerTest extends TestCase
|
|||||||
// mock stuff
|
// mock stuff
|
||||||
$this->mock(BudgetRepositoryInterface::class);
|
$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();
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ class DeleteControllerTest extends TestCase
|
|||||||
$budget = $this->getRandomBudget();
|
$budget = $this->getRandomBudget();
|
||||||
Log::debug('Now in testDestroy()');
|
Log::debug('Now in testDestroy()');
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$this->mock(UserRepositoryInterface::class);
|
$this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class EditControllerTest extends TestCase
|
|||||||
Log::debug('Now in testEdit()');
|
Log::debug('Now in testEdit()');
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$this->mock(BudgetRepositoryInterface::class);
|
$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();
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
@ -74,7 +74,7 @@ class EditControllerTest extends TestCase
|
|||||||
Log::debug('Now in testUpdate()');
|
Log::debug('Now in testUpdate()');
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$budget = $this->getRandomBudget();
|
$budget = $this->getRandomBudget();
|
||||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$this->mock(UserRepositoryInterface::class);
|
$this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$repository->shouldReceive('findNull')->andReturn($budget);
|
$repository->shouldReceive('findNull')->andReturn($budget);
|
||||||
|
@ -65,7 +65,7 @@ class IndexControllerTest extends TestCase
|
|||||||
public function testIndex(string $range): void
|
public function testIndex(string $range): void
|
||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$budget = $this->getRandomBudget();
|
$budget = $this->getRandomBudget();
|
||||||
$budgetLimit = $this->getRandomBudgetLimit();
|
$budgetLimit = $this->getRandomBudgetLimit();
|
||||||
$budgetLimit->start_date = Carbon::now()->startOfMonth();
|
$budgetLimit->start_date = Carbon::now()->startOfMonth();
|
||||||
$budgetLimit->end_date = Carbon::now()->endOfMonth();
|
$budgetLimit->end_date = Carbon::now()->endOfMonth();
|
||||||
@ -102,7 +102,7 @@ class IndexControllerTest extends TestCase
|
|||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$this->changeDateRange($this->user(), $range);
|
$this->changeDateRange($this->user(), $range);
|
||||||
$response = $this->get(route('budgets.index'));
|
$response = $this->get(route('budgets.index'));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
// has bread crumb
|
// has bread crumb
|
||||||
$response->assertSee('<ol class="breadcrumb">');
|
$response->assertSee('<ol class="breadcrumb">');
|
||||||
|
@ -222,7 +222,7 @@ class ShowControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class CreateControllerTest extends TestCase
|
|||||||
Log::debug('TestCreate()');
|
Log::debug('TestCreate()');
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$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);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
@ -71,7 +71,7 @@ class CreateControllerTest extends TestCase
|
|||||||
public function testStore(): void
|
public function testStore(): void
|
||||||
{
|
{
|
||||||
Log::debug('Test store()');
|
Log::debug('Test store()');
|
||||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(UserRepositoryInterface::class);
|
$this->mock(UserRepositoryInterface::class);
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$repository->shouldReceive('findNull')->andReturn(new Category);
|
$repository->shouldReceive('findNull')->andReturn(new Category);
|
||||||
|
@ -53,7 +53,7 @@ class DeleteControllerTest extends TestCase
|
|||||||
// mock stuff
|
// mock stuff
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
@ -67,7 +67,6 @@ class EditControllerTest extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\Category\EditController
|
* @covers \FireflyIII\Http\Controllers\Category\EditController
|
||||||
* @covers \FireflyIII\Http\Requests\CategoryFormRequest
|
* @covers \FireflyIII\Http\Requests\CategoryFormRequest
|
||||||
@ -75,8 +74,8 @@ class EditControllerTest extends TestCase
|
|||||||
public function testUpdate(): void
|
public function testUpdate(): void
|
||||||
{
|
{
|
||||||
Log::debug('Test update()');
|
Log::debug('Test update()');
|
||||||
$category = Category::first();
|
$category = Category::first();
|
||||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
$this->mock(UserRepositoryInterface::class);
|
$this->mock(UserRepositoryInterface::class);
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
@ -67,10 +67,10 @@ class NoCategoryControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testNoCategory(string $range): void
|
public function testNoCategory(string $range): void
|
||||||
{
|
{
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
// list size
|
// list size
|
||||||
@ -108,11 +108,11 @@ class NoCategoryControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testNoCategoryAll(string $range): void
|
public function testNoCategoryAll(string $range): void
|
||||||
{
|
{
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
// list size
|
// list size
|
||||||
@ -150,12 +150,12 @@ class NoCategoryControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testNoCategoryDate(string $range): void
|
public function testNoCategoryDate(string $range): void
|
||||||
{
|
{
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
|
|
||||||
|
@ -123,10 +123,10 @@ class ShowControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testShowAll(string $range): void
|
public function testShowAll(string $range): void
|
||||||
{
|
{
|
||||||
$withdrawal = $this->getRandomWithdrawalAsArray();
|
$withdrawal = $this->getRandomWithdrawalAsArray();
|
||||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$pref = new Preference;
|
$pref = new Preference;
|
||||||
|
@ -26,12 +26,9 @@ use Carbon\Carbon;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
|
||||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||||
use FireflyIII\Models\Account;
|
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
@ -118,14 +115,14 @@ class AccountControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testExpenseBudget(string $range): void
|
public function testExpenseBudget(string $range): void
|
||||||
{
|
{
|
||||||
$generator = $this->mock(GeneratorInterface::class);
|
$generator = $this->mock(GeneratorInterface::class);
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
$this->mock(CurrencyRepositoryInterface::class);
|
$this->mock(CurrencyRepositoryInterface::class);
|
||||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||||
$withdrawal = $this->getRandomWithdrawalAsArray();
|
$withdrawal = $this->getRandomWithdrawalAsArray();
|
||||||
$budget = $this->user()->budgets()->find($withdrawal['budget_id']);
|
$budget = $this->user()->budgets()->find($withdrawal['budget_id']);
|
||||||
|
|
||||||
// mock default session
|
// mock default session
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
@ -158,14 +155,14 @@ class AccountControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testExpenseBudgetAll(string $range): void
|
public function testExpenseBudgetAll(string $range): void
|
||||||
{
|
{
|
||||||
$generator = $this->mock(GeneratorInterface::class);
|
$generator = $this->mock(GeneratorInterface::class);
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$this->mock(CurrencyRepositoryInterface::class);
|
$this->mock(CurrencyRepositoryInterface::class);
|
||||||
$this->mock(FiscalHelperInterface::class);
|
$this->mock(FiscalHelperInterface::class);
|
||||||
$withdrawal = $this->getRandomWithdrawalAsArray();
|
$withdrawal = $this->getRandomWithdrawalAsArray();
|
||||||
$budget = $this->user()->budgets()->find($withdrawal['budget_id']);
|
$budget = $this->user()->budgets()->find($withdrawal['budget_id']);
|
||||||
|
|
||||||
// mock default session
|
// mock default session
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
@ -202,9 +199,9 @@ class AccountControllerTest extends TestCase
|
|||||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
$this->mock(CurrencyRepositoryInterface::class);
|
$this->mock(CurrencyRepositoryInterface::class);
|
||||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||||
$withdrawal = $this->getRandomWithdrawalAsArray();
|
$withdrawal = $this->getRandomWithdrawalAsArray();
|
||||||
$category = $this->user()->categories()->find($withdrawal['category_id']);
|
$category = $this->user()->categories()->find($withdrawal['category_id']);
|
||||||
|
|
||||||
// mock default session
|
// mock default session
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
@ -245,8 +242,8 @@ class AccountControllerTest extends TestCase
|
|||||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$this->mock(CurrencyRepositoryInterface::class);
|
$this->mock(CurrencyRepositoryInterface::class);
|
||||||
$withdrawal = $this->getRandomWithdrawalAsArray();
|
$withdrawal = $this->getRandomWithdrawalAsArray();
|
||||||
$category = $this->user()->categories()->find($withdrawal['category_id']);
|
$category = $this->user()->categories()->find($withdrawal['category_id']);
|
||||||
|
|
||||||
// mock default session
|
// mock default session
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
@ -404,7 +401,7 @@ class AccountControllerTest extends TestCase
|
|||||||
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
||||||
|
|
||||||
|
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
$accountRepos->shouldReceive('oldestJournalDate')->andReturn(new Carbon);
|
$accountRepos->shouldReceive('oldestJournalDate')->andReturn(new Carbon);
|
||||||
@ -433,7 +430,7 @@ class AccountControllerTest extends TestCase
|
|||||||
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
||||||
|
|
||||||
|
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
|
@ -27,9 +27,7 @@ use Exception;
|
|||||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||||
use FireflyIII\Models\Budget;
|
|
||||||
use FireflyIII\Models\BudgetLimit;
|
use FireflyIII\Models\BudgetLimit;
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
@ -309,8 +307,8 @@ class BudgetControllerTest extends TestCase
|
|||||||
public function testFrontpageNoLimits(string $range): void
|
public function testFrontpageNoLimits(string $range): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$generator = $this->mock(GeneratorInterface::class);
|
$generator = $this->mock(GeneratorInterface::class);
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$budget = $this->getRandomBudget();
|
$budget = $this->getRandomBudget();
|
||||||
|
|
||||||
@ -341,11 +339,11 @@ class BudgetControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testPeriod(): void
|
public function testPeriod(): void
|
||||||
{
|
{
|
||||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$generator = $this->mock(GeneratorInterface::class);
|
$generator = $this->mock(GeneratorInterface::class);
|
||||||
$budgetLimit = $this->getRandomBudgetLimit();
|
$budgetLimit = $this->getRandomBudgetLimit();
|
||||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
|
|
||||||
// mock default session
|
// mock default session
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
@ -26,10 +26,6 @@ use Carbon\Carbon;
|
|||||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||||
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
|
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||||
use FireflyIII\Models\BudgetLimit;
|
use FireflyIII\Models\BudgetLimit;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
@ -39,6 +35,7 @@ use Log;
|
|||||||
use Preferences;
|
use Preferences;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BudgetReportControllerTest
|
* Class BudgetReportControllerTest
|
||||||
*/
|
*/
|
||||||
@ -134,7 +131,7 @@ class BudgetReportControllerTest extends TestCase
|
|||||||
$limit3->budget_id = $budget->id;
|
$limit3->budget_id = $budget->id;
|
||||||
$limit3->start_date = new Carbon('2012-01-01');
|
$limit3->start_date = new Carbon('2012-01-01');
|
||||||
$limit3->end_date = new Carbon('2012-01-31');
|
$limit3->end_date = new Carbon('2012-01-31');
|
||||||
$limit3->amount = '100';
|
$limit3->amount = '100';
|
||||||
$limit3->save();
|
$limit3->save();
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,18 +26,13 @@ use Carbon\Carbon;
|
|||||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||||
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
|
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use Log;
|
use Log;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CategoryReportControllerTest
|
* Class CategoryReportControllerTest
|
||||||
*/
|
*/
|
||||||
@ -173,7 +168,7 @@ class CategoryReportControllerTest extends TestCase
|
|||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$withdrawal = $this->getRandomWithdrawalAsArray();
|
$withdrawal = $this->getRandomWithdrawalAsArray();
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
||||||
|
@ -58,7 +58,7 @@ class ExpenseReportControllerTest extends TestCase
|
|||||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||||
$expense = $this->getRandomExpense();
|
$expense = $this->getRandomExpense();
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$withdrawal = $this->getRandomWithdrawalAsArray();
|
$withdrawal = $this->getRandomWithdrawalAsArray();
|
||||||
|
|
||||||
$accountRepository->shouldReceive('findByName')->once()->andReturn($expense);
|
$accountRepository->shouldReceive('findByName')->once()->andReturn($expense);
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$generator = $this->mock(GeneratorInterface::class);
|
$generator = $this->mock(GeneratorInterface::class);
|
||||||
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
/** @var PiggyBankEvent $event */
|
/** @var PiggyBankEvent $event */
|
||||||
$event = PiggyBankEvent::inRandomOrder()->first();
|
$event = PiggyBankEvent::inRandomOrder()->first();
|
||||||
$piggy = $event->piggy_bank_id;
|
$piggy = $event->piggy_bank_id;
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
@ -194,9 +194,9 @@ class TagReportControllerTest extends TestCase
|
|||||||
public function testMainChart(): void
|
public function testMainChart(): void
|
||||||
{
|
{
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
$generator = $this->mock(GeneratorInterface::class);
|
$generator = $this->mock(GeneratorInterface::class);
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||||
|
|
||||||
$withdrawal = $this->getRandomWithdrawalAsArray();
|
$withdrawal = $this->getRandomWithdrawalAsArray();
|
||||||
@ -234,11 +234,11 @@ class TagReportControllerTest extends TestCase
|
|||||||
public function testTagExpense(): void
|
public function testTagExpense(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$generator = $this->mock(GeneratorInterface::class);
|
$generator = $this->mock(GeneratorInterface::class);
|
||||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
$tag = $this->user()->tags()->first();
|
$tag = $this->user()->tags()->first();
|
||||||
$tagRepos->shouldReceive('setUser');
|
$tagRepos->shouldReceive('setUser');
|
||||||
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
$tagRepos->shouldReceive('get')->andReturn(new Collection([$tag]));
|
||||||
|
|
||||||
|
@ -24,9 +24,7 @@ namespace Tests\Feature\Controllers;
|
|||||||
|
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
use FireflyIII\Models\TransactionCurrency;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
@ -169,9 +167,9 @@ class CurrencyControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$euro = $this->getEuro();
|
$euro = $this->getEuro();
|
||||||
|
|
||||||
|
|
||||||
$repository->shouldReceive('currencyInUse')->andReturn(false);
|
$repository->shouldReceive('currencyInUse')->andReturn(false);
|
||||||
@ -192,9 +190,9 @@ class CurrencyControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$euro = $this->getEuro();
|
$euro = $this->getEuro();
|
||||||
|
|
||||||
$repository->shouldReceive('currencyInUse')->andReturn(false);
|
$repository->shouldReceive('currencyInUse')->andReturn(false);
|
||||||
$repository->shouldReceive('destroy')->andReturn(true)->once();
|
$repository->shouldReceive('destroy')->andReturn(true)->once();
|
||||||
@ -350,8 +348,8 @@ class CurrencyControllerTest extends TestCase
|
|||||||
$this->mockIntroPreference('shown_demo_currencies_index');
|
$this->mockIntroPreference('shown_demo_currencies_index');
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$currencies = TransactionCurrency::get();
|
$currencies = TransactionCurrency::get();
|
||||||
|
|
||||||
@ -385,8 +383,8 @@ class CurrencyControllerTest extends TestCase
|
|||||||
$this->mockIntroPreference('shown_demo_currencies_index');
|
$this->mockIntroPreference('shown_demo_currencies_index');
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$repository->shouldReceive('getCurrencyByPreference')->andReturn(new TransactionCurrency);
|
$repository->shouldReceive('getCurrencyByPreference')->andReturn(new TransactionCurrency);
|
||||||
@ -418,8 +416,8 @@ class CurrencyControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$repository->shouldReceive('store')->andReturn(new TransactionCurrency);
|
$repository->shouldReceive('store')->andReturn(new TransactionCurrency);
|
||||||
@ -447,8 +445,8 @@ class CurrencyControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$repository->shouldReceive('store')->andReturnNull();
|
$repository->shouldReceive('store')->andReturnNull();
|
||||||
@ -476,8 +474,8 @@ class CurrencyControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$repository->shouldReceive('store')->andReturn(new TransactionCurrency);
|
$repository->shouldReceive('store')->andReturn(new TransactionCurrency);
|
||||||
@ -505,8 +503,8 @@ class CurrencyControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$repository->shouldReceive('update')->andReturn(new TransactionCurrency);
|
$repository->shouldReceive('update')->andReturn(new TransactionCurrency);
|
||||||
|
@ -22,8 +22,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Feature\Controllers;
|
namespace Tests\Feature\Controllers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
@ -55,7 +53,7 @@ class DebugControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@ -71,7 +69,7 @@ class DebugControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
||||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||||
|
|
||||||
@ -115,7 +113,7 @@ class DebugControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
|||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
use Log;
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
|
use Preferences;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
use Preferences;
|
|
||||||
/**
|
/**
|
||||||
* Class AccountControllerTest
|
* Class AccountControllerTest
|
||||||
*
|
*
|
||||||
@ -56,8 +56,8 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testIndex(): void
|
public function testIndex(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$prereq = $this->mock(FakePrerequisites::class);
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
$this->mock(ImportJobRepositoryInterface::class);
|
$this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
@ -69,10 +69,9 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
$job->file_type = '';
|
$job->file_type = '';
|
||||||
$job->save();
|
$job->save();
|
||||||
|
|
||||||
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_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(), '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(), 'ynab_client_id', null])->andReturnNull();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
@ -97,7 +96,7 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testIndexBadState(): void
|
public function testIndexBadState(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$this->mock(ImportJobRepositoryInterface::class);
|
$this->mock(ImportJobRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
@ -110,10 +109,10 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
$job->file_type = '';
|
$job->file_type = '';
|
||||||
$job->save();
|
$job->save();
|
||||||
|
|
||||||
Preferences::shouldReceive('getForUser')->atLeast()->once()->withArgs([Mockery::any(),'bunq_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(), '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(), '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(), 'fake_api_key', null])->andReturnNull();
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
@ -134,9 +133,9 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
$prereq = $this->mock(FakePrerequisites::class);
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
$repository = $this->mock(ImportJobRepositoryInterface::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(), '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(), '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(), 'ynab_client_id', null])->andReturnNull();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
@ -171,9 +170,9 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
$prereq = $this->mock(FakePrerequisites::class);
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
$repository = $this->mock(ImportJobRepositoryInterface::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(), '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(), '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(), '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(),'fake_api_key',null])->andReturnNull();
|
||||||
|
|
||||||
|
|
||||||
@ -206,13 +205,13 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testPostBadState(): void
|
public function testPostBadState(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$prereq = $this->mock(FakePrerequisites::class);
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
$this->mock(ImportJobRepositoryInterface::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(), '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(), '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(), 'ynab_client_id', null])->andReturnNull();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
$job->user_id = $this->user()->id;
|
$job->user_id = $this->user()->id;
|
||||||
@ -242,13 +241,13 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testPostNoJob(): void
|
public function testPostNoJob(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$prereq = $this->mock(FakePrerequisites::class);
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
$this->mock(ImportJobRepositoryInterface::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(), '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(), '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(), 'ynab_client_id', null])->andReturnNull();
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->atLeast()->once()->andReturn(false);
|
||||||
|
|
||||||
@ -272,13 +271,13 @@ class PrerequisitesControllerTest extends TestCase
|
|||||||
public function testPostWithMessages(): void
|
public function testPostWithMessages(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$prereq = $this->mock(FakePrerequisites::class);
|
$prereq = $this->mock(FakePrerequisites::class);
|
||||||
$this->mock(ImportJobRepositoryInterface::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(), '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(), '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(), '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(),'fake_api_key',null])->andReturnNull();
|
||||||
|
|
||||||
$job = new ImportJob;
|
$job = new ImportJob;
|
||||||
|
@ -62,8 +62,8 @@ class JavascriptControllerTest extends TestCase
|
|||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$account = $this->getRandomAsset();
|
$account = $this->getRandomAsset();
|
||||||
$euro = $this->getEuro();
|
$euro = $this->getEuro();
|
||||||
$pref = new Preference;
|
$pref = new Preference;
|
||||||
$pref->data = 'EUR';
|
$pref->data = 'EUR';
|
||||||
|
|
||||||
Preferences::shouldReceive('get')->withArgs(['currencyPreference', 'EUR'])->atLeast()->once()->andReturn($pref);
|
Preferences::shouldReceive('get')->withArgs(['currencyPreference', 'EUR'])->atLeast()->once()->andReturn($pref);
|
||||||
|
|
||||||
|
@ -111,7 +111,8 @@ class BoxControllerTest extends TestCase
|
|||||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController
|
* @covers \FireflyIII\Http\Controllers\Json\BoxController
|
||||||
*/
|
*/
|
||||||
public function testBalance(): void
|
public function testBalance(): void
|
||||||
{ $this->mockDefaultSession();
|
{
|
||||||
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
@ -138,11 +139,11 @@ class BoxControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testBalanceTransactions(): void
|
public function testBalanceTransactions(): void
|
||||||
{
|
{
|
||||||
$withdrawal = $this->getRandomWithdrawalAsArray();
|
$withdrawal = $this->getRandomWithdrawalAsArray();
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$euro =$this->getEuro();
|
$euro = $this->getEuro();
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
||||||
|
@ -24,7 +24,6 @@ namespace Tests\Feature\Controllers\Json;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||||
use FireflyIII\Models\CurrencyExchangeRate;
|
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Services\Currency\ExchangeRateInterface;
|
use FireflyIII\Services\Currency\ExchangeRateInterface;
|
||||||
use Log;
|
use Log;
|
||||||
@ -58,7 +57,7 @@ class ExchangeControllerTest extends TestCase
|
|||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
$rate = $this->getRandomCer();
|
$rate = $this->getRandomCer();
|
||||||
@ -77,7 +76,7 @@ class ExchangeControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$rate = $this->getRandomCer();
|
$rate = $this->getRandomCer();
|
||||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Feature\Controllers\Json;
|
namespace Tests\Feature\Controllers\Json;
|
||||||
|
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
|
||||||
use Preferences;
|
use Preferences;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class IntroControllerTest
|
* Class IntroControllerTest
|
||||||
|
@ -27,14 +27,10 @@ namespace Tests\Feature\Controllers\Json;
|
|||||||
use Amount;
|
use Amount;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
|
|
||||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
@ -110,13 +106,13 @@ class ReconcileControllerTest extends TestCase
|
|||||||
$this->mock(RecurringRepositoryInterface::class);
|
$this->mock(RecurringRepositoryInterface::class);
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$euro =$this->getEuro();
|
$euro = $this->getEuro();
|
||||||
$withdrawal = $this->getRandomWithdrawalAsArray();
|
$withdrawal = $this->getRandomWithdrawalAsArray();
|
||||||
|
|
||||||
|
|
||||||
$accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);
|
$accountRepos->shouldReceive('getAccountCurrency')->atLeast()->once()->andReturn($euro);
|
||||||
|
@ -22,8 +22,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Feature\Controllers;
|
namespace Tests\Feature\Controllers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Feature\Controllers;
|
namespace Tests\Feature\Controllers;
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
|
@ -425,7 +425,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
$piggyRepos = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
$repetition = PiggyBankRepetition::first();
|
$repetition = PiggyBankRepetition::first();
|
||||||
$piggyBank = $this->getRandomPiggyBank();
|
$piggyBank = $this->getRandomPiggyBank();
|
||||||
|
|
||||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->atLeast()->once();
|
||||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||||
@ -449,8 +449,8 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
$piggyBank = $this->getRandomPiggyBank();
|
$piggyBank = $this->getRandomPiggyBank();
|
||||||
$this->mock(CurrencyRepositoryInterface::class);
|
$this->mock(CurrencyRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
@ -471,12 +471,12 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$this->mockIntroPreference('shown_demo_piggy-banks_show');
|
$this->mockIntroPreference('shown_demo_piggy-banks_show');
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$first = $this->user()->transactionJournals()->inRandomOrder()->first();
|
$first = $this->user()->transactionJournals()->inRandomOrder()->first();
|
||||||
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$transformer = $this->mock(PiggyBankTransformer::class);
|
$transformer = $this->mock(PiggyBankTransformer::class);
|
||||||
$piggyBank = $this->getRandomPiggyBank();
|
$piggyBank = $this->getRandomPiggyBank();
|
||||||
$this->mock(CurrencyRepositoryInterface::class);
|
$this->mock(CurrencyRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
@ -506,7 +506,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
$this->mock(CurrencyRepositoryInterface::class);
|
$this->mock(CurrencyRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
@ -535,8 +535,8 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
||||||
$piggyBank = $this->getRandomPiggyBank();
|
$piggyBank = $this->getRandomPiggyBank();
|
||||||
$this->mock(CurrencyRepositoryInterface::class);
|
$this->mock(CurrencyRepositoryInterface::class);
|
||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
|
@ -25,13 +25,10 @@ namespace Tests\Feature\Controllers\Popup;
|
|||||||
use Amount;
|
use Amount;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Helpers\Report\PopupReportInterface;
|
use FireflyIII\Helpers\Report\PopupReportInterface;
|
||||||
use FireflyIII\Models\Account;
|
|
||||||
use FireflyIII\Models\Budget;
|
use FireflyIII\Models\Budget;
|
||||||
use FireflyIII\Models\Category;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@ -192,8 +189,8 @@ class ReportControllerTest extends TestCase
|
|||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$popupReport = $this->mock(PopupReportInterface::class);
|
$popupReport = $this->mock(PopupReportInterface::class);
|
||||||
$account = $this->getRandomAsset();
|
$account = $this->getRandomAsset();
|
||||||
$budget = $this->getRandomBudget();
|
$budget = $this->getRandomBudget();
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
|
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
|
||||||
@ -227,7 +224,7 @@ class ReportControllerTest extends TestCase
|
|||||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||||
$budget = $this->getRandomBudget();
|
$budget = $this->getRandomBudget();
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
|
$budgetRepos->shouldReceive('findNull')->andReturn($budget)->once()->withArgs([1]);
|
||||||
@ -259,7 +256,7 @@ class ReportControllerTest extends TestCase
|
|||||||
$this->mock(AccountRepositoryInterface::class);
|
$this->mock(AccountRepositoryInterface::class);
|
||||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||||
$category = $this->getRandomCategory();
|
$category = $this->getRandomCategory();
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$categoryRepos->shouldReceive('findNull')->andReturn($category)->once()->withArgs([1]);
|
$categoryRepos->shouldReceive('findNull')->andReturn($category)->once()->withArgs([1]);
|
||||||
@ -292,7 +289,7 @@ class ReportControllerTest extends TestCase
|
|||||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$account = $this->getRandomAsset();
|
$account = $this->getRandomAsset();
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
|
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
|
||||||
@ -325,7 +322,7 @@ class ReportControllerTest extends TestCase
|
|||||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||||
$popupHelper = $this->mock(PopupReportInterface::class);
|
$popupHelper = $this->mock(PopupReportInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$account = $this->getRandomAsset();
|
$account = $this->getRandomAsset();
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
|
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($account)->once();
|
||||||
|
@ -24,9 +24,7 @@ namespace Tests\Feature\Controllers;
|
|||||||
|
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
@ -104,7 +102,7 @@ class PreferencesControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->andReturn(false);
|
$userRepos->shouldReceive('hasRole')->andReturn(false);
|
||||||
|
|
||||||
|
@ -24,8 +24,6 @@ namespace Tests\Feature\Controllers;
|
|||||||
|
|
||||||
use Amount;
|
use Amount;
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Google2FA;
|
use Google2FA;
|
||||||
@ -33,6 +31,7 @@ use Illuminate\Support\Collection;
|
|||||||
use Log;
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
|
use stdClass;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,7 +132,7 @@ class ProfileControllerTest extends TestCase
|
|||||||
$repository->shouldReceive('unblockUser');
|
$repository->shouldReceive('unblockUser');
|
||||||
$preference = new Preference;
|
$preference = new Preference;
|
||||||
$preference->data = 'existing-token';
|
$preference->data = 'existing-token';
|
||||||
/** @var \stdClass $preference */
|
/** @var stdClass $preference */
|
||||||
$preference->user = $this->user();
|
$preference->user = $this->user();
|
||||||
Preferences::shouldReceive('findByName')->withArgs(['email_change_confirm_token'])->andReturn(new Collection([$preference]));
|
Preferences::shouldReceive('findByName')->withArgs(['email_change_confirm_token'])->andReturn(new Collection([$preference]));
|
||||||
// email_change_confirm_token
|
// email_change_confirm_token
|
||||||
@ -205,8 +204,8 @@ class ProfileControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
//$this->mockDefaultSession(); // DISABLED ON PURPOSE
|
//$this->mockDefaultSession(); // DISABLED ON PURPOSE
|
||||||
$this->mockDefaultConfiguration();
|
$this->mockDefaultConfiguration();
|
||||||
$repository = $this->mock(UserRepositoryInterface::class);
|
$repository = $this->mock(UserRepositoryInterface::class);
|
||||||
$euro = $this->getEuro();
|
$euro = $this->getEuro();
|
||||||
|
|
||||||
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->times(1)->andReturn(false);
|
$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');
|
$hash = hash('sha256', 'previous@example.com');
|
||||||
$tokenPreference = new Preference;
|
$tokenPreference = new Preference;
|
||||||
$tokenPreference->data = 'token';
|
$tokenPreference->data = 'token';
|
||||||
/** @var \stdClass $tokenPreference */
|
/** @var stdClass $tokenPreference */
|
||||||
$tokenPreference->user = $this->user();
|
$tokenPreference->user = $this->user();
|
||||||
|
|
||||||
$hashPreference = new Preference;
|
$hashPreference = new Preference;
|
||||||
$hashPreference->data = 'previous@example.com';
|
$hashPreference->data = 'previous@example.com';
|
||||||
/** @var \stdClass $hashPreference */
|
/** @var stdClass $hashPreference */
|
||||||
$hashPreference->user = $this->user();
|
$hashPreference->user = $this->user();
|
||||||
|
|
||||||
Preferences::shouldReceive('findByName')->once()->andReturn(new Collection([$tokenPreference]));
|
Preferences::shouldReceive('findByName')->once()->andReturn(new Collection([$tokenPreference]));
|
||||||
@ -567,12 +566,12 @@ class ProfileControllerTest extends TestCase
|
|||||||
$hash = hash('sha256', 'previous@example.comX');
|
$hash = hash('sha256', 'previous@example.comX');
|
||||||
$tokenPreference = new Preference;
|
$tokenPreference = new Preference;
|
||||||
$tokenPreference->data = 'token';
|
$tokenPreference->data = 'token';
|
||||||
/** @var \stdClass $tokenPreference */
|
/** @var stdClass $tokenPreference */
|
||||||
$tokenPreference->user = $this->user();
|
$tokenPreference->user = $this->user();
|
||||||
|
|
||||||
$hashPreference = new Preference;
|
$hashPreference = new Preference;
|
||||||
$hashPreference->data = 'previous@example.com';
|
$hashPreference->data = 'previous@example.com';
|
||||||
/** @var \stdClass $hashPreference */
|
/** @var stdClass $hashPreference */
|
||||||
$hashPreference->user = $this->user();
|
$hashPreference->user = $this->user();
|
||||||
|
|
||||||
Preferences::shouldReceive('findByName')->once()->andReturn(new Collection([$tokenPreference]));
|
Preferences::shouldReceive('findByName')->once()->andReturn(new Collection([$tokenPreference]));
|
||||||
|
@ -29,7 +29,6 @@ use Carbon\Carbon;
|
|||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Tests\Feature\Controllers\Recurring;
|
namespace Tests\Feature\Controllers\Recurring;
|
||||||
|
|
||||||
|
use FireflyConfig;
|
||||||
use FireflyIII\Factory\CategoryFactory;
|
use FireflyIII\Factory\CategoryFactory;
|
||||||
use FireflyIII\Models\Configuration;
|
use FireflyIII\Models\Configuration;
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
@ -91,7 +92,7 @@ class IndexControllerTest extends TestCase
|
|||||||
$collection = $this->user()->recurrences()->take(2)->get();
|
$collection = $this->user()->recurrences()->take(2)->get();
|
||||||
|
|
||||||
// mock cron job config:
|
// 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();
|
$repository->shouldReceive('get')->andReturn($collection)->once();
|
||||||
|
|
||||||
@ -125,9 +126,9 @@ class IndexControllerTest extends TestCase
|
|||||||
'recurrence_repetitions' => [
|
'recurrence_repetitions' => [
|
||||||
[
|
[
|
||||||
'occurrences' => [
|
'occurrences' => [
|
||||||
'2019-01-01'
|
'2019-01-01',
|
||||||
]
|
],
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -295,7 +295,7 @@ class ReportControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$this->mock(BudgetRepositoryInterface::class);
|
$this->mock(BudgetRepositoryInterface::class);
|
||||||
$this->mock(ReportHelperInterface::class);
|
$this->mock(ReportHelperInterface::class);
|
||||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
$account = new Account();
|
$account = new Account();
|
||||||
$account->name = 'Something';
|
$account->name = 'Something';
|
||||||
@ -338,7 +338,7 @@ class ReportControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
Log::debug(sprintf('Now in test %s', __METHOD__));
|
Log::debug(sprintf('Now in test %s', __METHOD__));
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(BudgetRepositoryInterface::class);
|
$this->mock(BudgetRepositoryInterface::class);
|
||||||
$this->mock(ReportHelperInterface::class);
|
$this->mock(ReportHelperInterface::class);
|
||||||
$category = $this->getRandomCategory();
|
$category = $this->getRandomCategory();
|
||||||
@ -383,8 +383,8 @@ class ReportControllerTest extends TestCase
|
|||||||
$this->mock(ReportHelperInterface::class);
|
$this->mock(ReportHelperInterface::class);
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(TagRepositoryInterface::class);
|
$this->mock(TagRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$asset = $this->getRandomAsset();
|
$asset = $this->getRandomAsset();
|
||||||
// find the user's asset account
|
// find the user's asset account
|
||||||
$accountRepos->shouldReceive('findNull')->withArgs([1])->andReturn($asset)->atLeast()->once();
|
$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__));
|
Log::debug(sprintf('Now in test %s', __METHOD__));
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$this->mock(BudgetRepositoryInterface::class);
|
$this->mock(BudgetRepositoryInterface::class);
|
||||||
$this->mock(ReportHelperInterface::class);
|
$this->mock(ReportHelperInterface::class);
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
@ -446,7 +446,7 @@ class ReportControllerTest extends TestCase
|
|||||||
$this->mock(ReportHelperInterface::class);
|
$this->mock(ReportHelperInterface::class);
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(TagRepositoryInterface::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();
|
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
@ -472,7 +472,7 @@ class ReportControllerTest extends TestCase
|
|||||||
$this->mock(ReportHelperInterface::class);
|
$this->mock(ReportHelperInterface::class);
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(TagRepositoryInterface::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();
|
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
@ -530,7 +530,7 @@ class ReportControllerTest extends TestCase
|
|||||||
$this->mock(ReportHelperInterface::class);
|
$this->mock(ReportHelperInterface::class);
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(TagRepositoryInterface::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();
|
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||||
|
|
||||||
@ -558,8 +558,8 @@ class ReportControllerTest extends TestCase
|
|||||||
$this->mock(BudgetRepositoryInterface::class);
|
$this->mock(BudgetRepositoryInterface::class);
|
||||||
$this->mock(ReportHelperInterface::class);
|
$this->mock(ReportHelperInterface::class);
|
||||||
$this->mock(TagRepositoryInterface::class);
|
$this->mock(TagRepositoryInterface::class);
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||||
|
|
||||||
$categoryRepos->shouldReceive('findNull')->andReturn($this->user()->categories()->find(1))->twice();
|
$categoryRepos->shouldReceive('findNull')->andReturn($this->user()->categories()->find(1))->twice();
|
||||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->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(ReportHelperInterface::class);
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(TagRepositoryInterface::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();
|
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||||
|
|
||||||
@ -615,7 +615,7 @@ class ReportControllerTest extends TestCase
|
|||||||
$this->mock(ReportHelperInterface::class);
|
$this->mock(ReportHelperInterface::class);
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(TagRepositoryInterface::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();
|
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||||
|
|
||||||
@ -642,7 +642,7 @@ class ReportControllerTest extends TestCase
|
|||||||
$this->mock(ReportHelperInterface::class);
|
$this->mock(ReportHelperInterface::class);
|
||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(TagRepositoryInterface::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();
|
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||||
|
|
||||||
@ -672,8 +672,8 @@ class ReportControllerTest extends TestCase
|
|||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(TagRepositoryInterface::class);
|
$this->mock(TagRepositoryInterface::class);
|
||||||
Log::debug(sprintf('Now in test %s', __METHOD__));
|
Log::debug(sprintf('Now in test %s', __METHOD__));
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||||
|
|
||||||
/** @var Tag $tag */
|
/** @var Tag $tag */
|
||||||
$tag = $this->user()->tags()->find(1);
|
$tag = $this->user()->tags()->find(1);
|
||||||
@ -710,8 +710,8 @@ class ReportControllerTest extends TestCase
|
|||||||
$this->mock(CategoryRepositoryInterface::class);
|
$this->mock(CategoryRepositoryInterface::class);
|
||||||
$this->mock(TagRepositoryInterface::class);
|
$this->mock(TagRepositoryInterface::class);
|
||||||
Log::debug(sprintf('Now in test %s', __METHOD__));
|
Log::debug(sprintf('Now in test %s', __METHOD__));
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$tag2 = $this->user()->tags()->find(3);
|
$tag2 = $this->user()->tags()->find(3);
|
||||||
|
@ -25,9 +25,7 @@ namespace tests\Feature\Controllers\Rule;
|
|||||||
|
|
||||||
|
|
||||||
use FireflyIII\Models\Rule;
|
use FireflyIII\Models\Rule;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
|
@ -24,8 +24,6 @@ declare(strict_types=1);
|
|||||||
namespace tests\Feature\Controllers\Rule;
|
namespace tests\Feature\Controllers\Rule;
|
||||||
|
|
||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
@ -55,15 +53,14 @@ class DeleteControllerTest extends TestCase
|
|||||||
public function testDelete(): void
|
public function testDelete(): void
|
||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('rules.delete', [1]));
|
$response = $this->get(route('rules.delete', [1]));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
@ -76,7 +73,7 @@ class DeleteControllerTest extends TestCase
|
|||||||
public function testDestroy(): void
|
public function testDestroy(): void
|
||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||||
$repository->shouldReceive('destroy');
|
$repository->shouldReceive('destroy');
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
@ -25,8 +25,6 @@ namespace tests\Feature\Controllers\Rule;
|
|||||||
|
|
||||||
|
|
||||||
use FireflyIII\Models\Rule;
|
use FireflyIII\Models\Rule;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
@ -56,9 +54,9 @@ class EditControllerTest extends TestCase
|
|||||||
public function testEdit(): void
|
public function testEdit(): void
|
||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
$groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
@ -88,9 +86,9 @@ class EditControllerTest extends TestCase
|
|||||||
$this->session(['_old_input' => $old]);
|
$this->session(['_old_input' => $old]);
|
||||||
|
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
$groupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
|
||||||
@ -111,8 +109,8 @@ class EditControllerTest extends TestCase
|
|||||||
public function testUpdate(): void
|
public function testUpdate(): void
|
||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
|
@ -23,8 +23,6 @@ declare(strict_types=1);
|
|||||||
namespace Tests\Feature\Controllers\Rule;
|
namespace Tests\Feature\Controllers\Rule;
|
||||||
|
|
||||||
use FireflyIII\Models\RuleGroup;
|
use FireflyIII\Models\RuleGroup;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
|
@ -26,10 +26,7 @@ namespace tests\Feature\Controllers\Rule;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
|
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
|
||||||
use FireflyIII\Jobs\Job;
|
use FireflyIII\Jobs\Job;
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use FireflyIII\TransactionRules\TransactionMatcher;
|
use FireflyIII\TransactionRules\TransactionMatcher;
|
||||||
@ -82,7 +79,7 @@ class SelectControllerTest extends TestCase
|
|||||||
|
|
||||||
Queue::assertPushed(
|
Queue::assertPushed(
|
||||||
ExecuteRuleOnExistingTransactions::class, function (Job $job) {
|
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);
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$matcher->shouldReceive('setStrict')->once()->withArgs([false]);
|
$matcher->shouldReceive('setStrict')->once()->withArgs([false]);
|
||||||
|
|
||||||
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
|
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
|
||||||
|
@ -52,7 +52,7 @@ class CreateControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$this->mock(RuleGroupRepositoryInterface::class);
|
$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);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@ -69,7 +69,7 @@ class CreateControllerTest extends TestCase
|
|||||||
public function testStore(): void
|
public function testStore(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$repository = $this->mock(RuleGroupRepositoryInterface::class);
|
$repository = $this->mock(RuleGroupRepositoryInterface::class);
|
||||||
|
|
||||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||||
|
|
||||||
|
@ -24,9 +24,7 @@ namespace Tests\Feature\Controllers\RuleGroup;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Jobs\ExecuteRuleGroupOnExistingTransactions;
|
use FireflyIII\Jobs\ExecuteRuleGroupOnExistingTransactions;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
|
@ -75,7 +75,7 @@ class SearchControllerTest extends TestCase
|
|||||||
public function testSearch(): void
|
public function testSearch(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$search = $this->mock(SearchInterface::class);
|
$search = $this->mock(SearchInterface::class);
|
||||||
|
|
||||||
$search->shouldReceive('parseQuery')->once();
|
$search->shouldReceive('parseQuery')->once();
|
||||||
$search->shouldReceive('setLimit')->withArgs([50])->once();
|
$search->shouldReceive('setLimit')->withArgs([50])->once();
|
||||||
|
@ -30,6 +30,7 @@ use FireflyIII\Support\Cronjobs\RecurringCronjob;
|
|||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
|
use Preferences;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +62,7 @@ class CronControllerTest extends TestCase
|
|||||||
$job->shouldReceive('fire')->once()->andReturn(true);
|
$job->shouldReceive('fire')->once()->andReturn(true);
|
||||||
$repository = $this->mock(UserRepositoryInterface::class);
|
$repository = $this->mock(UserRepositoryInterface::class);
|
||||||
$repository->shouldReceive('all')->andReturn($users);
|
$repository->shouldReceive('all')->andReturn($users);
|
||||||
\Preferences::shouldReceive('getForUser')
|
Preferences::shouldReceive('getForUser')
|
||||||
->withArgs([Mockery::any(), 'access_token', null])
|
->withArgs([Mockery::any(), 'access_token', null])
|
||||||
->andReturn($preference)->once();
|
->andReturn($preference)->once();
|
||||||
$response = $this->get(route('cron.cron', ['token']));
|
$response = $this->get(route('cron.cron', ['token']));
|
||||||
@ -83,7 +84,7 @@ class CronControllerTest extends TestCase
|
|||||||
$job->shouldReceive('fire')->once()->andThrow(new FireflyException('Exception noted.'));
|
$job->shouldReceive('fire')->once()->andThrow(new FireflyException('Exception noted.'));
|
||||||
$repository = $this->mock(UserRepositoryInterface::class);
|
$repository = $this->mock(UserRepositoryInterface::class);
|
||||||
$repository->shouldReceive('all')->andReturn($users);
|
$repository->shouldReceive('all')->andReturn($users);
|
||||||
\Preferences::shouldReceive('getForUser')
|
Preferences::shouldReceive('getForUser')
|
||||||
->withArgs([Mockery::any(), 'access_token', null])
|
->withArgs([Mockery::any(), 'access_token', null])
|
||||||
->andReturn($preference)->once();
|
->andReturn($preference)->once();
|
||||||
$response = $this->get(route('cron.cron', ['token']));
|
$response = $this->get(route('cron.cron', ['token']));
|
||||||
@ -105,7 +106,7 @@ class CronControllerTest extends TestCase
|
|||||||
$job->shouldReceive('fire')->once()->andReturn(false);
|
$job->shouldReceive('fire')->once()->andReturn(false);
|
||||||
$repository = $this->mock(UserRepositoryInterface::class);
|
$repository = $this->mock(UserRepositoryInterface::class);
|
||||||
$repository->shouldReceive('all')->andReturn($users);
|
$repository->shouldReceive('all')->andReturn($users);
|
||||||
\Preferences::shouldReceive('getForUser')
|
Preferences::shouldReceive('getForUser')
|
||||||
->withArgs([Mockery::any(), 'access_token', null])
|
->withArgs([Mockery::any(), 'access_token', null])
|
||||||
->andReturn($preference)->once();
|
->andReturn($preference)->once();
|
||||||
$response = $this->get(route('cron.cron', ['token']));
|
$response = $this->get(route('cron.cron', ['token']));
|
||||||
|
@ -29,11 +29,9 @@ use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
|||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
use FireflyIII\Models\Tag;
|
use FireflyIII\Models\Tag;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Pagination\LengthAwarePaginator;
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Illuminate\Support\Collection;
|
|
||||||
use Log;
|
use Log;
|
||||||
use Mockery;
|
use Mockery;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
@ -65,7 +63,7 @@ class TagControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$this->mock(TagRepositoryInterface::class);
|
$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);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
@ -82,7 +80,7 @@ class TagControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$this->mock(TagRepositoryInterface::class);
|
$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);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
@ -99,7 +97,7 @@ class TagControllerTest extends TestCase
|
|||||||
public function testDestroy(): void
|
public function testDestroy(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$repository = $this->mock(TagRepositoryInterface::class);
|
$repository = $this->mock(TagRepositoryInterface::class);
|
||||||
|
|
||||||
$repository->shouldReceive('destroy');
|
$repository->shouldReceive('destroy');
|
||||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||||
@ -117,7 +115,7 @@ class TagControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$this->mock(TagRepositoryInterface::class);
|
$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);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
@ -133,8 +131,8 @@ class TagControllerTest extends TestCase
|
|||||||
public function testIndex(): void
|
public function testIndex(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$repository = $this->mock(TagRepositoryInterface::class);
|
$repository = $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);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
|
|
||||||
@ -315,7 +313,7 @@ class TagControllerTest extends TestCase
|
|||||||
public function testStore(): void
|
public function testStore(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$repository = $this->mock(TagRepositoryInterface::class);
|
$repository = $this->mock(TagRepositoryInterface::class);
|
||||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||||
|
|
||||||
$repository->shouldReceive('findNull')->andReturn(null);
|
$repository->shouldReceive('findNull')->andReturn(null);
|
||||||
@ -341,8 +339,8 @@ class TagControllerTest extends TestCase
|
|||||||
public function testUpdate(): void
|
public function testUpdate(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$repository = $this->mock(TagRepositoryInterface::class);
|
$repository = $this->mock(TagRepositoryInterface::class);
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,10 +24,8 @@ namespace Tests\Feature\Controllers\Transaction;
|
|||||||
|
|
||||||
use Amount;
|
use Amount;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||||
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
|
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
@ -193,8 +191,6 @@ class ConvertControllerTest extends TestCase
|
|||||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
|
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$data = ['source_account_id' => 1];
|
$data = ['source_account_id' => 1];
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->post(route('transactions.convert.index.post', ['transfer', $deposit->id]), $data);
|
$response = $this->post(route('transactions.convert.index.post', ['transfer', $deposit->id]), $data);
|
||||||
|
@ -26,9 +26,9 @@ use FireflyIII\Models\Preference;
|
|||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
use Mockery;
|
||||||
use Preferences;
|
use Preferences;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
use Mockery;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CreateControllerTest
|
* Class CreateControllerTest
|
||||||
@ -56,7 +56,7 @@ class CreateControllerTest extends TestCase
|
|||||||
$empty = new Preference;
|
$empty = new Preference;
|
||||||
$empty->data = [];
|
$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);
|
$accountRepos->shouldReceive('getCashAccount')->atLeast()->once()->andReturn($cash);
|
||||||
|
|
||||||
Preferences::shouldReceive('get')->withArgs(['transaction_journal_optional_fields', []])->atLeast()->once()->andReturn($empty);
|
Preferences::shouldReceive('get')->withArgs(['transaction_journal_optional_fields', []])->atLeast()->once()->andReturn($empty);
|
||||||
|
@ -53,9 +53,9 @@ class IndexControllerTest extends TestCase
|
|||||||
public function testIndex(): void
|
public function testIndex(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$group = $this->getRandomWithdrawalGroup();
|
$group = $this->getRandomWithdrawalGroup();
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
|
|
||||||
// generic set for the info blocks:
|
// generic set for the info blocks:
|
||||||
$groupArray = [$this->getRandomWithdrawalAsArray()];
|
$groupArray = [$this->getRandomWithdrawalAsArray()];
|
||||||
@ -95,9 +95,9 @@ class IndexControllerTest extends TestCase
|
|||||||
public function testIndexAll(): void
|
public function testIndexAll(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$group = $this->getRandomWithdrawalGroup();
|
$group = $this->getRandomWithdrawalGroup();
|
||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
$collector = $this->mock(GroupCollectorInterface::class);
|
$collector = $this->mock(GroupCollectorInterface::class);
|
||||||
|
|
||||||
// role?
|
// role?
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true);
|
||||||
|
@ -25,7 +25,6 @@ namespace Tests\Feature\Controllers\Transaction;
|
|||||||
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionJournalLink;
|
use FireflyIII\Models\TransactionJournalLink;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
|
||||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@ -60,8 +59,6 @@ class LinkControllerTest extends TestCase
|
|||||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@ -80,7 +77,6 @@ class LinkControllerTest extends TestCase
|
|||||||
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
|
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$linkRepos->shouldReceive('get')->atLeast()->once()->andReturn(new Collection);
|
$linkRepos->shouldReceive('get')->atLeast()->once()->andReturn(new Collection);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@ -94,8 +90,8 @@ class LinkControllerTest extends TestCase
|
|||||||
public function testDestroy(): void
|
public function testDestroy(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$link = $this->getRandomLink();
|
$link = $this->getRandomLink();
|
||||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||||
|
|
||||||
Preferences::shouldReceive('mark')->once();
|
Preferences::shouldReceive('mark')->once();
|
||||||
|
|
||||||
@ -203,7 +199,7 @@ class LinkControllerTest extends TestCase
|
|||||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||||
$journalRepos = $this->mockDefaultSession();
|
$journalRepos = $this->mockDefaultSession();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'link_other' => $withdrawal->id,
|
'link_other' => $withdrawal->id,
|
||||||
'link_type' => '1_inward',
|
'link_type' => '1_inward',
|
||||||
];
|
];
|
||||||
@ -224,8 +220,8 @@ class LinkControllerTest extends TestCase
|
|||||||
public function testSwitchLink(): void
|
public function testSwitchLink(): void
|
||||||
{
|
{
|
||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
$link = $this->getRandomLink();
|
$link = $this->getRandomLink();
|
||||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||||
$this->mock(UserRepositoryInterface::class);
|
$this->mock(UserRepositoryInterface::class);
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,13 +172,13 @@ class MassControllerTest extends TestCase
|
|||||||
$this->session(['transactions.mass-edit.uri' => 'http://localhost']);
|
$this->session(['transactions.mass-edit.uri' => 'http://localhost']);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'journals' => [$deposit->id],
|
'journals' => [$deposit->id],
|
||||||
'description' => [$deposit->id => 'Updated salary thing'],
|
'description' => [$deposit->id => 'Updated salary thing'],
|
||||||
'amount' => [$deposit->id => 1600],
|
'amount' => [$deposit->id => 1600],
|
||||||
'date' => [$deposit->id => '2014-07-24'],
|
'date' => [$deposit->id => '2014-07-24'],
|
||||||
'source_name' => [$deposit->id => 'Job'],
|
'source_name' => [$deposit->id => 'Job'],
|
||||||
'destination_id' => [$deposit->id => 1],
|
'destination_id' => [$deposit->id => 1],
|
||||||
'category' => [$deposit->id => 'Salary'],
|
'category' => [$deposit->id => 'Salary'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
@ -25,15 +25,26 @@ namespace Tests\Unit\Middleware;
|
|||||||
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Helpers\FiscalHelperInterface;
|
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||||
use FireflyIII\Http\Middleware\Binder;
|
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\Tag\TagRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
use Log;
|
||||||
|
use Mockery;
|
||||||
|
use Preferences;
|
||||||
use Route;
|
use Route;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BinderTest
|
* Class BinderTest
|
||||||
* Per object: works, not existing, not logged in + existing
|
* Per object: works, not existing, not logged in + existing
|
||||||
@ -76,6 +87,28 @@ class BinderTest extends TestCase
|
|||||||
$response->assertSee('count: 2');
|
$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\Http\Middleware\Binder
|
||||||
* @covers \FireflyIII\Support\Binder\AccountList
|
* @covers \FireflyIII\Support\Binder\AccountList
|
||||||
@ -357,6 +390,223 @@ class BinderTest extends TestCase
|
|||||||
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
$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\Http\Middleware\Binder
|
||||||
* @covers \FireflyIII\Models\Budget
|
* @covers \FireflyIII\Models\Budget
|
||||||
@ -730,56 +980,6 @@ class BinderTest extends TestCase
|
|||||||
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
$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\Http\Middleware\Binder
|
||||||
* @covers \FireflyIII\Models\ImportJob
|
* @covers \FireflyIII\Models\ImportJob
|
||||||
@ -836,16 +1036,15 @@ class BinderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testJournalList(): void
|
public function testJournalList(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
Route::middleware(Binder::class)->any(
|
Route::middleware(Binder::class)->any(
|
||||||
'/_test/binder/{journalList}', function (Collection $journals) {
|
'/_test/binder/{journalList}', static function (array $journals) {
|
||||||
return 'count: ' . $journals->count();
|
return 'count: ' . count($journals);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$this->be($this->user());
|
$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());
|
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||||
$response->assertSee('count: 2');
|
$response->assertSee('count: 2');
|
||||||
}
|
}
|
||||||
@ -856,19 +1055,33 @@ class BinderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testJournalListEmpty(): void
|
public function testJournalListEmpty(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
Route::middleware(Binder::class)->any(
|
Route::middleware(Binder::class)->any(
|
||||||
'/_test/binder/{journalList}', function (Collection $journals) {
|
'/_test/binder/{journalList}', static function (array $journals) {
|
||||||
return 'count: ' . $journals->count();
|
return 'count: ' . count($journals);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get('/_test/binder/-1');
|
$response = $this->get('/_test/binder/-1');
|
||||||
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
$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\Http\Middleware\Binder
|
||||||
* @covers \FireflyIII\Models\LinkType
|
* @covers \FireflyIII\Models\LinkType
|
||||||
@ -936,6 +1149,141 @@ class BinderTest extends TestCase
|
|||||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
$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\Http\Middleware\Binder
|
||||||
* @covers \FireflyIII\Models\PiggyBank
|
* @covers \FireflyIII\Models\PiggyBank
|
||||||
@ -1075,9 +1423,6 @@ class BinderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTJ(): void
|
public function testTJ(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
Route::middleware(Binder::class)->any(
|
Route::middleware(Binder::class)->any(
|
||||||
'/_test/binder/{tj}', function () {
|
'/_test/binder/{tj}', function () {
|
||||||
return 'OK';
|
return 'OK';
|
||||||
@ -1095,9 +1440,6 @@ class BinderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTJNotFound(): void
|
public function testTJNotFound(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
Route::middleware(Binder::class)->any(
|
Route::middleware(Binder::class)->any(
|
||||||
'/_test/binder/{tj}', function () {
|
'/_test/binder/{tj}', function () {
|
||||||
return 'OK';
|
return 'OK';
|
||||||
@ -1115,9 +1457,6 @@ class BinderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTJNotLoggedIn(): void
|
public function testTJNotLoggedIn(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
Route::middleware(Binder::class)->any(
|
Route::middleware(Binder::class)->any(
|
||||||
'/_test/binder/{tj}', function () {
|
'/_test/binder/{tj}', function () {
|
||||||
return 'OK';
|
return 'OK';
|
||||||
@ -1171,6 +1510,139 @@ class BinderTest extends TestCase
|
|||||||
$response->assertSee('count: 2');
|
$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\Http\Middleware\Binder
|
||||||
* @covers \FireflyIII\Support\Binder\TagList
|
* @covers \FireflyIII\Support\Binder\TagList
|
||||||
@ -1280,9 +1752,6 @@ class BinderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTransactionJournalLink(): void
|
public function testTransactionJournalLink(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
Route::middleware(Binder::class)->any(
|
Route::middleware(Binder::class)->any(
|
||||||
'/_test/binder/{journalLink}', function () {
|
'/_test/binder/{journalLink}', function () {
|
||||||
return 'OK';
|
return 'OK';
|
||||||
@ -1300,9 +1769,6 @@ class BinderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTransactionJournalLinkNotFound(): void
|
public function testTransactionJournalLinkNotFound(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
Route::middleware(Binder::class)->any(
|
Route::middleware(Binder::class)->any(
|
||||||
'/_test/binder/{journalLink}', function () {
|
'/_test/binder/{journalLink}', function () {
|
||||||
return 'OK';
|
return 'OK';
|
||||||
@ -1320,9 +1786,6 @@ class BinderTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testTransactionJournalLinkNotLoggedIn(): void
|
public function testTransactionJournalLinkNotLoggedIn(): void
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
|
||||||
|
|
||||||
return;
|
|
||||||
Route::middleware(Binder::class)->any(
|
Route::middleware(Binder::class)->any(
|
||||||
'/_test/binder/{journalLink}', function () {
|
'/_test/binder/{journalLink}', function () {
|
||||||
return 'OK';
|
return 'OK';
|
||||||
@ -1382,64 +1845,4 @@ class BinderTest extends TestCase
|
|||||||
$response = $this->get('/_test/binder/withdrawal');
|
$response = $this->get('/_test/binder/withdrawal');
|
||||||
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
$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());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user