Code cleanup and realign.

This commit is contained in:
James Cole
2018-08-06 19:14:30 +02:00
parent f7eef25fed
commit 5908c0ce8c
188 changed files with 1019 additions and 1031 deletions

View File

@@ -107,35 +107,6 @@ 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
@@ -167,7 +138,7 @@ class LinkControllerTest extends TestCase
*/
public function testStoreInvalid(): void
{
$data = [
$data = [
'link_other' => 0,
'link_type' => '1_inward',
];
@@ -183,6 +154,33 @@ 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::switchLink
*/