<?php
declare(strict_types=1);
use Machweis\Backend\IndustryProfileCatalog;
require dirname(__DIR__) . '/src/autoload.php';
$migration = file_get_contents(dirname(__DIR__) . '/migrations/006_industry_profiles.sql');
assert(is_string($migration));
foreach ([
'CREATE TABLE IF NOT EXISTS industry_profiles',
'CREATE TABLE IF NOT EXISTS tenant_industry_profiles',
'PRIMARY KEY (tenant_id, industry_code)',
'FOREIGN KEY (tenant_id) REFERENCES tenants(id)',
'FOREIGN KEY (industry_code) REFERENCES industry_profiles(code)',
] as $requiredSchema) assert(str_contains($migration, $requiredSchema));
$selected = IndustryProfileCatalog::normalize(['handwerk', 'facility_services', 'handwerk']);
assert($selected === ['handwerk', 'facility_services']);
foreach ([null, [], ['unknown'], ['handwerk', 1]] as $invalid) {
try {
IndustryProfileCatalog::normalize($invalid);
assert(false);
} catch (InvalidArgumentException) {
}
}
assert(array_keys(IndustryProfileCatalog::PROFILES) === [
'handwerk',
'bau_montage',
'containerdienst',
'entsorgung_recycling',
'leckortung_rohrbruch',
'facility_services',
'sonstige_technische_dienste',
]);
fwrite(STDOUT, "industry_profiles_contract: OK\n");
