Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Expand tests.
James Colebae2161ee31f
diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.phpindex ff685856e7..d22d725a0e 100644--- a/app/Models/TransactionType.php+++ b/app/Models/TransactionType.php@@ -43,7 +43,7 @@ class TransactionType extends Modelif (!auth()->check()) {throw new NotFoundHttpException;}- $transactionType = self::where('type', $type)->first();+ $transactionType = self::where('type', ucfirst($type))->first();if (!is_null($transactionType)) {return $transactionType;}diff --git a/tests/acceptance/Controllers/Popup/ReportControllerTest.php b/tests/acceptance/Controllers/Popup/ReportControllerTest.phpindex f68c134da3..e4efaa3933 100644--- a/tests/acceptance/Controllers/Popup/ReportControllerTest.php+++ b/tests/acceptance/Controllers/Popup/ReportControllerTest.php@@ -11,6 +11,7 @@namespace Popup;+use Carbon\Carbon;use TestCase;/**@@ -31,21 +32,118 @@ class ReportControllerTest extends TestCase/*** @covers \FireflyIII\Http\Controllers\Popup\ReportController::general- * Implement testGeneral().*/- public function testGeneral()+ public function testBalanceAmount(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );++ $this->be($this->user());+ $arguments = [+ 'attributes' => [+ 'location' => 'balance-amount',+ 'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),+ 'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),+ 'accounts' => 1,+ 'accountId' => 1,+ 'categoryId' => 1,+ 'budgetId' => 1,+ 'role' => 1,+ ],+ ];+ $uri = route('popup.general') . '?' . http_build_query($arguments);+ $this->call('get', $uri);+ $this->assertResponseStatus(200);}/**- * Tears down the fixture, for example, closes a network connection.- * This method is called after a test is executed.+ * @covers \FireflyIII\Http\Controllers\Popup\ReportController::general*/- protected function tearDown()+ public function testBudgetSpentAmount(){++ $this->be($this->user());+ $arguments = [+ 'attributes' => [+ 'location' => 'budget-spent-amount',+ 'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),+ 'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),+ 'accounts' => 1,+ 'accountId' => 1,+ 'categoryId' => 1,+ 'budgetId' => 1,+ ],+ ];+ $uri = route('popup.general') . '?' . http_build_query($arguments);+ $this->call('get', $uri);+ $this->assertResponseStatus(200);}++ /**+ * @covers \FireflyIII\Http\Controllers\Popup\ReportController::general+ */+ public function testCategoryEntry()+ {++ $this->be($this->user());+ $arguments = [+ 'attributes' => [+ 'location' => 'category-entry',+ 'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),+ 'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),+ 'accounts' => 1,+ 'accountId' => 1,+ 'categoryId' => 1,+ 'budgetId' => 1,+ ],+ ];+ $uri = route('popup.general') . '?' . http_build_query($arguments);+ $this->call('get', $uri);+ $this->assertResponseStatus(200);+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Popup\ReportController::general+ */+ public function testExpenseEntry()+ {++ $this->be($this->user());+ $arguments = [+ 'attributes' => [+ 'location' => 'expense-entry',+ 'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),+ 'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),+ 'accounts' => 1,+ 'accountId' => 1,+ 'categoryId' => 1,+ 'budgetId' => 1,+ ],+ ];+ $uri = route('popup.general') . '?' . http_build_query($arguments);+ $this->call('get', $uri);+ $this->assertResponseStatus(200);+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Popup\ReportController::general+ */+ public function testIncomeEntry()+ {++ $this->be($this->user());+ $arguments = [+ 'attributes' => [+ 'location' => 'income-entry',+ 'startDate' => Carbon::now()->startOfMonth()->format('Ymd'),+ 'endDate' => Carbon::now()->endOfMonth()->format('Ymd'),+ 'accounts' => 1,+ 'accountId' => 1,+ 'categoryId' => 1,+ 'budgetId' => 1,+ ],+ ];+ $uri = route('popup.general') . '?' . http_build_query($arguments);+ $this->call('get', $uri);+ $this->assertResponseStatus(200);+ }+}diff --git a/tests/acceptance/Controllers/Report/AccountControllerTest.php b/tests/acceptance/Controllers/Report/AccountControllerTest.phpindex 6c0d6fe0cf..40a1968bcf 100644--- a/tests/acceptance/Controllers/Report/AccountControllerTest.php+++ b/tests/acceptance/Controllers/Report/AccountControllerTest.php@@ -31,21 +31,12 @@ class AccountControllerTest extends TestCase/*** @covers \FireflyIII\Http\Controllers\Report\AccountController::general- * Implement testGeneral().*/public function testGeneral(){- // 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('report-data.account.general', ['1', '20120101', '20120131']));+ $this->assertResponseStatus(200);}- /**- * Tears down the fixture, for example, closes a network connection.- * This method is called after a test is executed.- */- protected function tearDown()- {- }}diff --git a/tests/acceptance/Controllers/Report/BalanceControllerTest.php b/tests/acceptance/Controllers/Report/BalanceControllerTest.phpindex e4bf4c5f97..aadfa39ec7 100644--- a/tests/acceptance/Controllers/Report/BalanceControllerTest.php+++ b/tests/acceptance/Controllers/Report/BalanceControllerTest.php@@ -31,21 +31,11 @@ class BalanceControllerTest extends TestCase/*** @covers \FireflyIII\Http\Controllers\Report\BalanceController::general- * Implement testGeneral().*/public function testGeneral(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );- }-- /**- * Tears down the fixture, for example, closes a network connection.- * This method is called after a test is executed.- */- protected function tearDown()- {+ $this->be($this->user());+ $this->call('get', route('report-data.balance.general', ['1', '20120101', '20120131']));+ $this->assertResponseStatus(200);}}diff --git a/tests/acceptance/Controllers/Report/BudgetControllerTest.php b/tests/acceptance/Controllers/Report/BudgetControllerTest.phpindex 055ab950d6..e13c2bf47c 100644--- a/tests/acceptance/Controllers/Report/BudgetControllerTest.php+++ b/tests/acceptance/Controllers/Report/BudgetControllerTest.php@@ -31,33 +31,21 @@ class BudgetControllerTest extends TestCase/*** @covers \FireflyIII\Http\Controllers\Report\BudgetController::general- * Implement testGeneral().*/public function testGeneral(){- // 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('report-data.budget.general', ['1', '20120101', '20120131']));+ $this->assertResponseStatus(200);}/*** @covers \FireflyIII\Http\Controllers\Report\BudgetController::period- * Implement testPeriod().*/public function testPeriod(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );- }-- /**- * Tears down the fixture, for example, closes a network connection.- * This method is called after a test is executed.- */- protected function tearDown()- {+ $this->be($this->user());+ $this->call('get', route('report-data.budget.period', ['1', '20120101', '20120131']));+ $this->assertResponseStatus(200);}}diff --git a/tests/acceptance/Controllers/Report/CategoryControllerTest.php b/tests/acceptance/Controllers/Report/CategoryControllerTest.phpindex 50a24e15db..44f12f599d 100644--- a/tests/acceptance/Controllers/Report/CategoryControllerTest.php+++ b/tests/acceptance/Controllers/Report/CategoryControllerTest.php@@ -31,45 +31,31 @@ class CategoryControllerTest extends TestCase/*** @covers \FireflyIII\Http\Controllers\Report\CategoryController::expenses- * Implement testExpenses().*/public function testExpenses(){- // 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('report-data.category.expenses', ['1', '20120101', '20120131']));+ $this->assertResponseStatus(200);}/*** @covers \FireflyIII\Http\Controllers\Report\CategoryController::income- * Implement testIncome().*/public function testIncome(){- // 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('report-data.category.income', ['1', '20120101', '20120131']));+ $this->assertResponseStatus(200);}/*** @covers \FireflyIII\Http\Controllers\Report\CategoryController::operations- * Implement testOperations().*/public function testOperations(){- // Remove the following lines when you implement this test.- $this->markTestIncomplete(- 'This test has not been implemented yet.'- );- }-- /**- * Tears down the fixture, for example, closes a network connection.- * This method is called after a test is executed.- */- protected function tearDown()- {+ $this->be($this->user());+ $this->call('get', route('report-data.category.operations', ['1', '20120101', '20120131']));+ $this->assertResponseStatus(200);}}diff --git a/tests/acceptance/Controllers/Report/OperationsControllerTest.php b/tests/acceptance/Controllers/Report/OperationsControllerTest.phpindex b37384af48..027bc2a0e9 100644--- a/tests/acceptance/Controllers/Report/OperationsControllerTest.php+++ b/tests/acceptance/Controllers/Report/OperationsControllerTest.php@@ -31,45 +31,32 @@ class OperationsControllerTest extends TestCase/*** @covers \FireflyIII\Http\Controllers\Report\OperationsController::expenses- * Implement testExpenses().*/public function testExpenses(){- // 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('report-data.operations.expenses', ['1', '20120101', '20120131']));+ $this->assertResponseStatus(200);}/*** @covers \FireflyIII\Http\Controllers\Report\OperationsController::income- * Implement testIncome().*/public function testIncome(){- // 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('report-data.operations.income', ['1', '20120101', '20120131']));+ $this->assertResponseStatus(200);}/*** @covers \FireflyIII\Http\Controllers\Report\OperationsController::operations- * Implement testOperations().*/public function testOperations(){- // 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('report-data.operations.operations', ['1', '20120101', '20120131']));+ $this->assertResponseStatus(200);}- /**- * Tears down the fixture, for example, closes a network connection.- * This method is called after a test is executed.- */- protected function tearDown()- {- }}diff --git a/tests/acceptance/Controllers/Transaction/ConvertControllerTest.php b/tests/acceptance/Controllers/Transaction/ConvertControllerTest.phpindex ca19665d35..6925ac1c2c 100644--- a/tests/acceptance/Controllers/Transaction/ConvertControllerTest.php+++ b/tests/acceptance/Controllers/Transaction/ConvertControllerTest.php@@ -31,33 +31,79 @@ class ConvertControllerTest extends TestCase/*** @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::index- * Implement testIndex().*/- public function testIndex()+ public function testIndexDepositTransfer(){- // 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.convert.index', ['transfer', 683]));+ $this->assertResponseStatus(200);+ $this->see('Convert a deposit into a transfer');}/**- * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::postIndex- * Implement testPostIndex().+ * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::index*/- public function testPostIndex()+ public function testIndexDepositWithdrawal(){- // 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.convert.index', ['withdrawal', 683]));+ $this->assertResponseStatus(200);+ $this->see('Convert a deposit into a withdrawal');}/**- * Tears down the fixture, for example, closes a network connection.- * This method is called after a test is executed.+ * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::index*/- protected function tearDown()+ public function testIndexTransferDeposit()+ {+ $this->be($this->user());+ $this->call('get', route('transactions.convert.index', ['deposit', 684]));+ $this->assertResponseStatus(200);+ $this->see('Convert a transfer into a deposit');+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::index+ */+ public function testIndexTransferWithdrawal()+ {+ $this->be($this->user());+ $this->call('get', route('transactions.convert.index', ['withdrawal', 684]));+ $this->assertResponseStatus(200);+ $this->see('Convert a transfer into a withdrawal');+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::index+ */+ public function testIndexWithdrawalDeposit()+ {+ $this->be($this->user());+ $this->call('get', route('transactions.convert.index', ['deposit', 672]));+ $this->assertResponseStatus(200);+ $this->see('Convert a withdrawal into a deposit');+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::index+ */+ public function testIndexWithdrawalTransfer()+ {+ $this->be($this->user());+ $this->call('get', route('transactions.convert.index', ['transfer', 672]));+ $this->assertResponseStatus(200);+ $this->see('Convert a withdrawal into a transfer');+ }++ /**+ * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::postIndex+ */+ public function testPostIndex(){+ //+ $this->be($this->user());+ $this->call('post', route('transactions.convert.index', ['transfer', 672]));+ $this->assertResponseStatus(302);+ $this->assertRedirectedToRoute('transactions.show', [672]);}}