forked from eatvio/eatvio-infra
added feature test plan
This commit is contained in:
94
tests/Plan/CreateTest.php
Normal file
94
tests/Plan/CreateTest.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Plan;
|
||||
use Livewire\Livewire;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
// use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use App\Models\Plan;
|
||||
use App\Models\User;
|
||||
use App\Livewire\Plan\Create;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CreateTest extends TestCase
|
||||
{
|
||||
// use RefreshDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_show_form_create_plan()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)
|
||||
->get('/plan/create');
|
||||
|
||||
$response
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
public function test_publish_new_plan_success(): void
|
||||
{
|
||||
$plan = Plan::factory()->make();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
Livewire::test(Create::class)
|
||||
->set('name', $plan->name)
|
||||
->set('image', $plan->image)
|
||||
->set('duration', $plan->duration)
|
||||
->set('state', $plan->state)
|
||||
->set('type', $plan->type)
|
||||
->set('details', $plan->details)
|
||||
->set('packets_count', $plan->packets_count)
|
||||
->set('packet1_options', $plan->packet1_options)
|
||||
->set('packet2_options', $plan->packet2_options)
|
||||
->set('packet3_options', $plan->packet3_options)
|
||||
->call('publish')
|
||||
->assertRedirect('/plan/'. $plan->id);
|
||||
}
|
||||
|
||||
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)
|
||||
->set('image', $plan->image)
|
||||
->set('duration', $plan->duration)
|
||||
->set('state', $plan->state)
|
||||
->set('type', $plan->type)
|
||||
->set('details', $plan->details)
|
||||
->set('packets_count', $plan->packets_count)
|
||||
->set('packet1_options', $plan->packet1_options)
|
||||
->set('packet2_options', $plan->packet2_options)
|
||||
->set('packet3_options', $plan->packet3_options)
|
||||
->call('addToDrafts')
|
||||
->assertRedirect('/plan/'. $plan->id);
|
||||
}
|
||||
|
||||
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)
|
||||
->set('image', $plan->image)
|
||||
->set('duration', $plan->duration)
|
||||
->set('state', $plan->state)
|
||||
->set('type', $plan->type)
|
||||
->set('details', $plan->details)
|
||||
->set('packets_count', $plan->packets_count)
|
||||
->set('packet1_options', $plan->packet1_options)
|
||||
->set('packet2_options', $plan->packet2_options)
|
||||
->set('packet3_options', $plan->packet3_options)
|
||||
->call('addToDrafts')
|
||||
->assertRedirect('/plan/'. $plan->id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user