Skip to content

Commit

Permalink
update all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bosun18 committed Feb 2, 2024
1 parent c1e62b4 commit 6e9500a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
6 changes: 2 additions & 4 deletions tests/Feature/LabelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ class LabelTest extends TestCase
{
private User $user;
private Label $label;
private string $name;
private string $nameUpdate;

public function setUp(): void
{
parent::setUp();
$this->user = User::factory()->create();
$this->label = Label::factory()->create();
$this->name = Label::factory()->make()->name;
$this->nameUpdate = Label::factory()->make()->name;
}

public function testIndex(): void
Expand All @@ -40,6 +36,7 @@ public function testCreate(): void

public function testStore(): void
{
$this->name = Label::factory()->make()->name;
$response = $this
->actingAs($this->user)
->post(route('labels.store'), [
Expand All @@ -62,6 +59,7 @@ public function testEdit(): void

public function testUpdate(): void
{
$this->nameUpdate = Label::factory()->make()->name;
$response = $this
->actingAs($this->user)
->patch(route('labels.update', ['label' => $this->label]), [
Expand Down
6 changes: 2 additions & 4 deletions tests/Feature/TaskStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ class TaskStatusTest extends TestCase
{
private User $user;
private TaskStatus $taskStatus;
private string $name;
private string $nameUpdate;

public function setUp(): void
{
parent::setUp();
$this->user = User::factory()->create();
$this->taskStatus = TaskStatus::factory()->create();
$this->name = TaskStatus::factory()->make()->name;
$this->nameUpdate = TaskStatus::factory()->make()->name;
}


Expand All @@ -40,6 +36,7 @@ public function testCreate(): void

public function testStore(): void
{
$this->name = TaskStatus::factory()->make()->name;
$response = $this
->actingAs($this->user)
->post(route('task_statuses.store'), [
Expand All @@ -62,6 +59,7 @@ public function testEdit(): void

public function testUpdate(): void
{
$this->nameUpdate = TaskStatus::factory()->make()->name;
$response = $this
->actingAs($this->user)
->patch(route('task_statuses.update', ['task_status' => $this->taskStatus]), [
Expand Down
29 changes: 12 additions & 17 deletions tests/Feature/TaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@

use Tests\TestCase;
use App\Models\User;
use App\Models\TaskStatus;
use App\Models\Task;

class TaskTest extends TestCase
{
private User $user;
private Task $task;
private array $newTaskData;
private array $taskDataForUpdate;

public function setUp(): void
{
Expand All @@ -22,20 +19,6 @@ public function setUp(): void
$this->task = Task::factory()->create([
'created_by_id' => $this->user->id,
]);

$this->newTaskData = Task::factory()->make()->only([
'name',
'description',
'status_id',
'assigned_to_id',
]);

$this->taskDataForUpdate = Task::factory()->make()->only([
'name',
'description',
'status_id',
'assigned_to_id',
]);
}

public function testIndex(): void
Expand All @@ -57,6 +40,12 @@ public function testCreate(): void
*/
public function testStore(): void
{
$this->newTaskData = Task::factory()->make()->only([
'name',
'description',
'status_id',
'assigned_to_id',
]);
$response = $this
->actingAs($this->user)
->post(route('tasks.store'), $this->newTaskData);
Expand Down Expand Up @@ -87,6 +76,12 @@ public function testEdit(): void
*/
public function testUpdate(): void
{
$this->taskDataForUpdate = Task::factory()->make()->only([
'name',
'description',
'status_id',
'assigned_to_id',
]);
$response = $this
->actingAs($this->user)
->patch(route('tasks.update', ['task' => $this->task]), $this->taskDataForUpdate);
Expand Down

0 comments on commit 6e9500a

Please sign in to comment.