This repository was archived by the owner on Jun 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 1010
1111trait TestsRabbitMQ
1212{
13+
14+ /**
15+ * @var string
16+ */
17+ protected $ expectedRoutingKey = '' ;
18+
19+ /**
20+ * @var string
21+ */
22+ protected $ expectedExchangeName = '' ;
23+
1324 public function sendMessage (AmqpMessage $ message )
1425 {
1526 /**
@@ -42,12 +53,24 @@ protected function setUpRabbitMQ() {
4253 $ this ->app ->instance (RabbitMQ::class, $ this ->rabbitMQ );
4354 }
4455
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+
4568 /**
4669 * @param string $event
4770 * @param array $expectedData
4871 */
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 ();
5174 $ this ->rabbitMQ ->shouldReceive ( 'publish ' )->withArgs ( function ( $ data ) use ( $ expectedData ) {
5275 $ anyMatch = false ;
5376
You can’t perform that action at this time.
0 commit comments