create(); $posts = Post::factory(5)->create(); $response = $this->actingAs($user) ->getJson('/api/posts'); $response->assertStatus(200) ->assertJsonStructure([ 'posts' => [ '*' => [ 'id', 'title', 'summary', 'author', ], ], 'pagination', ]); } public function test_author_can_create_post(): void { $user = User::factory()->create(['role' => 'author']); $response = $this->actingAs($user) ->postJson('/api/posts', [ 'title' => 'Test Post', 'content' => 'Test Content', 'summary' => 'Test Summary', ]); $response->assertStatus(200) ->assertJson([ 'message' => 'Post created successfully', ]); $this->assertDatabaseHas('posts', [ 'title' => 'Test Post', 'author_id' => $user->id, ]); } }