Expand test coverage.

This commit is contained in:
James Cole
2017-12-23 17:42:07 +01:00
parent 8bd76d1ff0
commit 08b743ddcb
82 changed files with 1413 additions and 142 deletions

View File

@@ -99,13 +99,13 @@ class LinkController extends Controller
JournalRepositoryInterface $journalRepository,
TransactionJournal $journal
) {
Log::debug('We are here (store)');
$linkInfo = $request->getLinkInfo();
if (0 === $linkInfo['transaction_journal_id']) {
Session::flash('error', trans('firefly.invalid_link_selection'));
return redirect(route('transactions.show', [$journal->id]));
}
$linkType = $repository->find($linkInfo['link_type_id']);
$other = $journalRepository->find($linkInfo['transaction_journal_id']);
$alreadyLinked = $repository->findLink($journal, $other);
if ($alreadyLinked) {
@@ -115,22 +115,7 @@ class LinkController extends Controller
}
Log::debug(sprintf('Journal is %d, opposing is %d', $journal->id, $other->id));
$journalLink = new TransactionJournalLink;
$journalLink->linkType()->associate($linkType);
if ('inward' === $linkInfo['direction']) {
Log::debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->inward, $other->id, $journal->id));
$journalLink->source()->associate($other);
$journalLink->destination()->associate($journal);
}
if ('outward' === $linkInfo['direction']) {
Log::debug(sprintf('Link type is inwards ("%s"), so %d is source and %d is destination.', $linkType->outward, $journal->id, $other->id));
$journalLink->source()->associate($journal);
$journalLink->destination()->associate($other);
}
$journalLink->comment = $linkInfo['comments'];
$journalLink->save();
$repository->storeLink($linkInfo, $other, $journal);
Session::flash('success', trans('firefly.journals_linked'));
return redirect(route('transactions.show', [$journal->id]));