Skip to content

Commit 55518cd

Browse files
Support rpc-server request lifecycle events (#6306)
Co-authored-by: 李铭昕 <715557344@qq.com>
1 parent 0b82994 commit 55518cd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/Stub/ContainerStub.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
use Hyperf\Framework\Logger\StdoutLogger;
1919
use Hyperf\RpcMultiplex\Socket;
2020
use Hyperf\RpcMultiplex\SocketFactory;
21+
use Hyperf\Server\ServerFactory;
2122
use Mockery;
2223
use Multiplex\Contract\IdGeneratorInterface;
2324
use Multiplex\Contract\PackerInterface;
2425
use Multiplex\Contract\SerializerInterface;
2526
use Multiplex\IdGenerator;
2627
use Multiplex\Packer;
2728
use Multiplex\Serializer\StringSerializer;
29+
use Psr\EventDispatcher\EventDispatcherInterface;
2830

2931
class ContainerStub
3032
{
@@ -44,6 +46,16 @@ public static function mockContainer(): Container
4446
$container->shouldReceive('make')->with(SocketFactory::class, Mockery::any())->andReturnUsing(function ($_, $args) use ($container) {
4547
return new SocketFactory($container, ...array_values($args));
4648
});
49+
50+
$dispatcher = Mockery::mock(EventDispatcherInterface::class);
51+
$dispatcher->shouldReceive('dispatch')->andReturn(true);
52+
$container->shouldReceive('has')->with(EventDispatcherInterface::class)->andReturn(true);
53+
$container->shouldReceive('get')->with(EventDispatcherInterface::class)->andReturn($dispatcher);
54+
55+
$serverFactory = Mockery::mock(ServerFactory::class);
56+
$serverFactory->shouldReceive('getConfig')->andReturn(null);
57+
$container->shouldReceive('get')->with(ServerFactory::class)->andReturn($serverFactory);
58+
4759
return $container;
4860
}
4961
}

0 commit comments

Comments
 (0)