A common challenge in testing is not only HOW to test something, but WHAT you can test. All test examples focus on testing concepts and can be applied to all testing frameworks.
it('stores a product', function () { $this->actingAs(User::factory()->create()) ->post('product', [ 'title' => 'Product name', 'description' => 'Product description', ])->assertSuccessful(); $this->assertDatabaseCount(Product::class, 1); $this->assertDatabaseHas(Product::class, [ 'title' => 'Product name', 'description' => 'Product description', ]); }); The example ensures that a product is created and stored in the database for our post route.
it('imports product', function() { Http::fake([ 'https://christoph-rumpel.com/import' => Http::response([ 'title' => 'My new product', 'description' => 'This is a description', ]), ]); $user = User::factory()->create(); (new ImportProductAction)->handle($user); $this->assertDatabaseHas(Product::class, [ 'title' => 'My new product', 'description' => 'This is a description', ]); }); Testing HTTP Calls