mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code cleanup and realign.
This commit is contained in:
@@ -69,46 +69,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test minimal set of data to make factory work (asset account).
|
||||
*
|
||||
* @covers \FireflyIII\Factory\AccountFactory
|
||||
* @covers \FireflyIII\Factory\AccountMetaFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\AccountServiceTrait
|
||||
*/
|
||||
public function testCreateBasicEmptyVb(): void
|
||||
{
|
||||
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
'accountType' => 'asset',
|
||||
'iban' => null,
|
||||
'name' => 'Basic asset account #' . random_int(1, 10000),
|
||||
'virtualBalance' => '',
|
||||
'active' => true,
|
||||
'accountRole' => 'defaultAsset',
|
||||
];
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
$factory->setUser($this->user());
|
||||
$account = $factory->create($data);
|
||||
|
||||
// assert stuff about account:
|
||||
$this->assertEquals($account->name, $data['name']);
|
||||
$this->assertEquals(AccountType::ASSET, $account->accountType->type);
|
||||
$this->assertEquals('', $account->iban);
|
||||
$this->assertTrue($account->active);
|
||||
$this->assertEquals('0', $account->virtual_balance);
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
}
|
||||
@@ -148,17 +109,56 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('ccAsset', $meta->data);
|
||||
|
||||
// get the date:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','ccMonthlyPaymentDate')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'ccMonthlyPaymentDate')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('2018-01-01', $meta->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test minimal set of data to make factory work (asset account).
|
||||
*
|
||||
* @covers \FireflyIII\Factory\AccountFactory
|
||||
* @covers \FireflyIII\Factory\AccountMetaFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\AccountServiceTrait
|
||||
*/
|
||||
public function testCreateBasicEmptyVb(): void
|
||||
{
|
||||
|
||||
$data = [
|
||||
'account_type_id' => null,
|
||||
'accountType' => 'asset',
|
||||
'iban' => null,
|
||||
'name' => 'Basic asset account #' . random_int(1, 10000),
|
||||
'virtualBalance' => '',
|
||||
'active' => true,
|
||||
'accountRole' => 'defaultAsset',
|
||||
];
|
||||
|
||||
/** @var AccountFactory $factory */
|
||||
$factory = app(AccountFactory::class);
|
||||
$factory->setUser($this->user());
|
||||
$account = $factory->create($data);
|
||||
|
||||
// assert stuff about account:
|
||||
$this->assertEquals($account->name, $data['name']);
|
||||
$this->assertEquals(AccountType::ASSET, $account->accountType->type);
|
||||
$this->assertEquals('', $account->iban);
|
||||
$this->assertTrue($account->active);
|
||||
$this->assertEquals('0', $account->virtual_balance);
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an expense account. This overrules the virtual balance.
|
||||
* Role should not be set.
|
||||
@@ -194,7 +194,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNull($meta);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNull($meta);
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
|
||||
@@ -320,7 +320,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
|
||||
@@ -362,7 +362,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
}
|
||||
@@ -401,7 +401,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
}
|
||||
@@ -443,7 +443,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
|
||||
@@ -487,7 +487,7 @@ class AccountFactoryTest extends TestCase
|
||||
|
||||
// get the role:
|
||||
/** @var AccountMeta $meta */
|
||||
$meta = $account->accountMeta()->where('name','accountRole')->first();
|
||||
$meta = $account->accountMeta()->where('name', 'accountRole')->first();
|
||||
$this->assertNotNull($meta);
|
||||
$this->assertEquals('defaultAsset', $meta->data);
|
||||
|
||||
|
@@ -67,6 +67,20 @@ class TransactionCurrencyFactoryTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* submit ID = 1000
|
||||
*
|
||||
* @covers \FireflyIII\Factory\TransactionCurrencyFactory
|
||||
*/
|
||||
public function testFindByBadID(): void
|
||||
{
|
||||
$currency = TransactionCurrency::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
/** @var TransactionCurrencyFactory $factory */
|
||||
$factory = app(TransactionCurrencyFactory::class);
|
||||
$result = $factory->find(1000, $currency->code);
|
||||
$this->assertEquals($currency->id, $result->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Factory\TransactionCurrencyFactory
|
||||
*/
|
||||
@@ -92,20 +106,6 @@ class TransactionCurrencyFactoryTest extends TestCase
|
||||
$this->assertEquals($currency->id, $result->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* submit ID = 1000
|
||||
*
|
||||
* @covers \FireflyIII\Factory\TransactionCurrencyFactory
|
||||
*/
|
||||
public function testFindByBadID(): void
|
||||
{
|
||||
$currency = TransactionCurrency::inRandomOrder()->whereNull('deleted_at')->first();
|
||||
/** @var TransactionCurrencyFactory $factory */
|
||||
$factory = app(TransactionCurrencyFactory::class);
|
||||
$result = $factory->find(1000, $currency->code);
|
||||
$this->assertEquals($currency->id, $result->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Factory\TransactionCurrencyFactory
|
||||
*/
|
||||
|
@@ -704,11 +704,11 @@ class TransactionFactoryTest extends TestCase
|
||||
public function testCreatePairReconciliation(): void
|
||||
{
|
||||
// objects:
|
||||
$asset = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
$asset = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
$reconAccount = $this->user()->accounts()->where('account_type_id', 10)->first();
|
||||
//$opposing = $this->user()->accounts()->where('id', '!=', $asset->id)->where('account_type_id', 3)->first();
|
||||
$euro = TransactionCurrency::first();
|
||||
$foreign = TransactionCurrency::where('id', '!=', $euro->id)->first();
|
||||
$euro = TransactionCurrency::first();
|
||||
$foreign = TransactionCurrency::where('id', '!=', $euro->id)->first();
|
||||
|
||||
// mocked classes
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
@@ -90,7 +90,7 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
||||
'data' => 'bye!',
|
||||
]
|
||||
);
|
||||
$count = $journal->transactionJournalMeta()->count();
|
||||
$count = $journal->transactionJournalMeta()->count();
|
||||
|
||||
$set = [
|
||||
'journal' => $journal,
|
||||
@@ -101,7 +101,7 @@ class TransactionJournalMetaFactoryTest extends TestCase
|
||||
$factory = app(TransactionJournalMetaFactory::class);
|
||||
$factory->updateOrCreate($set);
|
||||
|
||||
$this->assertEquals($count-1, $journal->transactionJournalMeta()->count());
|
||||
$this->assertEquals($count - 1, $journal->transactionJournalMeta()->count());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user