data = '1M'; $this->be($pref->user); Preferences::shouldReceive('get', 'viewRange')->andReturn($pref); // CURRENCY: $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]); $this->call('GET', '/accounts/create/asset'); $this->assertResponseOk(); $this->assertViewHas('subTitle', 'Create a new asset account'); $this->assertViewHas('subTitleIcon', 'fa-money'); $this->assertViewHas('what', 'asset'); } public function testDelete() { // fake an account. $account = FactoryMuffin::create('FireflyIII\Models\Account'); $account->accountType->type = 'Asset account'; $account->accountType->save(); $this->be($account->user); $this->call('GET', '/accounts/delete/' . $account->id); $this->assertResponseOk(); $this->assertViewHas('subTitle', 'Delete ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"'); } public function testDestroy() { // fake an account. $account = FactoryMuffin::create('FireflyIII\Models\Account'); $account->accountType->type = 'Asset account'; $account->accountType->save(); $this->be($account->user); $this->assertCount(1, DB::table('accounts')->where('id', $account->id)->whereNull('deleted_at')->get()); // post it! $this->call('POST', '/accounts/destroy/' . $account->id, ['_token' => 'replaceme']); $this->assertSessionHas('success'); $this->assertCount(0, DB::table('accounts')->where('id', $account->id)->whereNull('deleted_at')->get()); } public function testEdit() { // fake an account. $account = FactoryMuffin::create('FireflyIII\Models\Account'); $account->accountType->type = 'Asset account'; $account->accountType->save(); $this->be($account->user); $this->assertCount(1, DB::table('accounts')->where('id', $account->id)->whereNull('deleted_at')->get()); // create a transaction journal that will act as opening balance: $openingBalance = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); $repository->shouldReceive('openingBalanceTransaction')->andReturn($openingBalance); // create a transaction that will be returned for the opening balance transaction: $openingBalanceTransaction = FactoryMuffin::create('FireflyIII\Models\Transaction'); $repository->shouldReceive('getFirstTransaction')->andReturn($openingBalanceTransaction); // CURRENCY: $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]); // get edit page: $this->call('GET', '/accounts/edit/' . $account->id); // assert stuff: $this->assertResponseOk(); $this->assertSessionHas('preFilled'); $this->assertViewHas('subTitle', 'Edit ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"'); } public function testIndex() { $user = FactoryMuffin::create('FireflyIII\User'); $this->be($user); // get currency code: $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); Amount::shouldReceive('getCurrencyCode')->andReturn($currency->code); // put stuff in session: $this->session(['start' => new Carbon, 'end' => new Carbon]); // get edit page: $this->call('GET', '/accounts/asset'); $this->assertResponseOk(); $this->assertViewHas('what', 'asset'); } public function testShow() { $this->markTestIncomplete(); } public function testStore() { $this->markTestIncomplete(); } public function testUpdate() { $this->markTestIncomplete(); } }