91 lines
2.3 KiB
PHP
91 lines
2.3 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Feature\Admin;
|
||
|
|
|
||
|
|
use App\Models\CustomPostType;
|
||
|
|
use App\Models\Page;
|
||
|
|
use App\Models\Post;
|
||
|
|
use App\Models\User;
|
||
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||
|
|
use Tests\TestCase;
|
||
|
|
|
||
|
|
class ContentEditorLoadingTest extends TestCase
|
||
|
|
{
|
||
|
|
use RefreshDatabase;
|
||
|
|
|
||
|
|
protected $admin;
|
||
|
|
|
||
|
|
protected function setUp(): void
|
||
|
|
{
|
||
|
|
parent::setUp();
|
||
|
|
|
||
|
|
$this->withoutVite();
|
||
|
|
|
||
|
|
$this->admin = User::factory()->create();
|
||
|
|
$adminRole = \App\Models\Role::firstOrCreate(['slug' => 'admin', 'name' => 'Administrator']);
|
||
|
|
$this->admin->roles()->attach($adminRole);
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @test */
|
||
|
|
public function it_can_load_the_page_create_view()
|
||
|
|
{
|
||
|
|
$response = $this->actingAs($this->admin)
|
||
|
|
->get(route('admin.pages.create'));
|
||
|
|
|
||
|
|
$response->assertStatus(200);
|
||
|
|
$response->assertViewHas('a11yIssues');
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @test */
|
||
|
|
public function it_can_load_the_page_edit_view()
|
||
|
|
{
|
||
|
|
$page = Page::factory()->create();
|
||
|
|
|
||
|
|
$response = $this->actingAs($this->admin)
|
||
|
|
->get(route('admin.pages.edit', $page));
|
||
|
|
|
||
|
|
$response->assertStatus(200);
|
||
|
|
$response->assertViewHas('a11yIssues');
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @test */
|
||
|
|
public function it_can_load_the_post_create_view()
|
||
|
|
{
|
||
|
|
$cpt = new CustomPostType();
|
||
|
|
$cpt->name = 'News';
|
||
|
|
$cpt->singular_name = 'News Item';
|
||
|
|
$cpt->slug = 'news';
|
||
|
|
$cpt->save();
|
||
|
|
|
||
|
|
$response = $this->actingAs($this->admin)
|
||
|
|
->get(route('admin.posts.create', $cpt));
|
||
|
|
|
||
|
|
$response->assertStatus(200);
|
||
|
|
$response->assertViewHas('a11yIssues');
|
||
|
|
}
|
||
|
|
|
||
|
|
/** @test */
|
||
|
|
public function it_can_load_the_post_edit_view()
|
||
|
|
{
|
||
|
|
$cpt = new CustomPostType();
|
||
|
|
$cpt->name = 'News';
|
||
|
|
$cpt->singular_name = 'News Item';
|
||
|
|
$cpt->slug = 'news';
|
||
|
|
$cpt->save();
|
||
|
|
|
||
|
|
$post = new Post();
|
||
|
|
$post->custom_post_type_id = $cpt->id;
|
||
|
|
$post->user_id = $this->admin->id;
|
||
|
|
$post->title = 'Test Post';
|
||
|
|
$post->slug = 'test-post';
|
||
|
|
$post->content = [];
|
||
|
|
$post->save();
|
||
|
|
|
||
|
|
$response = $this->actingAs($this->admin)
|
||
|
|
->get(route('admin.posts.edit', [$cpt, $post]));
|
||
|
|
|
||
|
|
$response->assertStatus(200);
|
||
|
|
$response->assertViewHas('a11yIssues');
|
||
|
|
}
|
||
|
|
}
|