Fixes for tests.

This commit is contained in:
James Cole
2014-08-21 15:16:12 +02:00
parent fdba0addb6
commit a0b12ece54
16 changed files with 246 additions and 73 deletions

View File

@@ -71,6 +71,8 @@ class ProfileControllerTest extends TestCase
public function testPostChangePasswordOK()
{
$user = f::create('User');
$user->password = 'sander';
$user->save();
// for binding
Auth::shouldReceive('user')->andReturn($user);
Auth::shouldReceive('check')->andReturn(true);
@@ -82,6 +84,7 @@ class ProfileControllerTest extends TestCase
'POST', 'ProfileController@postChangePassword',
['old' => 'sander', 'new1' => 'sander2', 'new2' => 'sander2']
);
$this->assertSessionHas('success');
$this->assertResponseStatus(302);
}

View File

@@ -2,7 +2,7 @@
use League\FactoryMuffin\Facade;
Facade::define(
'Budget',
'Category',
[
'name' => 'word',
'user_id' => 'factory|User',

View File

@@ -0,0 +1,24 @@
<?php
use Carbon\Carbon;
use League\FactoryMuffin\Facade;
Facade::define(
'Limit',
[
'component_id' => 'factory|Budget',
'startdate' => function () {
$start = new Carbon;
$start->startOfMonth();
return $start;
},
'amount' => 100,
'repeats' => 'boolean',
'repeat_freq' => function(){
$frequencies = ['daily','weekly','monthly','quarterly','half-year','yearly'];
return $frequencies[rand(0,5)];
}
]
);

View File

@@ -0,0 +1,26 @@
<?php
use Carbon\Carbon;
use League\FactoryMuffin\Facade;
Facade::define(
'LimitRepetition',
[
'limit_id' => 'factory|Limit',
'startdate' => function () {
$start = new Carbon;
$start->startOfMonth();
return $start;
},
'enddate' => function () {
$end = new Carbon;
$end->endOfMonth();
return $end;
},
'amount' => 100
]
);

View File

@@ -0,0 +1,30 @@
<?php
use Carbon\Carbon;
use League\FactoryMuffin\Facade;
Facade::define(
'Piggybank',
[
'account_id' => 'factory|Account',
'name' => 'string',
'targetamount' => 'integer',
'startdate' => function () {
$start = new Carbon;
$start->startOfMonth();
return $start;
},
'targetdate' => function () {
$end = new Carbon;
$end->endOfMonth();
return $end;
},
'repeats' => 0,
'rep_length' => null,
'rep_times' => 0,
'rep_every' => 0,
'reminder' => null,
'reminder_skip' => 0,
'order' => 1,
]
);

View File

@@ -0,0 +1,23 @@
<?php
use Carbon\Carbon;
use League\FactoryMuffin\Facade;
Facade::define(
'PiggybankRepetition',
[
'piggybank_id' => 'factory|Piggybank',
'startdate' => function () {
$start = new Carbon;
$start->startOfMonth();
return $start;
},
'targetdate' => function () {
$end = new Carbon;
$end->endOfMonth();
return $end;
},
'currentamount' => 200
]
);

View File

@@ -0,0 +1,23 @@
<?php
use Carbon\Carbon;
use League\FactoryMuffin\Facade;
// TODO better factory.
Facade::define(
'RecurringTransaction',
[
'user_id' => 'factory|User',
'name' => 'string',
'match' => 'string',
'amount_max' => 100,
'amount_min' => 50,
'date' => new Carbon,
'active' => 'boolean',
'automatch' => 'boolean',
'repeat_freq' => 'monthly',
'skip' => 'boolean',
]
);

View File

@@ -0,0 +1,12 @@
<?php
use Carbon\Carbon;
use League\FactoryMuffin\Facade;
Facade::define(
'TransactionCurrency',
[
'code' => 'EUR'
]
);

View File

@@ -0,0 +1,17 @@
<?php
use Carbon\Carbon;
use League\FactoryMuffin\Facade;
Facade::define(
'TransactionJournal',
[
'transaction_type_id' => 'factory|TransactionType',
'transaction_currency_id' => 'factory|TransactionCurrency',
'description' => 'word',
'completed' => 'boolean',
'user_id' => 'factory|User',
'date' => new Carbon
]
);

View File

@@ -0,0 +1,15 @@
<?php
use Carbon\Carbon;
use League\FactoryMuffin\Facade;
Facade::define(
'TransactionType',
[
'type' => function() {
$types = ['Withdrawal','Deposit','Transfer','Opening balance'];
return $types[rand(0,3)];
}
]
);