Removed my own validation source in favour of Ardent.

This commit is contained in:
James Cole 2014-07-15 17:09:59 +02:00
parent a1fb4bdb60
commit aa36e8b7cf
17 changed files with 212 additions and 163 deletions

View File

@ -36,7 +36,6 @@ return [
'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider',
'Illuminate\View\ViewServiceProvider', 'Illuminate\View\ViewServiceProvider',
'Illuminate\Workbench\WorkbenchServiceProvider', 'Illuminate\Workbench\WorkbenchServiceProvider',
'Grumpydictator\Gchart\GchartServiceProvider',
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
'Barryvdh\Debugbar\ServiceProvider', 'Barryvdh\Debugbar\ServiceProvider',
'Firefly\Storage\StorageServiceProvider', 'Firefly\Storage\StorageServiceProvider',

View File

@ -19,11 +19,16 @@ class ChartController extends BaseController
/** /**
* Show home charts. * Show home charts.
*/ */
public function homeAccount($account = null) public function homeAccount($id = null)
{ {
list($start, $end) = tk::getDateRange(); list($start, $end) = tk::getDateRange();
$current = clone $start; $current = clone $start;
$return = []; $return = [];
$account = null;
if(!is_null($id)) {
$account = $this->accounts->find($id);
}
if (is_null($account)) { if (is_null($account)) {
$accounts = $this->accounts->getActiveDefault(); $accounts = $this->accounts->getActiveDefault();
@ -40,14 +45,8 @@ class ChartController extends BaseController
$current->addDay(); $current->addDay();
} }
} else { } else {
// do something experimental:
$account = $this->accounts->find($account);
if (is_null($account)) {
return View::make('error')->with('message', 'No account found.');
}
$return[0] = ['name' => $account->name, 'data' => []]; $return[0] = ['name' => $account->name, 'data' => []];
while ($current <= $end) { while ($current <= $end) {
$return[0]['data'][] = [$current->timestamp * 1000, $account->balance(clone $current)]; $return[0]['data'][] = [$current->timestamp * 1000, $account->balance(clone $current)];

View File

@ -61,15 +61,17 @@ class TransactionController extends BaseController
// create journal // create journal
/** @var \TransactionJournal $journal */ /** @var \TransactionJournal $journal */
$journal = $this->tj->createSimpleJournal($account,$beneficiary,$description,$amount,$date); $journal = $this->tj->createSimpleJournal($account, $beneficiary, $description, $amount, $date);
var_dump($journal);
// attach bud/cat (?) // attach bud/cat (?)
$journal->budgets()->save($budget); if (!is_null($budget)) {
$journal->categories()->save($category); $journal->budgets()->save($budget);
}
if (!is_null($category)) {
$journal->categories()->save($category);
}
Session::flash('success','Transaction saved'); Session::flash('success', 'Transaction saved');
return Redirect::route('index'); return Redirect::route('index');
} }

View File

@ -1,9 +1,11 @@
<?php <?php
namespace Firefly\Database; namespace Firefly\Database;
abstract class SingleTableInheritanceEntity extends \Elegant abstract class SingleTableInheritanceEntity extends \LaravelBook\Ardent\Ardent
{ {
/** /**
* The field that stores the subclass * The field that stores the subclass
@ -13,6 +15,7 @@ abstract class SingleTableInheritanceEntity extends \Elegant
protected $subclassField = null; protected $subclassField = null;
/** /**
* must be overridden and set to true in subclasses * must be overridden and set to true in subclasses
*
* @var bool * @var bool
*/ */
protected $isSubclass = false; protected $isSubclass = false;
@ -67,12 +70,16 @@ abstract class SingleTableInheritanceEntity extends \Elegant
} }
// ensure that the subclass field is assigned on save // ensure that the subclass field is assigned on save
public function save(
public function save(array $options = array()) array $rules = array(),
{ array $customMessages = array(),
array $options = array(),
\Closure $beforeSave = null,
\Closure $afterSave = null
) {
if ($this->subclassField) { if ($this->subclassField) {
$this->attributes[$this->subclassField] = get_class($this); $this->attributes[$this->subclassField] = get_class($this);
} }
return parent::save($options); return parent::save($rules, $customMessages, $options, $beforeSave, $afterSave);
} }
} }

View File

@ -91,9 +91,9 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
$journal->completed = false; $journal->completed = false;
$journal->description = $description; $journal->description = $description;
$journal->date = $date; $journal->date = $date;
if (!$journal->isValid()) { if (!$journal->save()) {
\Log::error('Cannot create valid journal.'); \Log::error('Cannot create valid journal.');
\Log::error('Errors: ' . print_r($journal->validator->messages()->all(), true)); \Log::error('Errors: ' . print_r($journal->errors()->all(), true));
throw new \Firefly\Exception\FireflyException('Cannot create valid journal.'); throw new \Firefly\Exception\FireflyException('Cannot create valid journal.');
} }
$journal->save(); $journal->save();
@ -104,9 +104,9 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
$fromTransaction->transactionJournal()->associate($journal); $fromTransaction->transactionJournal()->associate($journal);
$fromTransaction->description = null; $fromTransaction->description = null;
$fromTransaction->amount = $amountFrom; $fromTransaction->amount = $amountFrom;
if (!$fromTransaction->isValid()) { if (!$fromTransaction->save()) {
\Log::error('Cannot create valid transaction (from) for journal #' . $journal->id); \Log::error('Cannot create valid transaction (from) for journal #' . $journal->id);
\Log::error('Errors: ' . print_r($fromTransaction->validator->messages()->all(), true)); \Log::error('Errors: ' . print_r($fromTransaction->errors()->all(), true));
throw new \Firefly\Exception\FireflyException('Cannot create valid transaction (from).'); throw new \Firefly\Exception\FireflyException('Cannot create valid transaction (from).');
} }
$fromTransaction->save(); $fromTransaction->save();
@ -116,12 +116,10 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
$toTransaction->transactionJournal()->associate($journal); $toTransaction->transactionJournal()->associate($journal);
$toTransaction->description = null; $toTransaction->description = null;
$toTransaction->amount = $amountTo; $toTransaction->amount = $amountTo;
if (!$toTransaction->isValid()) { if (!$toTransaction->save()) {
if (!$toTransaction->isValid()) { \Log::error('Cannot create valid transaction (to) for journal #' . $journal->id);
\Log::error('Cannot create valid transaction (to) for journal #' . $journal->id); \Log::error('Errors: ' . print_r($toTransaction->errors()->all(), true));
\Log::error('Errors: ' . print_r($toTransaction->validator->messages()->all(), true)); throw new \Firefly\Exception\FireflyException('Cannot create valid transaction (to).');
throw new \Firefly\Exception\FireflyException('Cannot create valid transaction (to).');
}
} }
$toTransaction->save(); $toTransaction->save();
@ -222,7 +220,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
$name = $t->account->name; $name = $t->account->name;
$amount = floatval($t->amount) < 0 ? floatval($t->amount) * -1 : floatval($t->amount); $amount = floatval($t->amount) < 0 ? floatval($t->amount) * -1 : floatval($t->amount);
$result[$name] = isset($result[$name]) ? $result[$name]+$amount : $amount; $result[$name] = isset($result[$name]) ? $result[$name] + $amount : $amount;
} }
} }
} }

