Spec 432: Exchange PowerShell production runner boundary and runtime gate. Validation: php artisan test --filter=Spec432 --compact; ./vendor/bin/pint --dirty --test --format agent; git diff --check. Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #499
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\TenantConfiguration;
|
|
|
|
final class FakeExchangePowerShellProcessExecutor implements ExchangePowerShellProcessExecutor
|
|
{
|
|
/**
|
|
* @var list<array{arguments: list<string>, timeout_seconds: int}>
|
|
*/
|
|
public array $calls = [];
|
|
|
|
/**
|
|
* @param list<ExchangePowerShellProcessResult> $results
|
|
*/
|
|
public function __construct(
|
|
private bool $available = true,
|
|
private array $results = [],
|
|
) {}
|
|
|
|
public function setAvailable(bool $available): void
|
|
{
|
|
$this->available = $available;
|
|
}
|
|
|
|
public function pushResult(ExchangePowerShellProcessResult $result): void
|
|
{
|
|
$this->results[] = $result;
|
|
}
|
|
|
|
public function available(): bool
|
|
{
|
|
return $this->available;
|
|
}
|
|
|
|
public function run(ExchangePowerShellProcessCommand $command): ExchangePowerShellProcessResult
|
|
{
|
|
$this->calls[] = [
|
|
'arguments' => $command->arguments,
|
|
'timeout_seconds' => $command->timeoutSeconds,
|
|
];
|
|
|
|
return array_shift($this->results) ?? ExchangePowerShellProcessResult::completed(0, '[]');
|
|
}
|
|
}
|