New tests and factories.

This commit is contained in:
James Cole
2015-04-03 08:31:50 +02:00
parent 64c031c7fe
commit 6a9ffae25d
4 changed files with 169 additions and 14 deletions

View File

@@ -1,6 +1,8 @@
<?php
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionCurrency;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* Generated by PHPUnit_SkeletonGenerator on 2015-03-08 at 20:05:14.
*/
@@ -15,7 +17,6 @@ class AccountControllerTest extends TestCase
{
parent::setUp();
}
@@ -31,10 +32,10 @@ class AccountControllerTest extends TestCase
public function testCreate()
{
$this->be(new FireflyIII\User);
$pref = new Preference;
$pref = FactoryMuffin::create('FireflyIII\Models\Preference');
$pref->data = '1M';
$this->be($pref->user);
// CURRENCY:
$currency = new TransactionCurrency;
@@ -42,9 +43,8 @@ class AccountControllerTest extends TestCase
Preferences::shouldReceive('get', 'viewRange')->andReturn($pref);
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]);
// get all currencires?
$response = $this->call('GET', '/accounts/create/asset');
$this->call('GET', '/accounts/create/asset');
$this->assertResponseOk();
@@ -56,7 +56,16 @@ class AccountControllerTest extends TestCase
public function testDelete()
{
$this->markTestIncomplete();
// fake an account.
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$account->accountType->type = 'Asset account';
$account->accountType->save();
$this->be($account->user);
$this->call('GET', '/accounts/delete/' . $account->id);
$this->assertResponseOk();
$this->assertViewHas('subTitle', 'Delete ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"');
}
public function testDestroy()

35
tests/factories/all.php Normal file
View File

@@ -0,0 +1,35 @@
<?php
use League\FactoryMuffin\Facade as FactoryMuffin;
FactoryMuffin::define(
'FireflyIII\Models\Account', [
'user_id' => 'factory|FireflyIII\User',
'account_type_id' => 'factory|FireflyIII\Models\AccountType',
'name' => 'word',
'active' => 'boolean',
'encrypted' => 'boolean',
'virtual_balance' => 0
]
);
FactoryMuffin::define(
'FireflyIII\Models\Preference', [
'name' => 'word',
'data' => 'sentence',
'user_id' => 'factory|FireflyIII\User',
]
);
FactoryMuffin::define(
'FireflyIII\Models\AccountType', [
'type' => 'word',
'editable' => 1,
]
);
FactoryMuffin::define(
'FireflyIII\User', [
'email' => 'email',
'password' => bcrypt('james'),
]
);