update plan create test

This commit is contained in:
2023-12-08 13:25:02 +03:00
parent 29c2adf109
commit 52b29346e3
2 changed files with 36 additions and 13 deletions

View File

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