30 lines
1.0 KiB
PHP
30 lines
1.0 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace BlaxSoftware\LaravelWebSockets\Test;
|
||
|
|
|
||
|
|
use BlaxSoftware\LaravelWebSockets\Websocket\ChannelManager;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* A connection the server declines in onOpen (e.g. during a soft shutdown) is
|
||
|
|
* closed before it ever gets an app or socket id. Closing it must not throw:
|
||
|
|
* it used to log `Attempt to read property "id" on null` for every declined
|
||
|
|
* handshake, flooding the websocket log with errors that looked like a crash.
|
||
|
|
*/
|
||
|
|
class ClosedBeforeOpenTest extends TestCase
|
||
|
|
{
|
||
|
|
public function test_unsubscribing_a_connection_without_an_app_is_a_no_op()
|
||
|
|
{
|
||
|
|
// The Redis-backed manager needs Redis to construct; this path must not
|
||
|
|
// touch Redis at all, so the constructor is skipped.
|
||
|
|
$manager = (new \ReflectionClass(ChannelManager::class))->newInstanceWithoutConstructor();
|
||
|
|
|
||
|
|
$result = null;
|
||
|
|
$manager->unsubscribeFromAllChannels(new Mocks\Connection)
|
||
|
|
->then(function ($value) use (&$result) {
|
||
|
|
$result = $value;
|
||
|
|
});
|
||
|
|
|
||
|
|
$this->assertFalse($result);
|
||
|
|
}
|
||
|
|
}
|