Reformatted and checked everything. [skip ci]

This commit is contained in:
James Cole
2014-07-25 13:02:01 +02:00
parent bcd48f2e49
commit 30d5b88769
45 changed files with 980 additions and 330 deletions

View File

@@ -15,17 +15,16 @@ class AccountControllerTest extends TestCase
{
// mock account type(s):
$personal = $this->mock('AccountType');
$personal->shouldReceive('getAttribute','description')->andReturn('Default account');
$personal->shouldReceive('getAttribute', 'description')->andReturn('Default account');
$bene = $this->mock('AccountType');
$bene->shouldReceive('getAttribute','description')->andReturn('Beneficiary account');
$bene->shouldReceive('getAttribute', 'description')->andReturn('Beneficiary account');
$initial = $this->mock('AccountType');
$initial->shouldReceive('getAttribute','description')->andReturn('Initial balance account');
$initial->shouldReceive('getAttribute', 'description')->andReturn('Initial balance account');
$cash = $this->mock('AccountType');
$cash->shouldReceive('getAttribute','description')->andReturn('Cash account');
$cash->shouldReceive('getAttribute', 'description')->andReturn('Cash account');
// mock account(s)
@@ -40,16 +39,13 @@ class AccountControllerTest extends TestCase
$four = $this->mock('Account');
$four->shouldReceive('getAttribute')->andReturn($cash);
$c = new \Illuminate\Database\Eloquent\Collection([$one,$two,$three,$four]);
$c = new \Illuminate\Database\Eloquent\Collection([$one, $two, $three, $four]);
// mock account repository:
$accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
$accounts->shouldReceive('get')->andReturn($c);
$list = [
'personal' => [$one],
'beneficiaries' => [$two],
@@ -60,11 +56,10 @@ class AccountControllerTest extends TestCase
// mock:
View::shouldReceive('share');
View::shouldReceive('make')->with('accounts.index')->once()->andReturn(\Mockery::self())
->shouldReceive('with')->once()->with('accounts',$list)->andReturn(\Mockery::self())
->shouldReceive('with')->once()->with('accounts', $list)->andReturn(\Mockery::self())
->shouldReceive('with')->once()->with('total', 4)->andReturn(\Mockery::self());
// call
$this->call('GET', '/accounts');

View File

@@ -1,7 +1,8 @@
<?php
use \League\FactoryMuffin\Facade\FactoryMuffin;
use League\FactoryMuffin\Facade\FactoryMuffin;
/**
* Class BudgetControllerTest
*/
@@ -24,7 +25,6 @@ class BudgetControllerTest extends TestCase
$budget->limits()->save($limit);
// mock budget repository:
$budgets = $this->mock('Firefly\Storage\Budget\BudgetRepositoryInterface');
$budgets->shouldReceive('get')->once()->andReturn([$budget]);
@@ -46,7 +46,6 @@ class BudgetControllerTest extends TestCase
$budget->limits()->save($limit);
// mock budget repository:
$budgets = $this->mock('Firefly\Storage\Budget\BudgetRepositoryInterface');
$budgets->shouldReceive('get')->once()->andReturn([$budget]);
@@ -70,10 +69,10 @@ class BudgetControllerTest extends TestCase
public function testStore()
{
$data = [
'name' => 'X',
'amount' => 100,
'period' => 'monthly',
'repeats' => 0
'name' => 'X',
'amount' => 100,
'period' => 'monthly',
'repeats' => 0
];
$return = $data;
$return['repeat_freq'] = 'monthly';
@@ -84,7 +83,7 @@ class BudgetControllerTest extends TestCase
$budgets->shouldReceive('store')->with($return)->once()->andReturn(true);
// call
$this->call('POST', '/budget/store',$data);
$this->call('POST', '/budget/store', $data);
// test
$this->assertResponseStatus(302);
@@ -106,7 +105,7 @@ class BudgetControllerTest extends TestCase
// call
$this->call('GET', '/budget/show/'.$budget->id);
$this->call('GET', '/budget/show/' . $budget->id);
// test
$this->assertResponseOk();

View File

@@ -181,7 +181,7 @@ class ChartControllerTest extends TestCase
{
$account = FactoryMuffin::create('Account');
$second = FactoryMuffin::create('Account');
$date = \Carbon\Carbon::createFromDate('2012','01','01');
$date = \Carbon\Carbon::createFromDate('2012', '01', '01');
$transaction = FactoryMuffin::create('Transaction');
$transaction->account()->associate($second);
$journal = FactoryMuffin::create('TransactionJournal');
@@ -196,13 +196,8 @@ class ChartControllerTest extends TestCase
$tj->shouldReceive('getByAccountAndDate')->once()->andReturn([$journal]);
// call
$this->call('GET', '/chart/home/info/'.$account->name.'/'.$date->format('d/m/Y'));
$this->call('GET', '/chart/home/info/' . $account->name . '/' . $date->format('d/m/Y'));
// test
$this->assertResponseOk();

View File

@@ -71,7 +71,7 @@ class HomeControllerTest extends TestCase
// mock transaction journal repository:
$tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
$tj->shouldReceive('getByAccount')->with($account,15)->andReturn([]);
$tj->shouldReceive('getByAccount')->with($account, 15)->andReturn([]);
// mock preferences & pref:
$pref = $this->mock('Preference');

View File

@@ -1,12 +1,14 @@
<?php
class JsonControllerTest extends TestCase {
class JsonControllerTest extends TestCase
{
public function setUp()
{
parent::setUp();
}
public function testBeneficiaries() {
public function testBeneficiaries()
{
$obj = new stdClass;
$obj->name = 'Bla bla';
@@ -22,7 +24,8 @@ class JsonControllerTest extends TestCase {
}
public function testCategories() {
public function testCategories()
{
$obj = new stdClass;
$obj->name = 'Bla bla';
@@ -35,6 +38,7 @@ class JsonControllerTest extends TestCase {
// test
$this->assertResponseOk();
}
public function tearDown()
{
Mockery::close();

View File

@@ -57,6 +57,7 @@ class PreferencesControllerTest extends TestCase
$this->assertSessionHas('success');
$this->assertRedirectedToRoute('preferences');
}
public function tearDown()
{
Mockery::close();

View File

@@ -30,7 +30,7 @@ class TransactionControllerTest extends TestCase
View::shouldReceive('share');
View::shouldReceive('make')->with('transactions.create')->andReturn(\Mockery::self())
->shouldReceive('with')->once()
->with('what','withdrawal')
->with('what', 'withdrawal')
->andReturn(Mockery::self())
->shouldReceive('with')->once()
->with('accounts', [])
@@ -61,7 +61,7 @@ class TransactionControllerTest extends TestCase
View::shouldReceive('share');
View::shouldReceive('make')->with('transactions.create')->andReturn(\Mockery::self())
->shouldReceive('with')->once()
->with('what','deposit')
->with('what', 'deposit')
->andReturn(Mockery::self())
->shouldReceive('with')->once()
@@ -393,7 +393,7 @@ class TransactionControllerTest extends TestCase
$this->call('POST', '/transactions/store/withdrawal', $data);
// test
$this->assertRedirectedToRoute('transactions.create',['what' => 'withdrawal']);
$this->assertRedirectedToRoute('transactions.create', ['what' => 'withdrawal']);
}
/**
@@ -443,7 +443,7 @@ class TransactionControllerTest extends TestCase
$this->call('POST', '/transactions/store/deposit', $data);
// test
$this->assertRedirectedToRoute('transactions.create',['what' => 'deposit']);
$this->assertRedirectedToRoute('transactions.create', ['what' => 'deposit']);
}
/**
@@ -488,10 +488,11 @@ class TransactionControllerTest extends TestCase
$this->call('POST', '/transactions/store/transfer', $data);
// test
$this->assertRedirectedToRoute('transactions.create',['what' => 'transfer']);
$this->assertRedirectedToRoute('transactions.create', ['what' => 'transfer']);
}
public function testShow() {
public function testShow()
{
$journal = FactoryMuffin::create('TransactionJournal');
// mock transaction journal:
@@ -499,7 +500,6 @@ class TransactionControllerTest extends TestCase
$tj->shouldReceive('find')->with($journal->id)->andReturn($journal);
// call
$this->call('GET', '/transaction/show/' . $journal->id);
@@ -507,7 +507,8 @@ class TransactionControllerTest extends TestCase
$this->assertResponseOk();
}
public function testShowError() {
public function testShowError()
{
// mock transaction journal:
$tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
@@ -521,7 +522,8 @@ class TransactionControllerTest extends TestCase
$this->assertViewHas('message');
}
public function testEdit() {
public function testEdit()
{
$journal = FactoryMuffin::create('TransactionJournal');
// mock transaction journal:
@@ -533,7 +535,6 @@ class TransactionControllerTest extends TestCase
$accounts->shouldReceive('getActiveDefaultAsSelectList')->andReturn([]);
// call
$this->call('GET', '/transaction/edit/' . $journal->id);
@@ -541,7 +542,8 @@ class TransactionControllerTest extends TestCase
$this->assertResponseOk();
}
public function testEditError() {
public function testEditError()
{
// mock transaction journal:
$tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
$tj->shouldReceive('find')->with(1)->andReturn(null);

View File

@@ -64,7 +64,7 @@ class UserControllerTest extends TestCase
// test
$this->call('GET', '/register');
$this->assertResponseStatus(200);
$this->assertViewHas('message','Not possible');
$this->assertViewHas('message', 'Not possible');
}
/**
@@ -94,7 +94,6 @@ class UserControllerTest extends TestCase
}
/**
* Register and verify FAILED:
*/
@@ -189,7 +188,7 @@ class UserControllerTest extends TestCase
$this->call('POST', '/remindme');
$this->assertResponseOk();
$this->assertSessionHas('error','No good!');
$this->assertSessionHas('error', 'No good!');
}
public function testPostRegisterNotAllowed()
@@ -207,7 +206,7 @@ class UserControllerTest extends TestCase
// test
$this->call('POST', '/register', $data);
$this->assertResponseStatus(200);
$this->assertViewHas('message','Not possible');
$this->assertViewHas('message', 'Not possible');
}