Code cleanup and realign.

This commit is contained in:
James Cole
2018-08-06 19:14:30 +02:00
parent f7eef25fed
commit 5908c0ce8c
188 changed files with 1019 additions and 1031 deletions

View File

@@ -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);