feat(cms): sync site assets, revalidate webhook, and document download naming
This commit is contained in:
55
tests/Feature/Cms/AdminCmsAccessTest.php
Normal file
55
tests/Feature/Cms/AdminCmsAccessTest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Cms;
|
||||
|
||||
use App\Models\User;
|
||||
use Database\Seeders\FinancialWorkflowPermissionsSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminCmsAccessTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->artisan('db:seed', ['--class' => FinancialWorkflowPermissionsSeeder::class]);
|
||||
}
|
||||
|
||||
public function test_user_without_permissions_cannot_access_admin_articles(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->get('/admin/articles')
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function test_secretary_general_can_access_admin_articles_and_create_draft(): void
|
||||
{
|
||||
$role = Role::where('name', 'secretary_general')->firstOrFail();
|
||||
$user = User::factory()->create();
|
||||
$user->assignRole($role);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get('/admin/articles')
|
||||
->assertOk();
|
||||
|
||||
$res = $this->actingAs($user)->post('/admin/articles', [
|
||||
'title' => 'Test Article',
|
||||
'content' => 'Hello world',
|
||||
'content_type' => 'blog',
|
||||
'access_level' => 'public',
|
||||
'save_action' => 'draft',
|
||||
]);
|
||||
|
||||
$res->assertRedirect();
|
||||
$this->assertDatabaseHas('articles', [
|
||||
'title' => 'Test Article',
|
||||
'status' => 'draft',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user