diff --git a/tests/Feature/Controllers/Popup/ReportControllerTest.php b/tests/Feature/Controllers/Popup/ReportControllerTest.php new file mode 100644 index 0000000000..97ba0c1bae --- /dev/null +++ b/tests/Feature/Controllers/Popup/ReportControllerTest.php @@ -0,0 +1,143 @@ +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' => 3, // diff role, is complicated. + ], + ]; + $uri = route('popup.general') . '?' . http_build_query($arguments); + $response = $this->get($uri); + $response->assertStatus(200); + } + + /** + * @covers \FireflyIII\Http\Controllers\Popup\ReportController::general + */ + 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); + $response = $this->get($uri); + $response->assertStatus(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); + $response = $this->get($uri); + $response->assertStatus(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); + $response = $this->get($uri); + $response->assertStatus(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); + $response = $this->get($uri); + $response->assertStatus(200); + } + + +} \ No newline at end of file diff --git a/tests/Feature/Controllers/Report/AccountControllerTest.php b/tests/Feature/Controllers/Report/AccountControllerTest.php new file mode 100644 index 0000000000..b3742866a7 --- /dev/null +++ b/tests/Feature/Controllers/Report/AccountControllerTest.php @@ -0,0 +1,29 @@ +be($this->user()); + $response = $this->get(route('report-data.account.general', ['1', '20120101', '20120131'])); + $response->assertStatus(200); + } + +} \ No newline at end of file diff --git a/tests/Feature/Controllers/Report/BalanceControllerTest.php b/tests/Feature/Controllers/Report/BalanceControllerTest.php new file mode 100644 index 0000000000..9f86983084 --- /dev/null +++ b/tests/Feature/Controllers/Report/BalanceControllerTest.php @@ -0,0 +1,29 @@ +be($this->user()); + $response = $this->get(route('report-data.balance.general', ['1', '20120101', '20120131'])); + $response->assertStatus(200); + } + +} \ No newline at end of file diff --git a/tests/Feature/Controllers/Report/BudgetControllerTest.php b/tests/Feature/Controllers/Report/BudgetControllerTest.php new file mode 100644 index 0000000000..cac69e42ae --- /dev/null +++ b/tests/Feature/Controllers/Report/BudgetControllerTest.php @@ -0,0 +1,39 @@ +be($this->user()); + $response = $this->get(route('report-data.budget.general', ['1', '20120101', '20120131'])); + $response->assertStatus(200); + } + + /** + * @covers \FireflyIII\Http\Controllers\Report\BudgetController::period + */ + public function testPeriod() + { + $this->be($this->user()); + $response = $this->get(route('report-data.budget.period', ['1', '20120101', '20120131'])); + $response->assertStatus(200); + } + +} \ No newline at end of file diff --git a/tests/Feature/Controllers/Report/CategoryControllerTest.php b/tests/Feature/Controllers/Report/CategoryControllerTest.php new file mode 100644 index 0000000000..a2ee740193 --- /dev/null +++ b/tests/Feature/Controllers/Report/CategoryControllerTest.php @@ -0,0 +1,49 @@ +be($this->user()); + $response = $this->get(route('report-data.category.expenses', ['1', '20120101', '20120131'])); + $response->assertStatus(200); + } + + /** + * @covers \FireflyIII\Http\Controllers\Report\CategoryController::income + */ + public function testIncome() + { + $this->be($this->user()); + $response = $this->get(route('report-data.category.income', ['1', '20120101', '20120131'])); + $response->assertStatus(200); + } + + /** + * @covers \FireflyIII\Http\Controllers\Report\CategoryController::operations + */ + public function testOperations() + { + $this->be($this->user()); + $response = $this->get(route('report-data.category.operations', ['1', '20120101', '20120131'])); + $response->assertStatus(200); + } + +} \ No newline at end of file diff --git a/tests/Feature/Controllers/Report/OperationsControllerTest.php b/tests/Feature/Controllers/Report/OperationsControllerTest.php new file mode 100644 index 0000000000..7f73582bd5 --- /dev/null +++ b/tests/Feature/Controllers/Report/OperationsControllerTest.php @@ -0,0 +1,49 @@ +be($this->user()); + $response = $this->get(route('report-data.operations.expenses', ['1', '20120101', '20120131'])); + $response->assertStatus(200); + } + + /** + * @covers \FireflyIII\Http\Controllers\Report\OperationsController::income + */ + public function testIncome() + { + $this->be($this->user()); + $response = $this->get(route('report-data.operations.income', ['1', '20120101', '20120131'])); + $response->assertStatus(200); + } + + /** + * @covers \FireflyIII\Http\Controllers\Report\OperationsController::operations + */ + public function testOperations() + { + $this->be($this->user()); + $response = $this->get(route('report-data.operations.operations', ['1', '20120101', '20120131'])); + $response->assertStatus(200); + } + +} \ No newline at end of file diff --git a/tests/Feature/Controllers/Transaction/ConvertControllerTest.php b/tests/Feature/Controllers/Transaction/ConvertControllerTest.php new file mode 100644 index 0000000000..45f420d617 --- /dev/null +++ b/tests/Feature/Controllers/Transaction/ConvertControllerTest.php @@ -0,0 +1,115 @@ +where('user_id', $this->user()->id)->first(); + + $this->be($this->user()); + $response = $this->get(route('transactions.convert.index', ['transfer', $deposit->id])); + $response->assertStatus(200); + $response->assertSee('Convert a deposit into a transfer'); + } + + /** + * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::index + */ + public function testIndexDepositWithdrawal() + { + $deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first(); + $this->be($this->user()); + $response = $this->get(route('transactions.convert.index', ['withdrawal', $deposit->id])); + $response->assertStatus(200); + $response->assertSee('Convert a deposit into a withdrawal'); + } + + /** + * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::index + */ + public function testIndexTransferDeposit() + { + $transfer = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->first(); + $this->be($this->user()); + $response = $this->get(route('transactions.convert.index', ['deposit', $transfer->id])); + $response->assertStatus(200); + $response->assertSee('Convert a transfer into a deposit'); + } + + /** + * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::index + */ + public function testIndexTransferWithdrawal() + { + $transfer = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->first(); + $this->be($this->user()); + $response = $this->get(route('transactions.convert.index', ['withdrawal', $transfer->id])); + $response->assertStatus(200); + $response->assertSee('Convert a transfer into a withdrawal'); + } + + /** + * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::index + */ + public function testIndexWithdrawalDeposit() + { + $withdrawal= TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first(); + $this->be($this->user()); + $response = $this->get(route('transactions.convert.index', ['deposit', $withdrawal->id])); + $response->assertStatus(200); + $response->assertSee('Convert a withdrawal into a deposit'); + } + + /** + * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::index + */ + public function testIndexWithdrawalTransfer() + { + $withdrawal= TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first(); + $this->be($this->user()); + $response = $this->get(route('transactions.convert.index', ['transfer', $withdrawal->id])); + $response->assertStatus(200); + $response->assertSee('Convert a withdrawal into a transfer'); + } + + /** + * @covers \FireflyIII\Http\Controllers\Transaction\ConvertController::postIndex + */ + public function testPostIndex() + { + $withdrawal= TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first(); + // convert a withdrawal to a transfer. Requires the ID of another asset account. + $data = [ + 'destination_account_asset' => 2, + ]; + $this->be($this->user()); + $response = $this->post(route('transactions.convert.index', ['transfer', $withdrawal->id]), $data); + $response->assertStatus(302); + $response->assertRedirect(route('transactions.show', [$withdrawal->id])); + } + + +} \ No newline at end of file diff --git a/tests/Feature/Controllers/Transaction/MassControllerTest.php b/tests/Feature/Controllers/Transaction/MassControllerTest.php new file mode 100644 index 0000000000..77fc1b33f2 --- /dev/null +++ b/tests/Feature/Controllers/Transaction/MassControllerTest.php @@ -0,0 +1,103 @@ +where('user_id', $this->user()->id)->take(2)->get()->pluck('id')->toArray(); + $this->be($this->user()); + $response = $this->get(route('transactions.mass.delete', $withdrawals)); + $response->assertStatus(200); + $response->assertSee('Delete a number of transactions'); + // has bread crumb + $response->assertSee('