1
0
mirror of https://github.com/Kovah/LinkAce.git synced 2025-04-20 23:11:56 +02:00

Refactor all controller tests to use RefreshDatabase trait

This commit is contained in:
Kovah 2020-07-01 23:38:34 +02:00
parent 79a6c34a09
commit 4798d2762b
No known key found for this signature in database
GPG Key ID: AAAA031BA9830D7B
25 changed files with 53 additions and 103 deletions

View File

@ -6,14 +6,12 @@ use App\Jobs\SaveLinkToWaybackmachine;
use App\Models\Link;
use App\Models\LinkList;
use App\Models\Tag;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Queue;
class LinkApiTest extends ApiTestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testUnauthorizedRequest(): void
{

View File

@ -3,13 +3,11 @@
namespace Tests\Controller\API;
use App\Models\Link;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
class LinkCheckApiTest extends ApiTestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testUnauthorizedRequest(): void
{

View File

@ -4,15 +4,11 @@ namespace Tests\Controller\API;
use App\Models\Link;
use App\Models\Note;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class LinkNotesTest extends ApiTestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testLinksRequest(): void
{

View File

@ -3,13 +3,11 @@
namespace Tests\Controller\API;
use App\Models\LinkList;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ListApiTest extends ApiTestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testUnauthorizedRequest(): void
{

View File

@ -4,15 +4,11 @@ namespace Tests\Controller\API;
use App\Models\Link;
use App\Models\LinkList;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class ListLinksTest extends ApiTestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testLinksRequest(): void
{
@ -26,8 +22,8 @@ class ListLinksTest extends ApiTestCase
$response->assertOk()
->assertJson([
'data' => [
['url' => $link->url]
]
['url' => $link->url],
],
]);
}
@ -39,7 +35,7 @@ class ListLinksTest extends ApiTestCase
$response->assertOk()
->assertJson([
'data' => []
'data' => [],
]);
$responseBody = json_decode($response->content());

View File

@ -4,13 +4,11 @@ namespace Tests\Controller\API;
use App\Models\Link;
use App\Models\Note;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
class NoteApiTest extends ApiTestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testMinimalCreateRequest(): void
{

View File

@ -3,13 +3,11 @@
namespace Tests\Controller\API;
use App\Models\LinkList;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
class SearchListsTest extends ApiTestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testUnauthorizedRequest(): void
{

View File

@ -3,13 +3,11 @@
namespace Tests\Controller\API;
use App\Models\Tag;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
class SearchTagsTest extends ApiTestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testUnauthorizedRequest(): void
{

View File

@ -3,13 +3,11 @@
namespace Tests\Controller\API;
use App\Models\Tag;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
class TagApiTest extends ApiTestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testUnauthorizedRequest(): void
{

View File

@ -4,15 +4,11 @@ namespace Tests\Controller\API;
use App\Models\Link;
use App\Models\Tag;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class TagLinksTest extends ApiTestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testLinksRequest(): void
{

View File

@ -6,15 +6,13 @@ use App\Models\Link;
use App\Models\LinkList;
use App\Models\Note;
use App\Models\Tag;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\Controller\Traits\PreparesTrash;
class TrashApiTest extends ApiTestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
use PreparesTrash;
protected function setUp(): void

View File

@ -3,14 +3,12 @@
namespace Tests\Controller\App;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class BookmarkletControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testValidBookmarkletResponse(): void
{

View File

@ -3,14 +3,12 @@
namespace Tests\Controller\App;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class DashboardControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testValidDashboardResponse(): void
{

View File

@ -4,14 +4,12 @@ namespace Tests\Controller\App;
use App\Models\Link;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ExportControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
private $user;

View File

@ -4,15 +4,13 @@ namespace Tests\Controller\App;
use App\Models\Link;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Tests\TestCase;
class ImportControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
private $user;

View File

@ -6,14 +6,12 @@ use App\Models\Link;
use App\Models\LinkList;
use App\Models\Tag;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class SearchControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
private $user;

View File

@ -10,6 +10,7 @@ class SystemSettingsControllerTest extends TestCase
{
use RefreshDatabase;
/** @var User */
private $user;
public function setUp(): void

View File

@ -7,16 +7,14 @@ use App\Models\LinkList;
use App\Models\Note;
use App\Models\Tag;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\Controller\Traits\PreparesTrash;
use Tests\TestCase;
class TrashControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
use PreparesTrash;
/** @var User */

View File

@ -11,6 +11,7 @@ class UserSettingsControllerTest extends TestCase
{
use RefreshDatabase;
/** @var User */
private $user;
public function setUp(): void

View File

@ -3,14 +3,12 @@
namespace Tests\Controller\Auth;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class LoginControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testValidLoginResponse(): void
{

View File

@ -3,14 +3,12 @@
namespace Tests\Controller\Guest;
use App\Models\Setting;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class GuestControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testGuestModeEnabled(): void
{

View File

@ -5,14 +5,12 @@ namespace Tests\Controller\Guest;
use App\Models\Link;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class LinkControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
public function testValidLinkOverviewResponse(): void
{

View File

@ -5,14 +5,12 @@ namespace Tests\Controller\Guest;
use App\Models\LinkList;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ListControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
protected function setUp(): void
{

View File

@ -5,14 +5,12 @@ namespace Tests\Controller\Guest;
use App\Models\Setting;
use App\Models\Tag;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class TagControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
protected function setUp(): void
{

View File

@ -2,14 +2,12 @@
namespace Tests\Controller\Setup;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class MetaControllerTest extends TestCase
{
use DatabaseTransactions;
use DatabaseMigrations;
use RefreshDatabase;
protected function setUp(): void
{
@ -31,7 +29,7 @@ class MetaControllerTest extends TestCase
$response = $this->get('/');
$response->assertStatus(200);
$response->assertOk();
}
public function testRedirectIfSetupCompleted(): void
@ -47,7 +45,7 @@ class MetaControllerTest extends TestCase
{
$response = $this->get('setup/start');
$response->assertStatus(200)
$response->assertOk()
->assertSee('Welcome to the LinkAce setup');
}
}