mirror of
https://github.com/appwrite/appwrite
synced 2026-05-06 06:48:22 +00:00
fix unit test
This commit is contained in:
parent
4b02bf1aa8
commit
579f07f8bb
1 changed files with 14 additions and 5 deletions
|
|
@ -39,12 +39,21 @@ class Realtime extends MessagingAdapter
|
|||
*/
|
||||
public array $subscriptions = [];
|
||||
|
||||
private PubSubPool $pubSubPool;
|
||||
private ?PubSubPool $pubSubPool = null;
|
||||
|
||||
public function __construct()
|
||||
/**
|
||||
* Get the PubSubPool instance, initializing it lazily if needed.
|
||||
* This allows unit tests to work without requiring the global $register.
|
||||
*
|
||||
* @return PubSubPool
|
||||
*/
|
||||
private function getPubSubPool(): PubSubPool
|
||||
{
|
||||
global $register;
|
||||
$this->pubSubPool = new PubSubPool($register->get('pools')->get('pubsub'));
|
||||
if ($this->pubSubPool === null) {
|
||||
global $register;
|
||||
$this->pubSubPool = new PubSubPool($register->get('pools')->get('pubsub'));
|
||||
}
|
||||
return $this->pubSubPool;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -224,7 +233,7 @@ class Realtime extends MessagingAdapter
|
|||
$permissionsChanged = array_key_exists('permissionsChanged', $options) && $options['permissionsChanged'];
|
||||
$userId = array_key_exists('userId', $options) ? $options['userId'] : null;
|
||||
|
||||
$this->pubSubPool->publish('realtime', json_encode([
|
||||
$this->getPubSubPool()->publish('realtime', json_encode([
|
||||
'project' => $projectId,
|
||||
'roles' => $roles,
|
||||
'permissionsChanged' => $permissionsChanged,
|
||||
|
|
|
|||
Loading…
Reference in a new issue