Skip to content

Commit

Permalink
test: fix expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
hcdias committed Oct 10, 2023
1 parent 1da7001 commit 4044430
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions tests/Unit/Connectors/Consumer/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
use InvalidArgumentException;
use Metamorphosis\Connectors\Consumer\Manager;
use Metamorphosis\Consumers\ConsumerInterface;
use Metamorphosis\Exceptions\ResponseTimeoutException;
use Metamorphosis\Exceptions\ResponseWarningException;
use Metamorphosis\Middlewares\Handler\Dispatcher;
use Metamorphosis\Record\ConsumerRecord;
use Metamorphosis\TopicHandler\Consumer\Handler as ConsumerHandler;
use Mockery as m;
use RdKafka\Message as KafkaMessage;
use Tests\LaravelTestCase;
use Tests\Unit\Dummies\ConsumerHandlerDummy;
use Throwable;
use TypeError;

class ManagerTest extends LaravelTestCase
Expand Down Expand Up @@ -130,33 +127,30 @@ public function testShouldHandleAsyncCommit(): void
$kafkaMessage2->payload = 'original message 2';
$kafkaMessage2->err = RD_KAFKA_RESP_ERR_NO_ERROR;

$messages = [$kafkaMessage1, $kafkaMessage2];
$count = 0;
$exception = new ResponseTimeoutException(
'Consume timeout or finished to processed.'
);
$kafkaMessage3 = new KafkaMessage();
$kafkaMessage3->payload = 'original message 3';
$kafkaMessage3->err = RD_KAFKA_RESP_ERR_NO_ERROR;

// Expectations
$consumer->shouldReceive()
->consume()
->times(3)
->andReturn($kafkaMessage1, $kafkaMessage2);
->andReturn($kafkaMessage1, $kafkaMessage2, $kafkaMessage3);

$consumer->expects()
->commitAsync()
->twice(2);
->times(3);

$consumer->expects()
->canCommit()
->twice(2)
->times(3)
->andReturnTrue();

$dispatcher->expects()
->handle($consumerRecord)
->times(2);

$consumerHandler->expects()
->finished();
->times(3);
// $consumerHandler->expects()
// ->finished();

// Actions
$runner->handleMessage();
Expand Down

0 comments on commit 4044430

Please sign in to comment.