Update Admin tests for new auth implementation

This commit is contained in:
Jonny Barnes 2019-03-23 15:41:01 +00:00
parent 2e79492b01
commit dad45c4ab1
8 changed files with 136 additions and 91 deletions

View file

@ -2,6 +2,7 @@
namespace Tests\Feature\Admin;
use App\Models\User;
use Tests\TestCase;
use App\Jobs\SendWebMentions;
use Illuminate\Support\Facades\Queue;
@ -13,25 +14,25 @@ class NotesTest extends TestCase
public function test_index_page()
{
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/notes');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/notes');
$response->assertViewIs('admin.notes.index');
}
public function test_create_page()
{
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/notes/create');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/notes/create');
$response->assertViewIs('admin.notes.create');
}
public function test_create_a_new_note()
{
$this->withSession([
'loggedin' => true,
])->post('/admin/notes', [
$user = factory(User::class)->create();
$this->actingAs($user)->post('/admin/notes', [
'content' => 'A new test note',
]);
$this->assertDatabaseHas('notes', [
@ -41,19 +42,18 @@ class NotesTest extends TestCase
public function test_edit_page()
{
$response = $this->withSession([
'loggedin' => true,
])->get('/admin/notes/1/edit');
$user = factory(User::class)->create();
$response = $this->actingAs($user)->get('/admin/notes/1/edit');
$response->assertViewIs('admin.notes.edit');
}
public function test_edit_a_note()
{
Queue::fake();
$user = factory(User::class)->create();
$this->withSession([
'loggedin' => true,
])->post('/admin/notes/1', [
$this->actingAs($user)->post('/admin/notes/1', [
'_method' => 'PUT',
'content' => 'An edited note',
'webmentions' => true,
@ -67,9 +67,9 @@ class NotesTest extends TestCase
public function test_delete_note()
{
$this->withSession([
'loggedin' => true,
])->post('/admin/notes/1', [
$user = factory(User::class)->create();
$this->actingAs($user)->post('/admin/notes/1', [
'_method' => 'DELETE',
]);
$this->assertSoftDeleted('notes', [