mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-26 05:26:17 +00:00
Better mocking of objects.
This commit is contained in:
@@ -22,12 +22,10 @@ class ChartBudgetControllerTest extends TestCase
|
||||
public function testBudget()
|
||||
{
|
||||
|
||||
$repository = Mockery::mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$repository->shouldReceive('getExpensesPerMonth')->once()->andReturn(new Collection([new Budget]));
|
||||
$repository->shouldReceive('getFirstBudgetLimitDate')->once()->andReturn(new Carbon);
|
||||
|
||||
$this->app->instance('FireflyIII\Repositories\Budget\BudgetRepositoryInterface', $repository);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->call('GET', '/chart/budget/1');
|
||||
$this->assertEquals(200, $response->status());
|
||||
@@ -67,13 +65,10 @@ class ChartBudgetControllerTest extends TestCase
|
||||
$budget->dateFormatted = '2015';
|
||||
$budget->budgeted = 120;
|
||||
|
||||
$repository = Mockery::mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$repository->shouldReceive('getBudgetedPerYear')->once()->andReturn(new Collection([$budget]));
|
||||
$repository->shouldReceive('getBudgetsAndExpensesPerYear')->once()->andReturn([]);
|
||||
|
||||
$this->app->instance('FireflyIII\Repositories\Budget\BudgetRepositoryInterface', $repository);
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->call('GET', '/chart/budget/multi-year/default/20150101/20160101/1/1');
|
||||
$this->assertEquals(200, $response->status());
|
||||
@@ -85,11 +80,9 @@ class ChartBudgetControllerTest extends TestCase
|
||||
*/
|
||||
public function testYear()
|
||||
{
|
||||
$repository = Mockery::mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$repository = $this->mock('FireflyIII\Repositories\Budget\BudgetRepositoryInterface');
|
||||
$repository->shouldReceive('getBudgetsAndExpensesPerMonth')->once()->andReturn([]);
|
||||
|
||||
$this->app->instance('FireflyIII\Repositories\Budget\BudgetRepositoryInterface', $repository);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->call('GET', '/chart/budget/year/default/20150101/20151231/1');
|
||||
$this->assertEquals(200, $response->status());
|
||||
|
||||
@@ -41,11 +41,9 @@ class ChartCategoryControllerTest extends TestCase
|
||||
*/
|
||||
public function testEarnedInPeriod()
|
||||
{
|
||||
$repository = Mockery::mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||
$repository->shouldReceive('earnedForAccountsPerMonth')->once()->andReturn(new Collection);
|
||||
|
||||
$this->app->instance('FireflyIII\Repositories\Category\CategoryRepositoryInterface', $repository);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->call('GET', '/chart/category/earned-in-period/default/20150101/20151231/1');
|
||||
$this->assertEquals(200, $response->status());
|
||||
@@ -56,13 +54,10 @@ class ChartCategoryControllerTest extends TestCase
|
||||
*/
|
||||
public function testFrontpage()
|
||||
{
|
||||
$repository = Mockery::mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||
$repository->shouldReceive('spentForAccountsPerMonth')->once()->andReturn(new Collection);
|
||||
$repository->shouldReceive('sumSpentNoCategory')->once()->andReturn('120');
|
||||
|
||||
$this->app->instance('FireflyIII\Repositories\Category\CategoryRepositoryInterface', $repository);
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->call('GET', '/chart/category/frontpage');
|
||||
$this->assertEquals(200, $response->status());
|
||||
@@ -73,11 +68,9 @@ class ChartCategoryControllerTest extends TestCase
|
||||
*/
|
||||
public function testMultiYear()
|
||||
{
|
||||
$repository = Mockery::mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||
$repository->shouldReceive('listMultiYear')->once()->andReturn(new Collection);
|
||||
|
||||
$this->app->instance('FireflyIII\Repositories\Category\CategoryRepositoryInterface', $repository);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->call('GET', '/chart/category/multi-year/default/20150101/20151231/1/1');
|
||||
$this->assertEquals(200, $response->status());
|
||||
@@ -101,11 +94,9 @@ class ChartCategoryControllerTest extends TestCase
|
||||
{
|
||||
|
||||
|
||||
$repository = Mockery::mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
|
||||
$repository->shouldReceive('spentForAccountsPerMonth')->once()->andReturn(new Collection);
|
||||
|
||||
$this->app->instance('FireflyIII\Repositories\Category\CategoryRepositoryInterface', $repository);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->call('GET', '/chart/category/spent-in-period/default/20150101/20151231/1');
|
||||
$this->assertEquals(200, $response->status());
|
||||
|
||||
Reference in New Issue
Block a user