firefly-iii/tests/Feature/Controllers/Chart/BillControllerTest.php

72 lines
2.4 KiB
PHP
Raw Normal View History

2017-02-12 10:58:16 -06:00
<?php
/**
* BillControllerTest.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\Chart;
2017-03-12 01:38:13 -06:00
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
2017-03-25 07:41:17 -05:00
use FireflyIII\Models\Transaction;
2017-03-12 01:38:13 -06:00
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use Illuminate\Support\Collection;
2017-02-12 10:58:16 -06:00
use Tests\TestCase;
2017-03-12 03:22:33 -05:00
/**
* Class BillControllerTest
*
* @package Tests\Feature\Controllers\Chart
*/
2017-02-12 10:58:16 -06:00
class BillControllerTest extends TestCase
{
/**
* @covers \FireflyIII\Http\Controllers\Chart\BillController::frontpage
2017-02-17 13:14:38 -06:00
* @covers \FireflyIII\Http\Controllers\Chart\BillController::__construct
2017-02-12 10:58:16 -06:00
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testFrontpage(string $range)
{
2017-03-12 01:38:13 -06:00
$generator = $this->mock(GeneratorInterface::class);
$repository = $this->mock(BillRepositoryInterface::class);
$repository->shouldReceive('getBillsPaidInRange')->once()->andReturn('-1');
$repository->shouldReceive('getBillsUnpaidInRange')->once()->andReturn('2');
$generator->shouldReceive('pieChart')->once()->andReturn([]);
2017-02-12 10:58:16 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$response = $this->get(route('chart.bill.frontpage'));
$response->assertStatus(200);
}
/**
* @covers \FireflyIII\Http\Controllers\Chart\BillController::single
*/
public function testSingle()
{
2017-03-25 07:41:17 -05:00
$transaction = factory(Transaction::class)->make();
2017-03-12 01:38:13 -06:00
$generator = $this->mock(GeneratorInterface::class);
$collector = $this->mock(JournalCollectorInterface::class);
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
$collector->shouldReceive('setBills')->andReturnSelf()->once();
2017-03-25 07:41:17 -05:00
$collector->shouldReceive('getJournals')->andReturn(new Collection([$transaction]))->once();
2017-03-12 01:38:13 -06:00
$generator->shouldReceive('multiSet')->once()->andReturn([]);
2017-02-12 10:58:16 -06:00
$this->be($this->user());
$response = $this->get(route('chart.bill.single', [1]));
$response->assertStatus(200);
}
2017-02-16 15:33:32 -06:00
}