Skip to content

Commit 5216934

Browse files
Added test cases about Multiplex RPC component (#4172)
* 完善文档中 GRPC 包示例 * Added test cases about rpc-multiplex. Co-authored-by: 李铭昕 <715557344@qq.com>
1 parent 8480104 commit 5216934

File tree

2 files changed

+46
-24
lines changed

2 files changed

+46
-24
lines changed

tests/Cases/ChannelManagerTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://hyperf.wiki
9+
* @contact group@hyperf.io
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
namespace HyperfTest\RpcMultiplex\Cases;
13+
14+
use Hyperf\Utils\Coroutine;
15+
use Multiplex\ChannelManager;
16+
17+
/**
18+
* @internal
19+
* @coversNothing
20+
*/
21+
class ChannelManagerTest extends AbstractTestCase
22+
{
23+
public function testChannelManagerFlush()
24+
{
25+
$manager = new ChannelManager();
26+
$chan = $manager->get(1, true);
27+
$chan->push(true);
28+
$chan2 = $manager->get(2, true);
29+
$chan2->push(true);
30+
31+
Coroutine::create(function () use ($manager, $chan, $chan2) {
32+
$chan->push(true);
33+
$chan = $manager->get(3, true);
34+
$chan->push(true);
35+
$chan2->push(true);
36+
});
37+
38+
$channels = $manager->getChannels();
39+
foreach ($channels as $id => $channel) {
40+
$manager->get($id + 3, true);
41+
$manager->close($id);
42+
}
43+
44+
$this->assertSame([4, 3, 5], array_keys($manager->getChannels()));
45+
}
46+
}

tests/Cases/ExampleTest.php

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)