mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Optimise test code.
This commit is contained in:
@@ -233,6 +233,9 @@ class AccountController extends Controller
|
||||
* @param Account $account
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function transactions(Request $request, Account $account): JsonResponse
|
||||
{
|
||||
@@ -249,8 +252,6 @@ class AccountController extends Controller
|
||||
$types = $this->mapTransactionTypes($this->parameters->get('type'));
|
||||
$manager = new Manager();
|
||||
$baseUrl = $request->getSchemeAndHttpHost() . '/api/v1';
|
||||
|
||||
|
||||
$manager->setSerializer(new JsonApiSerializer($baseUrl));
|
||||
|
||||
/** @var User $admin */
|
||||
@@ -259,18 +260,8 @@ class AccountController extends Controller
|
||||
// use new group collector:
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector
|
||||
->setUser($admin)
|
||||
// set the account to filter on to the current one:
|
||||
->setAccounts(new Collection([$account]))
|
||||
// all info needed for the API:
|
||||
->withAPIInformation()
|
||||
// set page size:
|
||||
->setLimit($pageSize)
|
||||
// set page to retrieve
|
||||
->setPage($this->parameters->get('page'))
|
||||
// set types of transactions to return.
|
||||
->setTypes($types);
|
||||
$collector->setUser($admin)->setAccounts(new Collection([$account]))
|
||||
->withAPIInformation()->setLimit($pageSize)->setPage($this->parameters->get('page'))->setTypes($types);
|
||||
|
||||
// set range if necessary:
|
||||
if (null !== $this->parameters->get('start') && null !== $this->parameters->get('end')) {
|
||||
|
@@ -47,6 +47,8 @@ use League\Fractal\Serializer\JsonApiSerializer;
|
||||
|
||||
/**
|
||||
* Class BillController.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class BillController extends Controller
|
||||
{
|
||||
|
@@ -64,6 +64,8 @@ class CategoryController extends Controller
|
||||
* @param DateRequest $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
* TODO after 4.8.0, simplify
|
||||
*/
|
||||
public function overview(DateRequest $request): JsonResponse
|
||||
{
|
||||
|
@@ -98,6 +98,7 @@ class RuleGroupTriggerRequest extends Request
|
||||
Log::debug(sprintf('Searching for asset account with id "%s"', $accountId));
|
||||
$account = $accountRepository->findNull((int)$accountId);
|
||||
if ($this->validAccount($account)) {
|
||||
/** @noinspection NullPointerExceptionInspection */
|
||||
Log::debug(sprintf('Found account #%d ("%s") and its an asset account', $account->id, $account->name));
|
||||
$accounts->push($account);
|
||||
}
|
||||
|
@@ -204,9 +204,11 @@ class MigrateToRules extends Command
|
||||
],
|
||||
],
|
||||
'actions' => [
|
||||
[
|
||||
'type' => 'link_to_bill',
|
||||
'value' => $bill->name,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// two triggers or one, depends on bill content:
|
||||
|
@@ -28,6 +28,7 @@ use Exception;
|
||||
|
||||
/**
|
||||
* Class FireflyException.
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class FireflyException extends Exception
|
||||
{
|
||||
|
@@ -28,6 +28,7 @@ use Exception;
|
||||
|
||||
/**
|
||||
* Class NotImplementedException.
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class NotImplementedException extends Exception
|
||||
{
|
||||
|
@@ -28,6 +28,7 @@ use Exception;
|
||||
|
||||
/**
|
||||
* Class ValidationExceptions.
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ValidationException extends Exception
|
||||
{
|
||||
|
@@ -61,7 +61,6 @@ class DecryptDatabaseTest extends TestCase
|
||||
]);
|
||||
|
||||
|
||||
|
||||
FireflyConfig::shouldReceive('get')->withArgs([Mockery::any(), false])->atLeast()->once()->andReturn(null);
|
||||
FireflyConfig::shouldReceive('set')->withArgs([Mockery::any(), true])->atLeast()->once();
|
||||
|
||||
|
@@ -27,6 +27,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Engine\RuleEngine;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
@@ -59,6 +60,7 @@ class ApplyRulesTest extends TestCase
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$ruleEngine = $this->mock(RuleEngine::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// data
|
||||
$asset = $this->getRandomAsset();
|
||||
@@ -69,6 +71,7 @@ class ApplyRulesTest extends TestCase
|
||||
$rules = new Collection([$rule]);
|
||||
|
||||
// expected calls:
|
||||
$userRepos->shouldReceive('findNull')->atLeast()->once()->andReturn($this->user());
|
||||
$ruleRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$ruleGroupRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
@@ -109,7 +112,7 @@ class ApplyRulesTest extends TestCase
|
||||
*
|
||||
* @covers \FireflyIII\Console\Commands\Tools\ApplyRules
|
||||
*/
|
||||
public function testHandEmptye(): void
|
||||
public function testHandEmpty(): void
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
@@ -117,6 +120,7 @@ class ApplyRulesTest extends TestCase
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$ruleEngine = $this->mock(RuleEngine::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// data
|
||||
$asset = $this->getRandomAsset();
|
||||
@@ -125,6 +129,7 @@ class ApplyRulesTest extends TestCase
|
||||
$groups = new Collection([$group]);
|
||||
|
||||
// expected calls:
|
||||
$userRepos->shouldReceive('findNull')->atLeast()->once()->andReturn($this->user());
|
||||
$ruleRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$ruleGroupRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
@@ -172,6 +177,7 @@ class ApplyRulesTest extends TestCase
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$ruleEngine = $this->mock(RuleEngine::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// data
|
||||
$asset = $this->getRandomAsset();
|
||||
@@ -181,6 +187,7 @@ class ApplyRulesTest extends TestCase
|
||||
$rules = new Collection([$rule]);
|
||||
|
||||
// expected calls:
|
||||
$userRepos->shouldReceive('findNull')->atLeast()->once()->andReturn($this->user());
|
||||
$ruleRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$ruleGroupRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
@@ -227,6 +234,7 @@ class ApplyRulesTest extends TestCase
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$ruleEngine = $this->mock(RuleEngine::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// data
|
||||
$asset = $this->getRandomAsset();
|
||||
@@ -238,6 +246,7 @@ class ApplyRulesTest extends TestCase
|
||||
$rules = new Collection([$activeRule]);
|
||||
|
||||
// expected calls:
|
||||
$userRepos->shouldReceive('findNull')->atLeast()->once()->andReturn($this->user());
|
||||
$ruleRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$ruleGroupRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
@@ -287,6 +296,7 @@ class ApplyRulesTest extends TestCase
|
||||
$collector = $this->mock(GroupCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$ruleEngine = $this->mock(RuleEngine::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$activeGroup = $this->user()->ruleGroups()->where('active', 1)->inRandomOrder()->first();
|
||||
$inactiveGroup = $this->user()->ruleGroups()->where('active', 0)->inRandomOrder()->first();
|
||||
@@ -299,6 +309,7 @@ class ApplyRulesTest extends TestCase
|
||||
$rules = new Collection([$rule]);
|
||||
|
||||
// expected calls:
|
||||
$userRepos->shouldReceive('findNull')->atLeast()->once()->andReturn($this->user());
|
||||
$ruleRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$ruleGroupRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
@@ -348,8 +359,10 @@ class ApplyRulesTest extends TestCase
|
||||
$this->mock(GroupCollectorInterface::class);
|
||||
$this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(RuleEngine::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// expected calls:
|
||||
$userRepos->shouldReceive('findNull')->atLeast()->once()->andReturn($this->user());
|
||||
$ruleRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$ruleGroupRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
||||
@@ -374,15 +387,17 @@ class ApplyRulesTest extends TestCase
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$this->mock(RuleEngine::class);
|
||||
$this->mock(JournalRepositoryInterface::class);
|
||||
$this->mock(GroupCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(RuleEngine::class);
|
||||
|
||||
// data
|
||||
$expense = $this->getRandomExpense();
|
||||
|
||||
// expected calls:
|
||||
$userRepos->shouldReceive('findNull')->atLeast()->once()->andReturn($this->user());
|
||||
$ruleRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$ruleGroupRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
$accountRepos->shouldReceive('setUser')->atLeast()->once();
|
||||
|
@@ -57,6 +57,8 @@ class MigrateToGroupsTest extends TestCase
|
||||
public function testHandle(): void
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$service = $this->mock(JournalDestroyService::class);
|
||||
$groupFactory = $this->mock(TransactionGroupFactory::class);
|
||||
|
||||
// mock calls:
|
||||
$journalRepos->shouldReceive('getSplitJournals')
|
||||
@@ -85,6 +87,9 @@ class MigrateToGroupsTest extends TestCase
|
||||
public function testHandleNoGroup(): void
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$service = $this->mock(JournalDestroyService::class);
|
||||
$groupFactory = $this->mock(TransactionGroupFactory::class);
|
||||
|
||||
$asset = $this->getRandomAsset();
|
||||
$expense = $this->getRandomExpense();
|
||||
$journal = TransactionJournal::create(
|
||||
|
@@ -75,7 +75,8 @@ class PiggyBankEventFactoryTest extends TestCase
|
||||
* @covers \FireflyIII\Factory\PiggyBankEventFactory
|
||||
*/
|
||||
public function testCreateNoPiggy(): void
|
||||
{ $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
/** @var TransactionJournal $transfer */
|
||||
@@ -93,7 +94,8 @@ class PiggyBankEventFactoryTest extends TestCase
|
||||
* @covers \FireflyIII\Factory\PiggyBankEventFactory
|
||||
*/
|
||||
public function testCreateNoRep(): void
|
||||
{ $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
/** @var TransactionJournal $transfer */
|
||||
@@ -115,7 +117,8 @@ class PiggyBankEventFactoryTest extends TestCase
|
||||
* @covers \FireflyIII\Factory\PiggyBankEventFactory
|
||||
*/
|
||||
public function testCreateNotTransfer(): void
|
||||
{ $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
/** @var TransactionJournal $deposit */
|
||||
@@ -131,7 +134,8 @@ class PiggyBankEventFactoryTest extends TestCase
|
||||
* @covers \FireflyIII\Factory\PiggyBankEventFactory
|
||||
*/
|
||||
public function testCreateSuccess(): void
|
||||
{ $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
/** @var TransactionJournal $transfer */
|
||||
|
@@ -49,7 +49,8 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
||||
* @covers \FireflyIII\Factory\TransactionJournalMetaFactory
|
||||
*/
|
||||
public function testUpdateOrCreateBasic(): void
|
||||
{ $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
/** @var TransactionJournal $journal */
|
||||
@@ -72,7 +73,8 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
||||
* @covers \FireflyIII\Factory\TransactionJournalMetaFactory
|
||||
*/
|
||||
public function testUpdateOrCreateDate(): void
|
||||
{ $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
/** @var TransactionJournal $journal */
|
||||
@@ -95,7 +97,8 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
||||
* @covers \FireflyIII\Factory\TransactionJournalMetaFactory
|
||||
*/
|
||||
public function testUpdateOrCreateDeleteExisting(): void
|
||||
{ $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
/** @var TransactionJournal $journal */
|
||||
@@ -125,7 +128,8 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
||||
* @covers \FireflyIII\Factory\TransactionJournalMetaFactory
|
||||
*/
|
||||
public function testUpdateOrCreateEmpty(): void
|
||||
{ $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
/** @var TransactionJournal $journal */
|
||||
@@ -148,7 +152,8 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
||||
* @covers \FireflyIII\Factory\TransactionJournalMetaFactory
|
||||
*/
|
||||
public function testUpdateOrCreateExistingEmpty(): void
|
||||
{ $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
/** @var TransactionJournal $journal */
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\Import\Storage;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollector;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
@@ -620,7 +621,7 @@ class ImportArrayStorageTest extends TestCase
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
private function singleTransfer(): array
|
||||
{
|
||||
@@ -669,7 +670,7 @@ class ImportArrayStorageTest extends TestCase
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
private function singleWithdrawal(): array
|
||||
{
|
||||
|
@@ -835,7 +835,8 @@ class BinderTest extends TestCase
|
||||
* @covers \FireflyIII\Support\Binder\JournalList
|
||||
*/
|
||||
public function testJournalList(): void
|
||||
{ $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
Route::middleware(Binder::class)->any(
|
||||
@@ -854,7 +855,8 @@ class BinderTest extends TestCase
|
||||
* @covers \FireflyIII\Support\Binder\JournalList
|
||||
*/
|
||||
public function testJournalListEmpty(): void
|
||||
{ $this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
Route::middleware(Binder::class)->any(
|
||||
|
@@ -93,7 +93,8 @@ class ConvertToDepositTest extends TestCase
|
||||
* @covers \FireflyIII\TransactionRules\Actions\ConvertToDeposit
|
||||
*/
|
||||
public function testActWithdrawal()
|
||||
{$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$revenue = $this->getRandomRevenue();
|
||||
|
@@ -55,7 +55,8 @@ class ConvertToTransferTest extends TestCase
|
||||
* @covers \FireflyIII\TransactionRules\Actions\ConvertToTransfer
|
||||
*/
|
||||
public function testActDeposit(): void
|
||||
{$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$deposit = $this->getRandomDeposit();
|
||||
|
@@ -54,7 +54,8 @@ class ConvertToWithdrawalTest extends TestCase
|
||||
* @covers \FireflyIII\TransactionRules\Actions\ConvertToWithdrawal
|
||||
*/
|
||||
public function testActDeposit()
|
||||
{$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
{
|
||||
$this->markTestIncomplete('Needs to be rewritten for v4.8.0');
|
||||
|
||||
return;
|
||||
$expense = $this->getRandomExpense();
|
||||
|
Reference in New Issue
Block a user