mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix test method names.
This commit is contained in:
parent
de754ca4e0
commit
eaf2667abb
@ -35,7 +35,7 @@ class AboutControllerTest extends TestCase
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
|
@ -148,6 +148,40 @@ class AvailableBudgetControllerTest extends TestCase
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store new available budget without a valid currency.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AvailableBudgetController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AvailableBudgetRequest
|
||||
*/
|
||||
public function testStoreNoCurrencyAtAll(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(null)->once();
|
||||
$currencyRepository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'currency_id' => '1',
|
||||
'currency_code' => 'EUR',
|
||||
'amount' => '100',
|
||||
'start_date' => '2018-01-01',
|
||||
'end_date' => '2018-01-31',
|
||||
];
|
||||
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/available_budgets', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Could not find the indicated currency.'); // the amount
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store new available budget without a valid currency.
|
||||
*
|
||||
@ -186,40 +220,6 @@ class AvailableBudgetControllerTest extends TestCase
|
||||
$response->assertSee($availableBudget->amount); // the amount
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
/**
|
||||
* Store new available budget without a valid currency.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AvailableBudgetController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AvailableBudgetRequest
|
||||
*/
|
||||
public function testStoreNoCurrencyAtAll(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(null)->once();
|
||||
$currencyRepository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'currency_id' => '1',
|
||||
'currency_code' => 'EUR',
|
||||
'amount' => '100',
|
||||
'start_date' => '2018-01-01',
|
||||
'end_date' => '2018-01-31',
|
||||
];
|
||||
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/available_budgets', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Could not find the indicated currency.'); // the amount
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update available budget.
|
||||
|
@ -40,7 +40,7 @@ class BillControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
|
@ -239,7 +239,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::first());
|
||||
|
||||
$data = [
|
||||
'name' => 'new pigy bank ' . random_int(1, 10000),
|
||||
'name' => 'new pigy bank ' . random_int(1, 10000),
|
||||
'account_id' => 1,
|
||||
'target_amount' => '100',
|
||||
];
|
||||
|
@ -142,6 +142,72 @@ class RuleControllerTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RuleRequest
|
||||
*/
|
||||
public function testStoreNoActions(): void
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$rule = $this->user()->rules()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule',
|
||||
'rule_group_id' => 1,
|
||||
'trigger' => 'store-journal',
|
||||
'strict' => 1,
|
||||
'stop_processing' => 1,
|
||||
'active' => 1,
|
||||
'rule_triggers' => [
|
||||
[
|
||||
'name' => 'description_is',
|
||||
'value' => 'Hello',
|
||||
'stop_processing' => 1,
|
||||
],
|
||||
],
|
||||
'rule_actions' => [
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RuleRequest
|
||||
*/
|
||||
public function testStoreNoTriggers(): void
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$rule = $this->user()->rules()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule',
|
||||
'rule_group_id' => 1,
|
||||
'trigger' => 'store-journal',
|
||||
'strict' => 1,
|
||||
'stop_processing' => 1,
|
||||
'active' => 1,
|
||||
'rule_triggers' => [
|
||||
],
|
||||
'rule_actions' => [
|
||||
[
|
||||
'name' => 'add_tag',
|
||||
'value' => 'A',
|
||||
'stop_processing' => 1,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(422);
|
||||
$response->assertSee('');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RuleRequest
|
||||
@ -183,71 +249,4 @@ class RuleControllerTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RuleRequest
|
||||
*/
|
||||
public function testStoreNoTriggers(): void
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$rule = $this->user()->rules()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule',
|
||||
'rule_group_id' => 1,
|
||||
'trigger' => 'store-journal',
|
||||
'strict' => 1,
|
||||
'stop_processing' => 1,
|
||||
'active' => 1,
|
||||
'rule_triggers' => [
|
||||
],
|
||||
'rule_actions' => [
|
||||
[
|
||||
'name' => 'add_tag',
|
||||
'value' => 'A',
|
||||
'stop_processing' => 1,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(422);
|
||||
$response->assertSee('');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RuleRequest
|
||||
*/
|
||||
public function testStoreNoActions(): void
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$rule = $this->user()->rules()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule',
|
||||
'rule_group_id' => 1,
|
||||
'trigger' => 'store-journal',
|
||||
'strict' => 1,
|
||||
'stop_processing' => 1,
|
||||
'active' => 1,
|
||||
'rule_triggers' => [
|
||||
[
|
||||
'name' => 'description_is',
|
||||
'value' => 'Hello',
|
||||
'stop_processing' => 1,
|
||||
],
|
||||
],
|
||||
'rule_actions' => [
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(422);
|
||||
}
|
||||
|
||||
}
|
@ -90,7 +90,7 @@ class RuleGroupControllerTest extends TestCase
|
||||
public function testShow(): void
|
||||
{
|
||||
/** @var RuleGroup $ruleGroup */
|
||||
$ruleGroup = $this->user()->ruleGroups()->first();
|
||||
$ruleGroup = $this->user()->ruleGroups()->first();
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$ruleGroupRepos->shouldReceive('setUser')->once();
|
||||
|
||||
|
@ -40,7 +40,7 @@ class UserControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
|
@ -100,41 +100,6 @@ class ShowControllerTest extends TestCase
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testShowLiability(string $range): void
|
||||
{
|
||||
$date = new Carbon;
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
$account = $this->user()->accounts()->where('account_type_id', 12)->whereNull('deleted_at')->first();
|
||||
|
||||
// mock stuff:
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1');
|
||||
$tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1');
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getMetaValue')->andReturn('');
|
||||
$repository->shouldReceive('isLiability')->andReturn(true);
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('accounts.show', [$account->id]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect(route('accounts.show.all', [$account->id]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @dataProvider dateRangeProvider
|
||||
@ -277,4 +242,38 @@ class ShowControllerTest extends TestCase
|
||||
$response->assertStatus(302);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testShowLiability(string $range): void
|
||||
{
|
||||
$date = new Carbon;
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
$account = $this->user()->accounts()->where('account_type_id', 12)->whereNull('deleted_at')->first();
|
||||
|
||||
// mock stuff:
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1');
|
||||
$tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1');
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getMetaValue')->andReturn('');
|
||||
$repository->shouldReceive('isLiability')->andReturn(true);
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('accounts.show', [$account->id]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect(route('accounts.show.all', [$account->id]));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class ConfigurationControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -35,7 +35,7 @@ class HomeControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -36,7 +36,7 @@ class LinkControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -40,7 +40,7 @@ class UpdateControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -42,7 +42,7 @@ class AttachmentControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -34,7 +34,7 @@ class ForgotPasswordControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -36,7 +36,7 @@ class TwoFactorControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -51,7 +51,7 @@ class BillControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -159,9 +159,9 @@ class AmountControllerTest extends TestCase
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(2);
|
||||
|
||||
// collect transactions to return. First an expense, then income.
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '150';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '150';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$expense = new Transaction;
|
||||
$expense->transaction_amount = '100';
|
||||
$expenseCollection = new Collection([$expense]);
|
||||
@ -169,45 +169,6 @@ class AmountControllerTest extends TestCase
|
||||
$collector->shouldReceive('getTransactions')->andReturn($incomeCollection, $expenseCollection)->times(2);
|
||||
|
||||
|
||||
|
||||
$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
|
||||
$repository->shouldReceive('getAverageAvailable')->andReturn('100.123')->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('budgets.income.info', ['20170101', '20170131']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Budget\AmountController
|
||||
*/
|
||||
public function testInfoIncomeInversed(): void
|
||||
{
|
||||
Log::debug('Now in testInfoIncome()');
|
||||
// mock stuff
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('setRange')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(2);
|
||||
|
||||
// collect transactions to return. First an expense, then income.
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '100';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$expense = new Transaction;
|
||||
$expense->transaction_amount = '150';
|
||||
$expenseCollection = new Collection([$expense]);
|
||||
|
||||
$collector->shouldReceive('getTransactions')->andReturn($incomeCollection, $expenseCollection)->times(2);
|
||||
|
||||
|
||||
|
||||
$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
|
||||
@ -242,9 +203,9 @@ class AmountControllerTest extends TestCase
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(2);
|
||||
|
||||
// collect transactions to return. First an expense, then income.
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '150';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '150';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$expense = new Transaction;
|
||||
$expense->transaction_amount = '100';
|
||||
$expenseCollection = new Collection([$expense]);
|
||||
@ -257,6 +218,42 @@ class AmountControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Budget\AmountController
|
||||
*/
|
||||
public function testInfoIncomeInversed(): void
|
||||
{
|
||||
Log::debug('Now in testInfoIncome()');
|
||||
// mock stuff
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('setRange')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(2);
|
||||
|
||||
// collect transactions to return. First an expense, then income.
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '100';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$expense = new Transaction;
|
||||
$expense->transaction_amount = '150';
|
||||
$expenseCollection = new Collection([$expense]);
|
||||
|
||||
$collector->shouldReceive('getTransactions')->andReturn($incomeCollection, $expenseCollection)->times(2);
|
||||
|
||||
|
||||
$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
|
||||
$repository->shouldReceive('getAverageAvailable')->andReturn('100.123')->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('budgets.income.info', ['20170101', '20170131']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Budget\AmountController
|
||||
|
@ -49,7 +49,7 @@ class AccountControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -40,10 +40,10 @@ class BillControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug('Now in Feature/Controllers/Chart/Test.');
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,10 +46,10 @@ class BudgetControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug('Now in Feature/Controllers/Chart/Test.');
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ class BudgetReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -42,7 +42,7 @@ class CategoryControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -42,7 +42,7 @@ class CategoryReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -39,7 +39,7 @@ class ExpenseReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -37,7 +37,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -26,9 +26,10 @@ use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Steam;
|
||||
use Tests\TestCase;
|
||||
use Mockery;
|
||||
|
||||
/**
|
||||
* Class ReportControllerTest
|
||||
*/
|
||||
@ -37,7 +38,7 @@ class ReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -55,7 +56,7 @@ class ReportControllerTest extends TestCase
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
|
||||
$accountRepos->shouldReceive('getMetaValue')->times(2)
|
||||
->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1','0');
|
||||
->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1', '0');
|
||||
$accountRepos->shouldReceive('getMetaValue')
|
||||
->withArgs([Mockery::any(), 'currency_id'])->andReturn(1);
|
||||
$accountRepos->shouldReceive('getMetaValue')
|
||||
|
@ -46,7 +46,7 @@ class TagReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -45,7 +45,7 @@ class CurrencyControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -314,7 +314,7 @@ class CurrencyControllerTest extends TestCase
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('currencies.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('error','Could not store the new currency.');
|
||||
$response->assertSessionHas('error', 'Could not store the new currency.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ class DebugControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -46,7 +46,7 @@ class ExportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -39,7 +39,7 @@ class HelpControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -48,7 +48,7 @@ class HomeControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -26,9 +26,9 @@ namespace Tests\Feature\Controllers\Import;
|
||||
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -48,11 +48,12 @@ class CallbackControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Import\CallbackController
|
||||
*/
|
||||
public function testYnabBasic(): void {
|
||||
public function testYnabBasic(): void
|
||||
{
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
// config for job:
|
||||
$config = [];
|
||||
$config = [];
|
||||
$newConfig = ['auth_code' => 'abc'];
|
||||
|
||||
// mock calls.
|
||||
@ -72,7 +73,8 @@ class CallbackControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Import\CallbackController
|
||||
*/
|
||||
public function testYnabBasicBadJob(): void {
|
||||
public function testYnabBasicBadJob(): void
|
||||
{
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
// mock calls.
|
||||
@ -87,11 +89,12 @@ class CallbackControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Import\CallbackController
|
||||
*/
|
||||
public function testYnabBasicNoCode(): void {
|
||||
public function testYnabBasicNoCode(): void
|
||||
{
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
// config for job:
|
||||
$config = [];
|
||||
$config = [];
|
||||
$newConfig = ['auth_code' => 'abc'];
|
||||
|
||||
// mock calls.
|
||||
|
@ -46,7 +46,7 @@ class IndexControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -40,7 +40,7 @@ class JobConfigurationControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -45,7 +45,7 @@ class JobStatusControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -45,7 +45,7 @@ class JavascriptControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -62,7 +62,9 @@ class JavascriptControllerTest extends TestCase
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]))
|
||||
->withArgs([[AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT,AccountType::LOAN,AccountType::MORTGAGE, AccountType::CREDITCARD]])->once();
|
||||
->withArgs(
|
||||
[[AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD]]
|
||||
)->once();
|
||||
$currencyRepos->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(new TransactionCurrency);
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
|
||||
|
@ -52,7 +52,7 @@ class AutoCompleteControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -44,7 +44,7 @@ class BoxControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -182,37 +182,6 @@ class BoxControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController
|
||||
*/
|
||||
public function testNetWorthNoInclude(): void
|
||||
{
|
||||
$result = [
|
||||
[
|
||||
'currency' => TransactionCurrency::find(1),
|
||||
'balance' => '3',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$netWorthHelper = $this->mock(NetWorthInterface::class);
|
||||
$netWorthHelper->shouldReceive('setUser')->once();
|
||||
$netWorthHelper->shouldReceive('getNetWorthByCurrency')->once()->andReturn($result);
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('0');
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.net-worth'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController
|
||||
*/
|
||||
@ -278,6 +247,37 @@ class BoxControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController
|
||||
*/
|
||||
public function testNetWorthNoInclude(): void
|
||||
{
|
||||
$result = [
|
||||
[
|
||||
'currency' => TransactionCurrency::find(1),
|
||||
'balance' => '3',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$netWorthHelper = $this->mock(NetWorthInterface::class);
|
||||
$netWorthHelper->shouldReceive('setUser')->once();
|
||||
$netWorthHelper->shouldReceive('getNetWorthByCurrency')->once()->andReturn($result);
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('0');
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.net-worth'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController
|
||||
*/
|
||||
|
@ -40,7 +40,7 @@ class ExchangeControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -61,6 +61,20 @@ class ExchangeControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\ExchangeController
|
||||
*/
|
||||
public function testGetRateAmount(): void
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$rate = factory(CurrencyExchangeRate::class)->make();
|
||||
$repository->shouldReceive('getExchangeRate')->andReturn($rate);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.rate', ['EUR', 'USD', '20170101']) . '?amount=10');
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\ExchangeController
|
||||
*/
|
||||
@ -78,18 +92,4 @@ class ExchangeControllerTest extends TestCase
|
||||
$response = $this->get(route('json.rate', ['EUR', 'USD', '20170101']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\ExchangeController
|
||||
*/
|
||||
public function testGetRateAmount(): void
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$rate = factory(CurrencyExchangeRate::class)->make();
|
||||
$repository->shouldReceive('getExchangeRate')->andReturn($rate);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.rate', ['EUR', 'USD', '20170101']) . '?amount=10');
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class FrontpageControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -37,7 +37,7 @@ class IntroControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -41,7 +41,7 @@ class ReconcileControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -39,7 +39,7 @@ class JsonControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -42,7 +42,7 @@ class NewUserControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -50,7 +50,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -46,7 +46,7 @@ class ReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -43,7 +43,7 @@ class PreferencesControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -46,7 +46,7 @@ class ProfileControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -38,7 +38,7 @@ class AccountControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -39,7 +39,7 @@ class BalanceControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -40,7 +40,7 @@ class BudgetControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -40,7 +40,7 @@ class CategoryControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -42,7 +42,7 @@ class ExpenseControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -38,7 +38,7 @@ class OperationsControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -56,7 +56,7 @@ class ReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -565,7 +565,7 @@ class ReportControllerTest extends TestCase
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tagRepos = $this->mock(TagRepositoryInterface::class);
|
||||
/** @var Tag $tag */
|
||||
$tag = $this->user()->tags()->find(1);
|
||||
$tag = $this->user()->tags()->find(1);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($this->user()->accounts()->find(1))->twice();
|
||||
$tagRepos->shouldReceive('findByTag')->andReturn($tag)->twice();
|
||||
|
@ -75,7 +75,7 @@ class CreateControllerTest extends TestCase
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rules.create-from-bill', [1,1]));
|
||||
$response = $this->get(route('rules.create-from-bill', [1, 1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class RuleGroupControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -39,7 +39,7 @@ class SearchControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -45,7 +45,7 @@ class TagControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -42,7 +42,7 @@ class BulkControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -47,7 +47,7 @@ class ConvertControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -410,7 +410,7 @@ class ConvertControllerTest extends TestCase
|
||||
public function testPostIndexTransferDeposit(): void
|
||||
{
|
||||
// find transfer:
|
||||
$transfer =$this->getRandomTransfer();
|
||||
$transfer = $this->getRandomTransfer();
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
|
@ -43,7 +43,7 @@ class MassControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -57,7 +57,7 @@ class SingleControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -50,7 +50,7 @@ class SplitControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -46,7 +46,7 @@ class TransactionControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -119,6 +119,14 @@ abstract class TestCase extends BaseTestCase
|
||||
return $this->getRandomJournal(TransactionType::DEPOSIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function getRandomTransfer(): TransactionJournal
|
||||
{
|
||||
return $this->getRandomJournal(TransactionType::TRANSFER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
@ -128,11 +136,13 @@ abstract class TestCase extends BaseTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TransactionJournal
|
||||
*
|
||||
*/
|
||||
public function getRandomTransfer(): TransactionJournal
|
||||
public function setUp(): void
|
||||
{
|
||||
return $this->getRandomJournal(TransactionType::TRANSFER);
|
||||
parent::setUp();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,16 +178,6 @@ abstract class TestCase extends BaseTestCase
|
||||
return Mockery::mock('overload:' . $class);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*
|
||||
|
@ -66,7 +66,7 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category= $this->user()->categories()->inRandomOrder()->first();
|
||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
@ -160,7 +160,7 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category= $this->user()->categories()->inRandomOrder()->first();
|
||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
@ -187,7 +187,7 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||
|
||||
// data for basic recurrence.
|
||||
$data = [
|
||||
$data = [
|
||||
'recurrence' => [
|
||||
'type' => 'deposit',
|
||||
'first_date' => Carbon::create()->addDay(),
|
||||
@ -243,196 +243,6 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deposit. With piggy bank. With tags. With budget. With category.
|
||||
*
|
||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||
*/
|
||||
public function testBasicTransfer(): void
|
||||
{
|
||||
// objects to return:
|
||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category= $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
// mock calls:
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||
$piggyFactory->shouldReceive('setUser')->once();
|
||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->twice();
|
||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
||||
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||
|
||||
$budgetFactory->shouldReceive('setUser')->once();
|
||||
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||
|
||||
$categoryFactory->shouldReceive('setUser')->once();
|
||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||
|
||||
// data for basic recurrence.
|
||||
$data = [
|
||||
'recurrence' => [
|
||||
'type' => 'transfer',
|
||||
'first_date' => Carbon::create()->addDay(),
|
||||
'repetitions' => 0,
|
||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
||||
'description' => 'Description thing',
|
||||
'apply_rules' => true,
|
||||
'active' => true,
|
||||
'repeat_until' => null,
|
||||
],
|
||||
'meta' => [
|
||||
'tags' => ['a', 'b', 'c'],
|
||||
'piggy_bank_id' => 1,
|
||||
'piggy_bank_name' => 'Bla bla',
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'daily',
|
||||
'moment' => '',
|
||||
'skip' => 0,
|
||||
'weekend' => 1,
|
||||
],
|
||||
],
|
||||
'transactions' => [
|
||||
[
|
||||
'source_id' => 1,
|
||||
'source_name' => 'Some name',
|
||||
'destination_id' => 2,
|
||||
'destination_name' => 'some otjer name',
|
||||
'currency_id' => 1,
|
||||
'currency_code' => 'EUR',
|
||||
'foreign_currency_id' => null,
|
||||
'foreign_currency_code' => null,
|
||||
'foreign_amount' => null,
|
||||
'description' => 'Bla bla bla',
|
||||
'amount' => '100',
|
||||
'budget_id' => 1,
|
||||
'budget_name' => 'Some budget',
|
||||
'category_id' => 2,
|
||||
'category_name' => 'Some category',
|
||||
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(3));
|
||||
|
||||
$factory = new RecurrenceFactory;
|
||||
$factory->setUser($this->user());
|
||||
|
||||
$result = $factory->create($data);
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* With piggy bank. With tags. With budget. With category.
|
||||
*
|
||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||
*/
|
||||
public function testBasicNoTags(): void
|
||||
{
|
||||
// objects to return:
|
||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category= $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
// mock calls:
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||
$piggyFactory->shouldReceive('setUser')->once();
|
||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->twice();
|
||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
||||
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||
|
||||
$budgetFactory->shouldReceive('setUser')->once();
|
||||
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||
|
||||
$categoryFactory->shouldReceive('setUser')->once();
|
||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||
|
||||
// data for basic recurrence.
|
||||
$data = [
|
||||
'recurrence' => [
|
||||
'type' => 'withdrawal',
|
||||
'first_date' => Carbon::create()->addDay(),
|
||||
'repetitions' => 0,
|
||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
||||
'description' => 'Description thing',
|
||||
'apply_rules' => true,
|
||||
'active' => true,
|
||||
'repeat_until' => null,
|
||||
],
|
||||
'meta' => [
|
||||
'tags' => [],
|
||||
'piggy_bank_id' => 1,
|
||||
'piggy_bank_name' => 'Bla bla',
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'daily',
|
||||
'moment' => '',
|
||||
'skip' => 0,
|
||||
'weekend' => 1,
|
||||
],
|
||||
],
|
||||
'transactions' => [
|
||||
[
|
||||
'source_id' => 1,
|
||||
'source_name' => 'Some name',
|
||||
'destination_id' => 2,
|
||||
'destination_name' => 'some otjer name',
|
||||
'currency_id' => 1,
|
||||
'currency_code' => 'EUR',
|
||||
'foreign_currency_id' => null,
|
||||
'foreign_currency_code' => null,
|
||||
'foreign_amount' => null,
|
||||
'description' => 'Bla bla bla',
|
||||
'amount' => '100',
|
||||
'budget_id' => 1,
|
||||
'budget_name' => 'Some budget',
|
||||
'category_id' => 2,
|
||||
'category_name' => 'Some category',
|
||||
|
||||
],
|
||||
],
|
||||
];
|
||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
||||
$factory = new RecurrenceFactory;
|
||||
$factory->setUser($this->user());
|
||||
|
||||
$result = $factory->create($data);
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* No piggy bank. With tags. With budget. With category.
|
||||
*
|
||||
@ -446,7 +256,7 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category= $this->user()->categories()->inRandomOrder()->first();
|
||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
@ -527,6 +337,196 @@ class RecurrenceFactoryTest extends TestCase
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* With piggy bank. With tags. With budget. With category.
|
||||
*
|
||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||
*/
|
||||
public function testBasicNoTags(): void
|
||||
{
|
||||
// objects to return:
|
||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
// mock calls:
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||
$piggyFactory->shouldReceive('setUser')->once();
|
||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->twice();
|
||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
||||
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||
|
||||
$budgetFactory->shouldReceive('setUser')->once();
|
||||
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||
|
||||
$categoryFactory->shouldReceive('setUser')->once();
|
||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||
|
||||
// data for basic recurrence.
|
||||
$data = [
|
||||
'recurrence' => [
|
||||
'type' => 'withdrawal',
|
||||
'first_date' => Carbon::create()->addDay(),
|
||||
'repetitions' => 0,
|
||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
||||
'description' => 'Description thing',
|
||||
'apply_rules' => true,
|
||||
'active' => true,
|
||||
'repeat_until' => null,
|
||||
],
|
||||
'meta' => [
|
||||
'tags' => [],
|
||||
'piggy_bank_id' => 1,
|
||||
'piggy_bank_name' => 'Bla bla',
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'daily',
|
||||
'moment' => '',
|
||||
'skip' => 0,
|
||||
'weekend' => 1,
|
||||
],
|
||||
],
|
||||
'transactions' => [
|
||||
[
|
||||
'source_id' => 1,
|
||||
'source_name' => 'Some name',
|
||||
'destination_id' => 2,
|
||||
'destination_name' => 'some otjer name',
|
||||
'currency_id' => 1,
|
||||
'currency_code' => 'EUR',
|
||||
'foreign_currency_id' => null,
|
||||
'foreign_currency_code' => null,
|
||||
'foreign_amount' => null,
|
||||
'description' => 'Bla bla bla',
|
||||
'amount' => '100',
|
||||
'budget_id' => 1,
|
||||
'budget_name' => 'Some budget',
|
||||
'category_id' => 2,
|
||||
'category_name' => 'Some category',
|
||||
|
||||
],
|
||||
],
|
||||
];
|
||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(1));
|
||||
$factory = new RecurrenceFactory;
|
||||
$factory->setUser($this->user());
|
||||
|
||||
$result = $factory->create($data);
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deposit. With piggy bank. With tags. With budget. With category.
|
||||
*
|
||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||
* @covers \FireflyIII\Services\Internal\Support\RecurringTransactionTrait
|
||||
*/
|
||||
public function testBasicTransfer(): void
|
||||
{
|
||||
// objects to return:
|
||||
$piggyBank = $this->user()->piggyBanks()->inRandomOrder()->first();
|
||||
$accountA = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$accountB = $this->user()->accounts()->inRandomOrder()->first();
|
||||
$budget = $this->user()->budgets()->inRandomOrder()->first();
|
||||
$category = $this->user()->categories()->inRandomOrder()->first();
|
||||
|
||||
// mock other factories:
|
||||
$piggyFactory = $this->mock(PiggyBankFactory::class);
|
||||
$budgetFactory = $this->mock(BudgetFactory::class);
|
||||
$categoryFactory = $this->mock(CategoryFactory::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyFactory = $this->mock(TransactionCurrencyFactory::class);
|
||||
|
||||
// mock calls:
|
||||
Amount::shouldReceive('getDefaultCurrencyByUser')->andReturn(TransactionCurrency::find(1))->once();
|
||||
$piggyFactory->shouldReceive('setUser')->once();
|
||||
$piggyFactory->shouldReceive('find')->withArgs([1, 'Bla bla'])->andReturn($piggyBank);
|
||||
|
||||
$accountRepos->shouldReceive('setUser')->twice();
|
||||
$accountRepos->shouldReceive('findNull')->twice()->andReturn($accountA, $accountB);
|
||||
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([1, 'EUR'])->andReturn(null);
|
||||
$currencyFactory->shouldReceive('find')->once()->withArgs([null, null])->andReturn(null);
|
||||
|
||||
$budgetFactory->shouldReceive('setUser')->once();
|
||||
$budgetFactory->shouldReceive('find')->withArgs([1, 'Some budget'])->once()->andReturn($budget);
|
||||
|
||||
$categoryFactory->shouldReceive('setUser')->once();
|
||||
$categoryFactory->shouldReceive('findOrCreate')->withArgs([2, 'Some category'])->once()->andReturn($category);
|
||||
|
||||
// data for basic recurrence.
|
||||
$data = [
|
||||
'recurrence' => [
|
||||
'type' => 'transfer',
|
||||
'first_date' => Carbon::create()->addDay(),
|
||||
'repetitions' => 0,
|
||||
'title' => 'Test recurrence' . random_int(1, 100000),
|
||||
'description' => 'Description thing',
|
||||
'apply_rules' => true,
|
||||
'active' => true,
|
||||
'repeat_until' => null,
|
||||
],
|
||||
'meta' => [
|
||||
'tags' => ['a', 'b', 'c'],
|
||||
'piggy_bank_id' => 1,
|
||||
'piggy_bank_name' => 'Bla bla',
|
||||
],
|
||||
'repetitions' => [
|
||||
[
|
||||
'type' => 'daily',
|
||||
'moment' => '',
|
||||
'skip' => 0,
|
||||
'weekend' => 1,
|
||||
],
|
||||
],
|
||||
'transactions' => [
|
||||
[
|
||||
'source_id' => 1,
|
||||
'source_name' => 'Some name',
|
||||
'destination_id' => 2,
|
||||
'destination_name' => 'some otjer name',
|
||||
'currency_id' => 1,
|
||||
'currency_code' => 'EUR',
|
||||
'foreign_currency_id' => null,
|
||||
'foreign_currency_code' => null,
|
||||
'foreign_amount' => null,
|
||||
'description' => 'Bla bla bla',
|
||||
'amount' => '100',
|
||||
'budget_id' => 1,
|
||||
'budget_name' => 'Some budget',
|
||||
'category_id' => 2,
|
||||
'category_name' => 'Some category',
|
||||
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$typeFactory = $this->mock(TransactionTypeFactory::class);
|
||||
$typeFactory->shouldReceive('find')->once()->withArgs([ucfirst($data['recurrence']['type'])])->andReturn(TransactionType::find(3));
|
||||
|
||||
$factory = new RecurrenceFactory;
|
||||
$factory->setUser($this->user());
|
||||
|
||||
$result = $factory->create($data);
|
||||
$this->assertEquals($result->title, $data['recurrence']['title']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Factory\RecurrenceFactory
|
||||
*/
|
||||
|
@ -987,9 +987,9 @@ class TransactionFactoryTest extends TestCase
|
||||
public function testCreatePairSameBadType(): void
|
||||
{
|
||||
// objects:
|
||||
$expense = $this->user()->accounts()->where('account_type_id', 4)->first();
|
||||
$expense = $this->user()->accounts()->where('account_type_id', 4)->first();
|
||||
$revenue = $this->user()->accounts()->where('account_type_id', 5)->first();
|
||||
$euro = TransactionCurrency::first();
|
||||
$euro = TransactionCurrency::first();
|
||||
|
||||
// mocked classes
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
@ -163,7 +163,7 @@ class TransactionJournalFactoryTest extends TestCase
|
||||
'transactions' => [
|
||||
[
|
||||
'amount' => '',
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -54,7 +54,7 @@ class TransactionTypeFactoryTest extends TestCase
|
||||
/** @var TransactionTypeFactory $factory */
|
||||
$factory = app(TransactionTypeFactory::class);
|
||||
|
||||
$result = $factory->find($type->type);
|
||||
$result = $factory->find($type->type);
|
||||
|
||||
$this->assertEquals($result->id, $type->id);
|
||||
}
|
||||
|
@ -92,27 +92,6 @@ class ChartJsGeneratorTest extends TestCase
|
||||
$this->assertEquals('#123456', $result['datasets'][1]['backgroundColor']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Generator\Chart\Basic\ChartJsGenerator
|
||||
*/
|
||||
public function testPieChart(): void
|
||||
{
|
||||
|
||||
$data = [
|
||||
'one' => -1,
|
||||
'two' => -2,
|
||||
'three' => -3,
|
||||
];
|
||||
|
||||
/** @var ChartJsGenerator $generator */
|
||||
$generator = new ChartJsGenerator();
|
||||
$result = $generator->pieChart($data);
|
||||
|
||||
$this->assertEquals('three', $result['labels'][0]);
|
||||
$this->assertEquals(3.0, $result['datasets'][0]['data'][0]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Generator\Chart\Basic\ChartJsGenerator
|
||||
*/
|
||||
@ -120,9 +99,9 @@ class ChartJsGeneratorTest extends TestCase
|
||||
{
|
||||
|
||||
$data = [
|
||||
'one' => ['amount' => -1,'currency_symbol' => 'a'],
|
||||
'two' => ['amount' => -2,'currency_symbol' => 'b'],
|
||||
'three' => ['amount' => -3,'currency_symbol' => 'c'],
|
||||
'one' => ['amount' => -1, 'currency_symbol' => 'a'],
|
||||
'two' => ['amount' => -2, 'currency_symbol' => 'b'],
|
||||
'three' => ['amount' => -3, 'currency_symbol' => 'c'],
|
||||
];
|
||||
|
||||
/** @var ChartJsGenerator $generator */
|
||||
@ -141,9 +120,9 @@ class ChartJsGeneratorTest extends TestCase
|
||||
{
|
||||
|
||||
$data = [
|
||||
'one' => ['amount' => 1,'currency_symbol' => 'a'],
|
||||
'two' => ['amount' => 2,'currency_symbol' => 'b'],
|
||||
'three' => ['amount' => 3,'currency_symbol' => 'c'],
|
||||
'one' => ['amount' => 1, 'currency_symbol' => 'a'],
|
||||
'two' => ['amount' => 2, 'currency_symbol' => 'b'],
|
||||
'three' => ['amount' => 3, 'currency_symbol' => 'c'],
|
||||
];
|
||||
|
||||
/** @var ChartJsGenerator $generator */
|
||||
@ -155,6 +134,27 @@ class ChartJsGeneratorTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Generator\Chart\Basic\ChartJsGenerator
|
||||
*/
|
||||
public function testPieChart(): void
|
||||
{
|
||||
|
||||
$data = [
|
||||
'one' => -1,
|
||||
'two' => -2,
|
||||
'three' => -3,
|
||||
];
|
||||
|
||||
/** @var ChartJsGenerator $generator */
|
||||
$generator = new ChartJsGenerator();
|
||||
$result = $generator->pieChart($data);
|
||||
|
||||
$this->assertEquals('three', $result['labels'][0]);
|
||||
$this->assertEquals(3.0, $result['datasets'][0]['data'][0]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Generator\Chart\Basic\ChartJsGenerator
|
||||
*/
|
||||
|
@ -29,9 +29,10 @@ use FireflyIII\Handlers\Events\AdminEventHandler;
|
||||
use FireflyIII\Mail\AdminTestMail;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class AdminEventHandlerTest
|
||||
*/
|
||||
|
@ -152,8 +152,8 @@ class AttachmentHelperTest extends TestCase
|
||||
// mock calls:
|
||||
Storage::fake('upload');
|
||||
|
||||
$path = public_path('browserconfig.xml');
|
||||
$helper = new AttachmentHelper;
|
||||
$path = public_path('browserconfig.xml');
|
||||
$helper = new AttachmentHelper;
|
||||
|
||||
// make new attachment:
|
||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
|
||||
|
@ -34,8 +34,8 @@ use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class MetaPieChartTest
|
||||
|
@ -66,7 +66,7 @@ class HelpTest extends TestCase
|
||||
// now let's see what happens:
|
||||
$help = new Help;
|
||||
$result = $help->getFromGitHub('test-route', 'en_US');
|
||||
$this->assertEquals('<p>Some help text.</p>'."\n", $result);
|
||||
$this->assertEquals('<p>Some help text.</p>' . "\n", $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,20 @@ use Tests\TestCase;
|
||||
*/
|
||||
class AuthenticateTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware('auth')->any(
|
||||
'/_test/authenticate', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Authenticate
|
||||
*/
|
||||
@ -98,18 +112,4 @@ class AuthenticateTest extends TestCase
|
||||
$response->assertSessionHas('logoutMessage', (string)trans('firefly.email_changed_logout'));
|
||||
$response->assertRedirect(route('login'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware('auth')->any(
|
||||
'/_test/authenticate', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,20 @@ use Tests\TestCase;
|
||||
*/
|
||||
class AuthenticateTwoFactorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(AuthenticateTwoFactor::class)->any(
|
||||
'/_test/authenticate', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\AuthenticateTwoFactor
|
||||
*/
|
||||
@ -174,18 +188,4 @@ class AuthenticateTwoFactorTest extends TestCase
|
||||
$this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode());
|
||||
$response->assertRedirect(route('two-factor.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(AuthenticateTwoFactor::class)->any(
|
||||
'/_test/authenticate', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,20 @@ use Tests\TestCase;
|
||||
*/
|
||||
class IsAdminTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(IsAdmin::class)->any(
|
||||
'/_test/is-admin', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsAdmin
|
||||
*/
|
||||
@ -77,18 +91,4 @@ class IsAdminTest extends TestCase
|
||||
$response = $this->get('/_test/is-admin');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(IsAdmin::class)->any(
|
||||
'/_test/is-admin', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,20 @@ use Tests\TestCase;
|
||||
*/
|
||||
class IsDemoUserTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware([StartFireflySession::class, IsDemoUser::class])->any(
|
||||
'/_test/is-demo', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsDemoUser
|
||||
*/
|
||||
@ -63,18 +77,4 @@ class IsDemoUserTest extends TestCase
|
||||
$response = $this->get('/_test/is-demo');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware([StartFireflySession::class, IsDemoUser::class])->any(
|
||||
'/_test/is-demo', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,20 @@ use Tests\TestCase;
|
||||
*/
|
||||
class IsSandstormUserTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(IsSandStormUser::class)->any(
|
||||
'/_test/is-sandstorm', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\IsSandStormUser
|
||||
*/
|
||||
@ -69,18 +83,4 @@ class IsSandstormUserTest extends TestCase
|
||||
$response->assertRedirect(route('index'));
|
||||
putenv('SANDSTORM=0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(IsSandStormUser::class)->any(
|
||||
'/_test/is-sandstorm', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,20 @@ use Tests\TestCase;
|
||||
*/
|
||||
class RangeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(Range::class)->any(
|
||||
'/_test/range', function () {
|
||||
return view('test.test');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Range
|
||||
*/
|
||||
@ -62,18 +76,4 @@ class RangeTest extends TestCase
|
||||
$response = $this->get('/_test/range');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(Range::class)->any(
|
||||
'/_test/range', function () {
|
||||
return view('test.test');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,20 @@ use Tests\TestCase;
|
||||
*/
|
||||
class RedirectIf2FAAuthenticatedTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(RedirectIfTwoFactorAuthenticated::class)->any(
|
||||
'/_test/authenticate', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\RedirectIfTwoFactorAuthenticated
|
||||
*/
|
||||
@ -77,18 +91,4 @@ class RedirectIf2FAAuthenticatedTest extends TestCase
|
||||
$response = $this->get('/_test/authenticate');
|
||||
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(RedirectIfTwoFactorAuthenticated::class)->any(
|
||||
'/_test/authenticate', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,20 @@ use Tests\TestCase;
|
||||
*/
|
||||
class RedirectIfAuthenticatedTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(RedirectIfAuthenticated::class)->any(
|
||||
'/_test/authenticate', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\RedirectIfAuthenticated
|
||||
*/
|
||||
@ -52,18 +66,4 @@ class RedirectIfAuthenticatedTest extends TestCase
|
||||
$this->assertEquals(Response::HTTP_FOUND, $response->getStatusCode());
|
||||
$response->assertRedirect(route('index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(RedirectIfAuthenticated::class)->any(
|
||||
'/_test/authenticate', function () {
|
||||
return 'OK';
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,20 @@ use Tests\TestCase;
|
||||
*/
|
||||
class SandstormTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(Sandstorm::class)->any(
|
||||
'/_test/sandstorm', function () {
|
||||
return view('test.test');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Middleware\Sandstorm
|
||||
*/
|
||||
@ -56,18 +70,4 @@ class SandstormTest extends TestCase
|
||||
|
||||
putenv('SANDSTORM=0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Route::middleware(Sandstorm::class)->any(
|
||||
'/_test/sandstorm', function () {
|
||||
return view('test.test');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ class ChooseAccountsHandlerTest extends TestCase
|
||||
];
|
||||
$expected = $config;
|
||||
$expected['mapping'][0] = 456;
|
||||
$expected['bunq-iban'] = [];
|
||||
$expected['bunq-iban'] = [];
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
@ -22,7 +22,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\CategoryIs;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -69,7 +68,7 @@ class CategoryIsTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredTransaction(): void
|
||||
{
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
$transaction = $withdrawal->transactions()->first();
|
||||
$category = $withdrawal->user->categories()->first();
|
||||
|
||||
|
@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\HasAnyBudget;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
@ -22,7 +22,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\TransactionRules\Triggers\HasAttachment;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
@ -75,7 +75,7 @@ class HasNoCategoryTest extends TestCase
|
||||
*/
|
||||
public function testTriggeredTransaction(): void
|
||||
{
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
$transaction = $withdrawal->transactions()->first();
|
||||
$category = $withdrawal->user->categories()->first();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user