mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Code cleanup.
This commit is contained in:
parent
e5a2e1a8c7
commit
879f74e521
@ -13,7 +13,7 @@ trait CreatesApplication
|
|||||||
*/
|
*/
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
$app = require __DIR__.'/../bootstrap/app.php';
|
$app = require __DIR__ . '/../bootstrap/app.php';
|
||||||
|
|
||||||
$app->make(Kernel::class)->bootstrap();
|
$app->make(Kernel::class)->bootstrap();
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ class AccountControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$this->session(['start' => $date, 'end' => clone $date]);
|
$this->session(['start' => $date, 'end' => clone $date]);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@ -244,7 +244,7 @@ class AccountControllerTest extends TestCase
|
|||||||
$transaction = factory(Transaction::class)->make();
|
$transaction = factory(Transaction::class)->make();
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
$collector = $this->mock(JournalCollectorInterface::class);
|
$collector = $this->mock(JournalCollectorInterface::class);
|
||||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||||
@ -307,7 +307,7 @@ class AccountControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
$date = new Carbon;
|
$date = new Carbon;
|
||||||
$this->session(['start' => $date, 'end' => clone $date]);
|
$this->session(['start' => $date, 'end' => clone $date]);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
@ -40,7 +40,7 @@ class AttachmentControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
$repository->shouldReceive('destroy')->andReturn(true);
|
$repository->shouldReceive('destroy')->andReturn(true);
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class AttachmentControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
$repository->shouldReceive('exists')->once()->andReturn(true);
|
$repository->shouldReceive('exists')->once()->andReturn(true);
|
||||||
$repository->shouldReceive('getContent')->once()->andReturn('This is attachment number one.');
|
$repository->shouldReceive('getContent')->once()->andReturn('This is attachment number one.');
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
@ -104,7 +104,7 @@ class AttachmentControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
$repository = $this->mock(AttachmentRepositoryInterface::class);
|
||||||
$repository->shouldReceive('update')->once();
|
$repository->shouldReceive('update')->once();
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ class BudgetControllerTest extends TestCase
|
|||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
$collector = $this->mock(JournalCollectorInterface::class);
|
$collector = $this->mock(JournalCollectorInterface::class);
|
||||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
|
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
|
||||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||||
@ -238,7 +238,7 @@ class BudgetControllerTest extends TestCase
|
|||||||
public function testShowByBudgetLimit(string $range)
|
public function testShowByBudgetLimit(string $range)
|
||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
// mock account repository
|
// mock account repository
|
||||||
@ -276,7 +276,7 @@ class BudgetControllerTest extends TestCase
|
|||||||
public function testStore()
|
public function testStore()
|
||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$budget = factory(Budget::class)->make();
|
$budget = factory(Budget::class)->make();
|
||||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
@ -299,7 +299,7 @@ class BudgetControllerTest extends TestCase
|
|||||||
public function testUpdate()
|
public function testUpdate()
|
||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
$budget = factory(Budget::class)->make();
|
$budget = factory(Budget::class)->make();
|
||||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
|
@ -15,6 +15,7 @@ namespace Tests\Feature\Controllers\Chart;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class BudgetControllerTest extends TestCase
|
class BudgetControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ class BudgetControllerTest extends TestCase
|
|||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$this->changeDateRange($this->user(), $range);
|
$this->changeDateRange($this->user(), $range);
|
||||||
$response = $this->get(route('chart.budget.budget-limit', [1,1]));
|
$response = $this->get(route('chart.budget.budget-limit', [1, 1]));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +76,7 @@ class BudgetControllerTest extends TestCase
|
|||||||
public function testPeriod()
|
public function testPeriod()
|
||||||
{
|
{
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('chart.budget.period', [1,'1','20120101','20120131']));
|
$response = $this->get(route('chart.budget.period', [1, '1', '20120101', '20120131']));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +86,7 @@ class BudgetControllerTest extends TestCase
|
|||||||
public function testPeriodNoBudget()
|
public function testPeriodNoBudget()
|
||||||
{
|
{
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('chart.budget.period.no-budget', ['1','20120101','20120131']));
|
$response = $this->get(route('chart.budget.period.no-budget', ['1', '20120101', '20120131']));
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class ExportControllerTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
|
||||||
'export_start_range' => '2015-01-01',
|
'export_start_range' => '2015-01-01',
|
||||||
'export_end_range' => '2015-01-21',
|
'export_end_range' => '2015-01-21',
|
||||||
|
@ -13,8 +13,8 @@ namespace Tests\Feature\Controllers;
|
|||||||
|
|
||||||
use FireflyIII\Import\ImportProcedureInterface;
|
use FireflyIII\Import\ImportProcedureInterface;
|
||||||
use FireflyIII\Import\Setup\CsvSetup;
|
use FireflyIII\Import\Setup\CsvSetup;
|
||||||
use Tests\TestCase;
|
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
class ImportControllerTest extends TestCase
|
class ImportControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -160,8 +160,8 @@ class ImportControllerTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testUpload()
|
public function testUpload()
|
||||||
{
|
{
|
||||||
$path = resource_path('stubs/csv.csv');
|
$path = resource_path('stubs/csv.csv');
|
||||||
$file = new UploadedFile($path, 'upload.csv', filesize($path), 'text/csv', null, true);
|
$file = new UploadedFile($path, 'upload.csv', filesize($path), 'text/csv', null, true);
|
||||||
$response = $this->post(route('import.upload'), [], [], ['import_file' => $file], ['Accept' => 'application/json']);
|
$response = $this->post(route('import.upload'), [], [], ['import_file' => $file], ['Accept' => 'application/json']);
|
||||||
$response->assertStatus(302);
|
$response->assertStatus(302);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class ReportControllerTest extends TestCase
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
||||||
$response = $this->get($uri);
|
$response = $this->get($uri);
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ class ReportControllerTest extends TestCase
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
||||||
$response = $this->get($uri);
|
$response = $this->get($uri);
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ class ReportControllerTest extends TestCase
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
||||||
$response = $this->get($uri);
|
$response = $this->get($uri);
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ class ReportControllerTest extends TestCase
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
||||||
$response = $this->get($uri);
|
$response = $this->get($uri);
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ class ReportControllerTest extends TestCase
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
$uri = route('popup.general') . '?' . http_build_query($arguments);
|
||||||
$response = $this->get($uri);
|
$response = $this->get($uri);
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ class OperationsControllerTest extends TestCase
|
|||||||
public function testExpenses()
|
public function testExpenses()
|
||||||
{
|
{
|
||||||
$transactions = factory(Transaction::class, 10)->make();
|
$transactions = factory(Transaction::class, 10)->make();
|
||||||
$collector = $this->mock(JournalCollectorInterface::class);
|
$collector = $this->mock(JournalCollectorInterface::class);
|
||||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||||
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]])->andReturnSelf();
|
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]])->andReturnSelf();
|
||||||
@ -48,7 +48,7 @@ class OperationsControllerTest extends TestCase
|
|||||||
public function testIncome()
|
public function testIncome()
|
||||||
{
|
{
|
||||||
$transactions = factory(Transaction::class, 10)->make();
|
$transactions = factory(Transaction::class, 10)->make();
|
||||||
$collector = $this->mock(JournalCollectorInterface::class);
|
$collector = $this->mock(JournalCollectorInterface::class);
|
||||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||||
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::DEPOSIT, TransactionType::TRANSFER]])->andReturnSelf();
|
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::DEPOSIT, TransactionType::TRANSFER]])->andReturnSelf();
|
||||||
|
@ -147,8 +147,8 @@ class RuleGroupControllerTest extends TestCase
|
|||||||
public function testUpdate()
|
public function testUpdate()
|
||||||
{
|
{
|
||||||
$data = [
|
$data = [
|
||||||
'title' => 'C',
|
'title' => 'C',
|
||||||
'description' => 'XX',
|
'description' => 'XX',
|
||||||
];
|
];
|
||||||
$this->session(['rule-groups.edit.url' => 'http://localhost']);
|
$this->session(['rule-groups.edit.url' => 'http://localhost']);
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ use FireflyIII\Models\AccountType;
|
|||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\Support\Twig\Transaction;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
@ -90,7 +90,7 @@ class MassControllerTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::edit
|
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::edit
|
||||||
*/
|
*/
|
||||||
public function testEditMultipleNothingLeft()
|
public function testEditMultiple()
|
||||||
{
|
{
|
||||||
Log::debug('Edit multiple.');
|
Log::debug('Edit multiple.');
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
@ -98,7 +98,19 @@ class MassControllerTest extends TestCase
|
|||||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||||
|
|
||||||
// default transactions
|
// default transactions
|
||||||
$collection = new Collection;
|
$collection = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(2)->get();
|
||||||
|
|
||||||
|
// add deposit (with multiple sources)
|
||||||
|
$collection->push(
|
||||||
|
TransactionJournal::where('transaction_type_id', 2)
|
||||||
|
->whereNull('transaction_journals.deleted_at')
|
||||||
|
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
|
->groupBy('transaction_journals.id')
|
||||||
|
->orderBy('ct', 'DESC')
|
||||||
|
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
||||||
|
);
|
||||||
|
|
||||||
|
// add withdrawal (with multiple destinations)
|
||||||
$collection->push(
|
$collection->push(
|
||||||
TransactionJournal::where('transaction_type_id', 1)
|
TransactionJournal::where('transaction_type_id', 1)
|
||||||
->whereNull('transaction_journals.deleted_at')
|
->whereNull('transaction_journals.deleted_at')
|
||||||
@ -121,7 +133,7 @@ class MassControllerTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::edit
|
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::edit
|
||||||
*/
|
*/
|
||||||
public function testEditMultiple()
|
public function testEditMultipleNothingLeft()
|
||||||
{
|
{
|
||||||
Log::debug('Edit multiple.');
|
Log::debug('Edit multiple.');
|
||||||
// mock stuff:
|
// mock stuff:
|
||||||
@ -129,19 +141,7 @@ class MassControllerTest extends TestCase
|
|||||||
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
|
||||||
|
|
||||||
// default transactions
|
// default transactions
|
||||||
$collection = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(2)->get();
|
$collection = new Collection;
|
||||||
|
|
||||||
// add deposit (with multiple sources)
|
|
||||||
$collection->push(
|
|
||||||
TransactionJournal::where('transaction_type_id', 2)
|
|
||||||
->whereNull('transaction_journals.deleted_at')
|
|
||||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
|
||||||
->groupBy('transaction_journals.id')
|
|
||||||
->orderBy('ct', 'DESC')
|
|
||||||
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
|
|
||||||
);
|
|
||||||
|
|
||||||
// add withdrawal (with multiple destinations)
|
|
||||||
$collection->push(
|
$collection->push(
|
||||||
TransactionJournal::where('transaction_type_id', 1)
|
TransactionJournal::where('transaction_type_id', 1)
|
||||||
->whereNull('transaction_journals.deleted_at')
|
->whereNull('transaction_journals.deleted_at')
|
||||||
|
@ -185,54 +185,6 @@ class SingleControllerTest extends TestCase
|
|||||||
$response->assertStatus(302);
|
$response->assertStatus(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
|
||||||
*/
|
|
||||||
public function testStoreSuccess()
|
|
||||||
{
|
|
||||||
// mock results:
|
|
||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
|
||||||
$journal = new TransactionJournal();
|
|
||||||
$journal->id = 1000;
|
|
||||||
$journal->description = 'New journal';
|
|
||||||
$repository->shouldReceive('store')->andReturn($journal);
|
|
||||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
|
||||||
$this->expectsEvents(StoredTransactionJournal::class);
|
|
||||||
|
|
||||||
$errors = new MessageBag;
|
|
||||||
$errors->add('attachments','Fake error');
|
|
||||||
|
|
||||||
$messages = new MessageBag;
|
|
||||||
$messages->add('attachments','Fake error');
|
|
||||||
|
|
||||||
// mock attachment helper, trigger an error AND and info thing.
|
|
||||||
$attachmentRepo = $this->mock(AttachmentHelperInterface::class);
|
|
||||||
$attachmentRepo->shouldReceive('saveAttachmentsForModel');
|
|
||||||
$attachmentRepo->shouldReceive('getErrors')->andReturn($errors);
|
|
||||||
$attachmentRepo->shouldReceive('getMessages')->andReturn($messages);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->session(['transactions.create.url' => 'http://localhost']);
|
|
||||||
$this->be($this->user());
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'what' => 'withdrawal',
|
|
||||||
'amount' => '10',
|
|
||||||
'amount_currency_id_amount' => 1,
|
|
||||||
'source_account_id' => 1,
|
|
||||||
'destination_account_name' => 'Some destination',
|
|
||||||
'date' => '2016-01-01',
|
|
||||||
'description' => 'Test descr',
|
|
||||||
];
|
|
||||||
$response = $this->post(route('transactions.store', ['withdrawal']), $data);
|
|
||||||
$response->assertStatus(302);
|
|
||||||
$response->assertSessionHas('success');
|
|
||||||
$response->assertSessionHas('error');
|
|
||||||
$response->assertSessionHas('info');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
||||||
*/
|
*/
|
||||||
@ -261,6 +213,52 @@ class SingleControllerTest extends TestCase
|
|||||||
$response->assertSessionHas('error');
|
$response->assertSessionHas('error');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
||||||
|
*/
|
||||||
|
public function testStoreSuccess()
|
||||||
|
{
|
||||||
|
// mock results:
|
||||||
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$journal = new TransactionJournal();
|
||||||
|
$journal->id = 1000;
|
||||||
|
$journal->description = 'New journal';
|
||||||
|
$repository->shouldReceive('store')->andReturn($journal);
|
||||||
|
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
|
$this->expectsEvents(StoredTransactionJournal::class);
|
||||||
|
|
||||||
|
$errors = new MessageBag;
|
||||||
|
$errors->add('attachments', 'Fake error');
|
||||||
|
|
||||||
|
$messages = new MessageBag;
|
||||||
|
$messages->add('attachments', 'Fake error');
|
||||||
|
|
||||||
|
// mock attachment helper, trigger an error AND and info thing.
|
||||||
|
$attachmentRepo = $this->mock(AttachmentHelperInterface::class);
|
||||||
|
$attachmentRepo->shouldReceive('saveAttachmentsForModel');
|
||||||
|
$attachmentRepo->shouldReceive('getErrors')->andReturn($errors);
|
||||||
|
$attachmentRepo->shouldReceive('getMessages')->andReturn($messages);
|
||||||
|
|
||||||
|
|
||||||
|
$this->session(['transactions.create.url' => 'http://localhost']);
|
||||||
|
$this->be($this->user());
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'what' => 'withdrawal',
|
||||||
|
'amount' => '10',
|
||||||
|
'amount_currency_id_amount' => 1,
|
||||||
|
'source_account_id' => 1,
|
||||||
|
'destination_account_name' => 'Some destination',
|
||||||
|
'date' => '2016-01-01',
|
||||||
|
'description' => 'Test descr',
|
||||||
|
];
|
||||||
|
$response = $this->post(route('transactions.store', ['withdrawal']), $data);
|
||||||
|
$response->assertStatus(302);
|
||||||
|
$response->assertSessionHas('success');
|
||||||
|
$response->assertSessionHas('error');
|
||||||
|
$response->assertSessionHas('info');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::update
|
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::update
|
||||||
*/
|
*/
|
||||||
@ -272,9 +270,9 @@ class SingleControllerTest extends TestCase
|
|||||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journal = new TransactionJournal();
|
$journal = new TransactionJournal();
|
||||||
|
|
||||||
$type = TransactionType::find(1);
|
$type = TransactionType::find(1);
|
||||||
$journal->id = 1000;
|
$journal->id = 1000;
|
||||||
$journal->description = 'New journal';
|
$journal->description = 'New journal';
|
||||||
$journal->transactionType()->associate($type);
|
$journal->transactionType()->associate($type);
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,18 +67,6 @@ class TransactionControllerTest extends TestCase
|
|||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Http\Controllers\Controller::redirectToAccount
|
|
||||||
* @covers \FireflyIII\Http\Controllers\TransactionController::show
|
|
||||||
*/
|
|
||||||
public function testShowOpeningBalance()
|
|
||||||
{
|
|
||||||
$this->be($this->user());
|
|
||||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id',4)->first();
|
|
||||||
$response = $this->get(route('transactions.show', [$journal->id]));
|
|
||||||
$response->assertStatus(302);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\TransactionController::show
|
* @covers \FireflyIII\Http\Controllers\TransactionController::show
|
||||||
*/
|
*/
|
||||||
@ -90,4 +78,16 @@ class TransactionControllerTest extends TestCase
|
|||||||
$response->assertSee('<ol class="breadcrumb">');
|
$response->assertSee('<ol class="breadcrumb">');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \FireflyIII\Http\Controllers\Controller::redirectToAccount
|
||||||
|
* @covers \FireflyIII\Http\Controllers\TransactionController::show
|
||||||
|
*/
|
||||||
|
public function testShowOpeningBalance()
|
||||||
|
{
|
||||||
|
$this->be($this->user());
|
||||||
|
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 4)->first();
|
||||||
|
$response = $this->get(route('transactions.show', [$journal->id]));
|
||||||
|
$response->assertStatus(302);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,11 @@ class ExampleTest extends TestCase
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testBasicTest()
|
public function testAnotherBasicTest()
|
||||||
{
|
{
|
||||||
$response = $this->get('/login');
|
$response = $this->get('/');
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,10 +31,10 @@ class ExampleTest extends TestCase
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAnotherBasicTest()
|
public function testBasicTest()
|
||||||
{
|
{
|
||||||
$response = $this->get('/');
|
$response = $this->get('/login');
|
||||||
|
|
||||||
$response->assertStatus(302);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user