Files
portal/app/tests/Feature/ClientSms/MigrationTest.php
T
Дмитрий ea97bba219 feat(смс-клиент): таблицы имени/авто-правила + модели + грант админ-кошелька
client_sms_senders (жизненный цикл имени) и client_sms_auto_rule (авто-рассылка) —
RLS tenant-таблицы; гварды грантов для crm_supplier_worker/crm_admin_user (cross-tenant
джоб и админ-подтверждение). Грант записи в ad_wallets для crm_admin_user (approve
списывает/снимает заморозку). CHANGELOG v8.97/v8.98 с deploy-note про ре-ран srv_bypass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-25 23:20:51 +03:00

89 lines
3.4 KiB
PHP

<?php
declare(strict_types=1);
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
uses(RefreshDatabase::class);
it('creates client_sms_campaigns with expected columns', function () {
expect(Schema::hasTable('client_sms_campaigns'))->toBeTrue();
expect(Schema::hasColumns('client_sms_campaigns', [
'tenant_id', 'title', 'body', 'sender_name', 'source', 'audience_days',
'status', 'segments', 'planned_count', 'sent_count', 'total_sms',
'price_rub_per_sms', 'estimated_cost_rub', 'actual_cost_rub', 'created_by',
]))->toBeTrue();
});
it('creates client_sms_campaign_phones with expected columns', function () {
expect(Schema::hasTable('client_sms_campaign_phones'))->toBeTrue();
expect(Schema::hasColumns('client_sms_campaign_phones', [
'tenant_id', 'campaign_id', 'phone', 'expires_at',
]))->toBeTrue();
});
it('creates client_sms_messages with expected columns', function () {
expect(Schema::hasTable('client_sms_messages'))->toBeTrue();
expect(Schema::hasColumns('client_sms_messages', [
'tenant_id', 'campaign_id', 'deal_id', 'phone', 'operator', 'provider_key',
'status', 'cost_rub', 'provider_message_id', 'error',
]))->toBeTrue();
});
it('creates client_sms_optouts with expected columns', function () {
expect(Schema::hasTable('client_sms_optouts'))->toBeTrue();
expect(Schema::hasColumns('client_sms_optouts', [
'tenant_id', 'phone',
]))->toBeTrue();
});
it('creates client_sms_contacts with expected columns', function () {
expect(Schema::hasTable('client_sms_contacts'))->toBeTrue();
expect(Schema::hasColumns('client_sms_contacts', [
'tenant_id', 'phone', 'name', 'operator',
]))->toBeTrue();
});
it('creates client_sms_templates with expected columns', function () {
expect(Schema::hasTable('client_sms_templates'))->toBeTrue();
expect(Schema::hasColumns('client_sms_templates', [
'tenant_id', 'title', 'body',
]))->toBeTrue();
});
it('creates client_sms_tariffs with expected columns and seeds exactly 5 rows', function () {
expect(Schema::hasTable('client_sms_tariffs'))->toBeTrue();
expect(Schema::hasColumns('client_sms_tariffs', [
'min_qty', 'price_rub',
]))->toBeTrue();
expect(DB::table('client_sms_tariffs')->count())->toBe(5);
});
it('creates client_sms_settings with expected columns and seeds exactly 1 row', function () {
expect(Schema::hasTable('client_sms_settings'))->toBeTrue();
expect(Schema::hasColumns('client_sms_settings', [
'name_fee_rub_per_operator', 'name_debt_grace_days',
]))->toBeTrue();
expect(DB::table('client_sms_settings')->count())->toBe(1);
});
it('creates client_sms_senders with expected columns', function () {
expect(Schema::hasTable('client_sms_senders'))->toBeTrue();
expect(Schema::hasColumns('client_sms_senders', [
'tenant_id', 'name', 'name_type', 'status', 'operators',
'monthly_fee_rub', 'consent_at', 'note', 'requested_by',
'approved_at', 'paid_until', 'debt_since',
]))->toBeTrue();
});
it('creates client_sms_auto_rule with expected columns', function () {
expect(Schema::hasTable('client_sms_auto_rule'))->toBeTrue();
expect(Schema::hasColumns('client_sms_auto_rule', [
'tenant_id', 'enabled', 'body', 'sender_name', 'updated_by',
]))->toBeTrue();
});