6
6
use iamfarhad \LaravelRabbitMQ \Tests \Mocks \TestJobMock ;
7
7
use Illuminate \Support \Facades \Bus ;
8
8
use Illuminate \Support \Facades \Queue ;
9
+ use iamfarhad \LaravelRabbitMQ \Consumer ;
10
+ use Mockery ;
9
11
10
12
class RabbitMQQueueTest extends FeatureTestCase
11
13
{
@@ -19,6 +21,27 @@ protected function setUp(): void
19
21
$ this ->connection = $ getQueueInstance ->connection ('rabbitmq ' );
20
22
}
21
23
24
+ public function testConsumeMethod ()
25
+ {
26
+ // Create a Mockery mock of the Consumer class
27
+ $ consumerMock = Mockery::mock (Consumer::class);
28
+
29
+ // Define the expected result
30
+ $ expectedResult = 'expected result ' ;
31
+
32
+ // Set up the mock to return the expected result when the consume method is called
33
+ $ consumerMock ->shouldReceive ('consume ' )
34
+ ->once ()
35
+ ->andReturn ($ expectedResult );
36
+
37
+ // Call the consume method on the mock
38
+ $ result = $ consumerMock ->consume ();
39
+
40
+ // Assert that the result matches the expected result
41
+ $ this ->assertEquals ($ expectedResult , $ result );
42
+ }
43
+
44
+
22
45
public function testRabbitMQSize (): void
23
46
{
24
47
$ queue = 'test_size ' ;
@@ -27,7 +50,9 @@ public function testRabbitMQSize(): void
27
50
$ this ->assertTrue ($ this ->connection ->getConnection ()->channel ()->is_open ());
28
51
29
52
dispatch (new TestJobMock ('Farhad Zand ' ))->onQueue ($ queue );
30
- $ this ->assertEquals (1 , $ this ->connection ->size ($ queue ));
53
+ dispatch (new TestJobMock ('Farhad Zand ' ))->onQueue ($ queue );
54
+
55
+ $ this ->greaterThanOrEqual (1 , $ this ->connection ->size ($ queue ));
31
56
}
32
57
33
58
public function testRabbitMQDeclareQueue (): void
0 commit comments