be($account->user); // mock stuff: Steam::shouldReceive('balance')->andReturn(0); $this->call('GET', '/chart/account/' . $account->id); $this->assertResponseOk(); } public function testAllAccountsBalanceChart() { $account = FactoryMuffin::create('FireflyIII\Models\Account'); $this->be($account->user); $collection = new Collection; $collection->push($account); //mock stuff: Preferences::shouldReceive('get')->andReturn(new Preference); $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); $repository->shouldReceive('getFrontpageAccounts')->andReturn($collection); $this->call('GET', '/chart/home/account'); $this->assertResponseOk(); } public function testAllBudgetsAndSpending() { $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); $this->be($budget->user); $collection = new Collection; $collection->push($budget); // mock stuff: $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); $repository->shouldReceive('getBudgets')->andReturn($collection); $repository->shouldReceive('spentInMonth')->andReturn(rand(1, 100)); $this->call('GET', '/chart/budgets/spending/2015'); $this->assertResponseOk(); } public function testAllBudgetsHomeChart() { $budget = FactoryMuffin::create('FireflyIII\Models\Budget'); $budget1 = FactoryMuffin::create('FireflyIII\Models\Budget'); $this->be($budget->user); $start = Carbon::now()->startOfMonth(); $end = Carbon::now()->endOfMonth(); $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); $repetitions = new Collection; $repetitions->push($repetition); $emptyRepetitions = new Collection; $collection = new Collection; $collection->push($budget); $collection->push($budget1); // mock stuff: $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); $repository->shouldReceive('getBudgets')->andReturn($collection); $repository->shouldReceive('getBudgetLimitRepetitions')->once()->andReturn($repetitions, $emptyRepetitions); $repository->shouldReceive('sumBudgetExpensesInPeriod')->andReturn(12); $repository->shouldReceive('getWithoutBudgetSum')->andReturn(0); $this->call('GET', '/chart/home/budgets'); $this->assertResponseOk(); } public function testAllCategoriesHomeChart() { $category = FactoryMuffin::create('FireflyIII\Models\Category'); $this->be($category->user); $category->save(); $category->sum = 100; $collection = new Collection; $collection->push($category); // mock stuff: $repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface'); $repository->shouldReceive('getCategoriesAndExpenses')->andReturn($collection); Crypt::shouldReceive('decrypt')->andReturn('Hello!'); Crypt::shouldReceive('encrypt')->andReturn('Hello!'); $this->call('GET', '/chart/home/categories'); $this->assertResponseOk(); } public function testBillOverview() { $bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); $collection = new Collection; $collection->push($journal); $this->be($bill->user); // mock! $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); $repository->shouldReceive('getJournals')->andReturn($collection); // call! $this->call('GET', '/chart/bills/' . $bill->id); $this->assertResponseOk(); } public function testBillsOverview() { $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill2 = FactoryMuffin::create('FireflyIII\Models\Bill'); $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); $card1 = FactoryMuffin::create('FireflyIII\Models\Account'); $card2 = FactoryMuffin::create('FireflyIII\Models\Account'); $fake = FactoryMuffin::create('FireflyIII\Models\Bill'); $bills = new Collection([$bill1, $bill2]); $journals = new Collection([$journal1, $journal2]); $cards = new Collection([$card1, $card2]); $emptyCollection = new Collection; $ranges = [['start' => new Carbon, 'end' => new Carbon]]; $this->be($bill1->user); // mock! $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); $accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); // calls: $repository->shouldReceive('getActiveBills')->andReturn($bills); $repository->shouldReceive('getRanges')->andReturn($ranges); $repository->shouldReceive('getJournalsInRange')->andReturn($journals, $emptyCollection); $accounts->shouldReceive('getCreditCards')->andReturn($cards); $accounts->shouldReceive('getTransfersInRange')->andReturn($journals, $emptyCollection); $repository->shouldReceive('createFakeBill')->andReturn($fake); Steam::shouldReceive('balance')->andReturn(-1, 0); $this->call('GET', '/chart/home/bills'); $this->assertResponseOk(); } public function testBudgetLimitSpending() { $repetition = FactoryMuffin::create('FireflyIII\Models\LimitRepetition'); $budget = $repetition->budgetlimit->budget; $this->be($budget->user); ///chart/budget/{budget}/{limitrepetition} // mock! $repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface'); $repository->shouldReceive('expensesOnDay')->andReturn(rand(1, 1000)); $this->call('GET', '/chart/budget/' . $budget->id . '/' . $repetition->id); $this->assertResponseOk(); } public function testBudgetsAndSpending() { $this->markTestIncomplete(); } public function testCategoryOverviewChart() { $this->markTestIncomplete(); } public function testCategoryPeriodChart() { $this->markTestIncomplete(); } public function testPiggyBankHistory() { $this->markTestIncomplete(); } public function testYearInExp() { $this->markTestIncomplete(); } public function testYearInExpSum() { $this->markTestIncomplete(); } }