Expand tests.

This commit is contained in:
James Cole 2017-03-12 21:24:34 +01:00
parent aedc3fdff9
commit e53d294c1c
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
13 changed files with 448 additions and 6 deletions

View File

@ -20,7 +20,6 @@ use FireflyIII\Helpers\Collection\BalanceLine;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;

View File

@ -217,6 +217,7 @@ class AccountControllerTest extends TestCase
*/
public function testShowBrokenInitial()
{
// mock
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$date = new Carbon;
@ -301,6 +302,7 @@ class AccountControllerTest extends TestCase
*/
public function testShowInitial()
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$date = new Carbon;
@ -317,6 +319,7 @@ class AccountControllerTest extends TestCase
*/
public function testStore()
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('find')->andReturn(new Account)->once();
@ -340,6 +343,7 @@ class AccountControllerTest extends TestCase
*/
public function testUpdate()
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('find')->andReturn(new Account)->once();

View File

@ -24,6 +24,7 @@ class AttachmentControllerTest extends TestCase
*/
public function testDelete()
{
// mock stuff
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());

View File

@ -0,0 +1,181 @@
<?php
/**
* TagReportControllerTest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace Tests\Feature\Controllers\Chart;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Chart\MetaPieChartInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\TransactionType;
use Illuminate\Support\Collection;
use Tests\TestCase;
/**
* Class TagReportControllerTest
*
* @package Tests\Feature\Controllers\Chart
*/
class TagReportControllerTest extends TestCase
{
/**
* @covers \FireflyIII\Http\Controllers\Chart\TagReportController::accountExpense
* @covers \FireflyIII\Http\Controllers\Chart\TagReportController::__construct
*/
public function testAccountExpense()
{
$generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'account'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user());
$response = $this->get(route('chart.tag.account-expense', ['1', 'housing', '20120101', '20120131', 0]));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Chart\TagReportController::accountIncome
*/
public function testAccountIncome()
{
$generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['income', 'account'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user());
$response = $this->get(route('chart.tag.account-income', ['1', 'housing', '20120101', '20120131', 0]));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Chart\TagReportController::budgetExpense()
*/
public function testBudgetExpense()
{
$generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'budget'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user());
$response = $this->get(route('chart.tag.budget-expense', ['1', 'housing', '20120101', '20120131', 0]));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Chart\TagReportController::categoryExpense()
*/
public function testCategoryExpense()
{
$generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'category'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user());
$response = $this->get(route('chart.tag.category-expense', ['1', 'housing', '20120101', '20120131', 0]));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Chart\TagReportController::mainChart()
*/
public function testMainChart()
{
$generator = $this->mock(GeneratorInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]])->andReturnSelf();
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::DEPOSIT, TransactionType::TRANSFER]])->andReturnSelf();
$collector->shouldReceive('disableFilter')->andReturnSelf();
$collector->shouldReceive('setTags')->andReturnSelf();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
$collector->shouldReceive('getJournals')->andReturn(new Collection);
$generator->shouldReceive('multiSet')->andReturn([])->once();
$this->be($this->user());
$response = $this->get(route('chart.tag.main', ['1', 'housing', '20120101', '20120131']));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Chart\TagReportController::tagExpense()
*/
public function testTagExpense()
{
$generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['expense', 'tag'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user());
$response = $this->get(route('chart.tag.tag-expense', ['1', 'housing', '20120101', '20120131', 0]));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Chart\TagReportController::tagIncome()
*/
public function testTagIncome()
{
$generator = $this->mock(GeneratorInterface::class);
$pieChart = $this->mock(MetaPieChartInterface::class);
$pieChart->shouldReceive('setAccounts')->once()->andReturnSelf();
$pieChart->shouldReceive('setTags')->once()->andReturnSelf();
$pieChart->shouldReceive('setStart')->once()->andReturnSelf();
$pieChart->shouldReceive('setEnd')->once()->andReturnSelf();
$pieChart->shouldReceive('setCollectOtherObjects')->once()->andReturnSelf()->withArgs([false]);
$pieChart->shouldReceive('generate')->withArgs(['income', 'tag'])->andReturn([])->once();
$generator->shouldReceive('pieChart')->andReturn([])->once();
$this->be($this->user());
$response = $this->get(route('chart.tag.tag-income', ['1', 'housing', '20120101', '20120131', 0]));
$response->assertStatus(200);
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* JavascriptControllerTest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace Tests\Feature\Controllers;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Support\Collection;
use Tests\TestCase;
/**
* Class JavascriptControllerTest
*
* @package Tests\Feature\Controllers
*/
class JavascriptControllerTest extends TestCase
{
/**
* @covers \FireflyIII\Http\Controllers\JavascriptController::accounts
*/
public function testAccounts()
{
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$account = factory(Account::class)->make();
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]))
->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->once();
$currencyRepos->shouldReceive('findByCode')->withArgs(['EUR'])->andReturn(new TransactionCurrency);
$this->be($this->user());
$response = $this->get(route('javascript.accounts'));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\JavascriptController::variables
* @covers \FireflyIII\Http\Controllers\JavascriptController::getDateRangePicker
*
* @param string $range
*
* @dataProvider dateRangeProvider
*/
public function testVariables(string $range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$response = $this->get(route('javascript.variables'));
$response->assertStatus(200);
}
}

