f298984055
Компоненты:
- app/playwright/{package.json, refresh-session.js} — изолированный Node.js
+ Playwright chromium subprocess для headless логина
- PlaywrightProcessHandle interface + SymfonyPlaywrightProcessHandle (prod) +
StubPlaywrightProcessHandle (test) для DI без extending Symfony Process
- ProcessFactory + SymfonyProcessFactory
- PlaywrightBridge: PHP-обёртка, timeout 75s, JSON contract, exit code
→ SupplierAuthException
- RefreshSupplierSessionJob: stub → real (tries=3, backoff [2m/10m/30m],
Cache::lock concurrent guard, Redis TTL 6h)
- supplier:session:refresh Console command
- AppServiceProvider binds ProcessFactory → SymfonyProcessFactory
+7 tests (4 PlaywrightBridge + 2 Job + 1 Command).
NOTE: DOM-селекторы placeholder — финализация после Task 1 discovery.
NOTE: app/playwright/node_modules в .gitignore.
Quirks resolved:
- Mockery::mock(Process::class) + laravel/pao = stream_filter_remove fatal.
Решение: handle interface, pure-PHP test stub без extends Process.
- PHPStan Mockery union types — baseline entries (known Mockery+PHPStan compat).
KNOWN LIMITATION: на этой Windows машине pao stream filter conflict при
serial run SupplierPortalClient+RefreshSupplierSessionJob combo.
Tests pass individually + парами. Production Linux CI не affected.
68 lines
1.6 KiB
PHP
68 lines
1.6 KiB
PHP
<?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;
|
|
}
|
|
}
|