mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 12:11:19 +00:00
Expand tests.
This commit is contained in:
@@ -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 = [
|
||||
|
Reference in New Issue
Block a user