Expand tests.

This commit is contained in:
James Cole
2018-02-28 15:50:00 +01:00
parent 28debb46be
commit 46f4fa1a7d
34 changed files with 987 additions and 403 deletions

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace Tests\Feature\Controllers;
use Carbon\Carbon;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
use FireflyIII\Models\Bill;
use FireflyIII\Models\TransactionJournal;
@@ -30,6 +31,7 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
use Tests\TestCase;
/**
@@ -47,6 +49,7 @@ class BillControllerTest extends TestCase
public function testCreate()
{
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
@@ -63,6 +66,7 @@ class BillControllerTest extends TestCase
public function testDelete()
{
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
@@ -79,6 +83,7 @@ class BillControllerTest extends TestCase
public function testDestroy()
{
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$repository->shouldReceive('destroy')->andReturn(true);
@@ -97,6 +102,7 @@ class BillControllerTest extends TestCase
public function testEdit()
{
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
@@ -115,6 +121,7 @@ class BillControllerTest extends TestCase
public function testIndex()
{
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$bill = factory(Bill::class)->make();
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
@@ -125,7 +132,6 @@ class BillControllerTest extends TestCase
$repository->shouldReceive('getPaidDatesInRange')->twice()->andReturn(new Collection([new Carbon, new Carbon, new Carbon]));
$this->be($this->user());
$response = $this->get(route('bills.index'));
$response->assertStatus(200);
@@ -139,6 +145,7 @@ class BillControllerTest extends TestCase
public function testRescan()
{
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journal = factory(TransactionJournal::class)->make();
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
@@ -158,7 +165,9 @@ class BillControllerTest extends TestCase
public function testRescanInactive()
{
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$this->be($this->user());
@@ -173,6 +182,7 @@ class BillControllerTest extends TestCase
public function testShow()
{
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
@@ -204,10 +214,13 @@ class BillControllerTest extends TestCase
public function testStore()
{
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('store')->andReturn(new Bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
$data = [
'name' => 'New Bill ' . rand(1000, 9999),
@@ -233,10 +246,13 @@ class BillControllerTest extends TestCase
public function testUpdate()
{
// mock stuff
$attachHelper = $this->mock(AttachmentHelperInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
$repository->shouldReceive('update')->andReturn(new Bill);
$attachHelper->shouldReceive('saveAttachmentsForModel');
$attachHelper->shouldReceive('getMessages')->andReturn(new MessageBag);
$data = [
'name' => 'Updated Bill ' . rand(1000, 9999),