Implement board columns and project workflow settings
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Models;
|
||||
|
||||
use App\Models\BoardColumn;
|
||||
use App\Models\Project;
|
||||
use Database\Seeders\BoardColumnSeeder;
|
||||
use Database\Seeders\ProjectSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BoardColumnTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* Ensure the board column factory creates a position and related project.
|
||||
*/
|
||||
public function test_board_column_factory_creates_expected_defaults(): void
|
||||
{
|
||||
$boardColumn = BoardColumn::factory()->create();
|
||||
|
||||
$this->assertNotNull($boardColumn->project);
|
||||
$this->assertSame(1, $boardColumn->position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure projects expose board columns ordered by position.
|
||||
*/
|
||||
public function test_project_board_columns_are_returned_in_position_order(): void
|
||||
{
|
||||
$project = Project::factory()->create();
|
||||
|
||||
BoardColumn::factory()->for($project)->create([
|
||||
'name' => 'Done',
|
||||
'position' => 3,
|
||||
]);
|
||||
BoardColumn::factory()->for($project)->create([
|
||||
'name' => 'Todo',
|
||||
'position' => 1,
|
||||
]);
|
||||
BoardColumn::factory()->for($project)->create([
|
||||
'name' => 'In Progress',
|
||||
'position' => 2,
|
||||
]);
|
||||
|
||||
$this->assertSame(
|
||||
['Todo', 'In Progress', 'Done'],
|
||||
$project->fresh()->boardColumns->pluck('name')->all(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the board column seeder creates starter workflow columns for seeded projects.
|
||||
*/
|
||||
public function test_board_column_seeder_creates_default_columns_for_projects(): void
|
||||
{
|
||||
$this->seed([
|
||||
ProjectSeeder::class,
|
||||
BoardColumnSeeder::class,
|
||||
]);
|
||||
|
||||
$coreProject = Project::query()->where('key', 'CORE')->firstOrFail();
|
||||
|
||||
$this->assertDatabaseHas('board_columns', [
|
||||
'project_id' => $coreProject->id,
|
||||
'name' => 'Todo',
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('board_columns', [
|
||||
'project_id' => $coreProject->id,
|
||||
'name' => 'In Progress',
|
||||
'position' => 2,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('board_columns', [
|
||||
'project_id' => $coreProject->id,
|
||||
'name' => 'Done',
|
||||
'position' => 3,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user