Expanded test coverage.

This commit is contained in:
James Cole 2015-02-01 12:07:06 +01:00
parent 13d3d40376
commit 6b0a711395
9 changed files with 34 additions and 42 deletions

View File

@ -329,6 +329,8 @@ class GoogleChartController extends BaseController
*
* @param Budget $budget
*
* @param int $year
*
* @return \Illuminate\Http\JsonResponse
*/
public function budgetsAndSpending(Budget $budget, $year = 0)

View File

@ -79,9 +79,11 @@ class UserController extends BaseController
if ($user) {
$result = $email->sendVerificationMail($user);
if ($result === false && Config::get('mail.pretend') === false) {
// @CodeCoverageIgnoreStart
$user->delete();
return View::make('error')->with('message', 'The email message could not be send. See the log files.');
// @CodeCoverageIgnoreEnd
}
return View::make('user.verification-pending');

View File

@ -432,6 +432,7 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
* Returns all objects.
*
* @return Collection
* @throws NotImplementedException
* @codeCoverageIgnore
*/
public function get()

View File

@ -37,7 +37,9 @@ class FF3ServiceProvider extends ServiceProvider
*/
public function provides()
{
// @CodeCoverageIgnoreStart
return ['reminders', 'filters', 'datekit', 'navigation'];
// @CodeCoverageIgnoreEnd
}
/**

View File

@ -50,7 +50,7 @@ class Related implements RelatedInterface
// get already related transactions:
$exclude = [$journal->id];
foreach ($journal->transactiongroups()->get() as $group) {
foreach ($group->transactionjournals() as $current) {
foreach ($group->transactionjournals()->get() as $current) {
$exclude[] = $current->id;
}
}

View File

@ -243,49 +243,9 @@ class Report implements ReportInterface
$start->startOfMonth();
$end = clone $date;
$end->endOfMonth();
$userId = $this->_accounts->getUser()->id;
return $this->_queries->incomeByPeriod($start, $end);
// $list = \TransactionJournal::leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
// ->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
// ->leftJoin(
// 'account_meta', function (JoinClause $join) {
// $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
// }
// )
// ->transactionTypes(['Deposit'])
// ->where('transaction_journals.user_id', $userId)
// ->where('transactions.amount', '>', 0)
// ->where('transaction_journals.user_id', \Auth::user()->id)
// ->where('account_meta.data', '!=', '"sharedExpense"')
// ->orderBy('date', 'ASC')
// ->before($end)->after($start)->get(['transaction_journals.*']);
//
// // incoming from a shared account: it's profit (income):
// $transfers = \TransactionJournal::withRelevantData()
// ->leftJoin('transactions', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
// ->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')
// ->leftJoin(
// 'account_meta', function (JoinClause $join) {
// $join->on('account_meta.account_id', '=', 'accounts.id')->where('account_meta.name', '=', 'accountRole');
// }
// )
// ->transactionTypes(['Transfer'])
// ->where('transaction_journals.user_id', $userId)
// ->where('transactions.amount', '<', 0)
// ->where('account_meta.data', '=', '"sharedExpense"')
// ->orderBy('date', 'ASC')
// ->before($end)->after($start)->get(['transaction_journals.*']);
//
// $list = $list->merge($transfers);
// $list->sort(
// function (\TransactionJournal $journal) {
// return $journal->date->format('U');
// }
// );
//
// return $list;
}

View File

@ -86,6 +86,7 @@ class Account extends Eloquent
/**
*
* @param EloquentBuilder $query
* @param string $field
*/
public function scopeWithMeta(EloquentBuilder $query, $field = 'accountRole')
{

View File

@ -82,13 +82,19 @@ class TransactionJournal extends Eloquent
return ['created_at', 'updated_at', 'date'];
}
/**
* @param $value
*
* @return string
*/
public function getDescriptionAttribute($value)
{
if ($this->encrypted) {
return Crypt::decrypt($value);
}
// @CodeCoverageIgnoreStart
return $value;
// @CodeCoverageIgnoreEnd
}
/**
@ -207,6 +213,9 @@ class TransactionJournal extends Eloquent
);
}
/**
* @param $value
*/
public function setDescriptionAttribute($value)
{
$this->attributes['description'] = Crypt::encrypt($value);

View File

@ -69,6 +69,21 @@ class TransactionControllerCest
}
public function destroyTransferWithEvent(FunctionalTester $I)
{
// get withdrawal transaction type id:
$row = DB::table('piggy_bank_events')->whereNotNull('transaction_journal_id')->first();
$journalId = $row->transaction_journal_id;
$journal = TransactionJournal::find($journalId);
$I->wantTo('destroy a transfer connected to a piggy bank');
$I->amOnPage('/transaction/delete/' . $journal->id);
$I->submitForm('#destroy', []);
$I->see('Transaction &quot;' . $journal->description . '&quot; destroyed.');
}
public function destroyWithdrawal(FunctionalTester $I)
{
// get withdrawal transaction type id: