post('posts'); $response->assertSessionHasErrors('title')->assertStatus(302); // Post with title should succeed $response = $this->post('posts', ['title' => 'Some title']); $response->assertStatus(200); // Post with the same title should fail because it's not unique $response = $this->post('posts', ['title' => 'Some title']); $response->assertSessionHasErrors('title')->assertStatus(302); } }