Refactored a lot of tests.

This commit is contained in:
James Cole
2019-07-21 17:15:06 +02:00
parent 5242c0368b
commit b7a4b0fdfd
58 changed files with 1847 additions and 1564 deletions

View File

@@ -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');
}