mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Improve test coverage.
This commit is contained in:
@@ -80,12 +80,23 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
/**
|
||||
* Submit one, but offer no occurrences.
|
||||
*
|
||||
* TODO there is a random element in this test that breaks the test.
|
||||
*
|
||||
* @covers \FireflyIII\Jobs\CreateRecurringTransactions
|
||||
*/
|
||||
public function testSingle(): void
|
||||
{
|
||||
Log::info(sprintf('Now in test %s.', __METHOD__));
|
||||
// mock classes
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$date = new Carbon;
|
||||
$date->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $date;
|
||||
$recurrence->save();
|
||||
|
||||
Log::debug(sprintf('Test is going to use Recurrence #%d', $recurrence->id), $recurrence->toArray());
|
||||
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$groupRepos = $this->mock(TransactionGroupRepositoryInterface::class);
|
||||
@@ -308,7 +319,14 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
$date = new Carbon();
|
||||
$this->expectsEvents([StoredTransactionGroup::class]);
|
||||
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
// mock classes
|
||||
$carbon = new Carbon;
|
||||
$carbon->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $carbon;
|
||||
$recurrence->save();
|
||||
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// overrule some fields in the recurrence to make it seem it hasnt fired yet.
|
||||
@@ -359,11 +377,21 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
*/
|
||||
public function testForced(): void
|
||||
{
|
||||
Log::info(sprintf('Now in test %s.', __METHOD__));
|
||||
Event::fake();
|
||||
$date = new Carbon();
|
||||
$this->expectsEvents([StoredTransactionGroup::class]);
|
||||
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
// overrule some fields in the recurrence.
|
||||
$carbon = new Carbon;
|
||||
$carbon->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $carbon;
|
||||
$recurrence->save();
|
||||
|
||||
|
||||
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// overrule some fields in the recurrence to make it seem it hasnt fired yet.
|
||||
@@ -418,11 +446,12 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
Event::fake();
|
||||
$date = new Carbon();
|
||||
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// overrule some fields in the recurrence to make it seem it hasnt fired yet.
|
||||
$carbon = new Carbon;
|
||||
$carbon->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $carbon;
|
||||
$recurrence->save();
|
||||
|
||||
// mock classes
|
||||
@@ -459,11 +488,12 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
$tomorrow = new Carbon();
|
||||
$tomorrow->addDays(2);
|
||||
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
|
||||
// overrule some fields in the recurrence to make it seem it hasnt fired yet.
|
||||
$carbon = new Carbon;
|
||||
$carbon->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $carbon;
|
||||
$recurrence->save();
|
||||
|
||||
// mock classes
|
||||
@@ -503,12 +533,16 @@ class CreateRecurringTransactionsTest extends TestCase
|
||||
$date = new Carbon();
|
||||
$this->expectsEvents([StoredTransactionGroup::class]);
|
||||
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
|
||||
$group = $this->getRandomWithdrawalGroup();
|
||||
$piggy = $this->getRandomPiggyBank();
|
||||
|
||||
// overrule some fields in the recurrence to make it seem it hasnt fired yet.
|
||||
$carbon = new Carbon;
|
||||
$carbon->subDays(4);
|
||||
$recurrence = $this->getRandomRecurrence();
|
||||
$recurrence->latest_date = null;
|
||||
$recurrence->first_date = $carbon;
|
||||
$recurrence->save();
|
||||
|
||||
// mock classes
|
||||
|
||||
Reference in New Issue
Block a user