mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-10 23:45:48 -06:00
Improve test coverage.
This commit is contained in:
parent
ab9146b7c6
commit
477acafc4c
@ -101,11 +101,12 @@ class CategoryControllerTest extends TestCase
|
|||||||
public function testIndex()
|
public function testIndex()
|
||||||
{
|
{
|
||||||
// mock stuff
|
// mock stuff
|
||||||
|
$category = factory(Category::class)->make();
|
||||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('getCategories')->andReturn(new Collection);
|
$repository->shouldReceive('getCategories')->andReturn(new Collection([$category]))->once();
|
||||||
$repository->shouldReceive('lastUseDate')->andReturn(new Carbon);
|
$repository->shouldReceive('lastUseDate')->andReturn(new Carbon)->once();
|
||||||
|
|
||||||
$this->be($this->user());
|
$this->be($this->user());
|
||||||
$response = $this->get(route('categories.index'));
|
$response = $this->get(route('categories.index'));
|
||||||
@ -220,47 +221,6 @@ class CategoryControllerTest extends TestCase
|
|||||||
$response->assertSee('<ol class="breadcrumb">');
|
$response->assertSee('<ol class="breadcrumb">');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers \FireflyIII\Http\Controllers\CategoryController::show
|
|
||||||
* @covers \FireflyIII\Http\Controllers\CategoryController::getPeriodOverview
|
|
||||||
*
|
|
||||||
* @dataProvider dateRangeProvider
|
|
||||||
*
|
|
||||||
* @param string $range
|
|
||||||
*/
|
|
||||||
public function testShowEmpty(string $range)
|
|
||||||
{
|
|
||||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
|
||||||
|
|
||||||
// mock stuff
|
|
||||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
|
||||||
$repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon);
|
|
||||||
$repository->shouldReceive('spentInPeriod')->andReturn('0');
|
|
||||||
$repository->shouldReceive('earnedInPeriod')->andReturn('0');
|
|
||||||
|
|
||||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
|
||||||
$accountRepos->shouldReceive('getAccountsByType')->once()->andReturn(new Collection);
|
|
||||||
|
|
||||||
$collector = $this->mock(JournalCollectorInterface::class);
|
|
||||||
$collector->shouldReceive('setPage')->andReturnSelf()->times(3);
|
|
||||||
$collector->shouldReceive('setLimit')->andReturnSelf()->times(3);
|
|
||||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->times(3);
|
|
||||||
$collector->shouldReceive('setRange')->andReturnSelf()->times(3);
|
|
||||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->times(3);
|
|
||||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf()->times(3);
|
|
||||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(3);
|
|
||||||
|
|
||||||
$collector->shouldReceive('setCategory')->andReturnSelf()->times(3);
|
|
||||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->times(3);
|
|
||||||
|
|
||||||
$this->be($this->user());
|
|
||||||
$this->changeDateRange($this->user(), $range);
|
|
||||||
$response = $this->get(route('categories.show', [1]));
|
|
||||||
$response->assertStatus(200);
|
|
||||||
$response->assertSee('<ol class="breadcrumb">');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\CategoryController::show
|
* @covers \FireflyIII\Http\Controllers\CategoryController::show
|
||||||
* @covers \FireflyIII\Http\Controllers\CategoryController::getPeriodOverview
|
* @covers \FireflyIII\Http\Controllers\CategoryController::getPeriodOverview
|
||||||
@ -379,6 +339,47 @@ class CategoryControllerTest extends TestCase
|
|||||||
$response->assertSee('<ol class="breadcrumb">');
|
$response->assertSee('<ol class="breadcrumb">');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \FireflyIII\Http\Controllers\CategoryController::show
|
||||||
|
* @covers \FireflyIII\Http\Controllers\CategoryController::getPeriodOverview
|
||||||
|
*
|
||||||
|
* @dataProvider dateRangeProvider
|
||||||
|
*
|
||||||
|
* @param string $range
|
||||||
|
*/
|
||||||
|
public function testShowEmpty(string $range)
|
||||||
|
{
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
|
|
||||||
|
// mock stuff
|
||||||
|
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||||
|
$repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon);
|
||||||
|
$repository->shouldReceive('spentInPeriod')->andReturn('0');
|
||||||
|
$repository->shouldReceive('earnedInPeriod')->andReturn('0');
|
||||||
|
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$accountRepos->shouldReceive('getAccountsByType')->once()->andReturn(new Collection);
|
||||||
|
|
||||||
|
$collector = $this->mock(JournalCollectorInterface::class);
|
||||||
|
$collector->shouldReceive('setPage')->andReturnSelf()->times(3);
|
||||||
|
$collector->shouldReceive('setLimit')->andReturnSelf()->times(3);
|
||||||
|
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->times(3);
|
||||||
|
$collector->shouldReceive('setRange')->andReturnSelf()->times(3);
|
||||||
|
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->times(3);
|
||||||
|
$collector->shouldReceive('withCategoryInformation')->andReturnSelf()->times(3);
|
||||||
|
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(3);
|
||||||
|
|
||||||
|
$collector->shouldReceive('setCategory')->andReturnSelf()->times(3);
|
||||||
|
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->times(3);
|
||||||
|
|
||||||
|
$this->be($this->user());
|
||||||
|
$this->changeDateRange($this->user(), $range);
|
||||||
|
$response = $this->get(route('categories.show', [1]));
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$response->assertSee('<ol class="breadcrumb">');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\CategoryController::store
|
* @covers \FireflyIII\Http\Controllers\CategoryController::store
|
||||||
*/
|
*/
|
||||||
|
@ -43,8 +43,30 @@ class NewUserControllerTest extends TestCase
|
|||||||
$response->assertSee('<ol class="breadcrumb">');
|
$response->assertSee('<ol class="breadcrumb">');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \FireflyIII\Http\Controllers\NewUserController::index
|
||||||
|
* @covers \FireflyIII\Http\Controllers\NewUserController::__construct
|
||||||
|
*/
|
||||||
|
public function testIndexExisting()
|
||||||
|
{
|
||||||
|
// mock stuff
|
||||||
|
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||||
|
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||||
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
|
$accountRepos->shouldReceive('count')->andReturn(1);
|
||||||
|
|
||||||
|
|
||||||
|
$this->be($this->user());
|
||||||
|
$response = $this->get(route('new-user.index'));
|
||||||
|
$response->assertStatus(302);
|
||||||
|
$response->assertRedirect(route('index'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FireflyIII\Http\Controllers\NewUserController::submit
|
* @covers \FireflyIII\Http\Controllers\NewUserController::submit
|
||||||
|
* @covers \FireflyIII\Http\Controllers\NewUserController::createAssetAccount
|
||||||
|
* @covers \FireflyIII\Http\Controllers\NewUserController::createSavingsAccount
|
||||||
|
* @covers \FireflyIII\Http\Controllers\NewUserController::storeCreditCard
|
||||||
*/
|
*/
|
||||||
public function testSubmit()
|
public function testSubmit()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user