This fixes the broken tests.

This commit is contained in:
James Cole 2016-12-21 20:32:02 +01:00
parent 6fc971c4cb
commit f18a5a6f1b
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 47 additions and 31 deletions

View File

@ -11,6 +11,7 @@
namespace Transaction; namespace Transaction;
use FireflyIII\Models\TransactionJournal;
use TestCase; use TestCase;
/** /**
@ -34,8 +35,10 @@ class ConvertControllerTest extends TestCase
*/ */
public function testIndexDepositTransfer() public function testIndexDepositTransfer()
{ {
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
$this->be($this->user()); $this->be($this->user());
$this->call('get', route('transactions.convert.index', ['transfer', 683])); $this->call('get', route('transactions.convert.index', ['transfer', $deposit->id]));
$this->assertResponseStatus(200); $this->assertResponseStatus(200);
$this->see('Convert a deposit into a transfer'); $this->see('Convert a deposit into a transfer');
} }
@ -45,8 +48,9 @@ class ConvertControllerTest extends TestCase
*/ */
public function testIndexDepositWithdrawal() public function testIndexDepositWithdrawal()
{ {
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
$this->be($this->user()); $this->be($this->user());
$this->call('get', route('transactions.convert.index', ['withdrawal', 683])); $this->call('get', route('transactions.convert.index', ['withdrawal', $deposit->id]));
$this->assertResponseStatus(200); $this->assertResponseStatus(200);
$this->see('Convert a deposit into a withdrawal'); $this->see('Convert a deposit into a withdrawal');
} }
@ -56,8 +60,9 @@ class ConvertControllerTest extends TestCase
*/ */
public function testIndexTransferDeposit() public function testIndexTransferDeposit()
{ {
$transfer = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->first();
$this->be($this->user()); $this->be($this->user());
$this->call('get', route('transactions.convert.index', ['deposit', 684])); $this->call('get', route('transactions.convert.index', ['deposit', $transfer->id]));
$this->assertResponseStatus(200); $this->assertResponseStatus(200);
$this->see('Convert a transfer into a deposit'); $this->see('Convert a transfer into a deposit');
} }
@ -67,8 +72,9 @@ class ConvertControllerTest extends TestCase
*/ */
public function testIndexTransferWithdrawal() public function testIndexTransferWithdrawal()
{ {
$transfer = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->first();
$this->be($this->user()); $this->be($this->user());
$this->call('get', route('transactions.convert.index', ['withdrawal', 684])); $this->call('get', route('transactions.convert.index', ['withdrawal', $transfer->id]));
$this->assertResponseStatus(200); $this->assertResponseStatus(200);
$this->see('Convert a transfer into a withdrawal'); $this->see('Convert a transfer into a withdrawal');
} }
@ -78,8 +84,9 @@ class ConvertControllerTest extends TestCase
*/ */
public function testIndexWithdrawalDeposit() public function testIndexWithdrawalDeposit()
{ {
$withdrawal= TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first();
$this->be($this->user()); $this->be($this->user());
$this->call('get', route('transactions.convert.index', ['deposit', 672])); $this->call('get', route('transactions.convert.index', ['deposit', $withdrawal->id]));
$this->assertResponseStatus(200); $this->assertResponseStatus(200);
$this->see('Convert a withdrawal into a deposit'); $this->see('Convert a withdrawal into a deposit');
} }
@ -89,8 +96,9 @@ class ConvertControllerTest extends TestCase
*/ */
public function testIndexWithdrawalTransfer() public function testIndexWithdrawalTransfer()
{ {
$withdrawal= TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first();
$this->be($this->user()); $this->be($this->user());
$this->call('get', route('transactions.convert.index', ['transfer', 672])); $this->call('get', route('transactions.convert.index', ['transfer', $withdrawal->id]));
$this->assertResponseStatus(200); $this->assertResponseStatus(200);
$this->see('Convert a withdrawal into a transfer'); $this->see('Convert a withdrawal into a transfer');
} }
@ -100,13 +108,14 @@ class ConvertControllerTest extends TestCase
*/ */
public function testPostIndex() public function testPostIndex()
{ {
$withdrawal= TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->first();
// convert a withdrawal to a transfer. Requires the ID of another asset account. // convert a withdrawal to a transfer. Requires the ID of another asset account.
$data = [ $data = [
'destination_account_asset' => 2, 'destination_account_asset' => 2,
]; ];
$this->be($this->user()); $this->be($this->user());
$this->call('post', route('transactions.convert.index', ['transfer', 672]), $data); $this->call('post', route('transactions.convert.index', ['transfer', $withdrawal->id]), $data);
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
$this->assertRedirectedToRoute('transactions.show', [672]); $this->assertRedirectedToRoute('transactions.show', [$withdrawal->id]);
} }
} }

View File

