mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix some tests.
This commit is contained in:
parent
6d1bfd3956
commit
1d4434698e
@ -98,10 +98,10 @@ class CategoryControllerTest extends TestCase
|
|||||||
$this->mockDefaultSession();
|
$this->mockDefaultSession();
|
||||||
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
||||||
|
|
||||||
$repository->shouldReceive('spentInPeriod')->andReturn('0')->atLeast()->once();
|
$repository->shouldReceive('spentInPeriod')->andReturn([])->atLeast()->once();
|
||||||
$repository->shouldReceive('earnedInPeriod')->andReturn('0')->atLeast()->once();
|
$repository->shouldReceive('earnedInPeriod')->andReturn([])->atLeast()->once();
|
||||||
$repository->shouldReceive('firstUseDate')->andReturn($firstUseDate)->once();
|
$repository->shouldReceive('firstUseDate')->andReturn($firstUseDate)->once();
|
||||||
$accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET]])->andReturn(new Collection)->once();
|
$accountRepos->shouldReceive('getAccountsByType')->withArgs([[AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT,AccountType::MORTGAGE]])->andReturn(new Collection)->once();
|
||||||
$generator->shouldReceive('multiSet')->once()->andReturn([]);
|
$generator->shouldReceive('multiSet')->once()->andReturn([]);
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
@ -245,8 +245,8 @@ class CategoryControllerTest extends TestCase
|
|||||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
|
|
||||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
|
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
|
||||||
$repository->shouldReceive('spentInPeriod')->andReturn('0');
|
$repository->shouldReceive('spentInPeriod')->andReturn([]);
|
||||||
$repository->shouldReceive('earnedInPeriod')->andReturn('0');
|
$repository->shouldReceive('earnedInPeriod')->andReturn([]);
|
||||||
$generator->shouldReceive('multiSet')->andReturn([])->once();
|
$generator->shouldReceive('multiSet')->andReturn([])->once();
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
|
@ -26,7 +26,6 @@ use Carbon\Carbon;
|
|||||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||||
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
||||||
use FireflyIII\Helpers\Report\NetWorthInterface;
|
use FireflyIII\Helpers\Report\NetWorthInterface;
|
||||||
use FireflyIII\Models\TransactionCurrency;
|
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||||
@ -116,8 +115,12 @@ class ReportControllerTest extends TestCase
|
|||||||
|
|
||||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
$income = [1 => ['sum' => '100']];
|
$income = [
|
||||||
$expense = [2 => ['sum' => '-100']];
|
'accounts' => [
|
||||||
|
1 => ['sum' => '100']]];
|
||||||
|
$expense = [
|
||||||
|
'accounts' => [
|
||||||
|
2 => ['sum' => '-100']]];
|
||||||
$tasker->shouldReceive('getIncomeReport')->once()->andReturn($income);
|
$tasker->shouldReceive('getIncomeReport')->once()->andReturn($income);
|
||||||
$tasker->shouldReceive('getExpenseReport')->once()->andReturn($expense);
|
$tasker->shouldReceive('getExpenseReport')->once()->andReturn($expense);
|
||||||
$generator->shouldReceive('multiSet')->andReturn([]);
|
$generator->shouldReceive('multiSet')->andReturn([]);
|
||||||
@ -144,8 +147,12 @@ class ReportControllerTest extends TestCase
|
|||||||
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
|
||||||
|
|
||||||
$income = [];
|
$income = [
|
||||||
$expense = [];
|
'accounts' => [
|
||||||
|
1 => ['sum' => '100']]];
|
||||||
|
$expense = [
|
||||||
|
'accounts' => [
|
||||||
|
2 => ['sum' => '-100']]];
|
||||||
$tasker->shouldReceive('getIncomeReport')->andReturn($income)->times(1);
|
$tasker->shouldReceive('getIncomeReport')->andReturn($income)->times(1);
|
||||||
$tasker->shouldReceive('getExpenseReport')->andReturn($expense)->times(1);
|
$tasker->shouldReceive('getExpenseReport')->andReturn($expense)->times(1);
|
||||||
|
|
||||||
|
@ -108,32 +108,6 @@ class NavigationTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Support\Navigation
|
|
||||||
*/
|
|
||||||
public function testAddPeriodError(): void
|
|
||||||
{
|
|
||||||
$tests = [
|
|
||||||
// period, skip, start, expected end
|
|
||||||
['bla', 0, '2018-01-01', '2018-01-02'],
|
|
||||||
];
|
|
||||||
|
|
||||||
/** @var array $test */
|
|
||||||
foreach ($tests as $test) {
|
|
||||||
|
|
||||||
$freq = $test[0];
|
|
||||||
/** @noinspection MultiAssignmentUsageInspection */
|
|
||||||
$skip = $test[1];
|
|
||||||
$start = new Carbon($test[2]);
|
|
||||||
$nav = new Navigation;
|
|
||||||
try {
|
|
||||||
$nav->addPeriod($start, $freq, $skip);
|
|
||||||
} catch (FireflyException $e) {
|
|
||||||
$this->assertEquals('Cannot do addPeriod for $repeat_freq "bla"', $e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Support\Navigation
|
* @covers \FireflyIII\Support\Navigation
|
||||||
*/
|
*/
|
||||||
|
@ -88,21 +88,27 @@ class CategoryTransformerTest extends TestCase
|
|||||||
$parameters->set('end', new Carbon('2018-01-31'));
|
$parameters->set('end', new Carbon('2018-01-31'));
|
||||||
|
|
||||||
// mock some objects for the spent/earned lists.
|
// mock some objects for the spent/earned lists.
|
||||||
$expense = new Transaction;
|
$expense = [
|
||||||
$expense->transaction_currency_code = 'EUR';
|
'currency_id' => 1,
|
||||||
$expense->transactionCurrency = $this->getEuro();
|
'currency_code' => 'EUR',
|
||||||
$expense->transaction_amount = '-100';
|
'currency_symbol' => '€',
|
||||||
$income = new Transaction;
|
'currency_decimal_places' => 2,
|
||||||
$income->transaction_currency_code = 'EUR';
|
'amount' => -100,
|
||||||
$income->transactionCurrency = $this->getEuro();
|
];
|
||||||
$income->transaction_amount = '100';
|
$income = [
|
||||||
|
'currency_id' => 1,
|
||||||
|
'currency_code' => 'EUR',
|
||||||
|
'currency_symbol' => '€',
|
||||||
|
'currency_decimal_places' => 2,
|
||||||
|
'amount' => 100,
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
$incomeCollection = [$income];
|
$incomeCollection = [$income];
|
||||||
$expenseCollection = [$expense];
|
$expenseCollection = [$expense];
|
||||||
|
|
||||||
$repository->shouldReceive('spentInPeriodCollection')->atLeast()->once()->andReturn($expenseCollection);
|
$repository->shouldReceive('spentInPeriod')->atLeast()->once()->andReturn($expenseCollection);
|
||||||
$repository->shouldReceive('earnedInPeriodCollection')->atLeast()->once()->andReturn($incomeCollection);
|
$repository->shouldReceive('earnedInPeriod')->atLeast()->once()->andReturn($incomeCollection);
|
||||||
|
|
||||||
/** @var Category $category */
|
/** @var Category $category */
|
||||||
$category = Category::first();
|
$category = Category::first();
|
||||||
|
Loading…
Reference in New Issue
Block a user