Skip to content

Commit da6e421

Browse files
author
Farhad.Zand
committed
fix test
1 parent 5ff8745 commit da6e421

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tests/Feature/RabbitMQQueueTest.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
use iamfarhad\LaravelRabbitMQ\Tests\Mocks\TestJobMock;
77
use Illuminate\Support\Facades\Bus;
88
use Illuminate\Support\Facades\Queue;
9+
use iamfarhad\LaravelRabbitMQ\Consumer;
10+
use Mockery;
911

1012
class RabbitMQQueueTest extends FeatureTestCase
1113
{
@@ -19,6 +21,27 @@ protected function setUp(): void
1921
$this->connection = $getQueueInstance->connection('rabbitmq');
2022
}
2123

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+
2245
public function testRabbitMQSize(): void
2346
{
2447
$queue = 'test_size';
@@ -27,7 +50,9 @@ public function testRabbitMQSize(): void
2750
$this->assertTrue($this->connection->getConnection()->channel()->is_open());
2851

2952
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));
3156
}
3257

3358
public function testRabbitMQDeclareQueue(): void

0 commit comments

Comments
 (0)