2024-04-23 14:23:21 +03:00
|
|
|
<?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);
|
|
|
|
|
2024-04-25 09:48:11 +03:00
|
|
|
$response->assertRedirect();
|
2024-04-23 14:23:21 +03:00
|
|
|
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
}
|