forked from eatvio/eatvio-infra
added Test for show page
This commit is contained in:
60
tests/Feature/Plan/ShowTest.php
Normal file
60
tests/Feature/Plan/ShowTest.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Plan;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
// use Livewire\WithFileUploads;
|
||||
use Livewire\Livewire;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
|
||||
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 ShowTest extends TestCase
|
||||
{
|
||||
// use RefreshDatabase;
|
||||
use RefreshDatabase;
|
||||
|
||||
private $image;
|
||||
private $plan;
|
||||
protected User $user;
|
||||
|
||||
public function setUp():void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Storage::fake('plans');
|
||||
$this->image = UploadedFile::fake()->image('plan.png');
|
||||
|
||||
$this->user = User::factory()->create(['is_consultant' => true]);
|
||||
$this->plan = Plan::factory()->create();
|
||||
|
||||
}
|
||||
|
||||
public function test_show_form_success()
|
||||
{
|
||||
$response = $this->actingAs($this->user)
|
||||
->get('/plan/'. $this->plan->id);
|
||||
|
||||
$response
|
||||
->assertStatus(302)
|
||||
->assertRedirect('https://dev2.eatvio.com/ru');
|
||||
}
|
||||
|
||||
// When appear role for user
|
||||
// public function test_show_form_is_not_consultant()
|
||||
// {
|
||||
// $user = User::factory()->create(['is_consultant' => false]);
|
||||
|
||||
// $response = $this->actingAs($this->user)
|
||||
// ->get('/plan/'. $this->plan->id);
|
||||
|
||||
// $response
|
||||
// ->assertStatus(403);
|
||||
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user