mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-11-04 05:15:39 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			83 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/**
 | 
						|
 * BillControllerTest.php
 | 
						|
 * Copyright (c) 2017 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\Chart;
 | 
						|
 | 
						|
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
 | 
						|
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
 | 
						|
use FireflyIII\Models\Transaction;
 | 
						|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
 | 
						|
use Illuminate\Support\Collection;
 | 
						|
use Tests\TestCase;
 | 
						|
 | 
						|
/**
 | 
						|
 * Class BillControllerTest
 | 
						|
 *
 | 
						|
 * @SuppressWarnings(PHPMD.TooManyPublicMethods)
 | 
						|
 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
 | 
						|
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 | 
						|
 */
 | 
						|
class BillControllerTest extends TestCase
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * @covers       \FireflyIII\Http\Controllers\Chart\BillController::frontpage
 | 
						|
     * @covers       \FireflyIII\Http\Controllers\Chart\BillController::__construct
 | 
						|
     * @dataProvider dateRangeProvider
 | 
						|
     *
 | 
						|
     * @param string $range
 | 
						|
     */
 | 
						|
    public function testFrontpage(string $range)
 | 
						|
    {
 | 
						|
        $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([]);
 | 
						|
 | 
						|
        $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()
 | 
						|
    {
 | 
						|
        $transaction = factory(Transaction::class)->make();
 | 
						|
        $generator   = $this->mock(GeneratorInterface::class);
 | 
						|
        $collector   = $this->mock(JournalCollectorInterface::class);
 | 
						|
 | 
						|
        $collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
 | 
						|
        $collector->shouldReceive('setBills')->andReturnSelf()->once();
 | 
						|
        $collector->shouldReceive('getJournals')->andReturn(new Collection([$transaction]))->once();
 | 
						|
 | 
						|
        $generator->shouldReceive('multiSet')->once()->andReturn([]);
 | 
						|
 | 
						|
        $this->be($this->user());
 | 
						|
        $response = $this->get(route('chart.bill.single', [1]));
 | 
						|
        $response->assertStatus(200);
 | 
						|
    }
 | 
						|
}
 |