mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-16 22:58:09 +00:00
Expand tests.
This commit is contained in:
@@ -34,7 +34,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Navigation;
|
||||
use Steam;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -52,7 +51,9 @@ class CategoryControllerTest extends TestCase
|
||||
public function testCreate()
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$this->be($this->user());
|
||||
@@ -68,6 +69,8 @@ class CategoryControllerTest extends TestCase
|
||||
public function testDelete()
|
||||
{
|
||||
// mock stuff
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@@ -84,11 +87,12 @@ class CategoryControllerTest extends TestCase
|
||||
public function testDestroy()
|
||||
{
|
||||
// mock stuff
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
$categoryRepos->shouldReceive('destroy')->andReturn(true);
|
||||
|
||||
$this->session(['categories.delete.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
@@ -103,6 +107,8 @@ class CategoryControllerTest extends TestCase
|
||||
public function testEdit()
|
||||
{
|
||||
// mock stuff
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@@ -121,11 +127,12 @@ class CategoryControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff
|
||||
$category = factory(Category::class)->make();
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getCategories')->andReturn(new Collection([$category]))->once();
|
||||
$repository->shouldReceive('lastUseDate')->andReturn(new Carbon)->once();
|
||||
$categoryRepos->shouldReceive('getCategories')->andReturn(new Collection([$category]))->once();
|
||||
$categoryRepos->shouldReceive('lastUseDate')->andReturn(new Carbon)->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('categories.index'));
|
||||
@@ -145,6 +152,8 @@ class CategoryControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
|
||||
|
||||
@@ -175,12 +184,13 @@ class CategoryControllerTest extends TestCase
|
||||
*
|
||||
* @param string $range
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testNoCategoryAll(string $range)
|
||||
{
|
||||
// mock stuff
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
|
||||
|
||||
@@ -215,6 +225,8 @@ class CategoryControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
|
||||
|
||||
@@ -235,7 +247,7 @@ class CategoryControllerTest extends TestCase
|
||||
Navigation::shouldReceive('startOfPeriod')->andReturn(new Carbon);
|
||||
Navigation::shouldReceive('endOfPeriod')->andReturn(new Carbon);
|
||||
Navigation::shouldReceive('periodShow')->andReturn('Some date');
|
||||
Navigation::shouldReceive('blockPeriods')->andReturn([['period' =>'1M','start' => new Carbon, 'end' => new Carbon]])->once();
|
||||
Navigation::shouldReceive('blockPeriods')->andReturn([['period' => '1M', 'start' => new Carbon, 'end' => new Carbon]])->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
@@ -256,15 +268,15 @@ class CategoryControllerTest extends TestCase
|
||||
public function testShow(string $range)
|
||||
{
|
||||
$transaction = factory(Transaction::class)->make();
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->twice()->andReturn(new TransactionJournal);
|
||||
|
||||
// mock stuff
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn('0');
|
||||
$categoryRepos->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
$categoryRepos->shouldReceive('earnedInPeriod')->andReturn('0');
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getAccountsByType')->once()->andReturn(new Collection);
|
||||
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
@@ -287,7 +299,7 @@ class CategoryControllerTest extends TestCase
|
||||
Navigation::shouldReceive('startOfPeriod')->andReturn(new Carbon);
|
||||
Navigation::shouldReceive('endOfPeriod')->andReturn(new Carbon);
|
||||
Navigation::shouldReceive('periodShow')->andReturn('Some date');
|
||||
Navigation::shouldReceive('blockPeriods')->andReturn([['period' =>'1M','start' => new Carbon, 'end' => new Carbon]])->once();
|
||||
Navigation::shouldReceive('blockPeriods')->andReturn([['period' => '1M', 'start' => new Carbon, 'end' => new Carbon]])->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
@@ -309,6 +321,7 @@ class CategoryControllerTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$collector->shouldReceive('setPage')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
|
||||
@@ -422,6 +435,7 @@ class CategoryControllerTest extends TestCase
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
@@ -446,6 +460,7 @@ class CategoryControllerTest extends TestCase
|
||||
{
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('update');
|
||||
$repository->shouldReceive('find')->andReturn(new Category);
|
||||
|
||||
Reference in New Issue
Block a user