Files
firefly-iii/tests/Feature/Controllers/Budget/DeleteControllerTest.php

95 lines
2.8 KiB
PHP
Raw Normal View History

2018-07-14 15:22:21 +02:00
<?php
/**
* DeleteControllerTest.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\Budget;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
2018-09-03 18:52:46 +02:00
use FireflyIII\Repositories\User\UserRepositoryInterface;
2018-07-14 15:22:21 +02:00
use Log;
2018-09-03 18:52:46 +02:00
use Mockery;
use Preferences;
2018-07-14 15:22:21 +02:00
use Tests\TestCase;
/**
*
* Class DeleteControllerTest
*/
class DeleteControllerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
2019-04-09 20:05:20 +02:00
Log::info(sprintf('Now in %s.', get_class($this)));
2018-07-14 15:22:21 +02:00
}
/**
* @covers \FireflyIII\Http\Controllers\Budget\DeleteController
*/
public function testDelete(): void
{
Log::debug('Now in testDelete()');
// mock stuff
$this->mock(BudgetRepositoryInterface::class);
2018-09-03 18:52:46 +02:00
$userRepos = $this->mock(UserRepositoryInterface::class);
2018-09-03 18:52:46 +02:00
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
$this->mockDefaultSession();
2018-07-14 15:22:21 +02:00
$this->be($this->user());
$response = $this->get(route('budgets.delete', [1]));
$response->assertStatus(200);
// has bread crumb
$response->assertSee('<ol class="breadcrumb">');
}
/**
* @covers \FireflyIII\Http\Controllers\Budget\DeleteController
*/
public function testDestroy(): void
{
Log::debug('Now in testDestroy()');
// mock stuff
$repository = $this->mock(BudgetRepositoryInterface::class);
$this->mock(UserRepositoryInterface::class);
2018-09-03 18:52:46 +02:00
$this->mockDefaultSession();
Preferences::shouldReceive('mark')->atLeast()->once();
2018-07-14 15:22:21 +02:00
$repository->shouldReceive('destroy')->andReturn(true);
$this->session(['budgets.delete.uri' => 'http://localhost']);
$this->be($this->user());
$response = $this->post(route('budgets.destroy', [1]));
$response->assertStatus(302);
$response->assertSessionHas('success');
}
2018-07-22 20:33:17 +02:00
}