mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('currencies.create'));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('
');
}
/**
* @covers \FireflyIII\Http\Controllers\CurrencyController::defaultCurrency
*/
public function testDefaultCurrency()
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('currencies.default', [1]));
$response->assertStatus(302);
$response->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\CurrencyController::delete
*/
public function testDelete()
{
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('canDeleteCurrency')->andReturn(true);
$this->be($this->user());
$response = $this->get(route('currencies.delete', [2]));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('');
}
/**
* @covers \FireflyIII\Http\Controllers\CurrencyController::destroy
*/
public function testDestroy()
{
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$repository->shouldReceive('canDeleteCurrency')->andReturn(true);
$repository->shouldReceive('destroy')->andReturn(true);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->session(['currencies.delete.url' => 'http://localhost']);
$this->be($this->user());
$response = $this->post(route('currencies.destroy', [1]));
$response->assertStatus(302);
$response->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\CurrencyController::edit
*/
public function testEdit()
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('currencies.edit', [2]));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('');
}
/**
* @covers \FireflyIII\Http\Controllers\CurrencyController::index
* @covers \FireflyIII\Http\Controllers\CurrencyController::__construct
*/
public function testIndex()
{
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('getCurrencyByPreference')->andReturn(new TransactionCurrency);
$repository->shouldReceive('get')->andReturn(new Collection);
$this->be($this->user());
$response = $this->get(route('currencies.index'));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('');
}
/**
* @covers \FireflyIII\Http\Controllers\CurrencyController::store
*/
public function testStore()
{
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('store')->andReturn(new TransactionCurrency);
$this->session(['currencies.create.url' => 'http://localhost']);
$data = [
'name' => 'XX',
'code' => 'XXX',
'symbol' => 'x',
'decimal_places' => 2,
];
$this->be($this->user());
$response = $this->post(route('currencies.store'), $data);
$response->assertStatus(302);
$response->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\CurrencyController::update
*/
public function testUpdate()
{
// mock stuff
$repository = $this->mock(CurrencyRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('update')->andReturn(new TransactionCurrency);
$this->session(['currencies.edit.url' => 'http://localhost']);
$data = [
'name' => 'XA',
'code' => 'XAX',
'symbol' => 'a',
'decimal_places' => 2,
];
$this->be($this->user());
$response = $this->post(route('currencies.update', [2]), $data);
$response->assertStatus(302);
$response->assertSessionHas('success');
}
}