Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix tests.
James Coleb80b026246d6
diff --git a/tests/Feature/Controllers/Admin/UserControllerTest.php b/tests/Feature/Controllers/Admin/UserControllerTest.phpindex 8202f219ef..2cbfee9975 100644--- a/tests/Feature/Controllers/Admin/UserControllerTest.php+++ b/tests/Feature/Controllers/Admin/UserControllerTest.php@@ -84,6 +84,7 @@ class UserControllerTest extends TestCase$repository = $this->mock(UserRepositoryInterface::class);$repository->shouldReceive('changePassword')->once();$repository->shouldReceive('changeStatus')->once();+ $repository->shouldReceive('updateEmail')->once();$data = ['id' => 1,'email' => '[email protected]',diff --git a/tests/Feature/Controllers/BudgetControllerTest.php b/tests/Feature/Controllers/BudgetControllerTest.phpindex a345f04790..acb687037c 100644--- a/tests/Feature/Controllers/BudgetControllerTest.php+++ b/tests/Feature/Controllers/BudgetControllerTest.php@@ -151,6 +151,13 @@ class BudgetControllerTest extends TestCase// set budget limit to current month:$budgetLimit->start_date = Carbon::now()->startOfMonth();$budgetLimit->end_date = Carbon::now()->endOfMonth();+ $budgetInfo = [+ $budget->id => [+ 'spent' => '0',+ 'budgeted' => '0',+ 'currentRep' => false,+ ],+ ];$accountRepos = $this->mock(AccountRepositoryInterface::class);$repository = $this->mock(BudgetRepositoryInterface::class);@@ -163,6 +170,7 @@ class BudgetControllerTest extends TestCase$repository->shouldReceive('getInactiveBudgets')->andReturn(new Collection);$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');$repository->shouldReceive('spentInPeriod')->andReturn('-1');+ $repository->shouldReceive('collectBudgetInformation')->andReturn($budgetInfo);$repository->shouldReceive('getBudgetLimits')->andReturn(new Collection([$budgetLimit]));@@ -187,6 +195,13 @@ class BudgetControllerTest extends TestCase// mock stuff$budget = factory(Budget::class)->make();$budgetLimit = factory(BudgetLimit::class)->make();+ $budgetInfo = [+ $budget->id => [+ 'spent' => '0',+ 'budgeted' => '0',+ 'currentRep' => false,+ ],+ ];// set budget limit to current month:$budgetLimit->start_date = Carbon::now()->startOfMonth();@@ -204,6 +219,7 @@ class BudgetControllerTest extends TestCase$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');$repository->shouldReceive('spentInPeriod')->andReturn('-1');$repository->shouldReceive('getBudgetLimits')->andReturn(new Collection([$budgetLimit]));+ $repository->shouldReceive('collectBudgetInformation')->andReturn($budgetInfo);$this->be($this->user());@@ -231,6 +247,13 @@ class BudgetControllerTest extends TestCase// set budget limit to current month:$budgetLimit->start_date = Carbon::now()->startOfMonth();$budgetLimit->end_date = Carbon::now()->endOfMonth();+ $budgetInfo = [+ $budget->id => [+ 'spent' => '0',+ 'budgeted' => '0',+ 'currentRep' => false,+ ],+ ];$accountRepos = $this->mock(AccountRepositoryInterface::class);$repository = $this->mock(BudgetRepositoryInterface::class);@@ -244,6 +267,7 @@ class BudgetControllerTest extends TestCase$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');$repository->shouldReceive('spentInPeriod')->andReturn('-1');$repository->shouldReceive('getBudgetLimits')->andReturn(new Collection([$budgetLimit]));+ $repository->shouldReceive('collectBudgetInformation')->andReturn($budgetInfo);$this->be($this->user());@@ -373,7 +397,7 @@ class BudgetControllerTest extends TestCase$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);$repository->shouldReceive('setAvailableBudget');- $data = ['amount' => '200','start' => '2017-01-01','end' => '2017-01-31'];+ $data = ['amount' => '200', 'start' => '2017-01-01', 'end' => '2017-01-31'];$this->be($this->user());$response = $this->post(route('budgets.income.post'), $data);$response->assertStatus(302);diff --git a/tests/Feature/Controllers/JsonControllerTest.php b/tests/Feature/Controllers/JsonControllerTest.phpindex a4a7c3cf94..b42fd0b8bf 100644--- a/tests/Feature/Controllers/JsonControllerTest.php+++ b/tests/Feature/Controllers/JsonControllerTest.php@@ -52,98 +52,6 @@ class JsonControllerTest extends TestCase$response->assertStatus(200);}- /**- * @covers \FireflyIII\Http\Controllers\JsonController::boxBillsPaid- */- public function testBoxBillsPaid()- {- // mock stuff-- $billRepos = $this->mock(BillRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);- $billRepos->shouldReceive('getBillsPaidInRange')->andReturn('-100');-- $this->be($this->user());- $currency = Amount::getDefaultCurrency();- $response = $this->get(route('json.box.paid'));- $response->assertStatus(200);- $response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'bills-paid']);- }-- /**- * @covers \FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid- */- public function testBoxBillsUnpaid()- {- // mock stuff-- $billRepos = $this->mock(BillRepositoryInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);- $billRepos->shouldReceive('getBillsUnpaidInRange')->andReturn('100');--- $this->be($this->user());- $currency = Amount::getDefaultCurrency();- $response = $this->get(route('json.box.unpaid'));- $response->assertStatus(200);- $response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'bills-unpaid']);- }-- /**- * @covers \FireflyIII\Http\Controllers\JsonController::boxIn- */- public function testBoxIn()- {- // mock stuff-- $collector = $this->mock(JournalCollectorInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);- $transaction = factory(Transaction::class)->make();- $transaction->transaction_amount = '100.00';-- $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();- $collector->shouldReceive('setRange')->andReturnSelf()->once();- $collector->shouldReceive('getJournals')->andReturn(new Collection([$transaction]))->once();- $collector->shouldReceive('setTypes')->withArgs([[TransactionType::DEPOSIT]])->andReturnSelf()->once();- $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once();--- $this->be($this->user());- $currency = Amount::getDefaultCurrency();- $response = $this->get(route('json.box.in'));- $response->assertStatus(200);- $response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'in']);- }-- /**- * @covers \FireflyIII\Http\Controllers\JsonController::boxOut- */- public function testBoxOut()- {- // mock stuff-- $collector = $this->mock(JournalCollectorInterface::class);- $journalRepos = $this->mock(JournalRepositoryInterface::class);- $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);- $transaction = factory(Transaction::class)->make();- $transaction->transaction_amount = '100.00';-- $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();- $collector->shouldReceive('setRange')->andReturnSelf()->once();- $collector->shouldReceive('getJournals')->andReturn(new Collection([$transaction]))->once();- $collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL]])->andReturnSelf()->once();- $collector->shouldReceive('withOpposingAccount')->andReturnSelf()->once();-- $this->be($this->user());- $currency = Amount::getDefaultCurrency();- $response = $this->get(route('json.box.out'));- $response->assertStatus(200);- $response->assertExactJson(['amount' => Amount::formatAnything($currency, '100', false), 'amount_raw' => '100', 'box' => 'out']);- }-/*** @covers \FireflyIII\Http\Controllers\JsonController::budgets*/