diff --git a/tests/controllers/charts/ChartAccountControllerTest.php b/tests/controllers/charts/ChartAccountControllerTest.php index ed6c9fd02d..5e5cf56996 100644 --- a/tests/controllers/charts/ChartAccountControllerTest.php +++ b/tests/controllers/charts/ChartAccountControllerTest.php @@ -1,5 +1,10 @@ markTestIncomplete(); + $user = FactoryMuffin::create('FireflyIII\User'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + FactoryMuffin::create('FireflyIII\Models\AccountType'); + $asset = FactoryMuffin::create('FireflyIII\Models\AccountType'); + $one = FactoryMuffin::create('FireflyIII\Models\Account'); + $two = FactoryMuffin::create('FireflyIII\Models\Account'); + $one->account_type_id = $asset->id; + $two->account_type_id = $asset->id; + $one->save(); + $two->save(); + $accounts = new Collection([$one, $two]); + $date = new Carbon; + $this->be($user); + + // make one shared: + AccountMeta::create( + [ + 'account_id' => $one->id, + 'name' => 'accountRole', + 'data' => 'sharedAsset' + ] + ); + + + // mock! + $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); + + // fake! + $repository->shouldReceive('getAccounts')->once()->andReturn($accounts); + + $this->call('GET', '/chart/account/month/' . $date->format('Y/m')); + $this->assertResponseOk(); + } + + public function testAllShared() + { + $user = FactoryMuffin::create('FireflyIII\User'); + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $accounts = new Collection([$account]); + $date = new Carbon; + $this->be($user); + + // make it shared: + AccountMeta::create( + [ + 'account_id' => $account->id, + 'name' => 'accountRole', + 'data' => 'sharedAsset' + ] + ); + + + // mock! + $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); + + // fake! + $repository->shouldReceive('getAccounts')->once()->andReturn($accounts); + + + $this->call('GET', '/chart/account/month/' . $date->format('Y/m') . '/shared'); + $this->assertResponseOk(); } public function testFrontpage() { - $this->markTestIncomplete(); + $accounts = new Collection([FactoryMuffin::create('FireflyIII\Models\Account')]); + $user = FactoryMuffin::create('FireflyIII\User'); + $this->be($user); + + // mock! + $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); + + // fake! + $repository->shouldReceive('getFrontpageAccounts')->andReturn($accounts); + + $this->call('GET', '/chart/account/frontpage'); + $this->assertResponseOk(); + } public function testSingle() { - $this->markTestIncomplete(); + $account = FactoryMuffin::create('FireflyIII\Models\Account'); + $this->be($account->user); + + $this->call('GET', '/chart/account/' . $account->id); + $this->assertResponseOk(); + } } diff --git a/tests/controllers/charts/ChartBillControllerTest.php b/tests/controllers/charts/ChartBillControllerTest.php index 7d90eb5e0c..a83372d93b 100644 --- a/tests/controllers/charts/ChartBillControllerTest.php +++ b/tests/controllers/charts/ChartBillControllerTest.php @@ -1,5 +1,9 @@ be($user); + + } public function testFrontpage() { - $this->markTestIncomplete(); + $user = FactoryMuffin::create('FireflyIII\User'); + $this->be($user); + + // set! + $bills = new Collection([FactoryMuffin::create('FireflyIII\Models\Bill'), FactoryMuffin::create('FireflyIII\Models\Bill')]); + $journals = new Collection( + [FactoryMuffin::create('FireflyIII\Models\TransactionJournal'), FactoryMuffin::create('FireflyIII\Models\TransactionJournal')] + ); + $creditCards = new Collection([FactoryMuffin::create('FireflyIII\Models\Account'), FactoryMuffin::create('FireflyIII\Models\Account')]); + $ranges = [['start' => new Carbon, 'end' => new Carbon]]; + + // mock! + $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); + $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); + + + // fake! + $repository->shouldReceive('getActiveBills')->andReturn($bills); + $repository->shouldReceive('getRanges')->andReturn($ranges); + $repository->shouldReceive('getJournalsInRange')->andReturn(new Collection, $journals); + $accounts->shouldReceive('getCreditCards')->andReturn($creditCards); + $accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection); + $repository->shouldReceive('createFakeBill')->andReturn($bills->first()); + Steam::shouldReceive('balance')->andReturn(-10,0); + + + $this->call('GET', '/chart/bill/frontpage'); + $this->assertResponseOk(); + } public function testSingle() { - $this->markTestIncomplete(); + $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); + $this->be($bill->user); + + // set + $journals = new Collection([FactoryMuffin::create('FireflyIII\Models\TransactionJournal')]); + + // mock! + $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); + $repository->shouldReceive('getJournals')->andReturn($journals); + + // fake! + + $this->call('GET', '/chart/bill/' . $bill->id); + $this->assertResponseOk(); + } diff --git a/tests/controllers/charts/ChartBudgetControllerTest.php b/tests/controllers/charts/ChartBudgetControllerTest.php index 2cfe66339c..6017478d96 100644 --- a/tests/controllers/charts/ChartBudgetControllerTest.php +++ b/tests/controllers/charts/ChartBudgetControllerTest.php @@ -1,4 +1,8 @@ markTestIncomplete(); + $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); + $this->be($budget->user); + + $this->call('GET', '/chart/budget/' . $budget->id); + $this->assertResponseOk(); + + + } + + public function testBudgetLimit() + { + $user = FactoryMuffin::create('FireflyIII\User'); + $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); + /** @var \FireflyIII\Models\BudgetLimit $limit */ + $limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); + /** @var \FireflyIII\Models\LimitRepetition $repetition */ + $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); + + $start = Carbon::now()->startOfMonth(); + $end = Carbon::now()->endOfMonth(); + + $budget->user_id = $user->id; + $limit->budget_id = $budget->id; + $limit->startdate = $start; + $repetition->budget_limit_id = $limit->id; + $repetition->startdate = $start; + $repetition->enddate = $end; + + $budget->save(); + $limit->save(); + $repetition->save(); + + + $this->be($user); + + $this->call('GET', '/chart/budget/' . $budget->id . '/' . $repetition->id); + $this->assertResponseOk(); } public function testFrontpage() { - $this->markTestIncomplete(); + $user = FactoryMuffin::create('FireflyIII\User'); + $this->be($user); + + $start = Carbon::now()->startOfMonth(); + $end = Carbon::now()->endOfMonth(); + $budgets = new Collection; + $limits = []; + $repetitions = []; + + for ($i = 0; $i < 5; $i++) { + /** @var \FireflyIII\Models\Budget $budget */ + $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); + $budgets->push($budget); + + /** @var \FireflyIII\Models\BudgetLimit $limit */ + $limit = FactoryMuffin::create('FireflyIII\Models\BudgetLimit'); + $limit->budget_id = $budget->id; + $limit->startdate = $start; + $limit->save(); + + $set = new Collection([$limit]); + $limits[] = $set; + + /** @var \FireflyIII\Models\LimitRepetition $repetition */ + $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); + $repetition->budget_limit_id = $limit->id; + $repetition->startdate = $start; + $repetition->enddate = $end; + $repetition->save(); + $set = new Collection([$repetition]); + $repetitions[] = $set; + } + + // mock! + $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); + + // fake! + $repository->shouldReceive('getBudgets')->andReturn($budgets); + $repository->shouldReceive('getBudgetLimitRepetitions')->andReturn($repetitions[0], $repetitions[1], new Collection); + $repository->shouldReceive('spentInPeriodCorrected')->andReturn(10); + $repository->shouldReceive('getWithoutBudgetSum')->andReturn(10); + + $this->call('GET', '/chart/budget/frontpage'); + $this->assertResponseOk(); } public function testYear() { - $this->markTestIncomplete(); + $user = FactoryMuffin::create('FireflyIII\User'); + $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); + $collection = new Collection([$budget]); + $this->be($user); + + + // mock! + $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); + + // fake! + $repository->shouldReceive('getBudgets')->andReturn($collection); + $repository->shouldReceive('spentInPeriodCorrected')->andReturn(0); + + + $this->call('GET', '/chart/budget/year/2015'); + $this->assertResponseOk(); + } + + public function testYearShared() + { + $user = FactoryMuffin::create('FireflyIII\User'); + $this->be($user); + + $this->call('GET', '/chart/budget/year/2015/shared'); + $this->assertResponseOk(); } } diff --git a/tests/controllers/charts/ChartCategoryControllerTest.php b/tests/controllers/charts/ChartCategoryControllerTest.php index ee491763ac..f533e7459b 100644 --- a/tests/controllers/charts/ChartCategoryControllerTest.php +++ b/tests/controllers/charts/ChartCategoryControllerTest.php @@ -1,5 +1,8 @@ markTestIncomplete(); + + $category = FactoryMuffin::create('FireflyIII\Models\Category'); + $this->be($category->user); + + $this->call('GET', '/chart/category/'.$category->id.'/all'); + $this->assertResponseOk(); + + } public function testFrontpage() { - $this->markTestIncomplete(); + $user = FactoryMuffin::create('FireflyIII\User'); + $this->be($user); + + // make data: + $set = [ + ['name' => 'Something', 'sum' => 100], + ['name' => 'Something Else', 'sum' => 200], + ['name' => 'Something Else Entirely', 'sum' => 200] + ]; + + // mock! + $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); + + // fake! + $repository->shouldReceive('getCategoriesAndExpensesCorrected')->andReturn($set); + + //getCategoriesAndExpensesCorrected + + $this->call('GET', '/chart/category/frontpage'); + $this->assertResponseOk(); } public function testMonth() { - $this->markTestIncomplete(); + $category = FactoryMuffin::create('FireflyIII\Models\Category'); + $this->be($category->user); + + $this->call('GET', '/chart/category/'.$category->id.'/month'); + $this->assertResponseOk(); } public function testYear() { - $this->markTestIncomplete(); + $user = FactoryMuffin::create('FireflyIII\User'); + $this->be($user); + + $categories = new Collection([FactoryMuffin::create('FireflyIII\Models\Category')]); + + // mock! + $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); + + // fake! + $repository->shouldReceive('getCategories')->andReturn($categories); + $repository->shouldReceive('spentInPeriodCorrected')->andReturn(0); + + $this->call('GET', '/chart/category/year/2015'); + $this->assertResponseOk(); + } + + public function testYearShared() + { + $user = FactoryMuffin::create('FireflyIII\User'); + $this->be($user); + + $categories = new Collection([FactoryMuffin::create('FireflyIII\Models\Category')]); + + // mock! + $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); + + // fake! + $repository->shouldReceive('getCategories')->andReturn($categories); + $repository->shouldReceive('spentInPeriodCorrected')->andReturn(0); + + $this->call('GET', '/chart/category/year/2015/shared'); + $this->assertResponseOk(); } } diff --git a/tests/controllers/charts/ChartPiggyBankControllerTest.php b/tests/controllers/charts/ChartPiggyBankControllerTest.php index 2d61d83da2..bdb9038254 100644 --- a/tests/controllers/charts/ChartPiggyBankControllerTest.php +++ b/tests/controllers/charts/ChartPiggyBankControllerTest.php @@ -1,5 +1,7 @@ markTestIncomplete(); + $piggy = FactoryMuffin::create('FireflyIII\Models\PiggyBank'); + $this->be($piggy->account->user); + + // data: + $obj = new stdClass; + $obj->sum = 100; + $obj->date = '2015-01-01'; + $set = [ + $obj + ]; + + // mock! + $repository = $this->mock('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface'); + + // fake! + $repository->shouldReceive('getEventSummarySet')->andReturn($set); + + $this->call('GET', '/chart/piggyBank/' . $piggy->id); + $this->assertResponseOk(); } } diff --git a/tests/controllers/charts/ChartReportControllerTest.php b/tests/controllers/charts/ChartReportControllerTest.php index 68a40914f3..0579fddafe 100644 --- a/tests/controllers/charts/ChartReportControllerTest.php +++ b/tests/controllers/charts/ChartReportControllerTest.php @@ -1,5 +1,7 @@ markTestIncomplete(); + $user = FactoryMuffin::create('FireflyIII\User'); + $this->be($user); + + $this->call('GET', '/chart/report/in-out/2015'); + $this->assertResponseOk(); + + } + + public function testYearInOutShared() + { + $user = FactoryMuffin::create('FireflyIII\User'); + $this->be($user); + + $this->call('GET', '/chart/report/in-out/2015/shared'); + $this->assertResponseOk(); + } public function testYearInOutSummarized() { - $this->markTestIncomplete(); + $user = FactoryMuffin::create('FireflyIII\User'); + $this->be($user); + + $this->call('GET', '/chart/report/in-out-sum/2015'); + $this->assertResponseOk(); + } + + public function testYearInOutSummarizedShared() + { + $user = FactoryMuffin::create('FireflyIII\User'); + $this->be($user); + + $this->call('GET', '/chart/report/in-out-sum/2015/shared'); + $this->assertResponseOk(); } }