Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Split controller tests.
James Cole5c02eaa66c6b
diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.phpindex 595fb2ddbe..eb061a862f 100644--- a/app/Http/Controllers/Transaction/SplitController.php+++ b/app/Http/Controllers/Transaction/SplitController.php@@ -131,6 +131,7 @@ class SplitController extends Controller*/public function update(Request $request, JournalRepositoryInterface $repository, TransactionJournal $journal){+if ($this->isOpeningBalance($journal)) {return $this->redirectToAccount($journal);}diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.phpindex 451777784c..a16717d6c3 100644--- a/app/Http/breadcrumbs.php+++ b/app/Http/breadcrumbs.php@@ -681,15 +681,8 @@ Breadcrumbs::register(* SPLIT*/Breadcrumbs::register(- 'transactions.edit-split', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {+ 'transactions.split.edit', function (BreadCrumbGenerator $breadcrumbs, TransactionJournal $journal) {$breadcrumbs->parent('transactions.show', $journal);- $breadcrumbs->push(trans('breadcrumbs.edit_journal', ['description' => $journal->description]), route('transactions.edit-split', [$journal->id]));-}-);--Breadcrumbs::register(- 'split.journal.create', function (BreadCrumbGenerator $breadcrumbs, string $what) {- $breadcrumbs->parent('transactions.index', $what);- $breadcrumbs->push(trans('breadcrumbs.create_' . e($what)), route('split.journal.create', [$what]));+ $breadcrumbs->push(trans('breadcrumbs.edit_journal', ['description' => $journal->description]), route('transactions.split.edit', [$journal->id]));});diff --git a/tests/acceptance/Controllers/Transaction/SplitControllerTest.php b/tests/acceptance/Controllers/Transaction/SplitControllerTest.phpindex 1771843c4c..68b777dd1c 100644--- a/tests/acceptance/Controllers/Transaction/SplitControllerTest.php+++ b/tests/acceptance/Controllers/Transaction/SplitControllerTest.php@@ -35,10 +35,11 @@ class SplitControllerTest extends TestCase*/public function testEdit(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );+ $this->be($this->user());+ $this->call('get', route('transactions.split.edit', [18]));+ $this->assertResponseStatus(200);+ // has bread crumb+ $this->see('<ol class="breadcrumb">');}/**@@ -47,17 +48,37 @@ class SplitControllerTest extends TestCase*/public function testUpdate(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );- }+ $this->session(['transactions.edit-split.url' => 'http://localhost']);- /**- * Tears down the fixture, for example, closes a network connection.- * This method is called after a test is executed.- */- protected function tearDown()- {+ $data = [+ 'id' => 18,+ 'what' => 'deposit',+ 'journal_description' => 'Updated salary',+ 'currency_id' => 1,+ 'journal_destination_account_id' => 1,+ 'journal_amount' => 1591,+ 'date' => '2014-01-24',+ 'tags' => '',+ 'transactions' => [+ [+ 'description' => 'Split #1',+ 'source_account_name' => 'Job',+ 'amount' => 1591,+ 'category' => '',+ ],+ ],+ ];+ $this->be($this->user());+ $this->call('post', route('transactions.split.update', [18]), $data);+ $this->assertResponseStatus(302);+ $this->assertSessionHas('success');++ // journal is updated?+ $this->call('get', route('transactions.show', [18]));+ $this->assertResponseStatus(200);+ $this->see('Updated salary');+ // has bread crumb+ $this->see('<ol class="breadcrumb">');}+}