From bbe27efb6d54b26dd33b977eb41bb004400f89f8 Mon Sep 17 00:00:00 2001 From: Anatoliy Poloz Date: Mon, 18 Dec 2023 12:56:49 +0300 Subject: [PATCH] Recipe/EditTest cos rewriting neede --- tests/Feature/Recipe/EditTest.php | 105 ------------------------------ 1 file changed, 105 deletions(-) delete mode 100644 tests/Feature/Recipe/EditTest.php diff --git a/tests/Feature/Recipe/EditTest.php b/tests/Feature/Recipe/EditTest.php deleted file mode 100644 index 8978f9c..0000000 --- a/tests/Feature/Recipe/EditTest.php +++ /dev/null @@ -1,105 +0,0 @@ -create(); - $recipe = Recipe::factory()->create([ - 'steps' => [], - 'ingredients' => [], - ]); - $tag1 = Tag::factory()->create(); - $tag2 = Tag::factory()->create(); - - $title = $faker->sentence(3); - $description = $faker->paragraph(2); - $cooking_time = $faker->numberBetween(10, 120); - $type = $faker->randomElement(['Main Dish', 'Dessert', 'Appetizer']); - $video_url = $faker->url; - $image = UploadedFile::fake()->image('new_image.jpg'); - $ingredients_names = [$faker->word, $faker->word, $faker->word]; - $ingredients_portions = [$faker->numberBetween(1, 500), $faker->numberBetween(1, 500), $faker->numberBetween(1, 500)]; - $ingredient_units = [$faker->randomElement(['gr', 'ml', 'pcs']), $faker->randomElement(['gr', 'ml', 'pcs']), $faker->randomElement(['gr', 'ml', 'pcs'])]; - - Livewire::actingAs($user) - ->test('recipe.edit', ['recipe' => $recipe]) - ->set('title', $title) - ->set('description', $description) - ->set('cooking_time', $cooking_time) - ->set('type', $type) - ->set('video_url', $video_url) - ->set('image', $image) - ->set('tags', [$tag1->id, $tag2->id]) - ->call('addIngredient') - ->set('ingredients_name.0', $ingredients_names[0]) - ->set('ingredients_portion.0', $ingredients_portions[0]) - ->set('ingredients_unit.0', $ingredient_units[0]) - ->call('addIngredient') - ->set('ingredients_name.1', $ingredients_names[1]) - ->set('ingredients_portion.1', $ingredients_portions[1]) - ->set('ingredients_unit.1', $ingredient_units[1]) - ->call('addIngredient') - ->set('ingredients_name.2', $ingredients_names[2]) - ->set('ingredients_portion.2', $ingredients_portions[2]) - ->set('ingredients_unit.2', $ingredient_units[2]) - ->call('addStep') - ->set('steps.0.description', $faker->paragraph) - ->set('steps.0.image', UploadedFile::fake()->image('new_step_image0.jpg')) - ->call('addStep') - ->set('steps.1.description', $faker->paragraph) - ->set('steps.1.image', UploadedFile::fake()->image('new_step_image1.jpg')) - ->call('addStep') - ->set('steps.2.description', $faker->paragraph) - ->set('steps.2.image', UploadedFile::fake()->image('new_step_image2.jpg')) - ->call('publish'); - - $this->assertDatabaseHas('recipes', [ - 'title' => $title, - 'description' => $description, - 'cooking_time' => $cooking_time, - 'type' => $type, - 'video_url' => $video_url, - 'image' => $image, - 'ingredients_name.0' => $ingredients_names[0], - 'ingredients_portion.0' => $ingredients_portions[0], - 'ingredients_unit.0' => $ingredient_units[0], - 'ingredients_name.1' => $ingredients_names[1], - 'ingredients_portion.1' => $ingredients_portions[1], - 'ingredients_unit.1' => $ingredient_units[1], - 'ingredients_name.2' => $ingredients_names[2], - 'ingredients_portion.2' => $ingredients_portions[2], - 'ingredients_unit.2' => $ingredient_units[2], - ]); - - $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_image0.jpg'); - Storage::disk('public')->assertExists('steps/new_step_image1.jpg'); - Storage::disk('public')->assertExists('steps/new_step_image2.jpg'); - } -}