mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 19:01:58 +00:00
Fix tests, improve coverage.
This commit is contained in:
@@ -107,7 +107,7 @@ class LinkController extends Controller
|
|||||||
|
|
||||||
return redirect(route('transactions.show', [$journal->id]));
|
return redirect(route('transactions.show', [$journal->id]));
|
||||||
}
|
}
|
||||||
$other = $this->journalRepository->find($linkInfo['transaction_journal_id']);
|
$other = $this->journalRepository->findNull($linkInfo['transaction_journal_id']);
|
||||||
$alreadyLinked = $this->repository->findLink($journal, $other);
|
$alreadyLinked = $this->repository->findLink($journal, $other);
|
||||||
|
|
||||||
if ($other->id === $journal->id) {
|
if ($other->id === $journal->id) {
|
||||||
|
@@ -104,7 +104,9 @@ class Authenticate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (QueryException $e) {
|
} catch (QueryException $e) {
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
throw new FireflyException('It seems the database has not yet been initialized. Did you run the correct upgrade or installation commands?');
|
throw new FireflyException('It seems the database has not yet been initialized. Did you run the correct upgrade or installation commands?');
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->auth->authenticate();
|
return $this->auth->authenticate();
|
||||||
|
@@ -156,10 +156,10 @@ class TagControllerTest extends TestCase
|
|||||||
$collector = $this->mock(JournalCollectorInterface::class);
|
$collector = $this->mock(JournalCollectorInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$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('firstUseDate')->andReturn(new Carbon)->once();
|
||||||
$repository->shouldReceive('lastUseDate')->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();
|
$repository->shouldReceive('sumsOfTag')->andReturn($amounts)->once();
|
||||||
|
|
||||||
$collector->shouldReceive('removeFilter')->andReturnSelf()->once();
|
$collector->shouldReceive('removeFilter')->andReturnSelf()->once();
|
||||||
@@ -225,10 +225,10 @@ class TagControllerTest extends TestCase
|
|||||||
$collector = $this->mock(JournalCollectorInterface::class);
|
$collector = $this->mock(JournalCollectorInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
$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('firstUseDate')->andReturn(new Carbon)->once();
|
||||||
$repository->shouldReceive('lastUseDate')->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('removeFilter')->andReturnSelf()->once();
|
||||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
|
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
|
||||||
|
@@ -95,7 +95,7 @@ class LinkControllerTest extends TestCase
|
|||||||
];
|
];
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
$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('findLink')->andReturn(false);
|
||||||
$repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
|
$repository->shouldReceive('storeLink')->andReturn(new TransactionJournalLink);
|
||||||
|
|
||||||
@@ -107,6 +107,35 @@ class LinkControllerTest extends TestCase
|
|||||||
$response->assertRedirect(route('transactions.show', [1]));
|
$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\Controllers\Transaction\LinkController::store
|
||||||
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
* @covers \FireflyIII\Http\Requests\JournalLinkRequest
|
||||||
@@ -121,7 +150,7 @@ class LinkControllerTest extends TestCase
|
|||||||
];
|
];
|
||||||
|
|
||||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||||
$journalRepos->shouldReceive('find')->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('findNull')->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('findLink')->andReturn(true);
|
$repository->shouldReceive('findLink')->andReturn(true);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
Reference in New Issue
Block a user