mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Improve test coverage.
This commit is contained in:
@@ -23,6 +23,7 @@ namespace Tests\Unit\Console\Commands\Tools;
|
||||
|
||||
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
||||
@@ -31,6 +32,8 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\TransactionRules\Engine\RuleEngine;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Preferences;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -100,6 +103,11 @@ class ApplyRulesTest extends TestCase
|
||||
'--all_rules',
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('Will apply 1 rule(s) to 3 transaction(s).')
|
||||
->expectsOutput('Done!')
|
||||
@@ -159,6 +167,11 @@ class ApplyRulesTest extends TestCase
|
||||
'--all_rules',
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('No rules or rule groups have been included.')
|
||||
->expectsOutput('Done!')
|
||||
@@ -218,6 +231,11 @@ class ApplyRulesTest extends TestCase
|
||||
'--end_date=2019-01-01',
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('Will apply 1 rule(s) to 3 transaction(s).')
|
||||
->expectsOutput('Done!')
|
||||
@@ -281,6 +299,11 @@ class ApplyRulesTest extends TestCase
|
||||
sprintf('--rules=%d,%d', $activeRule->id, $inactiveRule->id),
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('Will apply 1 rule(s) to 3 transaction(s).')
|
||||
->expectsOutput('Done!')
|
||||
@@ -343,6 +366,11 @@ class ApplyRulesTest extends TestCase
|
||||
sprintf('--rule_groups=%d,%d', $activeGroup->id, $inactiveGroup->id),
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput(sprintf('Will ignore inactive rule group #%d ("%s")', $inactiveGroup->id, $inactiveGroup->title))
|
||||
// one rule out of 2 groups:
|
||||
@@ -379,6 +407,11 @@ class ApplyRulesTest extends TestCase
|
||||
'--all_rules',
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('Please use the --accounts option to indicate the accounts to apply rules to.')
|
||||
->assertExitCode(1);
|
||||
@@ -417,6 +450,11 @@ class ApplyRulesTest extends TestCase
|
||||
'--all_rules',
|
||||
];
|
||||
|
||||
// mock Preferences Facade:
|
||||
$pref = new Preference;
|
||||
$pref->data = 'token';
|
||||
Preferences::shouldReceive('getForUser')->withArgs([Mockery::any(), 'access_token',null])->atLeast()->once()->andReturn($pref);
|
||||
|
||||
$this->artisan('firefly-iii:apply-rules ' . implode(' ', $parameters))
|
||||
->expectsOutput('Please make sure all accounts in --accounts are asset accounts or liabilities.')
|
||||
->assertExitCode(1);
|
||||
|
@@ -22,6 +22,7 @@
|
||||
namespace Tests\Unit\Console\Commands\Upgrade;
|
||||
|
||||
|
||||
use Amount;
|
||||
use FireflyConfig;
|
||||
use FireflyIII\Models\BudgetLimit;
|
||||
use FireflyIII\Models\Configuration;
|
||||
@@ -49,6 +50,11 @@ class BudgetLimitCurrencyTest extends TestCase
|
||||
{
|
||||
BudgetLimit::whereNull('transaction_currency_id')->forceDelete();
|
||||
|
||||
$false = new Configuration;
|
||||
$false->data = false;
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['4780_bl_currency', false])->andReturn($false);
|
||||
FireflyConfig::shouldReceive('set')->withArgs(['4780_bl_currency', true]);
|
||||
|
||||
$this->artisan('firefly-iii:bl-currency')
|
||||
->expectsOutput('All budget limits are correct.')
|
||||
->assertExitCode(0);
|
||||
@@ -74,6 +80,9 @@ class BudgetLimitCurrencyTest extends TestCase
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['4780_bl_currency', false])->andReturn($false);
|
||||
FireflyConfig::shouldReceive('set')->withArgs(['4780_bl_currency', true]);
|
||||
|
||||
$currency = $this->getEuro();
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn($currency);
|
||||
|
||||
$this->artisan('firefly-iii:bl-currency')
|
||||
->expectsOutput(
|
||||
sprintf('Budget limit #%d (part of budget "%s") now has a currency setting (%s).',
|
||||
|
@@ -49,6 +49,12 @@ class RenameAccountMetaTest extends TestCase
|
||||
*/
|
||||
public function testHandle(): void
|
||||
{
|
||||
$false = new Configuration;
|
||||
$false->data = false;
|
||||
// check config
|
||||
FireflyConfig::shouldReceive('get')->withArgs(['4780_rename_account_meta', false])->andReturn($false);
|
||||
FireflyConfig::shouldReceive('set')->withArgs(['4780_rename_account_meta', true]);
|
||||
|
||||
// assume all is well.
|
||||
$this->artisan('firefly-iii:rename-account-meta')
|
||||
->expectsOutput('All account meta is OK.')
|
||||
|
@@ -24,10 +24,12 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\Factory;
|
||||
|
||||
|
||||
use Amount;
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\AccountFactory;
|
||||
use FireflyIII\Factory\AccountMetaFactory;
|
||||
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||
use FireflyIII\Factory\TransactionGroupFactory;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountMeta;
|
||||
@@ -60,9 +62,11 @@ class AccountFactoryTest extends TestCase
|
||||
*/
|
||||
public function testCreate(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
$this->mock(TransactionGroupFactory::class);
|
||||
$euro = $this->getEuro();
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
'account_type' => 'asset',
|
||||
@@ -80,6 +84,8 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', '1'])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'BIC', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
$currencyFactory->shouldReceive('find')->withArgs([0, ''])->atLeast()->once()->andReturnNull();
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->atLeast()->once()->andReturn($euro);
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
@@ -87,6 +93,8 @@ class AccountFactoryTest extends TestCase
|
||||
try {
|
||||
$account = $factory->create($data);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
|
||||
return;
|
||||
@@ -110,9 +118,12 @@ class AccountFactoryTest extends TestCase
|
||||
*/
|
||||
public function testCreateCC(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
$this->mock(TransactionGroupFactory::class);
|
||||
|
||||
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
'account_type' => 'asset',
|
||||
@@ -133,6 +144,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'cc_monthly_payment_date', '2018-01-01'])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'cc_type', ''])->atLeast()->once()->andReturnNull();
|
||||
$currencyFactory->shouldReceive('find')->withArgs([0, ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
@@ -140,6 +152,8 @@ class AccountFactoryTest extends TestCase
|
||||
try {
|
||||
$account = $factory->create($data);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
|
||||
return;
|
||||
@@ -163,8 +177,10 @@ class AccountFactoryTest extends TestCase
|
||||
*/
|
||||
public function testCreateEmptyVb(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
$this->mock(TransactionGroupFactory::class);
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
@@ -183,6 +199,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', '1'])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'BIC', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
$currencyFactory->shouldReceive('find')->withArgs([0, ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
@@ -190,6 +207,8 @@ class AccountFactoryTest extends TestCase
|
||||
try {
|
||||
$account = $factory->create($data);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
|
||||
return;
|
||||
@@ -216,6 +235,8 @@ class AccountFactoryTest extends TestCase
|
||||
{
|
||||
$this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(TransactionGroupFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
@@ -233,6 +254,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'interest', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'interest_period', ''])->atLeast()->once()->andReturnNull();
|
||||
$currencyFactory->shouldReceive('find')->withArgs([0, ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
@@ -240,6 +262,8 @@ class AccountFactoryTest extends TestCase
|
||||
try {
|
||||
$account = $factory->create($data);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
|
||||
return;
|
||||
@@ -270,8 +294,9 @@ class AccountFactoryTest extends TestCase
|
||||
{
|
||||
$this->mock(AccountRepositoryInterface::class);
|
||||
$this->mock(TransactionGroupFactory::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$data = [
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
'account_type' => 'Expense account',
|
||||
'iban' => null,
|
||||
@@ -291,10 +316,13 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'interest', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'interest_period', ''])->atLeast()->once()->andReturnNull();
|
||||
$currencyFactory->shouldReceive('find')->withArgs([0, ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
try {
|
||||
$account = $factory->create($data);
|
||||
} catch (FireflyException $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
|
||||
return;
|
||||
@@ -322,10 +350,12 @@ class AccountFactoryTest extends TestCase
|
||||
*/
|
||||
public function testCreateOB(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$groupFactory = $this->mock(TransactionGroupFactory::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$data = [
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$groupFactory = $this->mock(TransactionGroupFactory::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
$euro = $this->getEuro();
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
'account_type' => 'asset',
|
||||
'iban' => null,
|
||||
@@ -348,6 +378,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', '1'])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'BIC', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
$currencyFactory->shouldReceive('find')->withArgs([1, ''])->atLeast()->once()->andReturn($euro);
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
@@ -378,10 +409,12 @@ class AccountFactoryTest extends TestCase
|
||||
public function testCreateOBZero(): void
|
||||
{
|
||||
// mock repositories:
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$groupFactory = $this->mock(TransactionGroupFactory::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$data = [
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$groupFactory = $this->mock(TransactionGroupFactory::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
$euro = $this->getEuro();
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
'account_type' => 'asset',
|
||||
'iban' => null,
|
||||
@@ -404,6 +437,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', '1'])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'BIC', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
$currencyFactory->shouldReceive('find')->withArgs([1, ''])->atLeast()->once()->andReturn($euro);
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
@@ -438,6 +472,7 @@ class AccountFactoryTest extends TestCase
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
$this->mock(TransactionGroupFactory::class);
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
@@ -457,6 +492,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', '1'])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'BIC', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
$currencyFactory->shouldReceive('find')->withArgs([0, ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
@@ -490,6 +526,7 @@ class AccountFactoryTest extends TestCase
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
$this->mock(TransactionGroupFactory::class);
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
@@ -509,7 +546,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', '1'])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'BIC', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
$currencyFactory->shouldReceive('find')->withArgs([0, ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
@@ -543,6 +580,8 @@ class AccountFactoryTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$groupFactory = $this->mock(TransactionGroupFactory::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
$euro = $this->getEuro();
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
'account_type' => 'asset',
|
||||
@@ -566,6 +605,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', '1'])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'BIC', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
$currencyFactory->shouldReceive('find')->withArgs([1, ''])->atLeast()->once()->andReturn($euro);
|
||||
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
@@ -600,6 +640,7 @@ class AccountFactoryTest extends TestCase
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
$this->mock(TransactionGroupFactory::class);
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
@@ -624,7 +665,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', '1'])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'BIC', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
$currencyFactory->shouldReceive('find')->withArgs([0, ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
try {
|
||||
$account = $factory->create($data);
|
||||
@@ -656,6 +697,8 @@ class AccountFactoryTest extends TestCase
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$this->mock(TransactionGroupFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
$currency = $this->getDollar();
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
@@ -676,7 +719,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', $currency->id])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'BIC', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
$currencyFactory->shouldReceive('find')->withArgs([0, 'USD'])->atLeast()->once()->andReturn($currency);
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
@@ -710,6 +753,7 @@ class AccountFactoryTest extends TestCase
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
$this->mock(TransactionGroupFactory::class);
|
||||
$currency = $this->getDollar();
|
||||
$data = [
|
||||
@@ -731,7 +775,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', $currency->id])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'BIC', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
$currencyFactory->shouldReceive('find')->withArgs([7, ''])->atLeast()->once()->andReturn($currency);
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
@@ -858,6 +902,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory = $this->mock(AccountMetaFactory::class);
|
||||
/** @var Account $account */
|
||||
$account = $this->getRandomRevenue();
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'account_number', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'currency_id', '1'])->atLeast()->once()->andReturnNull();
|
||||
@@ -865,6 +910,7 @@ class AccountFactoryTest extends TestCase
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'include_net_worth', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'interest', ''])->atLeast()->once()->andReturnNull();
|
||||
$metaFactory->shouldReceive('crud')->withArgs([Mockery::any(), 'interest_period', ''])->atLeast()->once()->andReturnNull();
|
||||
$currencyFactory->shouldReceive('find')->withArgs([0, ''])->atLeast()->once()->andReturnNull();
|
||||
|
||||
$name = sprintf('New %s', $account->name);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -68,6 +68,8 @@ class ClearNotesTest extends TestCase
|
||||
try {
|
||||
$result = $action->act($journal);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
$this->assertTrue($result);
|
||||
|
@@ -75,6 +75,8 @@ class ConvertToDepositTest extends TestCase
|
||||
try {
|
||||
$result = $action->act($journal);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
$this->assertTrue($result);
|
||||
@@ -111,6 +113,8 @@ class ConvertToDepositTest extends TestCase
|
||||
try {
|
||||
$result = $action->act($journal);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
$this->assertTrue($result);
|
||||
|
@@ -64,7 +64,10 @@ class ConvertToTransferTest extends TestCase
|
||||
// mock used stuff:
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('setUser')->once();
|
||||
$accountRepos->shouldReceive('findByName')->withArgs([$asset->name, [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]])->andReturn($asset);
|
||||
$accountRepos->shouldReceive('findByName')->withArgs(
|
||||
[$asset->name,
|
||||
[AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]]
|
||||
)->andReturn($asset);
|
||||
|
||||
// fire the action:
|
||||
$rule = new Rule;
|
||||
@@ -77,6 +80,8 @@ class ConvertToTransferTest extends TestCase
|
||||
try {
|
||||
$result = $action->act($deposit);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
$this->assertTrue($result);
|
||||
@@ -94,8 +99,10 @@ class ConvertToTransferTest extends TestCase
|
||||
public function testActWithdrawal(): void
|
||||
{
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
/** @var Account $asset */
|
||||
$asset = $this->getRandomAsset();
|
||||
|
||||
// make sure that $asset is not the source account of $withdrawal:
|
||||
$forbiddenId = (int)$withdrawal->transactions()->where('amount', '<', 0)->first()->account_id;
|
||||
$asset = $this->getRandomAsset($forbiddenId);
|
||||
|
||||
// mock used stuff:
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
@@ -113,6 +120,8 @@ class ConvertToTransferTest extends TestCase
|
||||
try {
|
||||
$result = $action->act($withdrawal);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
$this->assertTrue($result);
|
||||
|
@@ -75,6 +75,8 @@ class ConvertToWithdrawalTest extends TestCase
|
||||
try {
|
||||
$result = $action->act($deposit);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
$this->assertTrue($result);
|
||||
@@ -108,6 +110,8 @@ class ConvertToWithdrawalTest extends TestCase
|
||||
try {
|
||||
$result = $action->act($transfer);
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
$this->assertTrue(false, $e->getMessage());
|
||||
}
|
||||
$this->assertTrue($result);
|
||||
|
@@ -25,8 +25,6 @@ namespace Tests\Unit\Transformers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Factory\CategoryFactory;
|
||||
use FireflyIII\Models\RecurrenceTransaction;
|
||||
use FireflyIII\Models\RecurrenceTransactionMeta;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||
@@ -81,9 +79,9 @@ class RecurrenceTransformerTest extends TestCase
|
||||
$recurrenceRepos->shouldReceive('repetitionDescription')->once()->andReturn('Rep descr');
|
||||
$recurrenceRepos->shouldReceive('getXOccurrences')->andReturn($ranges)->atLeast()->once();
|
||||
$factory->shouldReceive('findOrCreate')->atLeast()->once()->withArgs([null,Mockery::any()])->andReturn($category);
|
||||
$budgetRepos->shouldReceive('findNull')->atLeast()->once()->withArgs([2])->andReturn($budget);
|
||||
$piggyRepos->shouldReceive('findNull')->atLeast()->once()->withArgs([1])->andReturn($piggy);
|
||||
$billRepos->shouldReceive('find')->atLeast()->once()->withArgs([1])->andReturn($bill);
|
||||
$budgetRepos->shouldReceive('findNull')->atLeast()->once()->andReturn($budget);
|
||||
$piggyRepos->shouldReceive('findNull')->atLeast()->once()->andReturn($piggy);
|
||||
$billRepos->shouldReceive('find')->andReturn($bill);
|
||||
|
||||
// basic transformation:
|
||||
|
||||
|
Reference in New Issue
Block a user