Files
api/services/nginx/app/tests/Unit/Bird/DepartmentGatesRelayOpenTest.php
T
Jeppe Bundgaard 5875371d13 Add attachment payload handling and tests for self-serve tasks
- Introduced `selfserve_task_attachment_payloads` class for managing task attachments, including formatting and download URL generation.
- Added unit and API tests to validate attachment handling in self-serve tasks and customer-scoped workflows.
- Enhanced wash start simulation and studio graph projections to integrate task attachment data.
2026-04-29 16:03:03 +02:00

84 lines
2.3 KiB
PHP

<?php
app_require('classes/edge_gateway_manager.php');
app_require('classes/object_property.php');
app_require('objects/department_gates_o.php');
use classes\edge_gateway_manager;
use classes\object_property;
use objects\department_gates_o;
final class DepartmentGatesRelayManagerFake extends edge_gateway_manager
{
public array $switchCalls = [];
public function __construct()
{
}
public function dispatchRelaySwitch(int $departmentId, string $logicalRelayId, bool $on, array $actionContext = []): array
{
$this->switchCalls[] = [
'department_id' => $departmentId,
'relay_id' => $logicalRelayId,
'on' => $on,
];
return [
'relay_id' => $logicalRelayId,
'online' => true,
'on' => $on,
];
}
}
final class DepartmentGatesRelayOpenHarness extends department_gates_o
{
public function __construct(
array $config,
int $departmentId,
private readonly DepartmentGatesRelayManagerFake $manager,
) {
$this->id = 1001;
$departmentProperty = new object_property('department_gates', -1, 'department', 'int');
$departmentProperty->set($departmentId);
$this->department = $departmentProperty;
$nameProperty = new object_property('department_gates', -1, 'name', 'string');
$nameProperty->set('Entry gate');
$this->name = $nameProperty;
$configProperty = new object_property('department_gates', -1, 'config', 'json');
$configProperty->set($config);
$this->config = $configProperty;
}
public function requireSelected(): void
{
}
protected function resolveEdgeGatewayManager(): edge_gateway_manager
{
return $this->manager;
}
}
it('dispatches relay-backed gates through the edge gateway relay manager', function (): void {
$manager = new DepartmentGatesRelayManagerFake();
$gate = new DepartmentGatesRelayOpenHarness([
'type' => 'RELAY',
'relay_id' => 'ENTRY-GATE-1',
'pulse_seconds' => 0,
], 17, $manager);
$gate->openGate();
expect($manager->switchCalls)->toBe([
[
'department_id' => 17,
'relay_id' => 'ENTRY-GATE-1',
'on' => true,
],
]);
});