mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-24 22:48:18 +00:00
Improve test coverage.
This commit is contained in:
@@ -71,7 +71,7 @@ class CategoryControllerTest extends TestCase
|
||||
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
|
||||
$this->session(['categories.delete.url' => 'http://localhost']);
|
||||
$this->session(['categories.delete.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('categories.destroy', [1]));
|
||||
$response->assertStatus(302);
|
||||
@@ -220,6 +220,47 @@ class CategoryControllerTest extends TestCase
|
||||
$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::getPeriodOverview
|
||||
@@ -326,7 +367,7 @@ class CategoryControllerTest extends TestCase
|
||||
$collector->shouldReceive('setCategory')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([$transaction], 0, 10))->once();
|
||||
|
||||
$repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon);
|
||||
$repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon('1900-01-01'));
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('-1');
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn('1');
|
||||
|
||||
@@ -349,7 +390,7 @@ class CategoryControllerTest extends TestCase
|
||||
$repository->shouldReceive('find')->andReturn(new Category);
|
||||
$repository->shouldReceive('store')->andReturn(new Category);
|
||||
|
||||
$this->session(['categories.create.url' => 'http://localhost']);
|
||||
$this->session(['categories.create.uri' => 'http://localhost']);
|
||||
|
||||
$data = [
|
||||
'name' => 'New Category ' . rand(1000, 9999),
|
||||
@@ -371,7 +412,7 @@ class CategoryControllerTest extends TestCase
|
||||
$repository->shouldReceive('update');
|
||||
$repository->shouldReceive('find')->andReturn(new Category);
|
||||
|
||||
$this->session(['categories.edit.url' => 'http://localhost']);
|
||||
$this->session(['categories.edit.uri' => 'http://localhost']);
|
||||
|
||||
$data = [
|
||||
'name' => 'Updated Category ' . rand(1000, 9999),
|
||||
|
Reference in New Issue
Block a user