forked from eatvio/eatvio-infra
update plan create test
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use FakerRestaurant\Provider\en_US\Restaurant;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
@@ -34,10 +36,12 @@ class PlanFactory extends Factory
|
||||
'description' => $this->faker->text(),
|
||||
];
|
||||
|
||||
Storage::fake('plans');
|
||||
|
||||
return [
|
||||
'name' => $this->faker->foodName(),
|
||||
// 'image' => $this->faker->image('application/storage/fake_images', 640, 480, null, false),
|
||||
'image' => storage_path('public/img/Photo_C.png'),
|
||||
// 'image' => UploadedFile::fake()->image('plans/Photo_C.png'),
|
||||
'image' => UploadedFile::fake()->image('plan.png'),
|
||||
'duration' => $this->faker->randomElement([7, 14,21]),
|
||||
'state' => $this->faker->randomElement(['active', 'draft', 'archived']),
|
||||
'type' => $typeBody,
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Plan;
|
||||
// use Livewire\WithFileUploads;
|
||||
use Livewire\Livewire;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
// use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
@@ -23,18 +25,23 @@ class CreateTest extends TestCase
|
||||
->get('/plan/create');
|
||||
|
||||
$response
|
||||
->assertOk();
|
||||
->assertStatus(302)
|
||||
->assertRedirect('https://dev2.eatvio.com/ru');
|
||||
}
|
||||
|
||||
public function test_publish_new_plan_success(): void
|
||||
{
|
||||
$plan = Plan::factory()->make();
|
||||
$user = User::factory()->create();
|
||||
$user = User::factory()->create(['is_consultant' => true]);
|
||||
|
||||
$count = $plan->count();
|
||||
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
Livewire::test(Create::class)
|
||||
->set('name', $plan->name)
|
||||
->assertSet('name', $plan->name)
|
||||
->set('image', $plan->image)
|
||||
->set('duration', $plan->duration)
|
||||
->set('state', $plan->state)
|
||||
@@ -45,18 +52,24 @@ class CreateTest extends TestCase
|
||||
->set('packet2_options', $plan->packet2_options)
|
||||
->set('packet3_options', $plan->packet3_options)
|
||||
->call('publish')
|
||||
->assertRedirect('/plan/'. $plan->id);
|
||||
}
|
||||
// ->assertFileDownloaded('plan.png');
|
||||
->assertStatus(200)
|
||||
->assertRedirect('plan/'.$plan->count());
|
||||
|
||||
|
||||
$this->assertEquals($plan->count(), $count + 1);
|
||||
}
|
||||
//
|
||||
public function test_to_draft_new_plan_success(): void
|
||||
{
|
||||
$plan = Plan::factory()->make();
|
||||
$user = User::factory()->create();
|
||||
|
||||
//
|
||||
$this->actingAs($user);
|
||||
|
||||
//
|
||||
Livewire::test(Create::class)
|
||||
->set('name', $plan->name)
|
||||
->assertSet('name', $plan->name)
|
||||
->set('image', $plan->image)
|
||||
->set('duration', $plan->duration)
|
||||
->set('state', $plan->state)
|
||||
@@ -67,18 +80,20 @@ class CreateTest extends TestCase
|
||||
->set('packet2_options', $plan->packet2_options)
|
||||
->set('packet3_options', $plan->packet3_options)
|
||||
->call('addToDrafts')
|
||||
->assertRedirect('/plan/'. $plan->id);
|
||||
->assertStatus(200)
|
||||
->assertRedirect('plan/'.$plan->count());
|
||||
}
|
||||
|
||||
//
|
||||
public function test_to_preview_new_plan_success(): void
|
||||
{
|
||||
$plan = Plan::factory()->make();
|
||||
$user = User::factory()->create();
|
||||
|
||||
//
|
||||
$this->actingAs($user);
|
||||
|
||||
//
|
||||
Livewire::test(Create::class)
|
||||
->set('name', $plan->name)
|
||||
->assertSet('name', $plan->name)
|
||||
->set('image', $plan->image)
|
||||
->set('duration', $plan->duration)
|
||||
->set('state', $plan->state)
|
||||
@@ -89,6 +104,10 @@ class CreateTest extends TestCase
|
||||
->set('packet2_options', $plan->packet2_options)
|
||||
->set('packet3_options', $plan->packet3_options)
|
||||
->call('addToDrafts')
|
||||
->assertRedirect('/plan/'. $plan->id);
|
||||
->assertStatus(200)
|
||||
->assertRedirect('plan/'.$plan->count());
|
||||
|
||||
|
||||
// ->assertRedirect('/plan/'. $plan->id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user