<?php

app_require('classes/department_gate_config.php');

use classes\department_gate_config;

it('validates relay gate configs and keeps relay-specific fields in the payload', function (): void {
    $config = new department_gate_config([
        'type' => 'RELAY',
        'relay_id' => 'ENTRY-GATE-1',
        'pulse_seconds' => 0,
    ]);

    $config->validate();

    expect($config->toArray())->toMatchArray([
        'type' => 'RELAY',
        'relay_id' => 'ENTRY-GATE-1',
        'pulse_seconds' => 0,
    ]);
});

it('rejects relay gate configs without a logical relay id', function (): void {
    $config = new department_gate_config([
        'type' => 'RELAY',
    ]);

    expect(fn() => $config->validate())
        ->toThrow(Exception::class, 'relay_id is required for RELAY gate type');
});
