76 lines
1.9 KiB
PHP
76 lines
1.9 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Tests\Feature\admin;
|
||
|
|
||
|
use App\Models\Feedback;
|
||
|
use App\Models\FeedbackStatus;
|
||
|
use App\Models\News;
|
||
|
use App\Models\User;
|
||
|
use Illuminate\Http\UploadedFile;
|
||
|
use Tests\TestCase;
|
||
|
|
||
|
class FeedbackTest extends TestCase
|
||
|
{
|
||
|
private User $user;
|
||
|
private Feedback $feedback;
|
||
|
private array $data;
|
||
|
protected function setUp(): void
|
||
|
{
|
||
|
parent::setUp();
|
||
|
|
||
|
$this->feedbackStatus = FeedbackStatus::factory()->create();
|
||
|
$this->feedback = Feedback::factory()->create();
|
||
|
$this->data = Feedback::factory()->make()->only([
|
||
|
'contact',
|
||
|
'text',
|
||
|
'status_id',
|
||
|
]);
|
||
|
|
||
|
$this->user = User::factory()->create([
|
||
|
'name' => 'admin',
|
||
|
'email' => 'test@example.com',
|
||
|
'password' => 123456
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
public function testIndexFeedbacksPage(): void
|
||
|
{
|
||
|
$response = $this->actingAs($this->user)
|
||
|
->withSession(['banned' => false])
|
||
|
->get(route('feedback.index'));
|
||
|
|
||
|
$response->assertOk();
|
||
|
}
|
||
|
|
||
|
public function testStoreFeedback(): void
|
||
|
{
|
||
|
$response = $this->actingAs($this->user)
|
||
|
->withSession(['banned' => false])
|
||
|
->post(route('feedback.store'), $this->data);
|
||
|
|
||
|
$response->assertJson(["result" => "success"]);
|
||
|
|
||
|
$this->assertDatabaseHas('feedback', $this->data);
|
||
|
}
|
||
|
|
||
|
public function testEditFeedbackPage(): void
|
||
|
{
|
||
|
$response = $this->actingAs($this->user)
|
||
|
->withSession(['banned' => false])
|
||
|
->get(route('feedback.edit', $this->feedback));
|
||
|
|
||
|
$response->assertOk();
|
||
|
}
|
||
|
|
||
|
public function testUpdateFeedback(): void
|
||
|
{
|
||
|
$response = $this->actingAs($this->user)
|
||
|
->withSession(['banned' => false])
|
||
|
->patch(route('feedback.update', $this->feedback), $this->data);
|
||
|
|
||
|
$response->assertRedirect(route('feedback.index'));
|
||
|
|
||
|
$this->assertDatabaseHas('feedback', $this->data);
|
||
|
}
|
||
|
}
|