Files
portal/app/tests/Feature/SiteTrackingSchemaTest.php
T

31 lines
1.3 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
use Illuminate\Support\Facades\DB;
test('таблица site_visitors существует и имеет нужные колонки', function () {
$cols = collect(DB::select("
SELECT column_name FROM information_schema.columns WHERE table_name = 'site_visitors'
"))->pluck('column_name')->all();
expect($cols)->toContain('id', 'first_seen_at', 'last_seen_at', 'channel', 'utm_source',
'referrer', 'landing_path', 'device', 'user_agent', 'ip', 'city', 'asn_org',
'is_datacenter', 'is_human', 'tenant_id', 'user_id');
});
test('site_events партиционирована по месяцу', function () {
$parted = DB::selectOne("
SELECT c.relkind FROM pg_class c WHERE c.relname = 'site_events'
");
expect($parted->relkind)->toBe('p'); // p = partitioned table
});
test('клиентская роль crm_app_user не имеет доступа к site_visitors', function () {
$grants = DB::select("
SELECT grantee FROM information_schema.role_table_grants WHERE table_name = 'site_visitors'
");
$grantees = collect($grants)->pluck('grantee')->all();
expect($grantees)->not->toContain('crm_app_user');
})->skip(fn () => DB::selectOne("SELECT 1 FROM pg_roles WHERE rolname='crm_app_user'") === null,
'роли crm_app_user нет на dev');