Covered transaction controller.

This commit is contained in:
James Cole
2015-05-05 07:28:04 +02:00
parent 3176e54614
commit 59d2bf3f79
5 changed files with 119 additions and 20 deletions

View File

@@ -15,7 +15,7 @@ class TransactionControllerTest extends TestCase
public function setUp()
{
parent::setUp();
FactoryMuffin::create('FireflyIII\User');
}
/**
@@ -227,12 +227,92 @@ class TransactionControllerTest extends TestCase
public function testStore()
{
$this->markTestIncomplete();
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$this->be($account->user);
$data = [
'reminder_id' => '',
'what' => 'withdrawal',
'description' => 'Bla bla bla',
'account_id' => $account->id,
'expense_account' => 'Bla bla',
'amount' => '100',
'amount_currency_id' => $currency->id,
'date' => '2015-05-05',
'budget_id' => '0',
'create_another' => '1',
'category' => '',
'tags' => '',
'piggy_bank_id' => '0',
'_token' => 'replaceMe',
];
// mock!
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
// fake!
$repository->shouldReceive('store')->andReturn($journal);
$repository->shouldReceive('deactivateReminder')->andReturnNull();
$this->call('POST', '/transactions/store/withdrawal', $data);
//$this->assertSessionHas('errors','bla');
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
public function testUpdate()
{
$this->markTestIncomplete();
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType');
$this->be($journal->user);
$account->user_id = $journal->user_id;
$account->save();
$data = [
'_token' => 'replaceMe',
'id' => $journal->id,
'what' => 'withdrawal',
'description' => 'LunchX',
'account_id' => $account->id,
'expense_account' => 'Lunch House',
'amount' => '4.72',
'amount_currency_id' => '1',
'date' => '2015-05-31',
'budget_id' => '0',
'category' => 'Lunch',
'return_to_edit' => 1,
'tags' => '',
'piggy_bank_id' => '0',
];
$this->call('POST', '/transactions/store/withdrawal', $data);
// mock!
$repository = $this->mock('FireflyIII\Repositories\Journal\JournalRepositoryInterface');
// fake!
$repository->shouldReceive('update')->andReturn($journal);
$this->call('POST', '/transaction/update/' . $journal->id, $data);
//$this->assertSessionHas('errors','bla');
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
}