mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 19:35:16 +00:00
72 lines
2.3 KiB
PHP
72 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* PiggyBankControllerTest.php
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
|
*
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program 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 Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature\Controllers\Chart;
|
|
|
|
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
|
use FireflyIII\Models\PiggyBankEvent;
|
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
|
use Illuminate\Support\Collection;
|
|
use Log;
|
|
use Preferences;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Class PiggyBankControllerTest
|
|
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
|
*/
|
|
class PiggyBankControllerTest extends TestCase
|
|
{
|
|
/**
|
|
*
|
|
*/
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
Log::info(sprintf('Now in %s.', get_class($this)));
|
|
}
|
|
|
|
/**
|
|
* @covers \FireflyIII\Http\Controllers\Chart\PiggyBankController
|
|
*/
|
|
public function testHistory(): void
|
|
{
|
|
$generator = $this->mock(GeneratorInterface::class);
|
|
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
|
/** @var PiggyBankEvent $event */
|
|
$event = PiggyBankEvent::inRandomOrder()->first();
|
|
$piggy = $event->piggy_bank_id;
|
|
|
|
$this->mockDefaultSession();
|
|
Preferences::shouldReceive('lastActivity')->atLeast()->once()->andReturn('md512345');
|
|
|
|
$repository->shouldReceive('getEvents')->andReturn(new Collection([$event]));
|
|
$generator->shouldReceive('singleSet')->once()->andReturn([]);
|
|
|
|
$this->be($this->user());
|
|
$response = $this->get(route('chart.piggy-bank.history', [$piggy]));
|
|
$response->assertStatus(200);
|
|
}
|
|
}
|