Better mocking of objects.

This commit is contained in:
James Cole
2016-01-23 06:59:22 +01:00
parent bf9c1c1875
commit 0d5efb8d27
3 changed files with 31 additions and 33 deletions

View File

@@ -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());