mock(UserRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); $userRepos->shouldReceive('hasRole')->once()->andReturn(false); $this->be($this->user()); $response = $this->get(route('currencies.create')); $response->assertStatus(302); $response->assertSessionHas('error'); } /** * @covers \FireflyIII\Http\Controllers\CurrencyController::delete */ public function testCannotDelete() { // mock stuff $repository = $this->mock(CurrencyRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $userRepos = $this->mock(UserRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); $repository->shouldReceive('canDeleteCurrency')->andReturn(false); $userRepos->shouldReceive('hasRole')->once()->andReturn(true); $this->be($this->user()); $response = $this->get(route('currencies.delete', [2])); $response->assertStatus(302); // has bread crumb $response->assertSessionHas('error'); } /** * @covers \FireflyIII\Http\Controllers\CurrencyController::destroy */ public function testCannotDestroy() { // mock stuff $repository = $this->mock(CurrencyRepositoryInterface::class); $userRepos = $this->mock(UserRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $repository->shouldReceive('canDeleteCurrency')->andReturn(false); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); $userRepos->shouldReceive('hasRole')->once()->andReturn(true); $this->session(['currencies.delete.uri' => 'http://localhost']); $this->be($this->user()); $response = $this->post(route('currencies.destroy', [1])); $response->assertStatus(302); $response->assertSessionHas('error'); } /** * @covers \FireflyIII\Http\Controllers\CurrencyController::create */ public function testCreate() { // mock stuff $userRepos = $this->mock(UserRepositoryInterface::class); $journalRepos = $this->mock(JournalRepositoryInterface::class); $journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal); $userRepos->shouldReceive('hasRole')->once()->andReturn(true); $this->be($this->user()); $response = $this->get(route('currencies.create')); $response->assertStatus(200); // has bread crumb $response->assertSee('