<?php
declare(strict_types=1);
$migration = file_get_contents(dirname(__DIR__) . '/migrations/004_employee_profiles.sql');
$service = file_get_contents(dirname(__DIR__) . '/src/EmployeeProfileService.php');
$assignments = file_get_contents(dirname(__DIR__) . '/src/MasterDataService.php');
assert(is_string($migration) && is_string($service) && is_string($assignments));
foreach ([
'CREATE TABLE IF NOT EXISTS employee_profiles',
'user_id CHAR(36) NULL',
'employee_number VARCHAR(100) NOT NULL',
'row_version INT NOT NULL DEFAULT 1',
'deleted_at DATETIME NULL',
'FOREIGN KEY (tenant_id, user_id) REFERENCES tenant_memberships(tenant_id, user_id)',
'FOREIGN KEY (tenant_id, employee_id) REFERENCES employee_profiles(tenant_id, id)',
] as $requiredSchema) {
assert(str_contains($migration, $requiredSchema));
}
assert(str_contains($service, 'tenant_id = ? AND deleted_at IS NULL'));
assert(str_contains($service, 'WHERE id = ? AND tenant_id = ? AND deleted_at IS NULL'));
assert(str_contains($service, 'WHERE tenant_id = ? AND user_id = ?'));
assert(str_contains($assignments, 'EmployeeProfilePolicy::assertAssignable'));
fwrite(STDOUT, "employee_profiles_schema_contract: OK\n");