View File

@ -13,8 +13,18 @@ namespace Tests\Feature\Controllers\Popup;
use Carbon\Carbon;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget;
use FireflyIII\Models\Category;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use Illuminate\Support\Collection;
use Tests\TestCase;
/**
* Class ReportControllerTest
*
@ -25,9 +35,24 @@ class ReportControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::general
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::parseAttributes
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::balanceAmount
*/
public function testBalanceAmount()
{
$collector = $this->mock(JournalCollectorInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$budget = factory(Budget::class)->make();
$account = factory(Account::class)->make();
$budgetRepos->shouldReceive('find')->andReturn($budget)->once()->withArgs([1]);
$accountRepos->shouldReceive('find')->andReturn($account)->once()->withArgs([1]);
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL]])->andReturnSelf();
$collector->shouldReceive('setRange')->once()->andReturnSelf();
$collector->shouldReceive('withoutBudget')->once()->andReturnSelf();
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection);
$this->be($this->user());
$arguments = [
@ -49,9 +74,20 @@ class ReportControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::general
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::parseAttributes
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::budgetSpentAmount()
*/
public function testBudgetSpentAmount()
{
$collector = $this->mock(JournalCollectorInterface::class);
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
$budget = factory(Budget::class)->make();
$budgetRepos->shouldReceive('find')->andReturn($budget)->once()->withArgs([1]);
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setRange')->once()->andReturnSelf();
$collector->shouldReceive('setBudget')->once()->andReturnSelf();
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection);
$this->be($this->user());
$arguments = [
@ -72,9 +108,21 @@ class ReportControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::general
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::parseAttributes
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::categoryEntry()
*/
public function testCategoryEntry()
{
$collector = $this->mock(JournalCollectorInterface::class);
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
$category = factory(Category::class)->make();
$categoryRepos->shouldReceive('find')->andReturn($category)->once()->withArgs([1]);
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setTypes')->andReturnSelf()->once()->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]]);
$collector->shouldReceive('setRange')->once()->andReturnSelf();
$collector->shouldReceive('setCategory')->once()->andReturnSelf();
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection);
$this->be($this->user());
$arguments = [
@ -95,9 +143,20 @@ class ReportControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::general
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::parseAttributes
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::expenseEntry()
*/
public function testExpenseEntry()
{
$collector = $this->mock(JournalCollectorInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$account = factory(Account::class)->make();
$accountRepos->shouldReceive('find')->withArgs([1])->andReturn($account)->once();
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setTypes')->andReturnSelf()->once()->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]]);
$collector->shouldReceive('setRange')->once()->andReturnSelf();
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection);
$this->be($this->user());
$arguments = [
@ -118,9 +177,20 @@ class ReportControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::general
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::parseAttributes
* @covers \FireflyIII\Http\Controllers\Popup\ReportController::incomeEntry()
*/
public function testIncomeEntry()
{
$collector = $this->mock(JournalCollectorInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$account = factory(Account::class)->make();
$accountRepos->shouldReceive('find')->withArgs([1])->andReturn($account)->once();
$collector->shouldReceive('setAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setTypes')->andReturnSelf()->once()->withArgs([[TransactionType::DEPOSIT, TransactionType::TRANSFER]]);
$collector->shouldReceive('setRange')->once()->andReturnSelf();
$collector->shouldReceive('getJournals')->once()->andReturn(new Collection);
$this->be($this->user());
$arguments = [

View File

@ -12,8 +12,14 @@ declare(strict_types = 1);
namespace Tests\Feature\Controllers\Report;
use FireflyIII\Repositories\Account\AccountTaskerInterface;
use Tests\TestCase;
/**
* Class AccountControllerTest
*
* @package Tests\Feature\Controllers\Report
*/
class AccountControllerTest extends TestCase
{
/**
@ -21,6 +27,17 @@ class AccountControllerTest extends TestCase
*/
public function testGeneral()
{
$return = [
'accounts' => [],
'start' => '0',
'end' => '0',
'difference' => '0',
];
$tasker = $this->mock(AccountTaskerInterface::class);
$tasker->shouldReceive('getAccountReport')->andReturn($return);
$this->be($this->user());
$response = $this->get(route('report-data.account.general', ['1', '20120101', '20120131']));
$response->assertStatus(200);

View File

@ -12,8 +12,15 @@ declare(strict_types = 1);
namespace Tests\Feature\Controllers\Report;
use FireflyIII\Helpers\Collection\Balance;
use FireflyIII\Helpers\Report\BalanceReportHelperInterface;
use Tests\TestCase;
/**
* Class BalanceControllerTest
*
* @package Tests\Feature\Controllers\Report
*/
class BalanceControllerTest extends TestCase
{
/**
@ -21,6 +28,9 @@ class BalanceControllerTest extends TestCase
*/
public function testGeneral()
{
$balance = $this->mock(BalanceReportHelperInterface::class);
$balance->shouldReceive('getBalanceReport')->andReturn(new Balance);
$this->be($this->user());
$response = $this->get(route('report-data.balance.general', ['1', '20120101', '20120131']));
$response->assertStatus(200);

View File

@ -12,8 +12,16 @@ declare(strict_types = 1);
namespace Tests\Feature\Controllers\Report;
use FireflyIII\Helpers\Report\BudgetReportHelperInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use Illuminate\Support\Collection;
use Tests\TestCase;
/**
* Class BudgetControllerTest
*
* @package Tests\Feature\Controllers\Report
*/
class BudgetControllerTest extends TestCase
{
/**
@ -21,6 +29,10 @@ class BudgetControllerTest extends TestCase
*/
public function testGeneral()
{
$return = [];
$helper = $this->mock(BudgetReportHelperInterface::class);
$helper->shouldReceive('getBudgetReport')->andReturn($return);
$this->be($this->user());
$response = $this->get(route('report-data.budget.general', ['1', '20120101', '20120131']));
$response->assertStatus(200);
@ -28,9 +40,17 @@ class BudgetControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Report\BudgetController::period
* @covers \FireflyIII\Http\Controllers\Report\BudgetController::filterBudgetPeriodReport
*/
public function testPeriod()
{
$first = [1 => ['entries' => ['1', '1']]];
$second = ['entries' => ['1', '1']];
$repository = $this->mock(BudgetRepositoryInterface::class);
$repository->shouldReceive('getBudgets')->andReturn(new Collection);
$repository->shouldReceive('getBudgetPeriodReport')->andReturn($first);
$repository->shouldReceive('getNoBudgetPeriodReport')->andReturn($second);
$this->be($this->user());
$response = $this->get(route('report-data.budget.period', ['1', '20120101', '20120131']));
$response->assertStatus(200);

View File

@ -12,15 +12,26 @@ declare(strict_types = 1);
namespace Tests\Feature\Controllers\Report;
use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use Illuminate\Support\Collection;
use Tests\TestCase;
class CategoryControllerTest extends TestCase
{
/**
* @covers \FireflyIII\Http\Controllers\Report\CategoryController::expenses
* @covers \FireflyIII\Http\Controllers\Report\CategoryController::filterReport
*/
public function testExpenses()
{
$first = [1 => ['entries' => ['1', '1']]];
$second = ['entries' => ['1', '1']];
$repository = $this->mock(CategoryRepositoryInterface::class);
$repository->shouldReceive('getCategories')->andReturn(new Collection);
$repository->shouldReceive('periodExpenses')->andReturn($first);
$repository->shouldReceive('periodExpensesNoCategory')->andReturn($second);
$this->be($this->user());
$response = $this->get(route('report-data.category.expenses', ['1', '20120101', '20120131']));
$response->assertStatus(200);
@ -28,9 +39,17 @@ class CategoryControllerTest extends TestCase
/**
* @covers \FireflyIII\Http\Controllers\Report\CategoryController::income
* @covers \FireflyIII\Http\Controllers\Report\CategoryController::filterReport
*/
public function testIncome()
{
$first = [1 => ['entries' => ['1', '1']]];
$second = ['entries' => ['1', '1']];
$repository = $this->mock(CategoryRepositoryInterface::class);
$repository->shouldReceive('getCategories')->andReturn(new Collection);
$repository->shouldReceive('periodIncome')->andReturn($first);
$repository->shouldReceive('periodIncomeNoCategory')->andReturn($second);
$this->be($this->user());
$response = $this->get(route('report-data.category.income', ['1', '20120101', '20120131']));
$response->assertStatus(200);
@ -41,6 +60,11 @@ class CategoryControllerTest extends TestCase
*/
public function testOperations()
{
$repository = $this->mock(CategoryRepositoryInterface::class);
$category = factory(Category::class)->make();
$repository->shouldReceive('getCategories')->andReturn(new Collection([$category]));
$repository->shouldReceive('spentInPeriod')->andReturn('-1');
$this->be($this->user());
$response = $this->get(route('report-data.category.operations', ['1', '20120101', '20120131']));
$response->assertStatus(200);

View File

@ -17,6 +17,11 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionType;
use Tests\TestCase;
/**
* Class OperationsControllerTest
*
* @package Tests\Feature\Controllers\Report
*/
class OperationsControllerTest extends TestCase
{
/**
@ -28,6 +33,7 @@ class OperationsControllerTest extends TestCase
{
$transactions = factory(Transaction::class, 10)->make();
$collector = $this->mock(JournalCollectorInterface::class);
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]])->andReturnSelf();
@ -49,6 +55,7 @@ class OperationsControllerTest extends TestCase
{
$transactions = factory(Transaction::class, 10)->make();
$collector = $this->mock(JournalCollectorInterface::class);
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::DEPOSIT, TransactionType::TRANSFER]])->andReturnSelf();
@ -66,6 +73,17 @@ class OperationsControllerTest extends TestCase
*/
public function testOperations()
{
$collector = $this->mock(JournalCollectorInterface::class);
$transactions = factory(Transaction::class, 10)->make();
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::DEPOSIT, TransactionType::TRANSFER]])->andReturnSelf()->once();
$collector->shouldReceive('setTypes')->withArgs([[TransactionType::WITHDRAWAL, TransactionType::TRANSFER]])->andReturnSelf()->once();
$collector->shouldReceive('withOpposingAccount')->andReturnSelf();
$collector->shouldReceive('enableInternalFilter')->andReturnSelf();
$collector->shouldReceive('getJournals')->andReturn($transactions);
$this->be($this->user());
$response = $this->get(route('report-data.operations.operations', ['1', '20160101', '20160131']));
$response->assertStatus(200);

View File

@ -141,6 +141,46 @@ class ReportControllerTest extends TestCase
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\ReportController::options
* @covers \FireflyIII\Http\Controllers\ReportController::budgetReportOptions
*/
public function testOptionsBudget()
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('reports.options', ['budget']));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\ReportController::options
*/
public function testOptionsCategory()
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('reports.options', ['default']));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\ReportController::options
*/
public function testOptionsTag()
{
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
$response = $this->get(route('reports.options', ['default']));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
*/

View File

@ -19,7 +19,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Tests\TestCase;
/**
@ -97,7 +96,6 @@ class MassControllerTest extends TestCase
*/
public function testEditMultiple()
{
Log::debug('Edit multiple.');
// mock stuff:
$repository = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
@ -125,7 +123,6 @@ class MassControllerTest extends TestCase
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
);
$allIds = $collection->pluck('id')->toArray();
Log::debug('Ids', $allIds);
$this->be($this->user());
$response = $this->get(route('transactions.mass.edit', join(',', $allIds)));
@ -140,7 +137,6 @@ class MassControllerTest extends TestCase
*/
public function testEditMultipleNothingLeft()
{
Log::debug('Edit multiple.');
// mock stuff:
$repository = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('getAccountsByType')->once()->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection);
@ -156,7 +152,6 @@ class MassControllerTest extends TestCase
->where('user_id', $this->user()->id)->first(['transaction_journals.id', DB::raw('count(transactions.`id`) as ct')])
);
$allIds = $collection->pluck('id')->toArray();
Log::debug('Ids', $allIds);
$this->be($this->user());
$response = $this->get(route('transactions.mass.edit', join(',', $allIds)));