@ -11,6 +11,7 @@
namespace Transaction; namespace Transaction;
use FireflyIII\Models\TransactionJournal;
use TestCase; use TestCase;
/** /**
@ -34,8 +35,9 @@ class MassControllerTest extends TestCase
*/ */
public function testDelete() public function testDelete()
{ {
$withdrawals = TransactionJournal::where('transaction_type_id', 1)->where('user_id', $this->user()->id)->take(2)->get()->pluck('id')->toArray();
$this->be($this->user()); $this->be($this->user());
$this->call('get', route('transactions.mass.delete', [561, 562])); $this->call('get', route('transactions.mass.delete', $withdrawals));
$this->assertResponseStatus(200); $this->assertResponseStatus(200);
$this->see('Delete a number of transactions'); $this->see('Delete a number of transactions');
// has bread crumb // has bread crumb
@ -48,9 +50,9 @@ class MassControllerTest extends TestCase
public function testDestroy() public function testDestroy()
{ {
$this->session(['transactions.mass-delete.url' => 'http://localhost']); $this->session(['transactions.mass-delete.url' => 'http://localhost']);
$deposits = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->take(2)->get()->pluck('id')->toArray();
$data = [ $data = [
'confirm_mass_delete' => [56, 37], 'confirm_mass_delete' => $deposits,
]; ];
$this->be($this->user()); $this->be($this->user());
$this->call('post', route('transactions.mass.destroy'), $data); $this->call('post', route('transactions.mass.destroy'), $data);
@ -58,7 +60,7 @@ class MassControllerTest extends TestCase
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
// visit them should give 404. // visit them should give 404.
$this->call('get', route('transactions.show', [56])); $this->call('get', route('transactions.show', [$deposits[0]]));
$this->assertResponseStatus(404); $this->assertResponseStatus(404);
@ -69,8 +71,9 @@ class MassControllerTest extends TestCase
*/ */
public function testEdit() public function testEdit()
{ {
$transfers = TransactionJournal::where('transaction_type_id', 3)->where('user_id', $this->user()->id)->take(2)->get()->pluck('id')->toArray();
$this->be($this->user()); $this->be($this->user());
$this->call('get', route('transactions.mass.delete', [132, 113])); $this->call('get', route('transactions.mass.delete', $transfers));
$this->assertResponseStatus(200); $this->assertResponseStatus(200);
$this->see('Edit a number of transactions'); $this->see('Edit a number of transactions');
// has bread crumb // has bread crumb
@ -82,27 +85,29 @@ class MassControllerTest extends TestCase
*/ */
public function testUpdate() public function testUpdate()
{ {
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)
->whereNull('deleted_at')
->first();
$this->session(['transactions.mass-edit.url' => 'http://localhost']); $this->session(['transactions.mass-edit.url' => 'http://localhost']);
$data = [ $data = [
'journals' => [132], 'journals' => [$deposit->id],
'description' => [132 => 'Updated salary thing'], 'description' => [$deposit->id => 'Updated salary thing'],
'amount' => [132 => 1600], 'amount' => [$deposit->id => 1600],
'amount_currency_id_amount_132' => 1, 'amount_currency_id_amount_' . $deposit->id => 1,
'date' => [132 => '2014-07-24'], 'date' => [$deposit->id => '2014-07-24'],
'source_account_name' => [132 => 'Job'], 'source_account_name' => [$deposit->id => 'Job'],
'destination_account_id' => [132 => 1], 'destination_account_id' => [$deposit->id => 1],
'category' => [132 => 'Salary'], 'category' => [$deposit->id => 'Salary'],
]; ];
$this->be($this->user()); $this->be($this->user());
$this->call('post', route('transactions.mass.update', [132]), $data); $this->call('post', route('transactions.mass.update', [$deposit->id]), $data);
$this->assertSessionHas('success'); $this->assertSessionHas('success');
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
// visit them should show updated content // visit them should show updated content
$this->call('get', route('transactions.show', [132])); $this->call('get', route('transactions.show', [$deposit->id]));
$this->assertResponseStatus(200); $this->assertResponseStatus(200);
$this->see('Updated salary thing'); $this->see('Updated salary thing');
} }

View File

@ -11,6 +11,7 @@
namespace Transaction; namespace Transaction;
use FireflyIII\Models\TransactionJournal;
use TestCase; use TestCase;
/** /**
@ -35,8 +36,9 @@ class SplitControllerTest extends TestCase
*/ */
public function testEdit() public function testEdit()
{ {
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
$this->be($this->user()); $this->be($this->user());
$this->call('get', route('transactions.split.edit', [18])); $this->call('get', route('transactions.split.edit', [$deposit->id]));
$this->assertResponseStatus(200); $this->assertResponseStatus(200);
// has bread crumb // has bread crumb
$this->see('<ol class="breadcrumb">'); $this->see('<ol class="breadcrumb">');
@ -49,9 +51,9 @@ class SplitControllerTest extends TestCase
public function testUpdate() public function testUpdate()
{ {
$this->session(['transactions.edit-split.url' => 'http://localhost']); $this->session(['transactions.edit-split.url' => 'http://localhost']);
$deposit = TransactionJournal::where('transaction_type_id', 2)->where('user_id', $this->user()->id)->first();
$data = [ $data = [
'id' => 18, 'id' => $deposit->id,
'what' => 'deposit', 'what' => 'deposit',
'journal_description' => 'Updated salary', 'journal_description' => 'Updated salary',
'currency_id' => 1, 'currency_id' => 1,
@ -69,12 +71,12 @@ class SplitControllerTest extends TestCase
], ],
]; ];
$this->be($this->user()); $this->be($this->user());
$this->call('post', route('transactions.split.update', [18]), $data); $this->call('post', route('transactions.split.update', [$deposit->id]), $data);
$this->assertResponseStatus(302); $this->assertResponseStatus(302);
$this->assertSessionHas('success'); $this->assertSessionHas('success');
// journal is updated? // journal is updated?
$this->call('get', route('transactions.show', [18])); $this->call('get', route('transactions.show', [$deposit->id]));
$this->assertResponseStatus(200); $this->assertResponseStatus(200);
$this->see('Updated salary'); $this->see('Updated salary');
// has bread crumb // has bread crumb