Spec 430: Exchange PowerShell adapter contract slice 1. Validation was not rerun during PR creation handoff; branch contains implementation report and tests. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #497
56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Support\TenantConfiguration;
|
|
|
|
use App\Services\TenantConfiguration\ExchangePowerShellCommandContracts;
|
|
|
|
final class Spec430ExchangePowerShellFakeCommandRunner
|
|
{
|
|
/**
|
|
* @var list<array{command_name: string, parameters: array<string, mixed>}>
|
|
*/
|
|
public array $calls = [];
|
|
|
|
public function __construct(
|
|
private readonly ?ExchangePowerShellCommandContracts $contracts = null,
|
|
) {}
|
|
|
|
/**
|
|
* @param array<string, mixed> $parameters
|
|
* @param list<array<string, mixed>> $items
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function run(mixed $contract, array $parameters = [], array $items = []): array
|
|
{
|
|
$contracts = $this->contracts ?? new ExchangePowerShellCommandContracts;
|
|
$validation = $contracts->validateInvocation($contract, $parameters);
|
|
|
|
if (! $validation['accepted']) {
|
|
return [
|
|
'ok' => false,
|
|
'reason_code' => $validation['reason_code'],
|
|
'source' => 'spec430_fake_exchange_powershell_runner',
|
|
'shell_executed' => false,
|
|
'provider_call_executed' => false,
|
|
];
|
|
}
|
|
|
|
$this->calls[] = [
|
|
'command_name' => (string) $contract['command_name'],
|
|
'parameters' => $parameters,
|
|
];
|
|
|
|
return [
|
|
'ok' => true,
|
|
'reason_code' => null,
|
|
'source' => 'spec430_fake_exchange_powershell_runner',
|
|
'command_name' => (string) $contract['command_name'],
|
|
'items' => $items,
|
|
'shell_executed' => false,
|
|
'provider_call_executed' => false,
|
|
];
|
|
}
|
|
}
|