From 5375e06fb9baa37a99fc8f3efb06f050e8b9f448 Mon Sep 17 00:00:00 2001 From: Anatoliy Poloz Date: Thu, 21 Dec 2023 09:20:49 +0300 Subject: [PATCH 01/23] rectore auto-code-review added --- .gitea/workflows/test.yaml | 2 + composer.json | 2 + composer.lock | 92 +++++++++++++++++++++++++++++++++++++- rector.php | 29 ++++++++++++ 4 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 rector.php diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index a7fbed2..80105f8 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -62,6 +62,8 @@ jobs: - name: Run test run: vendor/bin/phpunit + - name: Code Rewiew + run: vendor/bin/rector process --dry-run #- name: Run Pint # run: vendor/bin/pint diff --git a/composer.json b/composer.json index 20adde8..f93c9ec 100644 --- a/composer.json +++ b/composer.json @@ -30,6 +30,7 @@ }, "require-dev": { "barryvdh/laravel-ide-helper": "^2.13", + "driftingly/rector-laravel": "^0.26.2", "fakerphp/faker": "^1.21", "larastan/larastan": "^2.7", "laravel/pint": "^1.13", @@ -39,6 +40,7 @@ "nunomaduro/phpinsights": "^2.11", "phpunit/phpunit": "^10.0", "psalm/phar": "^5.13", + "rector/rector": "^0.18.13", "spatie/laravel-ignition": "^2.0" }, "autoload": { diff --git a/composer.lock b/composer.lock index de1d128..3710b63 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cec18c9498d636695e0fcc9ba3d8ef15", + "content-hash": "71767f4485e6335b0a9d934fafcfad8e", "packages": [ { "name": "asantibanez/livewire-charts", @@ -10152,6 +10152,40 @@ }, "time": "2023-01-05T11:28:13+00:00" }, + { + "name": "driftingly/rector-laravel", + "version": "0.26.2", + "source": { + "type": "git", + "url": "https://github.com/driftingly/rector-laravel.git", + "reference": "cf6d0a7c8e2dc33b6e2bb8ccb4638f44a5c09671" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/cf6d0a7c8e2dc33b6e2bb8ccb4638f44a5c09671", + "reference": "cf6d0a7c8e2dc33b6e2bb8ccb4638f44a5c09671", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "rector-extension", + "autoload": { + "psr-4": { + "RectorLaravel\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Rector upgrades rules for Laravel Framework", + "support": { + "issues": "https://github.com/driftingly/rector-laravel/issues", + "source": "https://github.com/driftingly/rector-laravel/tree/0.26.2" + }, + "time": "2023-10-11T21:42:53+00:00" + }, { "name": "filp/whoops", "version": "2.15.4", @@ -12025,6 +12059,62 @@ }, "time": "2023-12-16T09:41:14+00:00" }, + { + "name": "rector/rector", + "version": "0.18.13", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "f8011a76d36aa4f839f60f3b4f97707d97176618" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/f8011a76d36aa4f839f60f3b4f97707d97176618", + "reference": "f8011a76d36aa4f839f60f3b4f97707d97176618", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.10.35" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/0.18.13" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2023-12-20T16:08:01+00:00" + }, { "name": "sebastian/cli-parser", "version": "2.0.0", diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..fdad3c1 --- /dev/null +++ b/rector.php @@ -0,0 +1,29 @@ +paths([ + __DIR__ . '/app', + __DIR__ . '/bootstrap', + __DIR__ . '/config', + __DIR__ . '/lang', + __DIR__ . '/public', + __DIR__ . '/resources', + __DIR__ . '/routes', + __DIR__ . '/tests', + ]); + +// $rectorConfig->import(SetList::CODING_STYLE); +// $rectorConfig->import(SetList::CODE_QUALITY); + $rectorConfig->import(SetList::DEAD_CODE); +// $rectorConfig->import(NetteSetList::NETTE_UTILS_CODE_QUALITY); +// $rectorConfig->import(LevelSetList::UP_TO_PHP_82); + $rectorConfig->import(LaravelSetList::LARAVEL_100); +}; + From ad2a02797470fcf27335c44885e212f8ffab0bda Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:34:42 +0300 Subject: [PATCH 02/23] added recipe factories --- database/factories/RecipeFactory.php | 85 ++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 database/factories/RecipeFactory.php diff --git a/database/factories/RecipeFactory.php b/database/factories/RecipeFactory.php new file mode 100644 index 0000000..bc17a8f --- /dev/null +++ b/database/factories/RecipeFactory.php @@ -0,0 +1,85 @@ + + */ +class RecipeFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + $faker = \Faker\Factory::create(); + $this->faker->addProvider(new Restaurant($faker)); + $this->faker->addProvider(new Youtube($faker)); + + return [ + 'title' => $this->faker->foodName(), + 'image' => $this->generateImageFile('recipes'), + 'state' => $this->faker->randomElement(['active', 'archived']), + 'cooking_time' => $this->faker->numberBetween(0, 59), + 'ingredients' => $this->createQuentityIngredients($this->faker->randomDigitNotNull()), // quentity - от 1 до 10 randomDigitNotNull + 'type' => $this->faker->randomElement(['first_meals', 'second_meals', 'salads', 'snacks', 'drinks', 'other']), + 'description' => $this->faker->text(), + 'steps' => $this->createQuentitySteps($this->faker->randomDigitNotNull()), + 'video_url' => $this->faker->youtubeRandomUri(), + ]; + } + + private function generateImageFile(string $name) + { + Storage::fake($name); + $file = UploadedFile::fake()->image($name . '.png'); + return $file->store($name, 'public'); + } + + private function generateIngredients(): array + { + return [ + 'name' => $this->faker->foodName(), + 'unit' => $this->faker->randomElement(['гр', 'ч. ложек', 'cт. ложек', 'мл', 'шт', 'зубчик', 'по вкусу']), + 'portion' => $this->faker->randomNumber(3, true), + ]; + } + + private function generateSteps(): array + { + return [ + 'image' => $this->generateImageFile('steps'), + 'description' => $this->faker->text(), + ]; + } + + private function createQuentitySteps($count) + { + $result = []; + + for ($i = 0; $i < $count; $i++) { + $result[] = $this->generateSteps(); + } + + return $result; + } + + private function createQuentityIngredients($count) + { + $result = []; + + for ($i = 0; $i < $count; $i++) { + $result[] = $this->generateIngredients(); + } + + return $result; + } +} From fba048f063461398a3c39b2607b9336081b8e468 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:35:16 +0300 Subject: [PATCH 03/23] added recipe seeder --- database/seeders/RecipeSeeder.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 database/seeders/RecipeSeeder.php diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php new file mode 100644 index 0000000..800b7df --- /dev/null +++ b/database/seeders/RecipeSeeder.php @@ -0,0 +1,17 @@ +count(10)->create(); + } +} From 206a7d873f8094a5e9392cb37b27bfb27107b0b4 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:35:28 +0300 Subject: [PATCH 04/23] added recipe author seeder --- database/seeders/RecipeAuthor.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 database/seeders/RecipeAuthor.php diff --git a/database/seeders/RecipeAuthor.php b/database/seeders/RecipeAuthor.php new file mode 100644 index 0000000..58c6319 --- /dev/null +++ b/database/seeders/RecipeAuthor.php @@ -0,0 +1,25 @@ + 0 && Recipe::count() > 0) { + Recipe::each(function ($recipe) { + User::inRandomOrder() + ->first() + ->author_of_recipe() + ->attach($recipe->id); + }); + } + } +} From 11f7bb21886ab51af5e57c3740f04c3dfea92177 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:48:25 +0300 Subject: [PATCH 05/23] added Recipe comment --- database/factories/RecipeCommentFactory.php | 26 +++++++++++++++ database/seeders/RecipeCommentSeeder.php | 37 +++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 database/factories/RecipeCommentFactory.php create mode 100644 database/seeders/RecipeCommentSeeder.php diff --git a/database/factories/RecipeCommentFactory.php b/database/factories/RecipeCommentFactory.php new file mode 100644 index 0000000..678f38a --- /dev/null +++ b/database/factories/RecipeCommentFactory.php @@ -0,0 +1,26 @@ + + */ +class RecipeCommentFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + + return [ + 'grade' => $this->faker->randomDigit(), + 'body' => $this->faker->text(), + ]; + + } +} diff --git a/database/seeders/RecipeCommentSeeder.php b/database/seeders/RecipeCommentSeeder.php new file mode 100644 index 0000000..3b24f5c --- /dev/null +++ b/database/seeders/RecipeCommentSeeder.php @@ -0,0 +1,37 @@ + 0 && Recipe::count() > 0) { + $comments = RecipeComment::factory()->count(5)->make(); + + $comments->each(function ($comment) { + $comment->author()->associate( + User::inRandomOrder() + ->first() + ->id + ); + + $comment->recipe()->associate( + Recipe::inRandomOrder() + ->first() + ->id + ); + + $comment->saveOrFail(); + }); + } + } +} From 659f519ff8396fb1d8a5a7e9b0d3d6ceaaf9df9e Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:48:44 +0300 Subject: [PATCH 06/23] added recipe seeders to database seeder --- database/seeders/DatabaseSeeder.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 4a70195..0fee10b 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -17,7 +17,9 @@ class DatabaseSeeder extends Seeder $this->call(UserSeeder::class); $this->call(PlanAuthor::class); $this->call(PlanCommentSeeder::class); - // $this->call(RecipeSeeder::class); + $this->call(RecipeSeeder::class); + $this->call(RecipeAuthor::class); + $this->call(RecipeCommentSeeder::class); // \App\Models\User::factory(10)->create(); } } From f09986efe4514413542424d2ace0eca0747c8562 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 15:01:03 +0300 Subject: [PATCH 07/23] recipe seeder and factories fix code style --- database/factories/RecipeCommentFactory.php | 4 ++-- database/factories/RecipeFactory.php | 6 ++++-- database/seeders/DatabaseSeeder.php | 10 +++------- database/seeders/RecipeAuthor.php | 4 +++- database/seeders/RecipeCommentSeeder.php | 4 +++- database/seeders/RecipeSeeder.php | 4 +++- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/database/factories/RecipeCommentFactory.php b/database/factories/RecipeCommentFactory.php index 678f38a..bea271f 100644 --- a/database/factories/RecipeCommentFactory.php +++ b/database/factories/RecipeCommentFactory.php @@ -1,5 +1,7 @@ $this->faker->randomDigit(), 'body' => $this->faker->text(), ]; - } } diff --git a/database/factories/RecipeFactory.php b/database/factories/RecipeFactory.php index bc17a8f..edf251e 100644 --- a/database/factories/RecipeFactory.php +++ b/database/factories/RecipeFactory.php @@ -1,5 +1,7 @@ generateSteps(); } @@ -76,7 +78,7 @@ class RecipeFactory extends Factory { $result = []; - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $result[] = $this->generateIngredients(); } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 0fee10b..b4935ee 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -1,17 +1,14 @@ call(PlanSeeder::class); $this->call(UserSeeder::class); @@ -20,6 +17,5 @@ class DatabaseSeeder extends Seeder $this->call(RecipeSeeder::class); $this->call(RecipeAuthor::class); $this->call(RecipeCommentSeeder::class); - // \App\Models\User::factory(10)->create(); } } diff --git a/database/seeders/RecipeAuthor.php b/database/seeders/RecipeAuthor.php index 58c6319..5381a41 100644 --- a/database/seeders/RecipeAuthor.php +++ b/database/seeders/RecipeAuthor.php @@ -1,5 +1,7 @@ 0 && Recipe::count() > 0) { - Recipe::each(function ($recipe) { + Recipe::each(static function ($recipe): void { User::inRandomOrder() ->first() ->author_of_recipe() diff --git a/database/seeders/RecipeCommentSeeder.php b/database/seeders/RecipeCommentSeeder.php index 3b24f5c..eb60093 100644 --- a/database/seeders/RecipeCommentSeeder.php +++ b/database/seeders/RecipeCommentSeeder.php @@ -1,5 +1,7 @@ 0 && Recipe::count() > 0) { $comments = RecipeComment::factory()->count(5)->make(); - $comments->each(function ($comment) { + $comments->each(static function ($comment): void { $comment->author()->associate( User::inRandomOrder() ->first() diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php index 800b7df..9c4588e 100644 --- a/database/seeders/RecipeSeeder.php +++ b/database/seeders/RecipeSeeder.php @@ -1,9 +1,11 @@ Date: Thu, 21 Dec 2023 17:16:05 +0300 Subject: [PATCH 08/23] added youtube url faker --- composer.json | 1 + composer.lock | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 20adde8..7f1ada7 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "license": "MIT", "require": { "php": "^8.0.2", + "aalaap/faker-youtube": "^2.0", "asantibanez/livewire-charts": "^3.0", "barryvdh/laravel-debugbar": "^3.6", "cyrildewit/eloquent-viewable": "^7.0", diff --git a/composer.lock b/composer.lock index de1d128..5015c72 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,57 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cec18c9498d636695e0fcc9ba3d8ef15", + "content-hash": "f1504229d84c399a1c8aea12005e3530", "packages": [ + { + "name": "aalaap/faker-youtube", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/aalaap/faker-youtube.git", + "reference": "eff2f96ee3f9a845d23140dd1721b14103b5c4d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aalaap/faker-youtube/zipball/eff2f96ee3f9a845d23140dd1721b14103b5c4d3", + "reference": "eff2f96ee3f9a845d23140dd1721b14103b5c4d3", + "shasum": "" + }, + "require": { + "fakerphp/faker": "^1.10", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.4.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Faker\\Provider\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "WTFPL" + ], + "authors": [ + { + "name": "Aalaap Ghag", + "email": "aalaap@gmail.com" + } + ], + "description": "Faker provider for generating fake YouTube video URLs", + "keywords": [ + "faker", + "provider", + "youtube" + ], + "support": { + "issues": "https://github.com/aalaap/faker-youtube/issues", + "source": "https://github.com/aalaap/faker-youtube/tree/2.0.3" + }, + "time": "2020-11-07T06:43:34+00:00" + }, { "name": "asantibanez/livewire-charts", "version": "v3.0.1", From 8173ca06b4be259f9cc2e34134d1cafa3ea7a78d Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 17:13:33 +0300 Subject: [PATCH 09/23] added create recipe test --- tests/Feature/Recipe/CreateTest.php | 200 ++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 tests/Feature/Recipe/CreateTest.php diff --git a/tests/Feature/Recipe/CreateTest.php b/tests/Feature/Recipe/CreateTest.php new file mode 100644 index 0000000..f2893fe --- /dev/null +++ b/tests/Feature/Recipe/CreateTest.php @@ -0,0 +1,200 @@ +image = UploadedFile::fake()->image('recipe.jpg'); + + $this->user = User::factory()->create(['is_consultant' => true]); + $this->recipe = Recipe::factory()->make(); + + $this->refreshApplicationWithLocale('en'); + } + + public function testShowFormCreateRecipe(): void + { + $response = $this + ->actingAs($this->user) + ->get(route('recipe.create')); + + $response->assertSuccessful(); + } + + public function testPublishNewRecipeSuccess(): void + { + $this->actingAs($this->user); + + self::assertEquals($this->recipe->count(), $count = Recipe::count()); + + Livewire::test(Create::class) + ->set('title', $this->recipe->title) + ->assertSet('title', $this->recipe->title) + ->set('image', $this->image) + ->set('state', $this->recipe->state) + ->assertSet('state', $this->recipe->state) + ->set('cooking_time', $this->recipe->cooking_time) + ->assertSet('cooking_time', $this->recipe->cooking_time) + ->set('ingredients', $this->recipe->ingredients) + ->assertSet('ingredients', $this->recipe->ingredients) + ->set('type', $this->recipe->type) + ->assertSet('type', $this->recipe->type) + ->set('description', $this->recipe->description) + ->assertSet('description', $this->recipe->description) + ->set('video_url', $this->recipe->video_url) + ->assertSet('video_url', $this->recipe->video_url) + ->call('publish') + ->assertSuccessful() + ->assertHasNoErrors(['title', 'image', 'state', 'cooking_time', 'ingredients', 'type', 'description', 'steps', 'video_url']); + + Storage::disk('public')->assertExists($this->recipe->image); + + self::assertEquals($count + 1, Recipe::count()); + } + + public function testToDraftNewRecipeSuccess(): void + { + $this->actingAs($this->user); + + self::assertEquals($this->recipe->count(), $count = Recipe::count()); + + Livewire::test(Create::class) + ->set('title', $this->recipe->title) + ->assertSet('title', $this->recipe->title) + ->set('image', $this->image) + ->set('state', $this->recipe->state) + ->assertSet('state', $this->recipe->state) + ->set('cooking_time', $this->recipe->cooking_time) + ->assertSet('cooking_time', $this->recipe->cooking_time) + ->set('ingredients', $this->recipe->ingredients) + ->assertSet('ingredients', $this->recipe->ingredients) + ->set('type', $this->recipe->type) + ->assertSet('type', $this->recipe->type) + ->set('description', $this->recipe->description) + ->assertSet('description', $this->recipe->description) + ->set('video_url', $this->recipe->video_url) + ->assertSet('video_url', $this->recipe->video_url) + ->call('draft') + ->assertSuccessful() + ->assertHasNoErrors(['title', 'image', 'state', 'cooking_time', 'ingredients', 'type', 'description', 'steps', 'video_url']); + + Storage::disk('public')->assertExists($this->recipe->image); + + self::assertEquals($count + 1, Recipe::count()); + + self::assertEquals(Recipe::find($count + 1)->state, 'archived'); + } + + public function testToPreviewNewRecipeSuccess(): void + { + $this->actingAs($this->user); + + self::assertEquals($this->recipe->count(), $count = Recipe::count()); + + Livewire::test(Create::class) + ->set('title', $this->recipe->title) + ->assertSet('title', $this->recipe->title) + ->set('image', $this->image) + ->set('state', $this->recipe->state) + ->assertSet('state', $this->recipe->state) + ->set('cooking_time', $this->recipe->cooking_time) + ->assertSet('cooking_time', $this->recipe->cooking_time) + ->set('ingredients', $this->recipe->ingredients) + ->assertSet('ingredients', $this->recipe->ingredients) + ->set('type', $this->recipe->type) + ->assertSet('type', $this->recipe->type) + ->set('description', $this->recipe->description) + ->assertSet('description', $this->recipe->description) + ->set('video_url', $this->recipe->video_url) + ->assertSet('video_url', $this->recipe->video_url) + ->call('preview') + ->assertSuccessful() + ->assertHasNoErrors(['title', 'image', 'state', 'cooking_time', 'ingredients', 'type', 'description', 'steps', 'video_url']); + + Storage::disk('public')->assertExists($this->recipe->image); + + self::assertEquals($count + 1, Recipe::count()); + + self::assertEquals(Recipe::find($count + 1)->state, 'archived'); + } + + public function testSetEmptyData(): void + { + $this->actingAs($this->user); + + self::assertEquals($this->recipe->count(), $count = Recipe::count()); + + Livewire::test(Create::class) + ->set('title', $this->recipe->title) + ->assertSet('title', $this->recipe->title) + ->set('image', null) + ->set('state', null) + ->set('cooking_time', null) + ->set('type', null) + ->set('description', null) + ->call('publish') + ->assertHasErrors(['image', 'state', 'type', 'description']); + + // doesnt to add to database + self::assertEquals($count, Recipe::count()); + } + + public function testIncorrectVideoUrl(): void + { + $this->actingAs($this->user); + + self::assertEquals($this->recipe->count(), $count = Recipe::count()); + + Livewire::test(Create::class) + ->set('title', $this->recipe->title) + ->assertSet('title', $this->recipe->title) + ->set('image', $this->image) + ->set('state', $this->recipe->state) + ->assertSet('state', $this->recipe->state) + ->set('cooking_time', $this->recipe->cooking_time) + ->assertSet('cooking_time', $this->recipe->cooking_time) + ->set('ingredients', $this->recipe->ingredients) + ->assertSet('ingredients', $this->recipe->ingredients) + ->set('type', $this->recipe->type) + ->assertSet('type', $this->recipe->type) + ->set('description', $this->recipe->description) + ->assertSet('description', $this->recipe->description) + ->set('video_url', 'video_url') + ->call('publish') + ->assertSuccessful() + ->assertHasErrors(['video_url']); + + // doesnt to add to database + self::assertEquals($count, Recipe::count()); + } +} From 4211e9bb967f69ea5dedaf037752fca836536544 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 17:19:51 +0300 Subject: [PATCH 10/23] fix protected to publis setUp --- tests/Feature/Recipe/CreateTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/Recipe/CreateTest.php b/tests/Feature/Recipe/CreateTest.php index f2893fe..93a0310 100644 --- a/tests/Feature/Recipe/CreateTest.php +++ b/tests/Feature/Recipe/CreateTest.php @@ -28,7 +28,7 @@ final class CreateTest extends TestCase private $steps; - protected function setUp(): void + public function setUp(): void { parent::setUp(); From cb2a64308f3d48f26b9e7a426249874dac02cb78 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 21:44:37 +0300 Subject: [PATCH 11/23] added recipe show test --- tests/Feature/Recipe/ShowTest.php | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/Feature/Recipe/ShowTest.php diff --git a/tests/Feature/Recipe/ShowTest.php b/tests/Feature/Recipe/ShowTest.php new file mode 100644 index 0000000..a640b21 --- /dev/null +++ b/tests/Feature/Recipe/ShowTest.php @@ -0,0 +1,35 @@ +user = User::factory()->create(['is_consultant' => true]); + $this->recipe = Recipe::inRandomOrder()->first(); + $this->refreshApplicationWithLocale('en'); + } + + public function test_show_form_success() + { + $response = $this->actingAs($this->user) + ->get(route('recipe.show', ['recipe' => $this->recipe->id])); + + $response + ->assertOk(); + } +} From 40dfb7158d133751e8b863f13117618f1ea10085 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 21:48:37 +0300 Subject: [PATCH 12/23] fix namespace show recipe test --- tests/Feature/Recipe/ShowTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Feature/Recipe/ShowTest.php b/tests/Feature/Recipe/ShowTest.php index a640b21..7e44036 100644 --- a/tests/Feature/Recipe/ShowTest.php +++ b/tests/Feature/Recipe/ShowTest.php @@ -1,6 +1,6 @@ Date: Fri, 22 Dec 2023 10:48:57 +0300 Subject: [PATCH 13/23] added index test recipe --- tests/Feature/Recipe/IndexTest.php | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/Feature/Recipe/IndexTest.php diff --git a/tests/Feature/Recipe/IndexTest.php b/tests/Feature/Recipe/IndexTest.php new file mode 100644 index 0000000..d4ea94a --- /dev/null +++ b/tests/Feature/Recipe/IndexTest.php @@ -0,0 +1,36 @@ +user = User::factory()->create(['is_consultant' => true]); + $this->recipe = Recipe::inRandomOrder()->first(); + $this->refreshApplicationWithLocale('en'); + } + + public function test_show_form_success() + { + $response = $this + ->actingAs($this->user) + ->get(route('recipe.index')); + + $response + ->assertOk(); + } +} From 157bf4238886fd01ed63a7623a179397ee5c0bff Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Fri, 22 Dec 2023 10:49:17 +0300 Subject: [PATCH 14/23] added edit form test recipe --- tests/Feature/Recipe/EditFormTest.php | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/Feature/Recipe/EditFormTest.php diff --git a/tests/Feature/Recipe/EditFormTest.php b/tests/Feature/Recipe/EditFormTest.php new file mode 100644 index 0000000..3975487 --- /dev/null +++ b/tests/Feature/Recipe/EditFormTest.php @@ -0,0 +1,43 @@ +user = User::factory()->create(['is_consultant' => true]); + + $this->recipe = Recipe::inRandomOrder()->first(); + + $this->refreshApplicationWithLocale('en'); + } + + public function testShowFormEditRecipe(): void + { + $response = $this + ->actingAs($this->user) + ->get(route('recipe.edit', ['recipe' => $this->recipe->id])); + + $response->assertSuccessful(); + } + +} From dd8e6c3166a963eb2750d5213b9b318562c57f82 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Fri, 22 Dec 2023 15:58:23 +0300 Subject: [PATCH 15/23] fix and correct tests --- tests/Feature/Plan/CreateTest.php | 4 +--- tests/Feature/Plan/ShowTest.php | 7 +++---- tests/Feature/Recipe/CreateTest.php | 16 +++++++--------- tests/Feature/Recipe/EditFormTest.php | 6 ++---- tests/Feature/Recipe/IndexTest.php | 5 ++--- tests/Feature/Recipe/ShowTest.php | 7 +++---- 6 files changed, 18 insertions(+), 27 deletions(-) diff --git a/tests/Feature/Plan/CreateTest.php b/tests/Feature/Plan/CreateTest.php index c96d2c1..34225b3 100644 --- a/tests/Feature/Plan/CreateTest.php +++ b/tests/Feature/Plan/CreateTest.php @@ -24,7 +24,7 @@ class CreateTest extends TestCase public function setUp(): void { - parent::setUp(); + $this->refreshApplicationWithLocale('en'); Storage::fake('plans'); $this->image = UploadedFile::fake()->image('plan.png'); @@ -32,7 +32,6 @@ class CreateTest extends TestCase $this->user = User::factory()->create(['is_consultant' => true]); $this->plan = Plan::factory()->make(); - $this->refreshApplicationWithLocale('en'); } public function test_show_form_create_plan() @@ -42,7 +41,6 @@ class CreateTest extends TestCase ->get(route('plan.create')); $response->assertSuccessful(); - // ->assertRedirect(route('home')); } public function test_publish_new_plan_success(): void diff --git a/tests/Feature/Plan/ShowTest.php b/tests/Feature/Plan/ShowTest.php index aa4cbb2..7c060d3 100644 --- a/tests/Feature/Plan/ShowTest.php +++ b/tests/Feature/Plan/ShowTest.php @@ -26,20 +26,19 @@ class ShowTest extends TestCase public function setUp(): void { - parent::setUp(); + $this->refreshApplicationWithLocale('en'); Storage::fake('plans'); $this->image = UploadedFile::fake()->image('plan.png'); $this->user = User::factory()->create(['is_consultant' => true]); $this->plan = Plan::inRandomOrder()->first(); - $this->refreshApplicationWithLocale('en'); } - public function test_show_form_success() + public function test_show_page_success() { $response = $this->actingAs($this->user) - ->get(route('plan.show', ['plan' => $this->plan->id])); + ->get(route('plan.show', $this->plan, false)); $response ->assertOk(); diff --git a/tests/Feature/Recipe/CreateTest.php b/tests/Feature/Recipe/CreateTest.php index 93a0310..5979aca 100644 --- a/tests/Feature/Recipe/CreateTest.php +++ b/tests/Feature/Recipe/CreateTest.php @@ -30,7 +30,7 @@ final class CreateTest extends TestCase public function setUp(): void { - parent::setUp(); + $this->refreshApplicationWithLocale('en'); Storage::fake('recipes'); @@ -38,11 +38,9 @@ final class CreateTest extends TestCase $this->user = User::factory()->create(['is_consultant' => true]); $this->recipe = Recipe::factory()->make(); - - $this->refreshApplicationWithLocale('en'); } - public function testShowFormCreateRecipe(): void + public function test_show_page_create_recipe(): void { $response = $this ->actingAs($this->user) @@ -51,7 +49,7 @@ final class CreateTest extends TestCase $response->assertSuccessful(); } - public function testPublishNewRecipeSuccess(): void + public function test_publish_new_recipe_success(): void { $this->actingAs($this->user); @@ -82,7 +80,7 @@ final class CreateTest extends TestCase self::assertEquals($count + 1, Recipe::count()); } - public function testToDraftNewRecipeSuccess(): void + public function test_to_draft_new_recipe_success(): void { $this->actingAs($this->user); @@ -115,7 +113,7 @@ final class CreateTest extends TestCase self::assertEquals(Recipe::find($count + 1)->state, 'archived'); } - public function testToPreviewNewRecipeSuccess(): void + public function test_to_preview_new_recipe_success(): void { $this->actingAs($this->user); @@ -148,7 +146,7 @@ final class CreateTest extends TestCase self::assertEquals(Recipe::find($count + 1)->state, 'archived'); } - public function testSetEmptyData(): void + public function test_set_empty_data(): void { $this->actingAs($this->user); @@ -169,7 +167,7 @@ final class CreateTest extends TestCase self::assertEquals($count, Recipe::count()); } - public function testIncorrectVideoUrl(): void + public function test_incorrect_video_url(): void { $this->actingAs($this->user); diff --git a/tests/Feature/Recipe/EditFormTest.php b/tests/Feature/Recipe/EditFormTest.php index 3975487..20c02b3 100644 --- a/tests/Feature/Recipe/EditFormTest.php +++ b/tests/Feature/Recipe/EditFormTest.php @@ -22,16 +22,14 @@ final class EditFormTest extends TestCase public function setUp(): void { - parent::setUp(); + $this->refreshApplicationWithLocale('en'); $this->user = User::factory()->create(['is_consultant' => true]); $this->recipe = Recipe::inRandomOrder()->first(); - - $this->refreshApplicationWithLocale('en'); } - public function testShowFormEditRecipe(): void + public function test_edit_page_recipe_success(): void { $response = $this ->actingAs($this->user) diff --git a/tests/Feature/Recipe/IndexTest.php b/tests/Feature/Recipe/IndexTest.php index d4ea94a..bc85a12 100644 --- a/tests/Feature/Recipe/IndexTest.php +++ b/tests/Feature/Recipe/IndexTest.php @@ -17,14 +17,13 @@ class IndexTest extends TestCase public function setUp(): void { - parent::setUp(); + $this->refreshApplicationWithLocale('en'); $this->user = User::factory()->create(['is_consultant' => true]); $this->recipe = Recipe::inRandomOrder()->first(); - $this->refreshApplicationWithLocale('en'); } - public function test_show_form_success() + public function test_index_page_success() { $response = $this ->actingAs($this->user) diff --git a/tests/Feature/Recipe/ShowTest.php b/tests/Feature/Recipe/ShowTest.php index 7e44036..6531298 100644 --- a/tests/Feature/Recipe/ShowTest.php +++ b/tests/Feature/Recipe/ShowTest.php @@ -17,17 +17,16 @@ class ShowTest extends TestCase public function setUp(): void { - parent::setUp(); + $this->refreshApplicationWithLocale('en'); $this->user = User::factory()->create(['is_consultant' => true]); $this->recipe = Recipe::inRandomOrder()->first(); - $this->refreshApplicationWithLocale('en'); } - public function test_show_form_success() + public function test_show_page_success() { $response = $this->actingAs($this->user) - ->get(route('recipe.show', ['recipe' => $this->recipe->id])); + ->get(route('recipe.show', $this->plan, false)); $response ->assertOk(); From 24c5cfdaacad0f724a91131a0db23b9a900ba87b Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 17:16:05 +0300 Subject: [PATCH 16/23] added youtube url faker --- composer.json | 1 + composer.lock | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 20adde8..7f1ada7 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "license": "MIT", "require": { "php": "^8.0.2", + "aalaap/faker-youtube": "^2.0", "asantibanez/livewire-charts": "^3.0", "barryvdh/laravel-debugbar": "^3.6", "cyrildewit/eloquent-viewable": "^7.0", diff --git a/composer.lock b/composer.lock index de1d128..5015c72 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,57 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cec18c9498d636695e0fcc9ba3d8ef15", + "content-hash": "f1504229d84c399a1c8aea12005e3530", "packages": [ + { + "name": "aalaap/faker-youtube", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/aalaap/faker-youtube.git", + "reference": "eff2f96ee3f9a845d23140dd1721b14103b5c4d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aalaap/faker-youtube/zipball/eff2f96ee3f9a845d23140dd1721b14103b5c4d3", + "reference": "eff2f96ee3f9a845d23140dd1721b14103b5c4d3", + "shasum": "" + }, + "require": { + "fakerphp/faker": "^1.10", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.4.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Faker\\Provider\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "WTFPL" + ], + "authors": [ + { + "name": "Aalaap Ghag", + "email": "aalaap@gmail.com" + } + ], + "description": "Faker provider for generating fake YouTube video URLs", + "keywords": [ + "faker", + "provider", + "youtube" + ], + "support": { + "issues": "https://github.com/aalaap/faker-youtube/issues", + "source": "https://github.com/aalaap/faker-youtube/tree/2.0.3" + }, + "time": "2020-11-07T06:43:34+00:00" + }, { "name": "asantibanez/livewire-charts", "version": "v3.0.1", From 1da207eb4f6c77ce7fc20652c757157fd982013f Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:34:42 +0300 Subject: [PATCH 17/23] added recipe factories --- database/factories/RecipeFactory.php | 85 ++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 database/factories/RecipeFactory.php diff --git a/database/factories/RecipeFactory.php b/database/factories/RecipeFactory.php new file mode 100644 index 0000000..bc17a8f --- /dev/null +++ b/database/factories/RecipeFactory.php @@ -0,0 +1,85 @@ + + */ +class RecipeFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + $faker = \Faker\Factory::create(); + $this->faker->addProvider(new Restaurant($faker)); + $this->faker->addProvider(new Youtube($faker)); + + return [ + 'title' => $this->faker->foodName(), + 'image' => $this->generateImageFile('recipes'), + 'state' => $this->faker->randomElement(['active', 'archived']), + 'cooking_time' => $this->faker->numberBetween(0, 59), + 'ingredients' => $this->createQuentityIngredients($this->faker->randomDigitNotNull()), // quentity - от 1 до 10 randomDigitNotNull + 'type' => $this->faker->randomElement(['first_meals', 'second_meals', 'salads', 'snacks', 'drinks', 'other']), + 'description' => $this->faker->text(), + 'steps' => $this->createQuentitySteps($this->faker->randomDigitNotNull()), + 'video_url' => $this->faker->youtubeRandomUri(), + ]; + } + + private function generateImageFile(string $name) + { + Storage::fake($name); + $file = UploadedFile::fake()->image($name . '.png'); + return $file->store($name, 'public'); + } + + private function generateIngredients(): array + { + return [ + 'name' => $this->faker->foodName(), + 'unit' => $this->faker->randomElement(['гр', 'ч. ложек', 'cт. ложек', 'мл', 'шт', 'зубчик', 'по вкусу']), + 'portion' => $this->faker->randomNumber(3, true), + ]; + } + + private function generateSteps(): array + { + return [ + 'image' => $this->generateImageFile('steps'), + 'description' => $this->faker->text(), + ]; + } + + private function createQuentitySteps($count) + { + $result = []; + + for ($i = 0; $i < $count; $i++) { + $result[] = $this->generateSteps(); + } + + return $result; + } + + private function createQuentityIngredients($count) + { + $result = []; + + for ($i = 0; $i < $count; $i++) { + $result[] = $this->generateIngredients(); + } + + return $result; + } +} From 15b4d45515c720fb29c03da9eb1e65893054043a Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:35:16 +0300 Subject: [PATCH 18/23] added recipe seeder --- database/seeders/RecipeSeeder.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 database/seeders/RecipeSeeder.php diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php new file mode 100644 index 0000000..800b7df --- /dev/null +++ b/database/seeders/RecipeSeeder.php @@ -0,0 +1,17 @@ +count(10)->create(); + } +} From ae0e76589c74ea085a7f82ce54a37832df5535a3 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:35:28 +0300 Subject: [PATCH 19/23] added recipe author seeder --- database/seeders/RecipeAuthor.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 database/seeders/RecipeAuthor.php diff --git a/database/seeders/RecipeAuthor.php b/database/seeders/RecipeAuthor.php new file mode 100644 index 0000000..58c6319 --- /dev/null +++ b/database/seeders/RecipeAuthor.php @@ -0,0 +1,25 @@ + 0 && Recipe::count() > 0) { + Recipe::each(function ($recipe) { + User::inRandomOrder() + ->first() + ->author_of_recipe() + ->attach($recipe->id); + }); + } + } +} From 182cfeb4b9396aec61843989a6da7ae704614c5d Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:48:25 +0300 Subject: [PATCH 20/23] added Recipe comment --- database/factories/RecipeCommentFactory.php | 26 +++++++++++++++ database/seeders/RecipeCommentSeeder.php | 37 +++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 database/factories/RecipeCommentFactory.php create mode 100644 database/seeders/RecipeCommentSeeder.php diff --git a/database/factories/RecipeCommentFactory.php b/database/factories/RecipeCommentFactory.php new file mode 100644 index 0000000..678f38a --- /dev/null +++ b/database/factories/RecipeCommentFactory.php @@ -0,0 +1,26 @@ + + */ +class RecipeCommentFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + + return [ + 'grade' => $this->faker->randomDigit(), + 'body' => $this->faker->text(), + ]; + + } +} diff --git a/database/seeders/RecipeCommentSeeder.php b/database/seeders/RecipeCommentSeeder.php new file mode 100644 index 0000000..3b24f5c --- /dev/null +++ b/database/seeders/RecipeCommentSeeder.php @@ -0,0 +1,37 @@ + 0 && Recipe::count() > 0) { + $comments = RecipeComment::factory()->count(5)->make(); + + $comments->each(function ($comment) { + $comment->author()->associate( + User::inRandomOrder() + ->first() + ->id + ); + + $comment->recipe()->associate( + Recipe::inRandomOrder() + ->first() + ->id + ); + + $comment->saveOrFail(); + }); + } + } +} From abd3b72e2ea7a40db187836bf366f1a799de9001 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 14:48:44 +0300 Subject: [PATCH 21/23] added recipe seeders to database seeder --- database/seeders/DatabaseSeeder.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 4a70195..0fee10b 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -17,7 +17,9 @@ class DatabaseSeeder extends Seeder $this->call(UserSeeder::class); $this->call(PlanAuthor::class); $this->call(PlanCommentSeeder::class); - // $this->call(RecipeSeeder::class); + $this->call(RecipeSeeder::class); + $this->call(RecipeAuthor::class); + $this->call(RecipeCommentSeeder::class); // \App\Models\User::factory(10)->create(); } } From 4e02272d2c285392f84eb34c6fc2ef55dd16dc15 Mon Sep 17 00:00:00 2001 From: alex-chevski Date: Thu, 21 Dec 2023 15:01:03 +0300 Subject: [PATCH 22/23] recipe seeder and factories fix code style --- database/factories/RecipeCommentFactory.php | 4 ++-- database/factories/RecipeFactory.php | 6 ++++-- database/seeders/DatabaseSeeder.php | 10 +++------- database/seeders/RecipeAuthor.php | 4 +++- database/seeders/RecipeCommentSeeder.php | 4 +++- database/seeders/RecipeSeeder.php | 4 +++- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/database/factories/RecipeCommentFactory.php b/database/factories/RecipeCommentFactory.php index 678f38a..bea271f 100644 --- a/database/factories/RecipeCommentFactory.php +++ b/database/factories/RecipeCommentFactory.php @@ -1,5 +1,7 @@ $this->faker->randomDigit(), 'body' => $this->faker->text(), ]; - } } diff --git a/database/factories/RecipeFactory.php b/database/factories/RecipeFactory.php index bc17a8f..edf251e 100644 --- a/database/factories/RecipeFactory.php +++ b/database/factories/RecipeFactory.php @@ -1,5 +1,7 @@ generateSteps(); } @@ -76,7 +78,7 @@ class RecipeFactory extends Factory { $result = []; - for ($i = 0; $i < $count; $i++) { + for ($i = 0; $i < $count; ++$i) { $result[] = $this->generateIngredients(); } diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 0fee10b..b4935ee 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -1,17 +1,14 @@ call(PlanSeeder::class); $this->call(UserSeeder::class); @@ -20,6 +17,5 @@ class DatabaseSeeder extends Seeder $this->call(RecipeSeeder::class); $this->call(RecipeAuthor::class); $this->call(RecipeCommentSeeder::class); - // \App\Models\User::factory(10)->create(); } } diff --git a/database/seeders/RecipeAuthor.php b/database/seeders/RecipeAuthor.php index 58c6319..5381a41 100644 --- a/database/seeders/RecipeAuthor.php +++ b/database/seeders/RecipeAuthor.php @@ -1,5 +1,7 @@ 0 && Recipe::count() > 0) { - Recipe::each(function ($recipe) { + Recipe::each(static function ($recipe): void { User::inRandomOrder() ->first() ->author_of_recipe() diff --git a/database/seeders/RecipeCommentSeeder.php b/database/seeders/RecipeCommentSeeder.php index 3b24f5c..eb60093 100644 --- a/database/seeders/RecipeCommentSeeder.php +++ b/database/seeders/RecipeCommentSeeder.php @@ -1,5 +1,7 @@ 0 && Recipe::count() > 0) { $comments = RecipeComment::factory()->count(5)->make(); - $comments->each(function ($comment) { + $comments->each(static function ($comment): void { $comment->author()->associate( User::inRandomOrder() ->first() diff --git a/database/seeders/RecipeSeeder.php b/database/seeders/RecipeSeeder.php index 800b7df..9c4588e 100644 --- a/database/seeders/RecipeSeeder.php +++ b/database/seeders/RecipeSeeder.php @@ -1,9 +1,11 @@ Date: Fri, 22 Dec 2023 16:47:55 +0300 Subject: [PATCH 23/23] fixed route tests recipe --- tests/Feature/Recipe/EditFormTest.php | 2 +- tests/Feature/Recipe/ShowTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Feature/Recipe/EditFormTest.php b/tests/Feature/Recipe/EditFormTest.php index 20c02b3..67bbb9e 100644 --- a/tests/Feature/Recipe/EditFormTest.php +++ b/tests/Feature/Recipe/EditFormTest.php @@ -33,7 +33,7 @@ final class EditFormTest extends TestCase { $response = $this ->actingAs($this->user) - ->get(route('recipe.edit', ['recipe' => $this->recipe->id])); + ->get(route('recipe.edit', $this->recipe, false)); $response->assertSuccessful(); } diff --git a/tests/Feature/Recipe/ShowTest.php b/tests/Feature/Recipe/ShowTest.php index 6531298..a29cec0 100644 --- a/tests/Feature/Recipe/ShowTest.php +++ b/tests/Feature/Recipe/ShowTest.php @@ -26,7 +26,7 @@ class ShowTest extends TestCase public function test_show_page_success() { $response = $this->actingAs($this->user) - ->get(route('recipe.show', $this->plan, false)); + ->get(route('recipe.show', $this->recipe, false)); $response ->assertOk();