/** * @covers FireflyIII\Http\Controllers\PreferencesController::index */ public function testIndex() { $user = FactoryMuffin::create('FireflyIII\\User'); $pref = FactoryMuffin::create('FireflyIII\\Models\\Preference'); $currency = FactoryMuffin::create('FireflyIII\\Models\\TransactionCurrency'); $this->be($user); // mock: $repository = $this->mock('FireflyIII\\Repositories\\Account\\AccountRepositoryInterface'); // fake! $repository->shouldReceive('getAccounts')->with(['Default account', 'Asset account'])->andReturn(new Collection()); Preferences::shouldReceive('get')->once()->withArgs(['viewRange', '1M'])->andReturn($pref); Preferences::shouldReceive('get')->once()->withArgs(['frontPageAccounts', []])->andReturn($pref); Preferences::shouldReceive('get')->once()->withArgs(['budgetMaximum', 1000])->andReturn($pref); Preferences::shouldReceive('get')->withArgs(['currencyPreference', 'EUR'])->andReturn($pref); Amount::shouldReceive('format')->andReturn('xx'); Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); Amount::shouldReceive('getAllCurrencies')->andReturn(new Collection()); Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); $lastActivity = FactoryMuffin::create('FireflyIII\\Models\\Preference'); $lastActivity->data = microtime(); Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); // language preference: $language = FactoryMuffin::create('FireflyIII\\Models\\Preference'); $language->data = 'en'; $language->save(); Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); $this->call('GET', '/preferences'); $this->assertResponseOk(); }
/** * @covers FireflyIII\Http\Controllers\NewUserController::index */ public function testIndex() { $user = FactoryMuffin::create('FireflyIII\\User'); $repository = $this->mock('FireflyIII\\Repositories\\Account\\AccountRepositoryInterface'); $this->be($user); // mock ALL THE THINGS! $repository->shouldReceive('countAccounts')->once()->andReturn(0); // language preference: $language = FactoryMuffin::create('FireflyIII\\Models\\Preference'); $language->data = 'en'; $language->save(); Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); $lastActivity = FactoryMuffin::create('FireflyIII\\Models\\Preference'); $lastActivity->data = microtime(); Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); $this->call('GET', '/new-user'); $this->assertResponseStatus(200); }
/** * @covers FireflyIII\Http\Controllers\HomeController::index */ public function testIndex() { $user = FactoryMuffin::create('FireflyIII\\User'); $preference = FactoryMuffin::create('FireflyIII\\Models\\Preference'); $journal = FactoryMuffin::create('FireflyIII\\Models\\TransactionJournal'); $journals = new Collection([$journal]); $account = FactoryMuffin::create('FireflyIII\\Models\\Account'); $accounts = new Collection([$account]); $repository = $this->mock('FireflyIII\\Repositories\\Account\\AccountRepositoryInterface'); $this->be($user); // mock ALL THE THINGS! $repository->shouldReceive('countAccounts')->once()->andReturn(3); Preferences::shouldReceive('get')->once()->withArgs(['frontPageAccounts', []])->andReturn($preference); $repository->shouldReceive('getFrontpageAccounts')->once()->with($preference)->andReturn($accounts); $repository->shouldReceive('getSavingsAccounts')->once()->andReturn($accounts); $repository->shouldReceive('getPiggyBankAccounts')->once()->andReturn($accounts); $repository->shouldReceive('sumOfEverything')->once()->andReturn(1); $repository->shouldReceive('getFrontpageTransactions')->once()->andReturn($journals); // language preference: $language = FactoryMuffin::create('FireflyIII\\Models\\Preference'); $language->data = 'en'; $language->save(); Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); $lastActivity = FactoryMuffin::create('FireflyIII\\Models\\Preference'); $lastActivity->data = microtime(); Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); Amount::shouldReceive('getCurrencyCode')->andReturn('EUR'); Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); Amount::shouldReceive('format')->andReturn('xxx'); Amount::shouldReceive('formatJournal')->with($journal)->andReturn('xxx'); $this->call('GET', '/'); $this->assertResponseOk(); }
/** * @covers FireflyIII\Http\Controllers\PiggyBankController::show */ public function testShow() { $piggyBank = FactoryMuffin::create('FireflyIII\\Models\\PiggyBank'); $this->be($piggyBank->account->user); $piggyBanks = $this->mock('FireflyIII\\Repositories\\PiggyBank\\PiggyBankRepositoryInterface'); $piggyBanks->shouldReceive('getEvents')->andReturn(new Collection()); Amount::shouldReceive('format')->andReturn('something'); Amount::shouldReceive('getCurrencySymbol')->andReturn('something'); Amount::shouldReceive('getCurrencyCode')->andReturn('something'); $this->call('GET', '/piggy-banks/show/' . $piggyBank->id); $this->assertResponseOk(); }
/** * @covers FireflyIII\Http\Controllers\TransactionController::show */ public function testShow() { $journal = FactoryMuffin::create('FireflyIII\\Models\\TransactionJournal'); $transaction1 = FactoryMuffin::create('FireflyIII\\Models\\Transaction'); $currency = FactoryMuffin::create('FireflyIII\\Models\\TransactionCurrency'); $transaction1->transaction_journal_id = $journal->id; $transaction1->save(); $this->be($journal->user); // mock! $repository = $this->mock('FireflyIII\\Repositories\\Journal\\JournalRepositoryInterface'); // fake! $repository->shouldReceive('getAmountBefore')->withAnyArgs()->andReturn(5); Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]); Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); Amount::shouldReceive('formatTransaction')->andReturn('X'); Amount::shouldReceive('format')->andReturn('X'); $this->call('GET', '/transaction/show/' . $journal->id); $this->assertResponseOk(); }
/** * @covers FireflyIII\Http\Controllers\ReportController::year */ public function testYear() { $user = FactoryMuffin::create('FireflyIII\\User'); $journal = FactoryMuffin::create('FireflyIII\\Models\\TransactionJournal'); $currency = FactoryMuffin::create('FireflyIII\\Models\\TransactionCurrency'); $account = FactoryMuffin::create('FireflyIII\\Models\\Account'); // make shared: AccountMeta::create(['account_id' => $account->id, 'name' => 'accountRole', 'data' => 'sharedAsset']); new Collection([$journal]); $this->be($user); $helper = $this->mock('FireflyIII\\Helpers\\Report\\ReportHelperInterface'); $helper->shouldReceive('getAccountReport')->once()->withAnyArgs()->andReturn([]); $helper->shouldReceive('getIncomeReport')->once()->withAnyArgs()->andReturn([]); $helper->shouldReceive('getExpenseReport')->once()->withAnyArgs()->andReturn([]); // mock stuff! Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]); Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); Amount::shouldReceive('format')->andReturn('X'); $this->call('GET', '/reports/2015/shared'); $this->assertResponseOk(); }
/** * @covers FireflyIII\Http\Controllers\AccountController::show */ public function testShow() { // an account: $this->be($this->account->user); // mock! Amount::shouldReceive('getCurrencyCode')->andReturn('A'); Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); $repository = $this->mock('FireflyIII\\Repositories\\Account\\AccountRepositoryInterface'); $repository->shouldReceive('getJournals')->andReturn(new LengthAwarePaginator([], 0, 10)); // get edit page: $this->call('GET', '/accounts/show/' . $this->account->id); $this->assertResponseOk(); }
/** * @covers FireflyIII\Http\Controllers\BudgetController::updateIncome */ public function testUpdateIncome() { // a budget: $budget = FactoryMuffin::create('FireflyIII\\Models\\Budget'); $this->be($budget->user); $date = Carbon::now()->format('FY'); $pref = FactoryMuffin::create('FireflyIII\\Models\\Preference'); Preferences::shouldReceive('get')->withArgs(['budgetIncomeTotal' . $date, 1000])->andReturn($pref); Amount::shouldReceive('format')->andReturn('xx'); Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); $lastActivity = FactoryMuffin::create('FireflyIII\\Models\\Preference'); $lastActivity->data = microtime(); Preferences::shouldReceive('lastActivity')->andReturn($lastActivity); // language preference: $language = FactoryMuffin::create('FireflyIII\\Models\\Preference'); $language->data = 'en'; $language->save(); Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); $this->call('GET', '/budgets/income'); $this->assertResponseOk(); $this->assertViewHas('amount'); }
/** * @covers FireflyIII\Http\Controllers\JsonController::boxOut */ public function testBoxOut() { $user = FactoryMuffin::create('FireflyIII\\User'); $this->be($user); $repository = $this->mock('FireflyIII\\Helpers\\Report\\ReportQueryInterface'); $repository->shouldReceive('expenseInPeriodCorrected')->andReturn(new Collection()); Amount::shouldReceive('format')->andReturn('xx'); Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); $this->call('GET', '/json/box/out'); $this->assertResponseOk(); }
/** * @covers FireflyIII\Http\Controllers\BillController::show */ public function testShow() { $bill = FactoryMuffin::create('FireflyIII\\Models\\Bill'); $journal = FactoryMuffin::create('FireflyIII\\Models\\TransactionJournal'); $collection = new Collection(); $bill->save(); $this->be($bill->user); $collection->push($journal); $repository = $this->mock('FireflyIII\\Repositories\\Bill\\BillRepositoryInterface'); $repository->shouldReceive('getJournals')->once()->andReturn($collection); $repository->shouldReceive('nextExpectedMatch')->once()->andReturn(new Carbon()); Amount::shouldReceive('format')->andReturn('XX'); Amount::shouldReceive('formatJournal')->andReturn('XX'); Amount::shouldReceive('getCurrencyCode')->andReturn('XX'); Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); $this->call('GET', '/bills/show/' . $bill->id); }
/** * @covers FireflyIII\Http\Controllers\CategoryController::show */ public function testShow() { $category = FactoryMuffin::create('FireflyIII\\Models\\Category'); $collection = new Collection(); $journal = FactoryMuffin::create('FireflyIII\\Models\\TransactionJournal'); $this->be($category->user); $collection->push($journal); $repository = $this->mock('FireflyIII\\Repositories\\Category\\CategoryRepositoryInterface'); $repository->shouldReceive('getJournals')->andReturn($collection); $repository->shouldReceive('countJournals')->andReturn(1); Amount::shouldReceive('format')->andReturn('xx'); Amount::shouldReceive('getCurrencyCode')->andReturn('xx'); Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); Amount::shouldReceive('formatJournal')->andReturn('xx'); $this->call('GET', '/categories/show/' . $category->id); $this->assertResponseOk(); $this->assertViewHas('hideCategory', true); }