mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-04 03:43:07 +00:00
Fixes for tests.
This commit is contained in:
@@ -35,27 +35,11 @@ class Limit extends Ardent
|
||||
'component_id' => 'required|exists:components,id',
|
||||
'startdate' => 'required|date',
|
||||
'amount' => 'numeric|required|min:0.01',
|
||||
'repeats' => 'required|between:0,1',
|
||||
'repeats' => 'required|boolean',
|
||||
'repeat_freq' => 'required|in:daily,weekly,monthly,quarterly,half-year,yearly'
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function factory()
|
||||
{
|
||||
$start = new Carbon;
|
||||
$start->startOfMonth();
|
||||
|
||||
return [
|
||||
'component_id' => 'factory|Budget',
|
||||
'startdate' => $start,
|
||||
'amount' => '100',
|
||||
'repeats' => 0,
|
||||
'repeat_freq' => 'monthly'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
|
@@ -31,24 +31,6 @@ class LimitRepetition extends Ardent
|
||||
'amount' => 'numeric|required|min:0.01',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function factory()
|
||||
{
|
||||
$start = new \Carbon\Carbon;
|
||||
$start->startOfMonth();
|
||||
$end = clone $start;
|
||||
$end->endOfMonth();
|
||||
|
||||
return [
|
||||
'limit_id' => 'factory|Limit',
|
||||
'startdate' => $start,
|
||||
'enddate' => $end,
|
||||
'amount' => 100
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
@@ -32,23 +32,6 @@ class PiggybankRepetition extends Ardent
|
||||
'currentamount' => 'required|numeric'
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function factory()
|
||||
{
|
||||
$start = new Carbon;
|
||||
$start->startOfMonth();
|
||||
$end = new Carbon;
|
||||
$end->endOfMonth();
|
||||
|
||||
return [
|
||||
'piggybank_id' => 'factory|Piggybank',
|
||||
'startdate' => $start->format('Y-m-d'),
|
||||
'targetdate' => $end->format('Y-m-d'),
|
||||
'currentamount' => 200
|
||||
];
|
||||
}
|
||||
|
||||
public function pct() {
|
||||
$total = $this->piggybank->targetamount;
|
||||
|
@@ -52,22 +52,6 @@ class TransactionJournal extends Ardent
|
||||
'completed' => 'required|between:0,1'
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function factory()
|
||||
{
|
||||
$date = new \Carbon\Carbon;
|
||||
|
||||
return [
|
||||
'transaction_type_id' => 'factory|TransactionType',
|
||||
'transaction_currency_id' => 'factory|TransactionCurrency',
|
||||
'description' => 'string',
|
||||
'completed' => '1',
|
||||
'user_id' => 'factory|User',
|
||||
'date' => $date
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
|
@@ -17,10 +17,6 @@ use LaravelBook\Ardent\Ardent;
|
||||
*/
|
||||
class TransactionType extends Ardent
|
||||
{
|
||||
public static $factory
|
||||
= [
|
||||
'type' => 'string'
|
||||
];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
use League\FactoryMuffin\Facade;
|
||||
|
||||
Facade::define(
|
||||
'Budget',
|
||||
'Category',
|
||||
[
|
||||
'name' => 'word',
|
||||
'user_id' => 'factory|User',
|
||||
|
24
app/tests/factories/Limit.php
Normal file
24
app/tests/factories/Limit.php
Normal 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)];
|
||||
}
|
||||
|
||||
|
||||
]
|
||||
);
|
26
app/tests/factories/LimitRepetition.php
Normal file
26
app/tests/factories/LimitRepetition.php
Normal 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
|
||||
|
||||
|
||||
]
|
||||
);
|
30
app/tests/factories/Piggybank.php
Normal file
30
app/tests/factories/Piggybank.php
Normal 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,
|
||||
]
|
||||
);
|
23
app/tests/factories/PiggybankRepetition.php
Normal file
23
app/tests/factories/PiggybankRepetition.php
Normal 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
|
||||
]
|
||||
);
|
23
app/tests/factories/RecurringTransaction.php
Normal file
23
app/tests/factories/RecurringTransaction.php
Normal 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',
|
||||
|
||||
]
|
||||
);
|
12
app/tests/factories/TransactionCurrency.php
Normal file
12
app/tests/factories/TransactionCurrency.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use League\FactoryMuffin\Facade;
|
||||
|
||||
Facade::define(
|
||||
'TransactionCurrency',
|
||||
[
|
||||
'code' => 'EUR'
|
||||
]
|
||||
);
|
17
app/tests/factories/TransactionJournal.php
Normal file
17
app/tests/factories/TransactionJournal.php
Normal 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
|
||||
]
|
||||
);
|
15
app/tests/factories/TransactionType.php
Normal file
15
app/tests/factories/TransactionType.php
Normal 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)];
|
||||
}
|
||||
]
|
||||
);
|
71
app/views/recurring/show.blade.php
Normal file
71
app/views/recurring/show.blade.php
Normal file
@@ -0,0 +1,71 @@
|
||||
@extends('layouts.default')
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<h1>Firefly
|
||||
<small>Recurring transaction "{{{$recurring->name}}}"</small>
|
||||
</h1>
|
||||
<p class="lead">Use recurring transactions to track repeated withdrawals</p>
|
||||
<p>
|
||||
<div class="btn-group btn-group-xs">
|
||||
<a href="{{route('recurring.edit',$recurring->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span> edit</a>
|
||||
<a href="{{route('recurring.delete',$recurring->id)}}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> delete</a>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-sm-6 col-md-12">
|
||||
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td>Matches on: </td>
|
||||
<td>
|
||||
@foreach(explode(' ',$recurring->match) as $word)
|
||||
<span class="label label-info">{{{$word}}}</span>
|
||||
@endforeach
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Between</td>
|
||||
<td> {{mf($recurring->amount_min)}} – {{mf($recurring->amount_max)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Repeats</td>
|
||||
<td>{{ucfirst($recurring->repeat_freq)}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Next reminder</td>
|
||||
<td>{{$recurring->next()->format('d-m-Y')}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Will be auto-matched</td>
|
||||
<td>
|
||||
@if($recurring->automatch)
|
||||
<span class="glyphicon glyphicon-ok"></span>
|
||||
@else
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Is active</td>
|
||||
|
||||
<td>
|
||||
@if($recurring->active)
|
||||
<span class="glyphicon glyphicon-ok"></span>
|
||||
@else
|
||||
<span class="glyphicon glyphicon-remove"></span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<td>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
Reference in New Issue
Block a user