Transitioned from obsolete gateway object classes (`edge_gateway_shell_action_jobs_o`, `edge_gateway_shell_events_o`, `edge_gateway_shell_sessions_o`, `edge_gateway_update_jobs_o`) to the new agent implementation (`edge-gateway-agent/agent.php`).
30 lines
1.5 KiB
PHP
30 lines
1.5 KiB
PHP
<?php
|
|
|
|
app_require('classes/edge_gateway_manager.php');
|
|
|
|
use classes\edge_gateway_manager;
|
|
|
|
it('adds a gateway metadata update endpoint with label and primary assignment fields', function (): void {
|
|
$routeSource = file_get_contents(app_path('routes/edgeGatewaysRoute.php'));
|
|
|
|
expect($routeSource)->not->toBeFalse();
|
|
expect($routeSource)->toContain("put('/edge-gateways/{id}'");
|
|
expect($routeSource)->toContain("self::requireParameters(['label', 'is_primary']);");
|
|
expect($routeSource)->toContain("self::requireType(self::getParameter('label'), self::TYPE_STRING());");
|
|
expect($routeSource)->toContain("self::requireType(self::getParameter('is_primary'), self::TYPE_BOOL());");
|
|
expect($routeSource)->toContain('updateGatewayMetadata(');
|
|
});
|
|
|
|
it('reassigns department primary gateways through dedicated manager helpers', function (): void {
|
|
$source = file_get_contents(app_path('classes/edge_gateway_manager.php'));
|
|
$reflection = new ReflectionClass(edge_gateway_manager::class);
|
|
|
|
expect($source)->not->toBeFalse();
|
|
expect($source)->toContain("\$this->setGatewayPrimaryState(\$gateway, true);");
|
|
expect($source)->toContain("\$replacement = \$this->findAlternateGatewayForDepartment(");
|
|
expect($source)->toContain("throw new Exception('Department must retain a primary gateway');");
|
|
expect($reflection->hasMethod('updateGatewayMetadata'))->toBeTrue();
|
|
expect($reflection->hasMethod('setGatewayPrimaryState'))->toBeTrue();
|
|
expect($reflection->hasMethod('findAlternateGatewayForDepartment'))->toBeTrue();
|
|
});
|