2017-02-12 17:58:16 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* BillControllerTest.php
|
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* This file is part of Firefly III.
|
|
|
|
*
|
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 14:42:21 +01:00
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
2017-02-12 17:58:16 +01:00
|
|
|
*/
|
2017-07-08 06:28:44 +02:00
|
|
|
declare(strict_types=1);
|
2017-02-12 17:58:16 +01:00
|
|
|
|
|
|
|
namespace Tests\Feature\Controllers\Chart;
|
|
|
|
|
2017-03-12 08:38:13 +01:00
|
|
|
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
|
|
|
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
2017-03-25 13:41:17 +01:00
|
|
|
use FireflyIII\Models\Transaction;
|
2017-03-12 08:38:13 +01:00
|
|
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
|
|
|
use Illuminate\Support\Collection;
|
2018-03-24 06:08:50 +01:00
|
|
|
use Log;
|
2017-02-12 17:58:16 +01:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
2017-03-12 09:22:33 +01:00
|
|
|
/**
|
|
|
|
* Class BillControllerTest
|
|
|
|
*
|
2017-08-12 10:27:45 +02:00
|
|
|
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
|
|
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
2017-03-12 09:22:33 +01:00
|
|
|
*/
|
2017-02-12 17:58:16 +01:00
|
|
|
class BillControllerTest extends TestCase
|
|
|
|
{
|
2018-03-24 06:08:50 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
Log::debug('Now in Feature/Controllers/Chart/Test.');
|
|
|
|
}
|
|
|
|
|
2017-02-12 17:58:16 +01:00
|
|
|
/**
|
|
|
|
* @covers \FireflyIII\Http\Controllers\Chart\BillController::frontpage
|
2017-02-17 20:14:38 +01:00
|
|
|
* @covers \FireflyIII\Http\Controllers\Chart\BillController::__construct
|
2017-02-12 17:58:16 +01:00
|
|
|
* @dataProvider dateRangeProvider
|
|
|
|
*
|
|
|
|
* @param string $range
|
|
|
|
*/
|
|
|
|
public function testFrontpage(string $range)
|
|
|
|
{
|
2017-03-12 08:38:13 +01: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 17:58:16 +01: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 13:41:17 +01:00
|
|
|
$transaction = factory(Transaction::class)->make();
|
2017-07-08 06:28:44 +02:00
|
|
|
$generator = $this->mock(GeneratorInterface::class);
|
|
|
|
$collector = $this->mock(JournalCollectorInterface::class);
|
2017-03-12 08:38:13 +01:00
|
|
|
|
|
|
|
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
|
|
|
|
$collector->shouldReceive('setBills')->andReturnSelf()->once();
|
2017-03-25 13:41:17 +01:00
|
|
|
$collector->shouldReceive('getJournals')->andReturn(new Collection([$transaction]))->once();
|
2017-03-12 08:38:13 +01:00
|
|
|
|
|
|
|
$generator->shouldReceive('multiSet')->once()->andReturn([]);
|
|
|
|
|
2017-02-12 17:58:16 +01:00
|
|
|
$this->be($this->user());
|
|
|
|
$response = $this->get(route('chart.bill.single', [1]));
|
|
|
|
$response->assertStatus(200);
|
|
|
|
}
|
2017-02-16 22:33:32 +01:00
|
|
|
}
|