create(); $recipe = Recipe::factory()->create([ 'steps' => [], 'ingredients' => [], ]); $tag1 = Tag::factory()->create(); $tag2 = Tag::factory()->create(); Livewire::actingAs($user) ->test('recipe.edit', ['recipe' => $recipe]) ->set('title', 'New Title') ->set('description', 'New Description') ->set('cooking_time', '30') ->set('type', 'Main Dish') ->set('video_url', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ') ->set('image', UploadedFile::fake()->image('new_image.jpg')) ->set('tags', [$tag1->id, $tag2->id]) ->call('addIngredient') ->set('ingredients_name.0', 'New Ingredient') ->set('ingredients_portion.0', '100') ->call('addStep') ->set('steps.0.description', 'New Step Description') ->set('steps.0.image', UploadedFile::fake()->image('new_step_image.jpg')) ->call('publish'); $this->assertDatabaseHas('recipes', [ 'title' => 'New Title', 'description' => 'New Description', 'cooking_time' => 30, 'type' => 'Main Dish', 'video_url' => 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'image' => 'recipes/new_image.jpg', 'state' => 'active', ]); $this->assertDatabaseHas('tags', [ 'id' => $tag1->id, ]); $this->assertDatabaseHas('tags', [ 'id' => $tag2->id, ]); Storage::disk('public')->assertExists('recipes/new_image.jpg'); Storage::disk('public')->assertExists('steps/new_step_image.jpg'); } }