|
11 | 11 | */ |
12 | 12 | class KafkaErrorCallbackTest extends TestCase |
13 | 13 | { |
14 | | - |
15 | | - public function getConsumerMock() |
16 | | - { |
17 | | - return $this->getMockBuilder(RdKafkaConsumer::class) |
18 | | - ->disableOriginalConstructor() |
19 | | - ->onlyMethods(['unsubscribe', 'getSubscription']) |
20 | | - ->getMock(); |
21 | | - } |
22 | | - |
23 | 14 | public function testInvokeWithBrokerException() |
24 | 15 | { |
25 | 16 | self::expectException('Jobcloud\Kafka\Exception\KafkaBrokerException'); |
26 | | - |
27 | | - $consumerMock = $this->getConsumerMock(); |
28 | | - |
29 | | - $consumerMock |
30 | | - ->expects(self::any()) |
31 | | - ->method('unsubscribe') |
32 | | - ->willReturn(null); |
33 | | - |
34 | | - $consumerMock |
35 | | - ->expects(self::any()) |
36 | | - ->method('getSubscription') |
37 | | - ->willReturn([]); |
38 | | - |
39 | 17 | $callback = new KafkaErrorCallback(); |
40 | | - call_user_func($callback, $consumerMock, 1, 'error'); |
| 18 | + call_user_func($callback, null, RD_KAFKA_RESP_ERR__FATAL, 'error'); |
41 | 19 | } |
42 | 20 |
|
43 | 21 | public function testInvokeWithAcceptableError() |
44 | 22 | { |
45 | | - $consumerMock = $this->getConsumerMock(); |
46 | | - |
47 | | - $consumerMock |
48 | | - ->expects(self::any()) |
49 | | - ->method('unsubscribe') |
50 | | - ->willReturn(null); |
51 | | - |
52 | | - $consumerMock |
53 | | - ->expects(self::any()) |
54 | | - ->method('getSubscription') |
55 | | - ->willReturn([]); |
56 | | - |
57 | 23 | $callback = new KafkaErrorCallback(); |
58 | | - $result = call_user_func($callback, $consumerMock, RD_KAFKA_RESP_ERR__TRANSPORT, 'error'); |
| 24 | + $result = call_user_func($callback, null, RD_KAFKA_RESP_ERR__TRANSPORT, 'error'); |
59 | 25 |
|
60 | 26 | self::assertNull($result); |
61 | 27 | } |
|
0 commit comments