diff --git a/src/Entities/InboxMessage.php b/src/Entities/InboxMessage.php index 6296b90..86fcdeb 100644 --- a/src/Entities/InboxMessage.php +++ b/src/Entities/InboxMessage.php @@ -12,7 +12,7 @@ public static function make(object $rawDbRecord): InboxMessage { $inboxMsg = new InboxMessage(); $inboxMsg->id = intval($rawDbRecord->id); - $inboxMsg->externalId = $rawDbRecord->externalId; + $inboxMsg->externalId = $rawDbRecord->external_id; $inboxMsg->rawPayload = $rawDbRecord->payload ?: '{}'; return $inboxMsg; diff --git a/tests/Integration/Commands/InboxWorkCommandTest.php b/tests/Integration/Commands/InboxWorkCommandTest.php index a020dc3..3785eda 100644 --- a/tests/Integration/Commands/InboxWorkCommandTest.php +++ b/tests/Integration/Commands/InboxWorkCommandTest.php @@ -54,6 +54,16 @@ public function testCommandPullsTheOrderedMsgAndProcessThem() // 4. validate $this->assertSame(0, $code); $this->assertStringContainsString('Processed 3 inbox messages', $result); + + $this->assertStringContainsString('Handling message with externalId: "evt_1NWX0RBGIr5C5v4TpncL2sCf"', $result); + $this->assertStringContainsString('Handled message with externalId: "evt_1NWX0RBGIr5C5v4TpncL2sCf"', $result); + + $this->assertStringContainsString('Handling message with externalId: "evt_1NWUFiBGIr5C5v4TptQhGyW3"', $result); + $this->assertStringContainsString('Handled message with externalId: "evt_1NWUFiBGIr5C5v4TptQhGyW3"', $result); + + $this->assertStringContainsString('Handling message with externalId: "evt_1Nh2fp2eZvKYlo2CzbNockEM"', $result); + $this->assertStringContainsString('Handled message with externalId: "evt_1Nh2fp2eZvKYlo2CzbNockEM"', $result); + $this->assertStringContainsString('[Info] No message found. Stopping...', $result); Event::assertDispatched( @@ -135,6 +145,22 @@ public function testCommandThrowsErrorWhenFailedToProcessAMessage() 'topic' => 'with_err_msg', ]); } + + public function testCommandStopsAfterAnAmountOfTime() + { + $beginAt = time(); + + $code = Artisan::call('inbox:work test --max-processing-time=10'); + $result = Artisan::output(); + + $finishedAt = time(); + + $this->assertSame(0, $code); + + $this->assertStringContainsString('[Info] Reached max processing time. Closing the process.', $result); + + $this->assertGreaterThanOrEqual(10, $finishedAt - $beginAt); + } } class InvoicePaymentSucceedEvent