Should cover models.

This commit is contained in:
James Cole
2015-05-24 11:13:46 +02:00
parent 8f2f912cdf
commit 6c71f68ed8
9 changed files with 555 additions and 116 deletions

View File

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