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

@@ -75,32 +75,6 @@ class BulkControllerTest extends TestCase
$response->assertSee('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
*/
public function testEditNull(): void
{
// mock stuff:
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal, null);
$journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer');
$journalRepos->shouldReceive('isJournalReconciled')->andReturn(false);
$transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(4)->get()->pluck('id')->toArray();
$this->be($this->user());
$response = $this->get(route('transactions.bulk.edit', $transfers));
$response->assertStatus(200);
$response->assertSee('Bulk edit a number of transactions');
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::edit
*/
@@ -136,6 +110,32 @@ class BulkControllerTest extends TestCase
$response->assertSee('multiple destination accounts');
}
/**
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController
*/
public function testEditNull(): void
{
// mock stuff:
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection);
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection);
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal, null);
$journalRepos->shouldReceive('getTransactionType')->andReturn('Transfer');
$journalRepos->shouldReceive('isJournalReconciled')->andReturn(false);
$transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(4)->get()->pluck('id')->toArray();
$this->be($this->user());
$response = $this->get(route('transactions.bulk.edit', $transfers));
$response->assertStatus(200);
$response->assertSee('Bulk edit a number of transactions');
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\Transaction\BulkController::update
* @covers \FireflyIII\Http\Requests\BulkEditJournalRequest

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
*/

View File

@@ -202,8 +202,8 @@ class MassControllerTest extends TestCase
'amount' => [$deposit->id => 1600],
'amount_currency_id_amount_' . $deposit->id => 1,
'date' => [$deposit->id => '2014-07-24'],
'source_name' => [$deposit->id => 'Job'],
'destination_id' => [$deposit->id => 1],
'source_name' => [$deposit->id => 'Job'],
'destination_id' => [$deposit->id => 1],
'category' => [$deposit->id => 'Salary'],
];

View File

@@ -29,7 +29,6 @@ use FireflyIII\Events\StoredTransactionJournal;
use FireflyIII\Events\UpdatedTransactionJournal;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Note;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
@@ -849,7 +848,6 @@ class SingleControllerTest extends TestCase
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection);
$linkRepos->shouldReceive('get')->andReturn(new Collection);
$linkRepos->shouldReceive('getLinks')->andReturn(new Collection);
$attRepos->shouldReceive('saveAttachmentsForModel');

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers\Transaction;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
@@ -77,7 +76,6 @@ class SplitControllerTest extends TestCase
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
$destination = $deposit->transactions()->where('amount', '>', 0)->first();
$account = $destination->account;
@@ -131,7 +129,6 @@ class SplitControllerTest extends TestCase
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1));
$currencyRepository->shouldReceive('get')->once()->andReturn(new Collection);
$budgetRepository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
@@ -292,15 +289,15 @@ class SplitControllerTest extends TestCase
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
$deposit = $this->user()->transactionJournals()->where('transaction_type_id', 2)->first();
$data = [
'id' => $deposit->id,
'what' => 'deposit',
'journal_description' => 'Updated salary',
'journal_currency_id' => 1,
'id' => $deposit->id,
'what' => 'deposit',
'journal_description' => 'Updated salary',
'journal_currency_id' => 1,
'journal_destination_id' => 1,
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
[
'transaction_description' => 'Split #1',
'source_name' => 'Job',
@@ -342,15 +339,15 @@ class SplitControllerTest extends TestCase
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
$opening = TransactionJournal::where('transaction_type_id', 4)->where('user_id', $this->user()->id)->first();
$data = [
'id' => $opening->id,
'what' => 'opening balance',
'journal_description' => 'Updated salary',
'journal_currency_id' => 1,
'id' => $opening->id,
'what' => 'opening balance',
'journal_description' => 'Updated salary',
'journal_currency_id' => 1,
'journal_destination_id' => 1,
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
[
'transaction_description' => 'Split #1',
'source_name' => 'Job',
@@ -390,18 +387,18 @@ class SplitControllerTest extends TestCase
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
$transfer = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 3)->first();
$data = [
'id' => $transfer->id,
'what' => 'transfer',
'journal_description' => 'Some updated withdrawal',
'journal_currency_id' => 1,
'journal_source_id' => 1,
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
'id' => $transfer->id,
'what' => 'transfer',
'journal_description' => 'Some updated withdrawal',
'journal_currency_id' => 1,
'journal_source_id' => 1,
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
[
'transaction_description' => 'Split #1',
'source_id' => '1',
'source_id' => '1',
'destination_id' => '2',
'transaction_currency_id' => 1,
'amount' => 1591,
@@ -446,15 +443,15 @@ class SplitControllerTest extends TestCase
$this->session(['transactions.edit-split.uri' => 'http://localhost']);
$withdrawal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 1)->first();
$data = [
'id' => $withdrawal->id,
'what' => 'withdrawal',
'journal_description' => 'Some updated withdrawal',
'journal_currency_id' => 1,
'journal_source_id' => 1,
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
'id' => $withdrawal->id,
'what' => 'withdrawal',
'journal_description' => 'Some updated withdrawal',
'journal_currency_id' => 1,
'journal_source_id' => 1,
'journal_amount' => 1591,
'date' => '2014-01-24',
'tags' => '',
'transactions' => [
[
'transaction_description' => 'Split #1',
'source_id' => '1',