mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-26 10:51:12 -06:00
Improve test coverage.
This commit is contained in:
parent
1e7e0facf1
commit
226e2f7185
@ -115,7 +115,7 @@ class CategoryController extends Controller
|
||||
switch ($step) {
|
||||
case '1D':
|
||||
while ($current <= $end) {
|
||||
Log::debug(sprintf('Current day is %s', $current->format('Y-m-d')));
|
||||
//Log::debug(sprintf('Current day is %s', $current->format('Y-m-d')));
|
||||
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $current, $current);
|
||||
$earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $current, $current);
|
||||
$sum = bcadd($spent, $earned);
|
||||
@ -134,7 +134,7 @@ class CategoryController extends Controller
|
||||
// @codeCoverageIgnoreEnd
|
||||
while ($current <= $end) {
|
||||
$currentEnd = app('navigation')->endOfPeriod($current, $step);
|
||||
Log::debug(sprintf('abc Range is %s to %s', $current->format('Y-m-d'), $currentEnd->format('Y-m-d')));
|
||||
//Log::debug(sprintf('abc Range is %s to %s', $current->format('Y-m-d'), $currentEnd->format('Y-m-d')));
|
||||
|
||||
$spent = $repository->spentInPeriod(new Collection([$category]), $accounts, $current, $currentEnd);
|
||||
$earned = $repository->earnedInPeriod(new Collection([$category]), $accounts, $current, $currentEnd);
|
||||
|
@ -1,97 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* TransactionController.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/>.
|
||||
*/
|
||||
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
|
||||
/** @noinspection MoreThanThreeArgumentsInspection */
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Support\Http\Controllers\ModelInformation;
|
||||
use FireflyIII\Support\Http\Controllers\PeriodOverview;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class TransactionController.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class TransactionController extends Controller
|
||||
{
|
||||
use ModelInformation, PeriodOverview;
|
||||
/** @var AttachmentRepositoryInterface */
|
||||
private $attachmentRepository;
|
||||
/** @var JournalRepositoryInterface Journals and transactions overview */
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* TransactionController constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('mainTitleIcon', 'fa-repeat');
|
||||
$this->repository = app(JournalRepositoryInterface::class);
|
||||
$this->attachmentRepository = app(AttachmentRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reorder transactions.
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function reorder(Request $request): JsonResponse
|
||||
{
|
||||
$ids = $request->get('items');
|
||||
$date = new Carbon($request->get('date'));
|
||||
if (count($ids) > 0) {
|
||||
$order = 0;
|
||||
$ids = array_unique($ids);
|
||||
foreach ($ids as $id) {
|
||||
$journal = $this->repository->findNull((int)$id);
|
||||
if (null !== $journal && $journal->date->isSameDay($date)) {
|
||||
$this->repository->setOrder($journal, $order);
|
||||
++$order;
|
||||
}
|
||||
}
|
||||
}
|
||||
app('preferences')->mark();
|
||||
|
||||
return response()->json([true]);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -45,20 +45,7 @@
|
||||
<directory suffix="Test.php">./tests/Unit/Helpers</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Account</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Admin</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Budget</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Category</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Chart</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Import</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Json</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Popup</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Recurring</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Report</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Rule</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/RuleGroup</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/System</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Transaction</directory>
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
</testsuite>
|
||||
|
||||
|
||||
|
@ -45,20 +45,7 @@
|
||||
<directory suffix="Test.php">./tests/Unit/Helpers</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Account</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Admin</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Budget</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Category</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Chart</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Import</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Json</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Popup</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Recurring</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Report</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Rule</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/RuleGroup</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/System</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Transaction</directory>
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
</testsuite>
|
||||
|
||||
|
||||
|
17
phpunit.xml
17
phpunit.xml
@ -45,22 +45,7 @@
|
||||
<directory suffix="Test.php">./tests/Unit/Helpers</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Account</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Admin</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Budget</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Category</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Chart</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Import</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Json</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Popup</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Recurring</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Report</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Rule</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/RuleGroup</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/System</directory>
|
||||
<directory suffix="Test.php">./tests/Feature/Controllers/Transaction</directory>
|
||||
<file>./tests/Feature/Controllers/AttachmentControllerTest.php</file>
|
||||
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
</testsuite>
|
||||
|
||||
<!--
|
||||
|
@ -24,13 +24,10 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers\Account;
|
||||
|
||||
|
||||
use Amount;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
@ -97,8 +94,8 @@ class CreateControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
|
||||
$repository->shouldReceive('store')->once()->andReturn($asset);
|
||||
|
||||
@ -133,8 +130,8 @@ class CreateControllerTest extends TestCase
|
||||
public function testStoreAnother(): void
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
|
||||
$repository->shouldReceive('store')->once()->andReturn($asset);
|
||||
|
||||
@ -149,7 +146,6 @@ class CreateControllerTest extends TestCase
|
||||
$this->mockDefaultSession();
|
||||
|
||||
|
||||
|
||||
Preferences::shouldReceive('mark')->atLeast()->once()->withNoArgs();
|
||||
|
||||
$this->session(['accounts.create.uri' => 'http://localhost']);
|
||||
@ -175,9 +171,9 @@ class CreateControllerTest extends TestCase
|
||||
public function testStoreLiability(): void
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$liability = $this->getRandomLoan();
|
||||
$loan = AccountType::where('type', AccountType::LOAN)->first();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$liability = $this->getRandomLoan();
|
||||
$loan = AccountType::where('type', AccountType::LOAN)->first();
|
||||
$repository->shouldReceive('store')->once()->andReturn($liability);
|
||||
|
||||
// mock default session stuff
|
||||
|
@ -24,17 +24,14 @@ declare(strict_types=1);
|
||||
namespace Tests\Feature\Controllers\Account;
|
||||
|
||||
|
||||
use Amount;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
use Preferences;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
||||
/**
|
||||
@ -62,9 +59,9 @@ class DeleteControllerTest extends TestCase
|
||||
public function testDelete(): void
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
|
||||
$repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET]])->andReturn(new Collection);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
@ -86,8 +83,8 @@ class DeleteControllerTest extends TestCase
|
||||
public function testDestroy(): void
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$asset = $this->getRandomAsset();
|
||||
$repository->shouldReceive('findNull')->withArgs([0])->once()->andReturn(null);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
|
||||
|
@ -24,10 +24,8 @@ namespace Tests\Feature\Controllers\Account;
|
||||
|
||||
use Amount;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
@ -66,10 +64,10 @@ class IndexControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff
|
||||
$this->mock(CurrencyRepositoryInterface::class);
|
||||
$account = $this->getRandomAsset();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
$account = $this->getRandomAsset();
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
|
@ -39,6 +39,9 @@ use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class ConfigurationControllerTest
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*
|
||||
*/
|
||||
class ReconcileControllerTest extends TestCase
|
||||
{
|
||||
|
@ -25,6 +25,7 @@ namespace Tests\Feature\Controllers\Account;
|
||||
|
||||
use Amount;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
@ -40,6 +41,9 @@ use Tests\TestCase;
|
||||
/**
|
||||
*
|
||||
* Class ShowControllerTest
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class ShowControllerTest extends TestCase
|
||||
{
|
||||
@ -58,24 +62,22 @@ class ShowControllerTest extends TestCase
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testShow(string $range): void
|
||||
{
|
||||
//Log::info(sprintf('testShow(%s)', $range));
|
||||
$date = new Carbon;
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
|
||||
// mock stuff:
|
||||
//$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$this->mock(CurrencyRepositoryInterface::class);
|
||||
//$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journal = $this->getRandomWithdrawalAsArray();
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
$asset = $this->getRandomAsset();
|
||||
$euro = $this->getEuro();
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journal = $this->getRandomWithdrawalAsArray();
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
$asset = $this->getRandomAsset();
|
||||
$euro = $this->getEuro();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
@ -115,16 +117,17 @@ class ShowControllerTest extends TestCase
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testShowAll(string $range): void
|
||||
{
|
||||
$date = new Carbon;
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
// mock stuff:
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$this->mock(AccountTaskerInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(CurrencyRepositoryInterface::class);
|
||||
$this->mock(AccountRepositoryInterface::class);
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journal = $this->getRandomWithdrawalAsArray();
|
||||
|
@ -22,11 +22,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Admin;
|
||||
|
||||
use Amount;
|
||||
use FireflyConfig;
|
||||
use FireflyIII\Models\Configuration;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Log;
|
||||
use Mockery;
|
||||
@ -52,14 +49,13 @@ class ConfigurationControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndex(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
|
||||
// for session
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
//Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
$this->be($this->user());
|
||||
@ -70,7 +66,7 @@ class ConfigurationControllerTest extends TestCase
|
||||
$trueConfig->data = true;
|
||||
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['single_user_mode', true])->once()->andReturn($trueConfig);
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->times(2)->andReturn($falseConfig);
|
||||
//FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->times(2)->andReturn($falseConfig);
|
||||
|
||||
$response = $this->get(route('admin.configuration.index'));
|
||||
$response->assertStatus(200);
|
||||
@ -85,14 +81,13 @@ class ConfigurationControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostIndex(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
|
||||
// for session
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
//Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
$this->mockDefaultPreferences();
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
@ -101,7 +96,7 @@ class ConfigurationControllerTest extends TestCase
|
||||
$falseConfig = new Configuration;
|
||||
$falseConfig->data = false;
|
||||
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
|
||||
//FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
|
||||
FireflyConfig::shouldReceive('set')->withArgs(['single_user_mode', false])->once();
|
||||
FireflyConfig::shouldReceive('set')->withArgs(['is_demo_site', false])->once();
|
||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||
|
@ -22,11 +22,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Admin;
|
||||
|
||||
use Amount;
|
||||
use Event;
|
||||
use FireflyIII\Events\AdminRequestedTestMessage;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Log;
|
||||
use Mockery;
|
||||
@ -51,15 +48,12 @@ class HomeControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndex(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
|
||||
// default for session
|
||||
$this->mockDefaultPreferences();
|
||||
$this->mockDefaultConfiguration();
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
@ -75,12 +69,8 @@ class HomeControllerTest extends TestCase
|
||||
*/
|
||||
public function testTestMessage(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
Amount::shouldReceive('getDefaultCurrency')->atLeast()->once()->andReturn($euro);
|
||||
$this->mockDefaultPreferences();
|
||||
$this->mockDefaultConfiguration();
|
||||
|
||||
|
@ -33,6 +33,10 @@ use Preferences;
|
||||
|
||||
/**
|
||||
* Class LinkControllerTest
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
||||
*/
|
||||
class LinkControllerTest extends TestCase
|
||||
{
|
||||
@ -51,7 +55,7 @@ class LinkControllerTest extends TestCase
|
||||
public function testCreate(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$this->mock(LinkTypeRepositoryInterface::class);
|
||||
|
||||
// mock default session stuff
|
||||
$this->mockDefaultSession();
|
||||
@ -97,7 +101,7 @@ class LinkControllerTest extends TestCase
|
||||
public function testDeleteNonEditable(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$this->mock(LinkTypeRepositoryInterface::class);
|
||||
$linkType = LinkType::where('editable', 0)->first();
|
||||
|
||||
// mock default session stuff
|
||||
@ -145,7 +149,7 @@ class LinkControllerTest extends TestCase
|
||||
public function testEditEditable(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$this->mock(LinkTypeRepositoryInterface::class);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
|
||||
@ -168,7 +172,7 @@ class LinkControllerTest extends TestCase
|
||||
public function testEditNonEditable(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$this->mock(LinkTypeRepositoryInterface::class);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
|
||||
@ -190,7 +194,7 @@ class LinkControllerTest extends TestCase
|
||||
public function testIndex(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$this->mock(LinkTypeRepositoryInterface::class);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
@ -324,7 +328,7 @@ class LinkControllerTest extends TestCase
|
||||
public function testUpdateNonEditable(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$this->mock(LinkTypeRepositoryInterface::class);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->andReturn(false)->atLeast()->once();
|
||||
|
@ -123,11 +123,10 @@ class AttachmentControllerTest extends TestCase
|
||||
|
||||
// mock stuff
|
||||
$attachment = $this->getRandomAttachment();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||
|
||||
$repository->shouldReceive('exists')->once()->andReturn(false);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('attachments.download', [$attachment->id]));
|
||||
|
@ -47,8 +47,11 @@ class TwoFactorControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndex(): void
|
||||
{
|
||||
$this->mockDefaultConfiguration();
|
||||
$this->be($this->user());
|
||||
|
||||
|
||||
|
||||
$truePref = new Preference;
|
||||
$truePref->data = true;
|
||||
$secretPreference = new Preference;
|
||||
|
@ -164,7 +164,6 @@ class BillControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$this->mock(AttachmentHelperInterface::class);
|
||||
$bill = $this->getRandomBill();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$transformer = $this->mock(BillTransformer::class);
|
||||
@ -180,7 +179,7 @@ class BillControllerTest extends TestCase
|
||||
);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$collection = new Collection([$bill]);
|
||||
$repository->shouldReceive('getPaginator')->andReturn(new LengthAwarePaginator($collection, 1, 50))->once();
|
||||
$repository->shouldReceive('setUser');
|
||||
@ -204,11 +203,10 @@ class BillControllerTest extends TestCase
|
||||
|
||||
// mock stuff
|
||||
$rule = $this->getRandomRule();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$this->mock(AttachmentHelperInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('getRulesForBill')->andReturn(new Collection([$rule]));
|
||||
|
||||
//calls for transaction matcher:
|
||||
|
@ -257,6 +257,12 @@ class IndexControllerTest extends TestCase
|
||||
*/
|
||||
public function testReorder(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$pref = new Preference;
|
||||
$pref->data = 50;
|
||||
Preferences::shouldReceive('get')->withArgs(['listPageSize', 50])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$data = [
|
||||
'budgetIds' => [1, 2],
|
||||
|
@ -56,7 +56,7 @@ class IndexControllerTest extends TestCase
|
||||
{
|
||||
Log::debug('Test index()');
|
||||
// mock stuff
|
||||
$category = factory(Category::class)->make();
|
||||
$category = $this->getRandomCategory();
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
|
@ -70,7 +70,6 @@ class NoCategoryControllerTest extends TestCase
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
@ -28,13 +28,13 @@ use FireflyIII\Helpers\Chart\MetaPieChartInterface;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Tests\TestCase;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
|
||||
/**
|
||||
* Class TagReportControllerTest
|
||||
@ -233,6 +233,7 @@ class TagReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testTagExpense(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
@ -265,6 +266,7 @@ class TagReportControllerTest extends TestCase
|
||||
*/
|
||||
public function testTagIncome(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$generator = $this->mock(GeneratorInterface::class);
|
||||
$pieChart = $this->mock(MetaPieChartInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
|
@ -171,10 +171,9 @@ class CurrencyControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('currencyInUse')->andReturn(false);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->times(2)->andReturn(true);
|
||||
|
||||
@ -195,12 +194,11 @@ class CurrencyControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
|
||||
$repository->shouldReceive('currencyInUse')->andReturn(false);
|
||||
$repository->shouldReceive('destroy')->andReturn(true)->once();
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->times(1)->andReturn(true);
|
||||
|
||||
$this->session(['currencies.delete.uri' => 'http://localhost']);
|
||||
@ -353,12 +351,11 @@ class CurrencyControllerTest extends TestCase
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$currencies = TransactionCurrency::get();
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('getCurrencyByPreference')->andReturn($currencies->first());
|
||||
$repository->shouldReceive('getAll')->andReturn($currencies);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->times(2)->andReturn(true);
|
||||
@ -389,10 +386,9 @@ class CurrencyControllerTest extends TestCase
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('getCurrencyByPreference')->andReturn(new TransactionCurrency);
|
||||
$repository->shouldReceive('getAll')->andReturn(new Collection);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->times(2)->andReturn(false);
|
||||
@ -424,9 +420,8 @@ class CurrencyControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('store')->andReturn(new TransactionCurrency);
|
||||
$userRepos->shouldReceive('hasRole')->once()->andReturn(true);
|
||||
|
||||
@ -454,9 +449,8 @@ class CurrencyControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('store')->andReturnNull();
|
||||
$userRepos->shouldReceive('hasRole')->once()->andReturn(true);
|
||||
|
||||
@ -484,9 +478,8 @@ class CurrencyControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('store')->andReturn(new TransactionCurrency);
|
||||
$userRepos->shouldReceive('hasRole')->once()->andReturn(true);
|
||||
|
||||
@ -514,9 +507,8 @@ class CurrencyControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('update')->andReturn(new TransactionCurrency);
|
||||
$userRepos->shouldReceive('hasRole')->once()->andReturn(true);
|
||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||
|
@ -54,6 +54,7 @@ class PrerequisitesControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndex(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$prereq = $this->mock(FakePrerequisites::class);
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
@ -88,6 +89,7 @@ class PrerequisitesControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndexBadState(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
@ -115,6 +117,7 @@ class PrerequisitesControllerTest extends TestCase
|
||||
*/
|
||||
public function testIndexComplete(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$prereq = $this->mock(FakePrerequisites::class);
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
@ -147,6 +150,7 @@ class PrerequisitesControllerTest extends TestCase
|
||||
*/
|
||||
public function testPost(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$prereq = $this->mock(FakePrerequisites::class);
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
@ -179,6 +183,7 @@ class PrerequisitesControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostBadState(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$prereq = $this->mock(FakePrerequisites::class);
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
@ -210,6 +215,7 @@ class PrerequisitesControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostNoJob(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$prereq = $this->mock(FakePrerequisites::class);
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
@ -235,6 +241,7 @@ class PrerequisitesControllerTest extends TestCase
|
||||
*/
|
||||
public function testPostWithMessages(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$prereq = $this->mock(FakePrerequisites::class);
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
@ -185,6 +185,7 @@ class BoxControllerTest extends TestCase
|
||||
*/
|
||||
public function testNetWorth(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$result = [
|
||||
[
|
||||
'currency' => TransactionCurrency::find(1),
|
||||
@ -217,6 +218,7 @@ class BoxControllerTest extends TestCase
|
||||
*/
|
||||
public function testNetWorthFuture(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$result = [
|
||||
[
|
||||
'currency' => TransactionCurrency::find(1),
|
||||
@ -252,6 +254,7 @@ class BoxControllerTest extends TestCase
|
||||
*/
|
||||
public function testNetWorthNoCurrency(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$result = [
|
||||
[
|
||||
'currency' => TransactionCurrency::find(1),
|
||||
@ -282,6 +285,7 @@ class BoxControllerTest extends TestCase
|
||||
*/
|
||||
public function testNetWorthNoInclude(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$result = [
|
||||
[
|
||||
'currency' => TransactionCurrency::find(1),
|
||||
@ -313,6 +317,7 @@ class BoxControllerTest extends TestCase
|
||||
*/
|
||||
public function testNetWorthVirtual(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$result = [
|
||||
[
|
||||
'currency' => TransactionCurrency::find(1),
|
||||
|
@ -61,7 +61,7 @@ class ExchangeControllerTest extends TestCase
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$rate = factory(CurrencyExchangeRate::class)->make();
|
||||
$rate = $this->getRandomCer();
|
||||
$repository->shouldReceive('getExchangeRate')->andReturn($rate);
|
||||
|
||||
$this->be($this->user());
|
||||
@ -74,8 +74,10 @@ class ExchangeControllerTest extends TestCase
|
||||
*/
|
||||
public function testGetRateAmount(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$rate = factory(CurrencyExchangeRate::class)->make();
|
||||
$rate = $this->getRandomCer();
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
@ -92,12 +94,14 @@ class ExchangeControllerTest extends TestCase
|
||||
*/
|
||||
public function testGetRateNull(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
$rate = factory(CurrencyExchangeRate::class)->make();
|
||||
$rate = $this->getRandomCer();
|
||||
$repository->shouldReceive('getExchangeRate')->andReturnNull();
|
||||
$interface = $this->mock(ExchangeRateInterface::class);
|
||||
$interface->shouldReceive('setUser')->once();
|
||||
|
@ -50,9 +50,8 @@ class RuleControllerTest extends TestCase
|
||||
*/
|
||||
public function testAction(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.action'));
|
||||
@ -64,9 +63,8 @@ class RuleControllerTest extends TestCase
|
||||
*/
|
||||
public function testTrigger(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.trigger'));
|
||||
|
@ -62,11 +62,10 @@ class PreferencesControllerTest extends TestCase
|
||||
$this->mockIntroPreference('shown_demo_preferences_index');
|
||||
// mock stuff
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection)->once();
|
||||
|
||||
// mock get preferences:
|
||||
@ -105,9 +104,8 @@ class PreferencesControllerTest extends TestCase
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->andReturn(false);
|
||||
|
||||
$data = [
|
||||
|
@ -207,8 +207,6 @@ class ProfileControllerTest extends TestCase
|
||||
$this->mockDefaultConfiguration();
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$euro = $this->getEuro();
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->times(1)->andReturn(false);
|
||||
|
||||
|
@ -51,6 +51,7 @@ class AccountControllerTest extends TestCase
|
||||
*/
|
||||
public function testGeneral(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$return = [
|
||||
'accounts' => [],
|
||||
'start' => '0',
|
||||
|
@ -53,6 +53,7 @@ class BalanceControllerTest extends TestCase
|
||||
*/
|
||||
public function testGeneral(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$balance = $this->mock(BalanceReportHelperInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
|
@ -54,6 +54,7 @@ class BudgetControllerTest extends TestCase
|
||||
*/
|
||||
public function testGeneral(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$return = [];
|
||||
$helper = $this->mock(BudgetReportHelperInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
@ -72,6 +73,7 @@ class BudgetControllerTest extends TestCase
|
||||
*/
|
||||
public function testPeriod(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$first = [1 => ['entries' => ['1', '1']]];
|
||||
$second = ['entries' => ['1', '1']];
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
@ -54,6 +54,7 @@ class CategoryControllerTest extends TestCase
|
||||
*/
|
||||
public function testExpenses(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$first = [1 => ['entries' => ['1', '1']]];
|
||||
$second = ['entries' => ['1', '1']];
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
@ -75,6 +76,7 @@ class CategoryControllerTest extends TestCase
|
||||
*/
|
||||
public function testIncome(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$first = [1 => ['entries' => ['1', '1']]];
|
||||
$second = ['entries' => ['1', '1']];
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
@ -96,8 +98,9 @@ class CategoryControllerTest extends TestCase
|
||||
*/
|
||||
public function testOperations(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$category = factory(Category::class)->make();
|
||||
$category = $this->getRandomCategory();
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||
|
@ -56,6 +56,7 @@ class ExpenseControllerTest extends TestCase
|
||||
*/
|
||||
public function testBudget(): void
|
||||
{
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
|
@ -52,6 +52,7 @@ class OperationsControllerTest extends TestCase
|
||||
*/
|
||||
public function testExpenses(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$return = [
|
||||
1 => [
|
||||
'id' => 1,
|
||||
@ -78,6 +79,7 @@ class OperationsControllerTest extends TestCase
|
||||
*/
|
||||
public function testIncome(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$date = new Carbon;
|
||||
@ -95,6 +97,7 @@ class OperationsControllerTest extends TestCase
|
||||
*/
|
||||
public function testOperations(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$return = [
|
||||
1 => [
|
||||
'id' => 1,
|
||||
|
@ -186,22 +186,20 @@ class SelectControllerTest extends TestCase
|
||||
'stop_processing' => 1,
|
||||
],
|
||||
];
|
||||
$set = factory(Transaction::class, 10)->make();
|
||||
|
||||
// mock stuff
|
||||
$matcher = $this->mock(TransactionMatcher::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
||||
$matcher->shouldReceive('setStrict')->once()->withArgs([false]);
|
||||
|
||||
$matcher->shouldReceive('setTriggeredLimit')->withArgs([10])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setSearchLimit')->withArgs([200])->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('setTriggers')->andReturnSelf()->once();
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn($set);
|
||||
$matcher->shouldReceive('findTransactionsByTriggers')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$uri = route('rules.test-triggers') . '?' . http_build_query($data);
|
||||
|
@ -179,7 +179,6 @@ class ConvertControllerTest extends TestCase
|
||||
public function testPostIndexDepositTransfer(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$this->mock(UserRepositoryInterface::class);
|
||||
$this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(RuleGroupRepositoryInterface::class);
|
||||
@ -194,7 +193,6 @@ class ConvertControllerTest extends TestCase
|
||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
|
||||
|
||||
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal)->atLeast()->once();
|
||||
|
||||
|
||||
$data = ['source_account_id' => 1];
|
||||
@ -210,7 +208,6 @@ class ConvertControllerTest extends TestCase
|
||||
public function testPostIndexBadSource(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$this->mock(UserRepositoryInterface::class);
|
||||
$this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(RuleGroupRepositoryInterface::class);
|
||||
@ -224,7 +221,6 @@ class ConvertControllerTest extends TestCase
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['Transfer']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->andReturn(false);
|
||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(true);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal)->atLeast()->once();
|
||||
|
||||
|
||||
$data = ['source_account_id' => 1];
|
||||
@ -241,7 +237,6 @@ class ConvertControllerTest extends TestCase
|
||||
public function testPostIndexBadDestination(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$this->mock(UserRepositoryInterface::class);
|
||||
$this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(RuleGroupRepositoryInterface::class);
|
||||
@ -255,7 +250,6 @@ class ConvertControllerTest extends TestCase
|
||||
$validator->shouldReceive('setTransactionType')->atLeast()->once()->withArgs(['Transfer']);
|
||||
$validator->shouldReceive('validateSource')->atLeast()->once()->andReturn(true);
|
||||
$validator->shouldReceive('validateDestination')->atLeast()->once()->andReturn(false);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal)->atLeast()->once();
|
||||
|
||||
|
||||
$data = ['source_account_id' => 1];
|
||||
|
@ -222,7 +222,7 @@ class LinkControllerTest extends TestCase
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('switchLink')->andReturn(false);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.link.switch', [$link->id]));
|
||||
|
@ -1,188 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* TransactionControllerTest.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 Tests\Feature\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\Transformers\TransactionTransformer;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class TransactionControllerTest
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class TransactionControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::info(sprintf('Now in %s.', get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController
|
||||
*/
|
||||
public function testReconcile(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$data = ['transactions' => [1, 2]];
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
|
||||
$repository->shouldReceive('firstNull')->times(1)->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('findTransaction')->andReturn(new Transaction)->twice();
|
||||
$repository->shouldReceive('reconcile')->twice();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.reconcile'), $data);
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController
|
||||
*/
|
||||
public function testReorder(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock stuff
|
||||
$journal = factory(TransactionJournal::class)->make();
|
||||
$journal->date = new Carbon('2016-01-01');
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$repository->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('findNull')->once()->andReturn($journal);
|
||||
$repository->shouldReceive('setOrder')->once()->andReturn(true);
|
||||
|
||||
$data = [
|
||||
'date' => '2016-01-01',
|
||||
'items' => [1],
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.reorder'), $data);
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController
|
||||
* @covers \FireflyIII\Http\Controllers\Controller
|
||||
*/
|
||||
public function testShow(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
// mock stuff
|
||||
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$transformer = $this->mock(TransactionTransformer::class);
|
||||
$attachment = new Attachment;
|
||||
$transaction = new Transaction;
|
||||
|
||||
$transformer->shouldReceive('setParameters')->atLeast()->once();
|
||||
$transformer->shouldReceive('transform')->atLeast()->once()->andReturn(
|
||||
[
|
||||
'id' => 5,
|
||||
]
|
||||
);
|
||||
|
||||
$collector->shouldReceive('setUser')->atLeast()->once()->andReturnSelf();
|
||||
$collector->shouldReceive('withOpposingAccount')->atLeast()->once()->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->atLeast()->once()->andReturnSelf();
|
||||
$collector->shouldReceive('withBudgetInformation')->atLeast()->once()->andReturnSelf();
|
||||
$collector->shouldReceive('setJournals')->atLeast()->once()->andReturnSelf();
|
||||
$collector->shouldReceive('getTransactions')->atLeast()->once()->andReturn(new Collection([$transaction, $transaction]));
|
||||
|
||||
$linkRepos->shouldReceive('get')->andReturn(new Collection);
|
||||
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->atLeast()->once()->andReturn(true);
|
||||
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal)->atLeast()->once();
|
||||
$journalRepos->shouldReceive('getAttachments')->andReturn(new Collection([$attachment]))->atLeast()->once();
|
||||
$journalRepos->shouldReceive('getPiggyBankEvents')->andReturn(new Collection)->atLeast()->once();
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection)->atLeast()->once();
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection)->atLeast()->once();
|
||||
$journalRepos->shouldReceive('getMetaField')->andReturn('')->atLeast()->once();
|
||||
|
||||
$attRepos->shouldReceive('exists')->atLeast()->once()->andReturn(false);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.show', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Controller
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController
|
||||
*/
|
||||
public function testShowOpeningBalance(): void
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$linkRepos = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$attRepos = $this->mock(AttachmentRepositoryInterface::class);
|
||||
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
|
||||
|
||||
$linkRepos->shouldReceive('get')->andReturn(new Collection);
|
||||
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 4)->first();
|
||||
$response = $this->get(route('transactions.show', [$journal->id]));
|
||||
$response->assertStatus(302);
|
||||
}
|
||||
}
|
@ -38,6 +38,7 @@ use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Configuration;
|
||||
use FireflyIII\Models\CurrencyExchangeRate;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\Rule;
|
||||
@ -63,6 +64,14 @@ use RuntimeException;
|
||||
*/
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* @return CurrencyExchangeRate
|
||||
*/
|
||||
public function getRandomCer(): CurrencyExchangeRate
|
||||
{
|
||||
return $this->user()->currencyExchangeRates()->inRandomOrder()->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PiggyBank
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user