firefly-iii/tests/Feature/Controllers/Report/CategoryControllerTest.php

74 lines
2.7 KiB
PHP
Raw Normal View History

2017-02-12 11:40:39 -06:00
<?php
/**
* CategoryControllerTest.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace Tests\Feature\Controllers\Report;
2017-03-12 15:24:34 -05:00
use FireflyIII\Models\Category;
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use Illuminate\Support\Collection;
2017-02-12 11:40:39 -06:00
use Tests\TestCase;
class CategoryControllerTest extends TestCase
{
/**
* @covers \FireflyIII\Http\Controllers\Report\CategoryController::expenses
2017-03-12 15:24:34 -05:00
* @covers \FireflyIII\Http\Controllers\Report\CategoryController::filterReport
2017-02-12 11:40:39 -06:00
*/
public function testExpenses()
{
2017-03-12 15:24:34 -05:00
$first = [1 => ['entries' => ['1', '1']]];
$second = ['entries' => ['1', '1']];
$repository = $this->mock(CategoryRepositoryInterface::class);
$repository->shouldReceive('getCategories')->andReturn(new Collection);
$repository->shouldReceive('periodExpenses')->andReturn($first);
$repository->shouldReceive('periodExpensesNoCategory')->andReturn($second);
2017-02-12 11:40:39 -06:00
$this->be($this->user());
$response = $this->get(route('report-data.category.expenses', ['1', '20120101', '20120131']));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Report\CategoryController::income
2017-03-12 15:24:34 -05:00
* @covers \FireflyIII\Http\Controllers\Report\CategoryController::filterReport
2017-02-12 11:40:39 -06:00
*/
public function testIncome()
{
2017-03-12 15:24:34 -05:00
$first = [1 => ['entries' => ['1', '1']]];
$second = ['entries' => ['1', '1']];
$repository = $this->mock(CategoryRepositoryInterface::class);
$repository->shouldReceive('getCategories')->andReturn(new Collection);
$repository->shouldReceive('periodIncome')->andReturn($first);
$repository->shouldReceive('periodIncomeNoCategory')->andReturn($second);
2017-02-12 11:40:39 -06:00
$this->be($this->user());
$response = $this->get(route('report-data.category.income', ['1', '20120101', '20120131']));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Report\CategoryController::operations
*/
public function testOperations()
{
2017-03-12 15:24:34 -05:00
$repository = $this->mock(CategoryRepositoryInterface::class);
$category = factory(Category::class)->make();
$repository->shouldReceive('getCategories')->andReturn(new Collection([$category]));
$repository->shouldReceive('spentInPeriod')->andReturn('-1');
2017-02-12 11:40:39 -06:00
$this->be($this->user());
$response = $this->get(route('report-data.category.operations', ['1', '20120101', '20120131']));
$response->assertStatus(200);
}
2017-02-16 15:33:32 -06:00
}