mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Removed my own validation source in favour of Ardent.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use \League\FactoryMuffin\Facade\FactoryMuffin;
|
||||
|
||||
class ChartControllerTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
@@ -51,21 +53,7 @@ class ChartControllerTest extends TestCase
|
||||
public function testHomeAccountWithInput()
|
||||
{
|
||||
// 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();
|
||||
$account = FactoryMuffin::create('Account');
|
||||
|
||||
// mock preference:
|
||||
$pref = $this->mock('Preference');
|
||||
@@ -83,54 +71,12 @@ class ChartControllerTest extends TestCase
|
||||
$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
|
||||
$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
|
||||
$this->call('GET', '/chart/home/account/' . $account->id);
|
||||
|
||||
// test
|
||||
$this->assertResponseOk();
|
||||
$this->assertViewHas('message');
|
||||
}
|
||||
|
||||
public function testhomeBudgets()
|
||||
|
@@ -1,20 +1,49 @@
|
||||
<?php
|
||||
|
||||
use \League\FactoryMuffin\Facade\FactoryMuffin;
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
$set = [0 => '(no budget)'];
|
||||
View::shouldReceive('share');
|
||||
View::shouldReceive('make')->with('transactions.withdrawal')->andReturn(\Mockery::self())
|
||||
->shouldReceive('with')->once()
|
||||
->with('accounts', [])
|
||||
->andReturn(Mockery::self());
|
||||
->andReturn(Mockery::self())
|
||||
->shouldReceive('with')->once()
|
||||
->with('budgets', $set)->andReturn(Mockery::self());
|
||||
|
||||
// mock account repository:
|
||||
$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
|
||||
$accounts->shouldReceive('getActiveDefaultAsSelectList')->andReturn([]);
|
||||
|
||||
// mock budget repository:
|
||||
$budgets = $this->mock('Firefly\Storage\Budget\BudgetRepositoryInterface');
|
||||
$budgets->shouldReceive('getAsSelectList')->andReturn($set);
|
||||
|
||||
|
||||
// call
|
||||
$this->call('GET', '/transactions/add/withdrawal');
|
||||
|
||||
@@ -22,4 +51,52 @@ class TransactionControllerTest extends TestCase
|
||||
$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');
|
||||
}
|
||||
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Zizaco\FactoryMuff\Facade\FactoryMuff;
|
||||
use \League\FactoryMuffin\Facade\FactoryMuffinin;
|
||||
|
||||
class AllModelsTest extends TestCase
|
||||
{
|
||||
@@ -29,14 +29,14 @@ class AllModelsTest extends TestCase
|
||||
*/
|
||||
public function testUser()
|
||||
{
|
||||
$user = FactoryMuff::create('User');
|
||||
$pref = FactoryMuff::create('Preference');
|
||||
$account = FactoryMuff::create('Account');
|
||||
$user = FactoryMuffin::create('User');
|
||||
$pref = FactoryMuffin::create('Preference');
|
||||
$account = FactoryMuffin::create('Account');
|
||||
|
||||
// some more stuff:
|
||||
$component = FactoryMuff::create('Component');
|
||||
$budget = FactoryMuff::create('Budget');
|
||||
$category = FactoryMuff::create('Category');
|
||||
$component = FactoryMuffin::create('Component');
|
||||
$budget = FactoryMuffin::create('Budget');
|
||||
$category = FactoryMuffin::create('Category');
|
||||
|
||||
$account->user()->associate($user);
|
||||
$pref->user()->associate($user);
|
||||
@@ -80,18 +80,18 @@ class AllModelsTest extends TestCase
|
||||
|
||||
public function testTransactionJournals()
|
||||
{
|
||||
$tj = FactoryMuff::create('TransactionJournal');
|
||||
$tj = FactoryMuffin::create('TransactionJournal');
|
||||
|
||||
$t1 = FactoryMuff::create('Transaction');
|
||||
$t2 = FactoryMuff::create('Transaction');
|
||||
$t3 = FactoryMuff::create('Transaction');
|
||||
$t1 = FactoryMuffin::create('Transaction');
|
||||
$t2 = FactoryMuffin::create('Transaction');
|
||||
$t3 = FactoryMuffin::create('Transaction');
|
||||
|
||||
$tj->transactions()->save($t1);
|
||||
$tj->transactions()->save($t2);
|
||||
$tj->transactions()->save($t3);
|
||||
|
||||
$budget = FactoryMuff::create('Budget');
|
||||
$category = FactoryMuff::create('Category');
|
||||
$budget = FactoryMuffin::create('Budget');
|
||||
$category = FactoryMuffin::create('Category');
|
||||
|
||||
$tj->components()->save($budget);
|
||||
$tj->components()->save($category);
|
||||
@@ -102,7 +102,7 @@ class AllModelsTest extends TestCase
|
||||
|
||||
$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_currency_id, $tj->transactionCurrency()->first()->id);
|
||||
@@ -111,7 +111,7 @@ class AllModelsTest extends TestCase
|
||||
|
||||
public function testTransactionJournalScope()
|
||||
{
|
||||
$tj = FactoryMuff::create('TransactionJournal');
|
||||
$tj = FactoryMuffin::create('TransactionJournal');
|
||||
$tj->date = new \Carbon\Carbon('2012-01-02');
|
||||
|
||||
$set = $tj->after(new \Carbon\Carbon)->before(new \Carbon\Carbon)->get();
|
||||
@@ -120,10 +120,10 @@ class AllModelsTest extends TestCase
|
||||
|
||||
public function testTransactionType()
|
||||
{
|
||||
$j1 = FactoryMuff::create('TransactionJournal');
|
||||
$j2 = FactoryMuff::create('TransactionJournal');
|
||||
$j1 = FactoryMuffin::create('TransactionJournal');
|
||||
$j2 = FactoryMuffin::create('TransactionJournal');
|
||||
|
||||
$type = FactoryMuff::create('TransactionType');
|
||||
$type = FactoryMuffin::create('TransactionType');
|
||||
$type->transactionjournals()->save($j1);
|
||||
$type->transactionjournals()->save($j2);
|
||||
|
||||
@@ -133,10 +133,10 @@ class AllModelsTest extends TestCase
|
||||
|
||||
public function testTransactionCurrency()
|
||||
{
|
||||
$j1 = FactoryMuff::create('TransactionJournal');
|
||||
$j2 = FactoryMuff::create('TransactionJournal');
|
||||
$j1 = FactoryMuffin::create('TransactionJournal');
|
||||
$j2 = FactoryMuffin::create('TransactionJournal');
|
||||
|
||||
$currency = FactoryMuff::create('TransactionCurrency');
|
||||
$currency = FactoryMuffin::create('TransactionCurrency');
|
||||
$currency->transactionjournals()->save($j1);
|
||||
$currency->transactionjournals()->save($j2);
|
||||
|
||||
@@ -146,9 +146,9 @@ class AllModelsTest extends TestCase
|
||||
|
||||
public function testAccountTypes()
|
||||
{
|
||||
$type = FactoryMuff::create('AccountType');
|
||||
$a1 = FactoryMuff::create('Account');
|
||||
$a2 = FactoryMuff::create('Account');
|
||||
$type = FactoryMuffin::create('AccountType');
|
||||
$a1 = FactoryMuffin::create('Account');
|
||||
$a2 = FactoryMuffin::create('Account');
|
||||
|
||||
$type->accounts()->save($a1);
|
||||
$type->accounts()->save($a2);
|
||||
@@ -158,12 +158,12 @@ class AllModelsTest extends TestCase
|
||||
|
||||
public function testTransactions()
|
||||
{
|
||||
$transaction = FactoryMuff::create('Transaction');
|
||||
$transaction = FactoryMuffin::create('Transaction');
|
||||
|
||||
$budget = FactoryMuff::create('Budget');
|
||||
$account = FactoryMuff::create('Account');
|
||||
$category = FactoryMuff::create('Category');
|
||||
$journal = FactoryMuff::create('TransactionJournal');
|
||||
$budget = FactoryMuffin::create('Budget');
|
||||
$account = FactoryMuffin::create('Account');
|
||||
$category = FactoryMuffin::create('Category');
|
||||
$journal = FactoryMuffin::create('TransactionJournal');
|
||||
|
||||
$transaction->components()->save($budget);
|
||||
$transaction->components()->save($category);
|
||||
@@ -180,11 +180,11 @@ class AllModelsTest extends TestCase
|
||||
|
||||
public function testComponents()
|
||||
{
|
||||
$component = FactoryMuff::create('Component');
|
||||
$user = FactoryMuff::create('User');
|
||||
$transaction = FactoryMuff::create('Transaction');
|
||||
$component = FactoryMuffin::create('Component');
|
||||
$user = FactoryMuffin::create('User');
|
||||
$transaction = FactoryMuffin::create('Transaction');
|
||||
|
||||
$journal = FactoryMuff::create('TransactionJournal');
|
||||
$journal = FactoryMuffin::create('TransactionJournal');
|
||||
$component->transactionjournals()->save($journal);
|
||||
$component->user()->associate($user);
|
||||
$component->transactions()->save($transaction);
|
||||
|
Reference in New Issue
Block a user