Fix tests

This commit is contained in:
James Cole
2018-04-27 11:29:09 +02:00
parent 28bcff99f6
commit bb25132865
20 changed files with 81 additions and 118 deletions

View File

@@ -73,6 +73,7 @@ class HasAnyCategoryTest extends TestCase
*/
public function testTriggeredTransactions()
{
/** @var TransactionJournal $journal */
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$category = $journal->user->categories()->first();
$journal->categories()->detach();
@@ -81,6 +82,7 @@ class HasAnyCategoryTest extends TestCase
// append to transaction, not to journal.
foreach ($journal->transactions()->get() as $index => $transaction) {
$transaction->categories()->sync([$category->id]);
$this->assertEquals(1, $transaction->categories()->count());
}
$this->assertEquals(0, $journal->categories()->count());

View File

@@ -72,9 +72,13 @@ class ToAccountEndsTest extends TestCase
*/
public function testTriggeredNot()
{
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$count = 0;
while ($count === 0) {
$journal = TransactionJournal::inRandomOrder()->whereNull('deleted_at')->first();
$count = $journal->transactions()->where('amount', '>', 0)->count();
}
$trigger = ToAccountEnds::makeFromStrings((string)random_int(1, 234), false);
$trigger = ToAccountEnds::makeFromStrings((string)random_int(1, 1234), false);
$result = $trigger->triggered($journal);
$this->assertFalse($result);
}