Files
php-qml/framework/php/tests/Helper/HubSpy.php

51 lines
1.1 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace PhpQml\Bridge\Tests\Helper;
use Symfony\Component\Mercure\HubInterface;
use Symfony\Component\Mercure\Jwt\TokenFactoryInterface;
use Symfony\Component\Mercure\Jwt\TokenProviderInterface;
use Symfony\Component\Mercure\Update;
/**
* Minimal HubInterface fake that records the last published Update.
* Used by Publisher / BridgeDoctorCommand tests.
*/
final class HubSpy implements HubInterface
{
public ?Update $captured = null;
public function __construct(private readonly string $stubReturnId = '')
{
}
public function getUrl(): string
{
return 'http://localhost/.well-known/mercure';
}
public function getPublicUrl(): string
{
return $this->getUrl();
}
public function getProvider(): TokenProviderInterface
{
throw new \LogicException('HubSpy::getProvider not used in tests.');
}
public function getFactory(): ?TokenFactoryInterface
{
return null;
}
public function publish(Update $update): string
{
$this->captured = $update;
return $this->stubReturnId;
}
}