Code cleanup for #595

This commit is contained in:
James Cole
2017-03-18 11:02:02 +01:00
parent 3215c4ee4b
commit 282ce041e1
14 changed files with 187 additions and 164 deletions

View File

@@ -97,10 +97,14 @@ class BillControllerTest extends TestCase
public function testIndex()
{
// mock stuff
$bill = factory(Bill::class)->make();
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$repository->shouldReceive('getBills')->andReturn(new Collection);
$repository->shouldReceive('getBills')->andReturn(new Collection([$bill]));
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('getPaidDatesInRange')->once()->andReturn(new Collection([1, 2, 3]));
$repository->shouldReceive('getPayDatesInRange')->once()->andReturn(new Collection([1, 2]));
$repository->shouldReceive('nextExpectedMatch')->andReturn(new Carbon);
$this->be($this->user());
$response = $this->get(route('bills.index'));
@@ -115,9 +119,11 @@ class BillControllerTest extends TestCase
public function testRescan()
{
// mock stuff
$journal = factory(TransactionJournal::class)->make();
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$repository->shouldReceive('getPossiblyRelatedJournals')->once()->andReturn(new Collection);
$repository->shouldReceive('getPossiblyRelatedJournals')->once()->andReturn(new Collection([$journal]));
$repository->shouldReceive('scan')->once();
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@@ -126,6 +132,22 @@ class BillControllerTest extends TestCase
$response->assertSessionHas('success');
}
/**
* @covers \FireflyIII\Http\Controllers\BillController::rescan
*/
public function testRescanInactive()
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('bills.rescan', [3]));
$response->assertStatus(302);
$response->assertSessionHas('warning');
}
/**
* @covers \FireflyIII\Http\Controllers\BillController::show
*/