1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Asiries335\redisSteamPhp\Tests; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use Asiries335\redisSteamPhp\ClientRedisStreamPhpInterface; |
8
|
|
|
use Asiries335\redisSteamPhp\StreamGroupConsumer; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
|
11
|
|
|
class StreamGroupConsumerTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
private $client; |
14
|
|
|
|
15
|
|
|
private const TEST_NAME_STREAM = 'test_stream'; |
16
|
|
|
|
17
|
|
|
private const TEST_NAME_GROUP = 'test_group'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* setUp |
21
|
|
|
* |
22
|
|
|
* @return void |
23
|
|
|
*/ |
24
|
|
|
public function setUp() : void |
25
|
|
|
{ |
26
|
|
|
$this->client = \Mockery::mock(ClientRedisStreamPhpInterface::class); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Create a group |
31
|
|
|
* |
32
|
|
|
* @return void |
33
|
|
|
* |
34
|
|
|
* @throws \Exception |
35
|
|
|
*/ |
36
|
|
|
public function testCreateGroup() : void |
37
|
|
|
{ |
38
|
|
|
$this->client->shouldReceive('call')->andReturn(true); |
39
|
|
|
|
40
|
|
|
$streamGroup = new StreamGroupConsumer($this->client, self::TEST_NAME_STREAM); |
41
|
|
|
|
42
|
|
|
$result = $streamGroup->create(self::TEST_NAME_GROUP, true); |
43
|
|
|
|
44
|
|
|
$this->assertEquals(true, $result); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Destroy a group |
49
|
|
|
* |
50
|
|
|
* @return void |
51
|
|
|
* |
52
|
|
|
* @throws \Exception |
53
|
|
|
*/ |
54
|
|
|
public function testDestroyGroup() : void |
55
|
|
|
{ |
56
|
|
|
$this->client->shouldReceive('call')->andReturn(true); |
57
|
|
|
|
58
|
|
|
$streamGroup = new StreamGroupConsumer($this->client, self::TEST_NAME_STREAM); |
59
|
|
|
|
60
|
|
|
$result = $streamGroup->destroy(self::TEST_NAME_GROUP); |
61
|
|
|
|
62
|
|
|
$this->assertEquals(true, $result); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Test delete a consumer from group |
67
|
|
|
* |
68
|
|
|
* @return void |
69
|
|
|
* |
70
|
|
|
* @throws \Exception |
71
|
|
|
*/ |
72
|
|
|
public function testDeleteConsumerGroup() : void |
73
|
|
|
{ |
74
|
|
|
$this->client->shouldReceive('call')->andReturn(true); |
75
|
|
|
|
76
|
|
|
$streamGroup = new StreamGroupConsumer($this->client, self::TEST_NAME_STREAM); |
77
|
|
|
|
78
|
|
|
$result = $streamGroup->deleteConsumer(self::TEST_NAME_GROUP, 'consumerName'); |
79
|
|
|
|
80
|
|
|
$this->assertEquals(true, $result); |
81
|
|
|
} |
82
|
|
|
} |