Files
portal/app/tests/Unit/Supplier/Stubs/StubPlaywrightProcessHandle.php
T

68 lines
1.6 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Tests\Unit\Supplier\Stubs;
use App\Services\Supplier\PlaywrightProcessHandle;
/**
* Pure-PHP stub для PlaywrightProcessHandle, БЕЗ наследования Symfony Process.
*
* Зачем: Mockery::mock(Process::class) И extending Process вызывают
* 'stream_filter_remove(): Unable to flush filter' fatal через laravel/pao
* stdout capture. Pure-PHP impl этой проблемы избегает.
*/
final class StubPlaywrightProcessHandle implements PlaywrightProcessHandle
{
public string $capturedInput = '';
public int $capturedTimeout = 0;
public function __construct(
private readonly bool $successful,
private readonly string $output = '',
private readonly string $errorOutput = '',
private readonly int $exitCode = 0,
) {}
public function setInput(string $input): self
{
$this->capturedInput = $input;
return $this;
}
public function setTimeoutSeconds(int $seconds): self
{
$this->capturedTimeout = $seconds;
return $this;
}
public function run(): int
{
return $this->successful ? 0 : $this->exitCode;
}
public function isSuccessful(): bool
{
return $this->successful;
}
public function getOutput(): string
{
return $this->output;
}
public function getErrorOutput(): string
{
return $this->errorOutput;
}
public function getExitCode(): int
{
return $this->successful ? 0 : $this->exitCode;
}
}