mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-23 03:31:25 +00:00
Speed up some tests.
This commit is contained in:
@@ -12,7 +12,9 @@
|
||||
namespace Chart;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use TestCase;
|
||||
|
||||
/**
|
||||
@@ -54,12 +56,22 @@ class CategoryControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Chart\CategoryController::currentPeriod
|
||||
* @covers \FireflyIII\Http\Controllers\Chart\CategoryController::makePeriodChart
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testCurrentPeriod(string $range)
|
||||
{
|
||||
// this is actually for makePeriodChart
|
||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$categoryRepository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$account = $this->user()->accounts()->where('account_type_id', 5)->first();
|
||||
$accountRepository->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
|
||||
$categoryRepository->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
$categoryRepository->shouldReceive('earnedInPeriod')->andReturn('0');
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$this->call('get', route('chart.category.current', [1]));
|
||||
@@ -74,9 +86,21 @@ class CategoryControllerTest extends TestCase
|
||||
*/
|
||||
public function testFrontpage(string $range)
|
||||
{
|
||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$categoryRepository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$category = $this->user()->categories()->first();
|
||||
$account = $this->user()->accounts()->where('account_type_id', 5)->first();
|
||||
// get one category
|
||||
$categoryRepository->shouldReceive('getCategories')->andReturn(new Collection([$category]));
|
||||
// get one account
|
||||
$accountRepository->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
|
||||
// always return zero
|
||||
$categoryRepository->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
$categoryRepository->shouldReceive('spentInPeriodWithoutCategory')->andReturn('0');
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$this->call('get', route('chart.category.current', [1]));
|
||||
$this->call('get', route('chart.category.frontpage', [1]));
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
|
||||
@@ -102,12 +126,20 @@ class CategoryControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Chart\CategoryController::specificPeriod
|
||||
* @covers \FireflyIII\Http\Controllers\Chart\CategoryController::makePeriodChart
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testSpecificPeriod(string $range)
|
||||
{
|
||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$categoryRepository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$account = $this->user()->accounts()->where('account_type_id', 5)->first();
|
||||
$accountRepository->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
|
||||
$categoryRepository->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
$categoryRepository->shouldReceive('earnedInPeriod')->andReturn('0');
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$this->call('get', route('chart.category.specific', ['1', '2012-01-01']));
|
||||
|
||||
Reference in New Issue
Block a user