Update tests so repositories are not called. Saves on DB calls, speeds up tests.

This commit is contained in:
James Cole
2018-09-04 16:47:01 +02:00
parent ca04113aa7
commit d43fa3790d
23 changed files with 376 additions and 65 deletions

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Unit\TransactionRules\Triggers;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\TransactionRules\Triggers\FromAccountStarts;
use Illuminate\Support\Collection;
@@ -49,7 +50,7 @@ class FromAccountStartsTest extends TestCase
public function testTriggered(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
/** @var TransactionJournal $journal */
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
$account = $this->user()->accounts()->inRandomOrder()->first();
@@ -67,6 +68,7 @@ class FromAccountStartsTest extends TestCase
public function testTriggeredLonger(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
/** @var TransactionJournal $journal */
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
@@ -85,6 +87,7 @@ class FromAccountStartsTest extends TestCase
public function testTriggeredNot(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
/** @var TransactionJournal $journal */
$journal = $this->user()->transactionJournals()->inRandomOrder()->first();
@@ -103,6 +106,8 @@ class FromAccountStartsTest extends TestCase
public function testWillMatchEverythingEmpty(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$value = '';
$result = FromAccountStarts::willMatchEverything($value);
$this->assertTrue($result);
@@ -114,6 +119,8 @@ class FromAccountStartsTest extends TestCase
public function testWillMatchEverythingNotNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$value = 'x';
$result = FromAccountStarts::willMatchEverything($value);
$this->assertFalse($result);
@@ -125,6 +132,8 @@ class FromAccountStartsTest extends TestCase
public function testWillMatchEverythingNull(): void
{
$repository = $this->mock(JournalRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$value = null;
$result = FromAccountStarts::willMatchEverything($value);
$this->assertTrue($result);