mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Should cover models.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use FireflyIII\Models\Account;
|
||||
use League\FactoryMuffin\Facade as FactoryMuffin;
|
||||
|
||||
/**
|
||||
* Class AccountModelTest
|
||||
*/
|
||||
@@ -40,7 +43,49 @@ class AccountModelTest extends TestCase
|
||||
*/
|
||||
public function testFirstOrCreateEncrypted()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
// create account:
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
|
||||
|
||||
// search for account with the same properties:
|
||||
$search = [
|
||||
'name' => $account->name,
|
||||
'account_type_id' => $account->account_type_id,
|
||||
'user_id' => $account->user_id
|
||||
];
|
||||
|
||||
$result = Account::firstOrCreateEncrypted($search);
|
||||
|
||||
// should be the same account:
|
||||
|
||||
$this->assertEquals($account->id, $result->id);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Models\Account::firstOrCreateEncrypted
|
||||
*/
|
||||
public function testFirstOrCreateEncryptedNew()
|
||||
{
|
||||
// create account:
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
|
||||
// search for account with the same properties:
|
||||
$search = [
|
||||
'name' => 'Some new account',
|
||||
'account_type_id' => $account->account_type_id,
|
||||
'user_id' => $account->user_id,
|
||||
'active' => 1,
|
||||
];
|
||||
|
||||
$result = Account::firstOrCreateEncrypted($search);
|
||||
|
||||
// should not be the same account:
|
||||
|
||||
$this->assertNotEquals($account->id, $result->id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,7 +93,48 @@ class AccountModelTest extends TestCase
|
||||
*/
|
||||
public function testFirstOrNullEncrypted()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
// create account:
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
|
||||
|
||||
// search for account with the same properties:
|
||||
$search = [
|
||||
'name' => $account->name,
|
||||
'account_type_id' => $account->account_type_id,
|
||||
'user_id' => $account->user_id
|
||||
];
|
||||
|
||||
$result = Account::firstOrNullEncrypted($search);
|
||||
|
||||
// should be the same account:
|
||||
|
||||
$this->assertEquals($account->id, $result->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Models\Account::firstOrNullEncrypted
|
||||
*/
|
||||
public function testFirstOrNullEncryptedNew()
|
||||
{
|
||||
// create account:
|
||||
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
||||
$user = FactoryMuffin::create('FireflyIII\User');
|
||||
|
||||
// search for account with the same properties:
|
||||
$search = [
|
||||
'name' => 'Some new account',
|
||||
'account_type_id' => $account->account_type_id,
|
||||
'user_id' => $account->user_id,
|
||||
'active' => 1,
|
||||
];
|
||||
|
||||
$result = Account::firstOrNullEncrypted($search);
|
||||
|
||||
// should not be the same account:
|
||||
|
||||
$this->assertNull($result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user