mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 20:16:22 +00:00
Refactored a lot of tests.
This commit is contained in:
@@ -23,9 +23,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Budget;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Log;
|
||||
use Mockery;
|
||||
@@ -53,6 +51,8 @@ class DeleteControllerTest extends TestCase
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$budget = $this->getRandomBudget();
|
||||
Log::debug('Now in testDelete()');
|
||||
// mock stuff
|
||||
$this->mock(BudgetRepositoryInterface::class);
|
||||
@@ -60,11 +60,9 @@ class DeleteControllerTest extends TestCase
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('budgets.delete', [1]));
|
||||
$response = $this->get(route('budgets.delete', [$budget->id]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
@@ -75,19 +73,21 @@ class DeleteControllerTest extends TestCase
|
||||
*/
|
||||
public function testDestroy(): void
|
||||
{
|
||||
$this->mockDefaultSession();
|
||||
$budget = $this->getRandomBudget();
|
||||
Log::debug('Now in testDestroy()');
|
||||
// mock stuff
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$this->mockDefaultSession();
|
||||
|
||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
|
||||
$this->session(['budgets.delete.uri' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('budgets.destroy', [1]));
|
||||
$response = $this->post(route('budgets.destroy', [$budget->id]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
Reference in New Issue
Block a user