View File

@ -17,9 +17,9 @@ class EloquentUserRepository implements UserRepositoryInterface
$user->reset = \Str::random(32); $user->reset = \Str::random(32);
$user->password = \Hash::make(\Str::random(12)); $user->password = \Hash::make(\Str::random(12));
if (!$user->isValid()) { if (!$user->save()) {
\Log::error('Invalid user'); \Log::error('Invalid user');
\Session::flash('error', 'Input invalid, please try again: ' . $user->validator->messages()->first()); \Session::flash('error', 'Input invalid, please try again: ' . $user->errors()->first());
return false; return false;
} }
$user->save(); $user->save();

View File

@ -1,9 +1,14 @@
<?php <?php
use LaravelBook\Ardent\Ardent as Ardent;
class Account extends Ardent
class Account extends Elegant
{ {
/**
* Validation rules.
*
* @var array
*/
public static $rules public static $rules
= [ = [
'name' => 'required|between:1,100', 'name' => 'required|between:1,100',
@ -13,6 +18,11 @@ class Account extends Elegant
]; ];
/**
* Factory instructions
*
* @var array
*/
public static $factory public static $factory
= [ = [
'name' => 'string', 'name' => 'string',
@ -21,11 +31,21 @@ class Account extends Elegant
'active' => '1' 'active' => '1'
]; ];
/**
* Account type.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function accountType() public function accountType()
{ {
return $this->belongsTo('AccountType'); return $this->belongsTo('AccountType');
} }
/**
* User
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user() public function user()
{ {
return $this->belongsTo('User'); return $this->belongsTo('User');
@ -42,11 +62,20 @@ class Account extends Elegant
{ {
$date = is_null($date) ? new \Carbon\Carbon : $date; $date = is_null($date) ? new \Carbon\Carbon : $date;
return floatval($this->transactions() return floatval(
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') $this->transactions()
->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')); ->leftJoin(
'transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id'
)
->where('transaction_journals.date', '<=', $date->format('Y-m-d'))->sum('transactions.amount')
);
} }
/**
* Transactions.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function transactions() public function transactions()
{ {
return $this->hasMany('Transaction'); return $this->hasMany('Transaction');

View File

@ -9,7 +9,6 @@ class Component extends Firefly\Database\SingleTableInheritanceEntity
'user_id' => 'exists:users,id|required', 'user_id' => 'exists:users,id|required',
'name' => 'required|between:1,255', 'name' => 'required|between:1,255',
'class' => 'required', 'class' => 'required',
'component_type_id' => 'required|exists:component_types,id'
]; ];
protected $table = 'components'; protected $table = 'components';
protected $subclassField = 'class'; protected $subclassField = 'class';

View File

@ -1,18 +0,0 @@
<?php
use \Illuminate\Database\Eloquent\Model as Eloquent;
class Elegant extends Eloquent
{
public static $rules = [];
public $validator;
public function isValid()
{
$validator = Validator::make(
$this->toArray(),
$this::$rules
);
$this->validator = $validator;
return $validator->passes();
}
}

View File

@ -1,19 +1,23 @@
<?php <?php
class Preference extends Elegant use LaravelBook\Ardent\Ardent;
class Preference extends Ardent
{ {
public static $rules public static $rules
= [ = [
'user_id' => 'required|exists:user,id', 'user_id' => 'required|exists:users,id',
'name' => 'required|between:1,255', 'name' => 'required|between:1,255',
'data' => 'required' 'data' => 'required'
]; ];
public static $factory = [ public static $factory
'user_id' => 'factory|User', = [
'name' => 'string', 'user_id' => 'factory|User',
'data' => 'string' 'name' => 'string',
]; 'data' => 'string'
];
public function user() public function user()
{ {

View File

@ -1,14 +1,16 @@
<?php <?php
use LaravelBook\Ardent\Ardent;
class Transaction extends Elegant
class Transaction extends Ardent
{ {
public static $rules public static $rules
= [ = [
'account_id' => 'numeric|required|exists:accounts,id', 'account_id' => 'numeric|required|exists:accounts,id',
'transaction_journal_id' => 'numeric|required|exists:transaction_journals,id', 'transaction_journal_id' => 'numeric|required|exists:transaction_journals,id',
'description' => 'between:1,255', 'description' => 'between:1,255',
'amount' => 'required|between:-65536,65536', 'amount' => 'required|between:-65536,65536|not_in:0,0.00',
]; ];
public static $factory public static $factory

View File

@ -1,15 +1,17 @@
<?php <?php
use LaravelBook\Ardent\Ardent;
class TransactionJournal extends Elegant
class TransactionJournal extends Ardent
{ {
public static $rules public static $rules
= [ = [
'transaction_type_id' => 'required|exists:transaction_types,id', 'transaction_type_id' => 'required|exists:transaction_types,id',
'transaction_currency_id' => 'required|exists:transaction_currencies,id', 'transaction_currency_id' => 'required|exists:transaction_currencies,id',
'description' => 'between:1,255', 'description' => 'required|between:1,255',
'date' => 'date', 'date' => 'required|date',
'completed' => 'required|between:0,1' 'completed' => 'required|between:0,1'
]; ];

View File

@ -4,8 +4,10 @@ use Illuminate\Auth\Reminders\RemindableInterface;
use Illuminate\Auth\Reminders\RemindableTrait; use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\UserInterface; use Illuminate\Auth\UserInterface;
use Illuminate\Auth\UserTrait; use Illuminate\Auth\UserTrait;
use LaravelBook\Ardent\Ardent;
class User extends Elegant implements UserInterface, RemindableInterface
class User extends Ardent implements UserInterface, RemindableInterface
{ {
use UserTrait, RemindableTrait; use UserTrait, RemindableTrait;
@ -22,7 +24,7 @@ class User extends Elegant implements UserInterface, RemindableInterface
public static $factory public static $factory
= [ = [
'email' => 'email', 'email' => 'email',
'password' => 'string', 'password' => 'string|60',
'migrated' => '0' 'migrated' => '0'
]; ];

View File

@ -1,5 +1,7 @@
<?php <?php
use \League\FactoryMuffin\Facade\FactoryMuffin;
class ChartControllerTest extends TestCase class ChartControllerTest extends TestCase
{ {
public function setUp() public function setUp()
@ -51,21 +53,7 @@ class ChartControllerTest extends TestCase
public function testHomeAccountWithInput() public function testHomeAccountWithInput()
{ {
// save actual account: // save actual account:
$type = new AccountType; $account = FactoryMuffin::create('Account');
$type->description = 'An account';
$type->save();
$user = new User;
$user->email = 'bla';
$user->migrated = false;
$user->password = 'bla';
$user->save();
$account = new Account;
$account->accountType()->associate($type);
$account->user()->associate($user);
$account->name = 'Hello';
$account->active = true;
$account->save();
// mock preference: // mock preference:
$pref = $this->mock('Preference'); $pref = $this->mock('Preference');
@ -83,54 +71,12 @@ class ChartControllerTest extends TestCase
$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface'); $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
$accounts->shouldReceive('find')->with(1)->andReturn($account); $accounts->shouldReceive('find')->with(1)->andReturn($account);
// call
$this->call('GET', '/chart/home/account/' . $account->id);
// test
$this->assertResponseOk();
}
public function testHomeAccountWithInvalidInput()
{
// save actual account:
$type = new AccountType;
$type->description = 'An account';
$type->save();
$user = new User;
$user->email = 'bla';
$user->migrated = false;
$user->password = 'bla';
$user->save();
$account = new Account;
$account->accountType()->associate($type);
$account->user()->associate($user);
$account->name = 'Hello';
$account->active = true;
$account->save();
// mock preference:
$pref = $this->mock('Preference');
$pref->shouldReceive('getAttribute', 'data')->andReturn('1M');
// mock preferences helper:
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
// mock toolkit:
$toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');
$toolkit->shouldReceive('getDateRange')->andReturn(null);
// mock account repository:
$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
$accounts->shouldReceive('find')->with(1)->andReturn(null);
// call // call
$this->call('GET', '/chart/home/account/' . $account->id); $this->call('GET', '/chart/home/account/' . $account->id);
// test // test
$this->assertResponseOk(); $this->assertResponseOk();
$this->assertViewHas('message');
} }
public function testhomeBudgets() public function testhomeBudgets()

View File

@ -1,20 +1,49 @@
<?php <?php
use \League\FactoryMuffin\Facade\FactoryMuffin;
class TransactionControllerTest extends TestCase class TransactionControllerTest extends TestCase
{ {
/**
* Default preparation for each test
*/
public function setUp()
{
parent::setUp();
$this->prepareForTests();
}
/**
* Migrate the database
*/
private function prepareForTests()
{
Artisan::call('migrate');
Artisan::call('db:seed');
}
public function testCreateWithdrawal() public function testCreateWithdrawal()
{ {
$set = [0 => '(no budget)'];
View::shouldReceive('share'); View::shouldReceive('share');
View::shouldReceive('make')->with('transactions.withdrawal')->andReturn(\Mockery::self()) View::shouldReceive('make')->with('transactions.withdrawal')->andReturn(\Mockery::self())
->shouldReceive('with')->once() ->shouldReceive('with')->once()
->with('accounts', []) ->with('accounts', [])
->andReturn(Mockery::self()); ->andReturn(Mockery::self())
->shouldReceive('with')->once()
->with('budgets', $set)->andReturn(Mockery::self());
// mock account repository: // mock account repository:
$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface'); $accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
$accounts->shouldReceive('getActiveDefaultAsSelectList')->andReturn([]); $accounts->shouldReceive('getActiveDefaultAsSelectList')->andReturn([]);
// mock budget repository:
$budgets = $this->mock('Firefly\Storage\Budget\BudgetRepositoryInterface');
$budgets->shouldReceive('getAsSelectList')->andReturn($set);
// call // call
$this->call('GET', '/transactions/add/withdrawal'); $this->call('GET', '/transactions/add/withdrawal');
@ -22,4 +51,52 @@ class TransactionControllerTest extends TestCase
$this->assertResponseOk(); $this->assertResponseOk();
} }
public function testPostCreateWithdrawal()
{
// create objects.
$account = FactoryMuffin::create('Account');
$beneficiary = FactoryMuffin::create('Account');
$category = FactoryMuffin::create('Category');
$budget = FactoryMuffin::create('Budget');
// data to send:
$data = [
'beneficiary' => $beneficiary->name,
'category' => $category->name,
'budget_id' => $budget->id,
'account_id' => $account->id,
'description' => 'Bla',
'amount' => 1.2,
'date' => '2012-01-01'
];
$journal = FactoryMuffin::create('TransactionJournal');
// mock account repository:
$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
$accounts->shouldReceive('createOrFindBeneficiary')->with($beneficiary->name)->andReturn($beneficiary);
$accounts->shouldReceive('find')->andReturn($account);
// mock category repository
$categories = $this->mock('Firefly\Storage\Category\CategoryRepositoryInterface');
$categories->shouldReceive('createOrFind')->with($category->name)->andReturn($category);
// mock budget repository
$budgets = $this->mock('Firefly\Storage\Budget\BudgetRepositoryInterface');
$budgets->shouldReceive('createOrFind')->with($budget->name)->andReturn($budget);
$budgets->shouldReceive('find')->andReturn($budget);
// mock transaction journal:
$tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
$tj->shouldReceive('createSimpleJournal')->once()->andReturn($journal);
$tj->shouldReceive('createSimpleJournal')->with($account, $beneficiary, $data['description'], $data['amount'], new \Carbon\Carbon($data['date']))->once()->andReturn($journal);
// call
$this->call('POST', '/transactions/add/withdrawal', $data);
// test
$this->assertRedirectedToRoute('index');
}
} }

