Update Admin tests for new auth implementation
This commit is contained in:
parent
2e79492b01
commit
dad45c4ab1
8 changed files with 136 additions and 91 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Feature\Admin;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
|
@ -12,21 +13,27 @@ class ArticlesTest extends TestCase
|
|||
|
||||
public function test_index_page()
|
||||
{
|
||||
$response = $this->withSession(['loggedin' => true])
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->get('/admin/blog');
|
||||
$response->assertSeeText('Select article to edit:');
|
||||
}
|
||||
|
||||
public function test_create_page()
|
||||
{
|
||||
$response = $this->withSession(['loggedin' => true])
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->get('/admin/blog/create');
|
||||
$response->assertSeeText('Title (URL)');
|
||||
}
|
||||
|
||||
public function test_create_new_article()
|
||||
{
|
||||
$this->withSession(['loggedin' => true])
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post('/admin/blog', [
|
||||
'title' => 'Test Title',
|
||||
'main' => 'Article content'
|
||||
|
@ -36,6 +43,7 @@ class ArticlesTest extends TestCase
|
|||
|
||||
public function test_create_new_article_with_upload()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$faker = \Faker\Factory::create();
|
||||
$text = $faker->text;
|
||||
if ($fh = fopen(sys_get_temp_dir() . '/article.md', 'w')) {
|
||||
|
@ -45,7 +53,7 @@ class ArticlesTest extends TestCase
|
|||
$path = sys_get_temp_dir() . '/article.md';
|
||||
$file = new UploadedFile($path, 'article.md', 'text/plain', filesize($path), null, true);
|
||||
|
||||
$this->withSession(['loggedin' => true])
|
||||
$this->actingAs($user)
|
||||
->post('/admin/blog', [
|
||||
'title' => 'Uploaded Article',
|
||||
'article' => $file,
|
||||
|
@ -59,14 +67,18 @@ class ArticlesTest extends TestCase
|
|||
|
||||
public function test_see_edit_form()
|
||||
{
|
||||
$response = $this->withSession(['loggedin' => true])
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->get('/admin/blog/1/edit');
|
||||
$response->assertSeeText('This is *my* new blog. It uses `Markdown`.');
|
||||
}
|
||||
|
||||
public function test_edit_article()
|
||||
{
|
||||
$this->withSession(['loggedin' => true])
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post('/admin/blog/1', [
|
||||
'_method' => 'PUT',
|
||||
'title' => 'My New Blog',
|
||||
|
@ -80,7 +92,9 @@ class ArticlesTest extends TestCase
|
|||
|
||||
public function test_delete_article()
|
||||
{
|
||||
$this->withSession(['loggedin' => true])
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post('/admin/blog/1', [
|
||||
'_method' => 'DELETE',
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue