This will be the first release!

This commit is contained in:
James Cole
2014-08-28 07:53:54 +02:00
parent c7f070a2d1
commit c4f42a604f
75 changed files with 1043 additions and 618 deletions

View File

@@ -247,10 +247,10 @@ class AccountControllerTest extends TestCase
$collection->add($account);
$list = [
'personal' => [],
'personal' => [],
'beneficiaries' => [],
'initial' => [],
'cash' => []
'initial' => [],
'cash' => []
];
$this->_repository->shouldReceive('get')->once()->andReturn($collection);
@@ -283,19 +283,19 @@ class AccountControllerTest extends TestCase
$data = [
'statistics' => [
'period' => [
'in' => 0,
'out' => 0,
'diff' => 0,
't_in' => 0,
't_out' => 0,
'period' => [
'in' => 0,
'out' => 0,
'diff' => 0,
't_in' => 0,
't_out' => 0,
't_diff' => 0
],
'categories' => [],
'budgets' => [],
'accounts' => []
'budgets' => [],
'accounts' => []
],
'journals' => $paginator,
'journals' => $paginator,
];
$this->_accounts->shouldReceive('show')->once()->andReturn($data);

View File

@@ -2,8 +2,8 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Mockery as m;
use League\FactoryMuffin\Facade as f;
use Mockery as m;
/**
* Class BudgetControllerTest
@@ -65,7 +65,7 @@ class BudgetControllerTest extends TestCase
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($budget->user_id);
Event::shouldReceive('fire')->once()->with('budgets.destroy',[$budget]);
Event::shouldReceive('fire')->once()->with('budgets.destroy', [$budget]);
$this->_repository->shouldReceive('destroy')->once()->andReturn(true);
$this->action('POST', 'BudgetController@destroy', $budget->id);
@@ -81,7 +81,7 @@ class BudgetControllerTest extends TestCase
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($budget->user_id);
Event::shouldReceive('fire')->once()->with('budgets.destroy',[$budget]);
Event::shouldReceive('fire')->once()->with('budgets.destroy', [$budget]);
$this->_repository->shouldReceive('destroy')->once()->andReturn(true);
$this->action('POST', 'BudgetController@destroy', [$budget->id, 'from' => 'date']);
@@ -97,7 +97,7 @@ class BudgetControllerTest extends TestCase
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($budget->user_id);
Event::shouldReceive('fire')->once()->with('budgets.destroy',[$budget]);
Event::shouldReceive('fire')->once()->with('budgets.destroy', [$budget]);
$this->_repository->shouldReceive('destroy')->once()->andReturn(false);
@@ -233,7 +233,7 @@ class BudgetControllerTest extends TestCase
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($budget->user_id);
$this->_repository->shouldReceive('update')->andReturn($budget);
Event::shouldReceive('fire')->with('budgets.update',[$budget]);
Event::shouldReceive('fire')->with('budgets.update', [$budget]);
$this->action('POST', 'BudgetController@update', $budget->id);
$this->assertRedirectedToRoute('budgets.index.budget');
@@ -248,7 +248,7 @@ class BudgetControllerTest extends TestCase
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($budget->user_id);
$this->_repository->shouldReceive('update')->andReturn($budget);
Event::shouldReceive('fire')->with('budgets.update',[$budget]);
Event::shouldReceive('fire')->with('budgets.update', [$budget]);
//$this->_user->shouldReceive('budgets')->andReturn([]); // trigger
$this->action('POST', 'BudgetController@update', [$budget->id, 'from' => 'date']);

View File

@@ -2,8 +2,8 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Mockery as m;
use League\FactoryMuffin\Facade as f;
use Mockery as m;
/**
* Class CategoryControllerTest

View File

@@ -2,8 +2,8 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Mockery as m;
use League\FactoryMuffin\Facade as f;
use Mockery as m;
/**

View File

@@ -1,7 +1,7 @@
<?php
use Carbon\Carbon as Carbon;
use Mockery as m;
use League\FactoryMuffin\Facade as f;
use Mockery as m;
/**
* Class HomeControllerTest
@@ -15,6 +15,7 @@ class HomeControllerTest extends TestCase
protected $_repository;
protected $_preferences;
protected $_journals;
protected $_reminders;
public function setUp()
{
@@ -25,6 +26,7 @@ class HomeControllerTest extends TestCase
$this->_repository = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
$this->_preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
$this->_journals = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
$this->_reminders = $this->mock('Firefly\Storage\Reminder\ReminderRepositoryInterface');
}
@@ -47,6 +49,11 @@ class HomeControllerTest extends TestCase
$preference = $this->mock('Preference');
$preference->shouldReceive('getAttribute')->with('data')->andReturn([]);
Event::shouldReceive('fire')->with('limits.check');
Event::shouldReceive('fire')->with('piggybanks.check');
Event::shouldReceive('fire')->with('recurring.check');
$this->_reminders->shouldReceive('getCurrentRecurringReminders')->once()->andReturn([]);
// mock accounts:
$this->_repository->shouldReceive('count')->once()->andReturn(0);
@@ -71,6 +78,12 @@ class HomeControllerTest extends TestCase
$preference = $this->mock('Preference');
$preference->shouldReceive('getAttribute')->with('data')->andReturn([$account->id]);
Event::shouldReceive('fire')->with('limits.check');
Event::shouldReceive('fire')->with('piggybanks.check');
Event::shouldReceive('fire')->with('recurring.check');
$this->_reminders->shouldReceive('getCurrentRecurringReminders')->once()->andReturn([]);
// mock accounts:
$this->_repository->shouldReceive('count')->once()->andReturn(0);
@@ -80,7 +93,7 @@ class HomeControllerTest extends TestCase
$this->_preferences->shouldReceive('get')->with('frontpageAccounts', [])->andReturn($preference);
// mock journals:
$this->_journals->shouldReceive('getByAccountInDateRange')->once()->with($account, 15, $start, $end)->andReturn(
$this->_journals->shouldReceive('getByAccountInDateRange')->once()->with($account, 10, $start, $end)->andReturn(
[1, 2]
);
@@ -104,6 +117,12 @@ class HomeControllerTest extends TestCase
$preference = $this->mock('Preference');
$preference->shouldReceive('getAttribute')->with('data')->andReturn($ids);
Event::shouldReceive('fire')->with('limits.check');
Event::shouldReceive('fire')->with('piggybanks.check');
Event::shouldReceive('fire')->with('recurring.check');
$this->_reminders->shouldReceive('getCurrentRecurringReminders')->once()->andReturn([]);
// mock accounts:
$this->_repository->shouldReceive('count')->once()->andReturn(0);

View File

@@ -1,6 +1,6 @@
<?php
use Mockery as m;
use League\FactoryMuffin\Facade as f;
use Mockery as m;
/**
* Class LimitControllerTest

View File

@@ -1,7 +1,7 @@
<?php
use Mockery as m;
use League\FactoryMuffin\Facade as f;
use Mockery as m;
/**
@@ -171,7 +171,7 @@ class PiggybankControllerTest extends TestCase
$input = [
$piggyBank->id,
'amount' => 10.0,
'what' => 'add'
'what' => 'add'
];
// for binding
@@ -181,7 +181,7 @@ class PiggybankControllerTest extends TestCase
$piggyBank->account()->first()->user_id
);
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
Event::shouldReceive('fire');//->with('piggybanks.modifyAmountAdd', [$piggyBank, 10.0]);
Event::shouldReceive('fire'); //->with('piggybanks.modifyAmountAdd', [$piggyBank, 10.0]);
$this->_piggybanks->shouldReceive('modifyAmount')->once();
$this->_piggybanks->shouldReceive('leftOnAccount')->once()->andReturn(200);
@@ -201,7 +201,7 @@ class PiggybankControllerTest extends TestCase
$input = [
$piggyBank->id,
'amount' => 10.0,
'what' => 'add'
'what' => 'add'
];
// for binding
@@ -230,7 +230,7 @@ class PiggybankControllerTest extends TestCase
$input = [
$piggyBank->id,
'amount' => 10.0,
'what' => 'yomoma'
'what' => 'yomoma'
];
// for binding
@@ -269,7 +269,7 @@ class PiggybankControllerTest extends TestCase
$input = [
$rep->piggybank()->first()->id,
'amount' => 10.0,
'what' => 'remove'
'what' => 'remove'
];
$this->action('POST', 'PiggybankController@modMoney', $input);
@@ -299,7 +299,7 @@ class PiggybankControllerTest extends TestCase
$input = [
$rep->piggybank()->first()->id,
'amount' => 10.0,
'what' => 'remove'
'what' => 'remove'
];
$this->action('POST', 'PiggybankController@modMoney', $input);
@@ -308,48 +308,6 @@ class PiggybankControllerTest extends TestCase
}
public function teststorePiggybank()
{
$piggy = f::create('Piggybank');
$piggy->repeats = 0;
$piggy->save();
Event::shouldReceive('fire')->with('piggybanks.store',[$piggy])->once();
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
$this->action('POST', 'PiggybankController@storePiggybank');
$this->assertResponseStatus(302);
}
public function testStoreRepeated()
{
$piggy = f::create('Piggybank');
$piggy->repeats = 1;
$piggy->save();
Event::shouldReceive('fire')->with('piggybanks.store',[$piggy])->once();
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
$this->action('POST', 'PiggybankController@storeRepeated');
$this->assertResponseStatus(302);
}
public function teststorePiggybankFails()
{
$piggy = f::create('Piggybank');
unset($piggy->id);
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
$this->action('POST', 'PiggybankController@storePiggybank');
$this->assertResponseStatus(302);
}
public function testStoreRepeatedFails()
{
$piggy = f::create('Piggybank');
unset($piggy->id);
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
$this->action('POST', 'PiggybankController@storeRepeated');
$this->assertResponseStatus(302);
}
public function testRemoveMoneyGET()
{
$pig = $this->mock('Piggybank');
@@ -375,19 +333,48 @@ class PiggybankControllerTest extends TestCase
public function testShow()
{
$piggyBank = f::create('Piggybank');
// for binding
$pig = $this->mock('Piggybank');
$piggybank = f::create('Piggybank');
$rep = f::create('PiggybankRepetition');
$rep->piggybank_id = $piggybank->id;
$rep->save();
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn(
$piggyBank->account()->first()->user_id
$piggybank->account()->first()->user_id
);
$this->_user->shouldReceive('getAttribute')->andReturn('some@email');
$this->action('GET', 'PiggybankController@show', $piggyBank->id);
$pig->shouldReceive('currentRelevantRep')->andReturn($rep);
// repos:
$this->_piggybanks->shouldReceive('leftOnAccount');
$this->action('GET', 'PiggybankController@show', $piggybank->id);
$this->assertResponseOk();
}
public function testStoreRepeated()
{
$piggy = f::create('Piggybank');
$piggy->repeats = 1;
$piggy->save();
Event::shouldReceive('fire')->with('piggybanks.store', [$piggy])->once();
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
$this->action('POST', 'PiggybankController@storeRepeated');
$this->assertResponseStatus(302);
}
public function testStoreRepeatedFails()
{
$piggy = f::create('Piggybank');
unset($piggy->id);
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
$this->action('POST', 'PiggybankController@storeRepeated');
$this->assertResponseStatus(302);
}
public function testUpdate()
{
$piggyBank = f::create('Piggybank');
@@ -401,7 +388,7 @@ class PiggybankControllerTest extends TestCase
$piggyBank->account()->first()->user_id
);
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
Event::shouldReceive('fire')->with('piggybanks.update',[$piggyBank]);
Event::shouldReceive('fire')->with('piggybanks.update', [$piggyBank]);
$this->action('POST', 'PiggybankController@update', $piggyBank->id);
$this->assertResponseStatus(302);
@@ -427,5 +414,27 @@ class PiggybankControllerTest extends TestCase
$this->assertResponseStatus(302);
}
public function teststorePiggybank()
{
$piggy = f::create('Piggybank');
$piggy->repeats = 0;
$piggy->save();
Event::shouldReceive('fire')->with('piggybanks.store', [$piggy])->once();
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
$this->action('POST', 'PiggybankController@storePiggybank');
$this->assertResponseStatus(302);
}
public function teststorePiggybankFails()
{
$piggy = f::create('Piggybank');
unset($piggy->id);
$this->_piggybanks->shouldReceive('store')->once()->andReturn($piggy);
$this->action('POST', 'PiggybankController@storePiggybank');
$this->assertResponseStatus(302);
}
}

View File

@@ -1,6 +1,6 @@
<?php
use Mockery as m;
use League\FactoryMuffin\Facade as f;
use Mockery as m;
/**
* Class ProfileControllerTest

View File

@@ -1,6 +1,6 @@
<?php
use Mockery as m;
use League\FactoryMuffin\Facade as f;
use Mockery as m;
/**
* Class RecurringControllerTest
@@ -40,6 +40,8 @@ class RecurringControllerTest extends TestCase
{
$recurringTransaction = f::create('RecurringTransaction');
// for binding
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
@@ -55,6 +57,8 @@ class RecurringControllerTest extends TestCase
{
$recurringTransaction = f::create('RecurringTransaction');
Event::shouldReceive('fire')->with('recurring.destroy',m::any());
// for binding
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
@@ -73,6 +77,7 @@ class RecurringControllerTest extends TestCase
// for binding
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
Event::shouldReceive('fire')->with('recurring.destroy',m::any());
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($recurringTransaction->user_id);
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
$this->_repository->shouldReceive('destroy')->andReturn(false);
@@ -123,6 +128,8 @@ class RecurringControllerTest extends TestCase
{
$recurringTransaction = f::create('RecurringTransaction');
Event::shouldReceive('fire')->with('recurring.store',m::any());
$this->_repository->shouldReceive('store')->andReturn($recurringTransaction);
$this->action('POST', 'RecurringController@store');
$this->assertResponseStatus(302);
@@ -132,6 +139,8 @@ class RecurringControllerTest extends TestCase
{
$recurringTransaction = f::create('RecurringTransaction');
Event::shouldReceive('fire')->with('recurring.store',m::any());
$this->_repository->shouldReceive('store')->andReturn($recurringTransaction);
$this->action('POST', 'RecurringController@store', ['create' => '1']);
$this->assertResponseStatus(302);
@@ -158,6 +167,8 @@ class RecurringControllerTest extends TestCase
$this->_user->shouldReceive('getAttribute')->with('id')->andReturn($recurringTransaction->user_id);
$this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
Event::shouldReceive('fire')->with('recurring.update',m::any());
$this->_repository->shouldReceive('update')->andReturn($recurringTransaction);

View File

@@ -1,7 +1,7 @@
<?php
use Mockery as m;
use League\FactoryMuffin\Facade as f;
use Mockery as m;
/**
* Class TransactionControllerTest

View File

@@ -1,7 +1,7 @@
<?php
use Mockery as m;
use League\FactoryMuffin\Facade as f;
use Mockery as m;
/**