Merge pull request 'Added Seeders factories and tests' (#27) from alex_chevski/eatvio:recipe-tests into main

Reviewed-on: eatvio/eatvio#27
This commit is contained in:
apoloz
2023-12-22 13:50:24 +00:00
6 changed files with 19 additions and 28 deletions

View File

@@ -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

View File

@@ -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();

View File

@@ -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);

View File

@@ -22,20 +22,18 @@ 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)
->get(route('recipe.edit', ['recipe' => $this->recipe->id]));
->get(route('recipe.edit', $this->recipe, false));
$response->assertSuccessful();
}

View File

@@ -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)

View File

@@ -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->recipe, false));
$response
->assertOk();