mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 01:42:19 +00:00
Fix #1313
This commit is contained in:
@@ -73,6 +73,11 @@ class AccountFactory
|
|||||||
$databaseData['virtual_balance'] = '0';
|
$databaseData['virtual_balance'] = '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fix virtual balance when it's empty
|
||||||
|
if ($databaseData['virtual_balance'] === '') {
|
||||||
|
$databaseData['virtual_balance'] = '0';
|
||||||
|
}
|
||||||
|
|
||||||
$newAccount = Account::create($databaseData);
|
$newAccount = Account::create($databaseData);
|
||||||
$this->updateMetaData($newAccount, $data);
|
$this->updateMetaData($newAccount, $data);
|
||||||
|
|
||||||
|
@@ -68,6 +68,40 @@ class AccountFactoryTest extends TestCase
|
|||||||
$this->assertEquals('defaultAsset', $account->getMeta('accountRole'));
|
$this->assertEquals('defaultAsset', $account->getMeta('accountRole'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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()
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'account_type_id' => null,
|
||||||
|
'accountType' => 'asset',
|
||||||
|
'iban' => null,
|
||||||
|
'name' => 'Basic asset account #' . random_int(1, 1000),
|
||||||
|
'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);
|
||||||
|
$this->assertEquals('defaultAsset', $account->getMeta('accountRole'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test creation of CC asset.
|
* Test creation of CC asset.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user