View File

@ -1,6 +1,6 @@
<?php <?php
use Zizaco\FactoryMuff\Facade\FactoryMuff; use \League\FactoryMuffin\Facade\FactoryMuffinin;
class AllModelsTest extends TestCase class AllModelsTest extends TestCase
{ {
@ -29,14 +29,14 @@ class AllModelsTest extends TestCase
*/ */
public function testUser() public function testUser()
{ {
$user = FactoryMuff::create('User'); $user = FactoryMuffin::create('User');
$pref = FactoryMuff::create('Preference'); $pref = FactoryMuffin::create('Preference');
$account = FactoryMuff::create('Account'); $account = FactoryMuffin::create('Account');
// some more stuff: // some more stuff:
$component = FactoryMuff::create('Component'); $component = FactoryMuffin::create('Component');
$budget = FactoryMuff::create('Budget'); $budget = FactoryMuffin::create('Budget');
$category = FactoryMuff::create('Category'); $category = FactoryMuffin::create('Category');
$account->user()->associate($user); $account->user()->associate($user);
$pref->user()->associate($user); $pref->user()->associate($user);
@ -80,18 +80,18 @@ class AllModelsTest extends TestCase
public function testTransactionJournals() public function testTransactionJournals()
{ {
$tj = FactoryMuff::create('TransactionJournal'); $tj = FactoryMuffin::create('TransactionJournal');
$t1 = FactoryMuff::create('Transaction'); $t1 = FactoryMuffin::create('Transaction');
$t2 = FactoryMuff::create('Transaction'); $t2 = FactoryMuffin::create('Transaction');
$t3 = FactoryMuff::create('Transaction'); $t3 = FactoryMuffin::create('Transaction');
$tj->transactions()->save($t1); $tj->transactions()->save($t1);
$tj->transactions()->save($t2); $tj->transactions()->save($t2);
$tj->transactions()->save($t3); $tj->transactions()->save($t3);
$budget = FactoryMuff::create('Budget'); $budget = FactoryMuffin::create('Budget');
$category = FactoryMuff::create('Category'); $category = FactoryMuffin::create('Category');
$tj->components()->save($budget); $tj->components()->save($budget);
$tj->components()->save($category); $tj->components()->save($category);
@ -102,7 +102,7 @@ class AllModelsTest extends TestCase
$this->assertCount(3, $tj->transactions()->get()); $this->assertCount(3, $tj->transactions()->get());
$this->assertTrue($tj->isValid()); $this->assertTrue($tj->validate());
$this->assertEquals($tj->transaction_type_id, $tj->transactionType()->first()->id); $this->assertEquals($tj->transaction_type_id, $tj->transactionType()->first()->id);
$this->assertEquals($tj->transaction_currency_id, $tj->transactionCurrency()->first()->id); $this->assertEquals($tj->transaction_currency_id, $tj->transactionCurrency()->first()->id);
@ -111,7 +111,7 @@ class AllModelsTest extends TestCase
public function testTransactionJournalScope() public function testTransactionJournalScope()
{ {
$tj = FactoryMuff::create('TransactionJournal'); $tj = FactoryMuffin::create('TransactionJournal');
$tj->date = new \Carbon\Carbon('2012-01-02'); $tj->date = new \Carbon\Carbon('2012-01-02');
$set = $tj->after(new \Carbon\Carbon)->before(new \Carbon\Carbon)->get(); $set = $tj->after(new \Carbon\Carbon)->before(new \Carbon\Carbon)->get();
@ -120,10 +120,10 @@ class AllModelsTest extends TestCase
public function testTransactionType() public function testTransactionType()
{ {
$j1 = FactoryMuff::create('TransactionJournal'); $j1 = FactoryMuffin::create('TransactionJournal');
$j2 = FactoryMuff::create('TransactionJournal'); $j2 = FactoryMuffin::create('TransactionJournal');
$type = FactoryMuff::create('TransactionType'); $type = FactoryMuffin::create('TransactionType');
$type->transactionjournals()->save($j1); $type->transactionjournals()->save($j1);
$type->transactionjournals()->save($j2); $type->transactionjournals()->save($j2);
@ -133,10 +133,10 @@ class AllModelsTest extends TestCase
public function testTransactionCurrency() public function testTransactionCurrency()
{ {
$j1 = FactoryMuff::create('TransactionJournal'); $j1 = FactoryMuffin::create('TransactionJournal');
$j2 = FactoryMuff::create('TransactionJournal'); $j2 = FactoryMuffin::create('TransactionJournal');
$currency = FactoryMuff::create('TransactionCurrency'); $currency = FactoryMuffin::create('TransactionCurrency');
$currency->transactionjournals()->save($j1); $currency->transactionjournals()->save($j1);
$currency->transactionjournals()->save($j2); $currency->transactionjournals()->save($j2);
@ -146,9 +146,9 @@ class AllModelsTest extends TestCase
public function testAccountTypes() public function testAccountTypes()
{ {
$type = FactoryMuff::create('AccountType'); $type = FactoryMuffin::create('AccountType');
$a1 = FactoryMuff::create('Account'); $a1 = FactoryMuffin::create('Account');
$a2 = FactoryMuff::create('Account'); $a2 = FactoryMuffin::create('Account');
$type->accounts()->save($a1); $type->accounts()->save($a1);
$type->accounts()->save($a2); $type->accounts()->save($a2);
@ -158,12 +158,12 @@ class AllModelsTest extends TestCase
public function testTransactions() public function testTransactions()
{ {
$transaction = FactoryMuff::create('Transaction'); $transaction = FactoryMuffin::create('Transaction');
$budget = FactoryMuff::create('Budget'); $budget = FactoryMuffin::create('Budget');
$account = FactoryMuff::create('Account'); $account = FactoryMuffin::create('Account');
$category = FactoryMuff::create('Category'); $category = FactoryMuffin::create('Category');
$journal = FactoryMuff::create('TransactionJournal'); $journal = FactoryMuffin::create('TransactionJournal');
$transaction->components()->save($budget); $transaction->components()->save($budget);
$transaction->components()->save($category); $transaction->components()->save($category);
@ -180,11 +180,11 @@ class AllModelsTest extends TestCase
public function testComponents() public function testComponents()
{ {
$component = FactoryMuff::create('Component'); $component = FactoryMuffin::create('Component');
$user = FactoryMuff::create('User'); $user = FactoryMuffin::create('User');
$transaction = FactoryMuff::create('Transaction'); $transaction = FactoryMuffin::create('Transaction');
$journal = FactoryMuff::create('TransactionJournal'); $journal = FactoryMuffin::create('TransactionJournal');
$component->transactionjournals()->save($journal); $component->transactionjournals()->save($journal);
$component->user()->associate($user); $component->user()->associate($user);
$component->transactions()->save($transaction); $component->transactions()->save($transaction);

View File

@ -22,14 +22,15 @@
}, },
"require": { "require": {
"laravel/framework": "4.2.*", "laravel/framework": "4.2.*",
"grumpydictator/gchart": "dev-master" "laravelbook/ardent": "dev-master"
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-debugbar": "1.*", "barryvdh/laravel-debugbar": "1.*",
"barryvdh/laravel-ide-helper": "1.*", "barryvdh/laravel-ide-helper": "1.*",
"mockery/mockery": "dev-master", "mockery/mockery": "dev-master",
"satooshi/php-coveralls": "dev-master", "satooshi/php-coveralls": "dev-master",
"zizaco/factory-muff": "dev-master" "zizaco/factory-muff": "dev-master",
"doctrine/dbal": "2.4.*"
}, },
"autoload": { "autoload": {
"classmap": [ "classmap": [