Files
firefly-iii/tests/Feature/Controllers/Recurring/IndexControllerTest.php

97 lines
3.1 KiB
PHP
Raw Normal View History

2018-09-02 20:13:25 +02:00
<?php
/**
* IndexControllerTest.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
*
* 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
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace Tests\Feature\Controllers\Recurring;
use FireflyIII\Models\Configuration;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Tests\TestCase;
/**
*
* Class IndexControllerTest
*/
class IndexControllerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
2018-09-03 18:52:46 +02:00
Log::info(sprintf('Now in %s.', \get_class($this)));
2018-09-02 20:13:25 +02:00
}
/**
* @covers \FireflyIII\Http\Controllers\Recurring\IndexController
*/
public function testIndex(): void
{
$repository = $this->mock(RecurringRepositoryInterface::class);
$config = new Configuration;
$config->data = 0;
$falseConfig = new Configuration;
$falseConfig->data = false;
$collection = $this->user()->recurrences()->take(2)->get();
// mock cron job config:
\FireflyConfig::shouldReceive('get')->withArgs(['last_rt_job', 0])->once()->andReturn($config);
\FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
$repository->shouldReceive('get')->andReturn($collection)->once();
$repository->shouldReceive('setUser');
$repository->shouldReceive('getNoteText')->andReturn('Notes');
$repository->shouldReceive('repetitionDescription')->andReturn('Bla');
$repository->shouldReceive('getXOccurrences')->andReturn([]);
$this->be($this->user());
$response = $this->get(route('recurring.index'));
$response->assertStatus(200);
$response->assertSee('<ol class="breadcrumb">');
}
public function testShow(): void
{
$repository = $this->mock(RecurringRepositoryInterface::class);
$recurrence = $this->user()->recurrences()->first();
$repository->shouldReceive('setUser');
$repository->shouldReceive('getNoteText')->andReturn('Notes');
$repository->shouldReceive('repetitionDescription')->andReturn('Bla');
$repository->shouldReceive('getXOccurrences')->andReturn([]);
$repository->shouldReceive('getTransactions')->andReturn(new Collection);
$this->be($this->user());
$response = $this->get(route('recurring.show', [$recurrence->id]));
$response->assertStatus(200);
$response->assertSee('<ol class="breadcrumb">');
}
}