This repository was archived by the owner on Jun 13, 2023. It is now read-only.
File tree 1 file changed +25
-2
lines changed
1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 10
10
11
11
trait TestsRabbitMQ
12
12
{
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $ expectedRoutingKey = '' ;
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ protected $ expectedExchangeName = '' ;
23
+
13
24
public function sendMessage (AmqpMessage $ message )
14
25
{
15
26
/**
@@ -42,12 +53,24 @@ protected function setUpRabbitMQ() {
42
53
$ this ->app ->instance (RabbitMQ::class, $ this ->rabbitMQ );
43
54
}
44
55
56
+ protected function expectEvent ($ routingKey )
57
+ {
58
+ $ this ->expectedRoutingKey = $ routingKey ;
59
+ return $ this ;
60
+ }
61
+
62
+ protected function onExchange ($ exchangeName )
63
+ {
64
+ $ this ->expectedExchangeName = $ exchangeName ;
65
+ return $ this ;
66
+ }
67
+
45
68
/**
46
69
* @param string $event
47
70
* @param array $expectedData
48
71
*/
49
- protected function expectMessage ( $ event , $ expectedData ) {
50
- $ this ->rabbitMQ ->shouldReceive ( 'onExchange ' )->with ( ' default-exchange ' , $ event )->once ()->andReturnSelf ();
72
+ protected function withMessage ( $ expectedData ) {
73
+ $ this ->rabbitMQ ->shouldReceive ( 'onExchange ' )->with ( $ this -> expectedExchangeName , $ this -> expectedRoutingKey )->once ()->andReturnSelf ();
51
74
$ this ->rabbitMQ ->shouldReceive ( 'publish ' )->withArgs ( function ( $ data ) use ( $ expectedData ) {
52
75
$ anyMatch = false ;
53
76
You can’t perform that action at this time.
0 commit comments