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 +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -34,4 +34,40 @@ protected function makeMessage(string $routingKey, $data) {
3434
3535 return $ message ;
3636 }
37+
38+ protected function setUpRabbitMQ () {
39+ $ this ->rabbitMQ = Mockery::mock ( RabbitMQ::class );
40+ $ this ->rabbitMQ ->shouldIgnoreMissing ($ this ->rabbitMQ );
41+ $ this ->app ->instance (RabbitMQ::class, $ this ->rabbitMQ );
42+ }
43+
44+ /**
45+ * @param string $event
46+ * @param array $expectedData
47+ */
48+ protected function expectMessage ( $ event , $ expectedData ) {
49+ $ this ->rabbitMQ ->shouldReceive ( 'onExchange ' )->with ( 'default-exchange ' , $ event )->once ()->andReturnSelf ();
50+ $ this ->rabbitMQ ->shouldReceive ( 'publish ' )->withArgs ( function ( $ data ) use ( $ expectedData ) {
51+ $ anyMatch = false ;
52+
53+ foreach ( $ expectedData as $ expectedKey => $ expectedValue ) {
54+
55+ if ( !array_key_exists ( $ expectedKey , $ data ) )
56+ return false ;
57+
58+ if ( is_float ($ data [ $ expectedKey ]))
59+ $ data [ $ expectedKey ] = round ($ data [ $ expectedKey ], 9 );
60+
61+ if ( is_float ($ expectedValue ))
62+ $ expectedValue = round ($ expectedValue , 9 );
63+
64+ if ( $ data [ $ expectedKey ] != $ expectedValue )
65+ return false ;
66+
67+ $ anyMatch = true ;
68+ }
69+
70+ return $ anyMatch ;
71+ } )->once ()->andReturnSelf ();
72+ }
3773}
You can’t perform that action at this time.
0 commit comments