- Add AllocationController with CRUD + bulk endpoints - Add AllocationValidationService for capacity/estimate validation - Add AllocationMatrixService for optimized matrix queries - Add AllocationPolicy for authorization - Add AllocationResource for API responses - Add frontend allocationService and matrix UI - Add E2E tests for allocation matrix (20 tests) - Add unit tests for validation service and policies - Fix month format conversion (YYYY-MM to YYYY-MM-01)
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Models\Allocation;
|
|
use App\Models\Project;
|
|
use App\Models\Role;
|
|
use App\Models\TeamMember;
|
|
use App\Services\AllocationMatrixService;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class AllocationCacheInvalidationTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
// 5.1.19 Unit test: Cache invalidation on mutation
|
|
public function test_matrix_service_returns_structure()
|
|
{
|
|
$role = Role::factory()->create();
|
|
$teamMember = TeamMember::factory()->create(['role_id' => $role->id]);
|
|
$project = Project::factory()->create();
|
|
|
|
Allocation::factory()->create([
|
|
'project_id' => $project->id,
|
|
'team_member_id' => $teamMember->id,
|
|
'month' => '2026-02',
|
|
'allocated_hours' => 40,
|
|
]);
|
|
|
|
$matrixService = new AllocationMatrixService;
|
|
$result = $matrixService->getMatrix('2026-02');
|
|
|
|
$this->assertArrayHasKey('allocations', $result);
|
|
$this->assertArrayHasKey('projectTotals', $result);
|
|
$this->assertArrayHasKey('teamMemberTotals', $result);
|
|
$this->assertArrayHasKey('grandTotal', $result);
|
|
}
|
|
}
|