Improve test coverage.

This commit is contained in:
James Cole
2018-09-02 20:13:25 +02:00
parent 96dd89fbeb
commit de754ca4e0
31 changed files with 861 additions and 385 deletions

View File

@@ -231,7 +231,6 @@ class ExpenseControllerTest extends TestCase
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setOpposingAccounts')->andReturnSelf();
$collector->shouldReceive('getTransactions')->andReturn($collection);
//$collector->shouldReceive('')->andReturnSelf();
$this->be($this->user());
$response = $this->get(route('report-data.expense.expenses', ['1', $expense->id, '20170101', '20170131']));
@@ -248,6 +247,36 @@ class ExpenseControllerTest extends TestCase
$repository = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('findByName')->once()->withArgs([$expense->name, [AccountType::REVENUE]])->andReturn($revenue);
// fake collection:
$transA = new Transaction;
$transA->transaction_currency_id = 1;
$transA->transaction_category_name = 'Category';
$transA->transaction_category_id = 1;
$transA->transaction_currency_symbol = 'A';
$transA->transaction_currency_dp = 2;
$transA->transaction_amount = '100';
$transA->opposing_account_id = $expense->id;
$transB = new Transaction;
$transB->transaction_currency_id = 2;
$transB->transaction_category_name = null;
$transB->transaction_category_id = 0;
$transB->transaction_journal_budget_name = 'Category2';
$transB->transaction_journal_budget_id = 2;
$transB->transaction_currency_symbol = 'A';
$transB->transaction_currency_dp = 2;
$transB->transaction_amount = '100';
$transB->opposing_account_id = $expense->id;
$collection = new Collection([$transA, $transB]);
$collector = $this->mock(TransactionCollectorInterface::class);
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('setTypes')->andReturnSelf();
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setOpposingAccounts')->andReturnSelf();
$collector->shouldReceive('getTransactions')->andReturn($collection);
//$collector->shouldReceive('')->andReturnSelf();
$this->be($this->user());
$response = $this->get(route('report-data.expense.income', ['1', $expense->id, '20170101', '20170131']));
$response->assertStatus(200);