Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
class PostTest extends TestCase { use RefreshDatabase; public function test_authenticated_user_can_create_post(): void { $user = User::factory()->create(); $this->actingAs($user) ->postJson("/api/posts", ["title" => "Hello", "body" => "World"]) ->assertCreated() ->assertJsonPath("data.title", "Hello"); $this->assertDatabaseHas("posts", ["title" => "Hello", "user_id" => $user->id]); } }
Result
Open