mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fix tests, improve coverage.
This commit is contained in:
@@ -156,10 +156,10 @@ class TagControllerTest extends TestCase
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('-1')->once();
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('-1')->times(2);
|
||||
$repository->shouldReceive('firstUseDate')->andReturn(new Carbon)->once();
|
||||
$repository->shouldReceive('lastUseDate')->andReturn(new Carbon)->once();
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn('1')->once();
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn('1')->times(2);
|
||||
$repository->shouldReceive('sumsOfTag')->andReturn($amounts)->once();
|
||||
|
||||
$collector->shouldReceive('removeFilter')->andReturnSelf()->once();
|
||||
@@ -225,10 +225,10 @@ class TagControllerTest extends TestCase
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('-1')->once();
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('-1')->times(2);
|
||||
$repository->shouldReceive('firstUseDate')->andReturn(new Carbon)->once();
|
||||
$repository->shouldReceive('lastUseDate')->andReturn(new Carbon)->once();
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn('1')->once();
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn('1')->times(2);
|
||||
|
||||
$collector->shouldReceive('removeFilter')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
|
||||
|
@@ -95,7 +95,7 @@ class LinkControllerTest extends TestCase
|
||||
];
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('find')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('findNull')->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('findLink')->andReturn(false);
|
||||
$repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
|
||||
|
||||
@@ -107,6 +107,35 @@ class LinkControllerTest extends TestCase
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||
*/
|
||||
public function testStoreSame(): void
|
||||
{
|
||||
$repository = $this->mock(LinkTypeRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$data = [
|
||||
'link_other' => 8,
|
||||
'link_type' => '1_inward',
|
||||
];
|
||||
$journal = $this->user()->transactionJournals()->first();
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn($journal);
|
||||
$journalRepos->shouldReceive('findNull')->andReturn($journal);
|
||||
$repository->shouldReceive('findLink')->andReturn(false);
|
||||
$repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.link.store', [$journal->id]), $data);
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('error');
|
||||
$response->assertRedirect(route('transactions.show', [1]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\LinkController::store
|
||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||
@@ -121,7 +150,7 @@ class LinkControllerTest extends TestCase
|
||||
];
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('find')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('findNull')->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('findLink')->andReturn(true);
|
||||
|
||||
$this->be($this->user());
|
||||
|
Reference in New Issue
Block a user