Skip to content

Commit

Permalink
Fix the LoggingTrait test
Browse files Browse the repository at this point in the history
  • Loading branch information
Hectorhammett committed Dec 5, 2024
1 parent 636f650 commit 3bbac24
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions tests/Logging/LoggingTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,18 @@ public function testRequestWithoutJwtShouldNotPrintAJwt()

public function testLogResponse()
{
ob_start();

$event = $this->getNewLogEvent();
$event->headers = ['Thisis' => "a header"];
$this->loggerContainer->logResponseEvent($event);

$buffer = ob_get_contents();
ob_end_clean();
$buffer = $this->getActualOutput();

$buffer = str_replace("\n", '', $buffer);

// The LogResponse method logs two evnets, one for info and one for debug.
[$debugEvent, $infoEvent] = explode('}{', $buffer);
$debugEvent .= '}';
$infoEvent = '{' . $infoEvent;
// The LogResponse method logs two events, one for info and one for debug.
[$infoEvent, $debugEvent] = explode('}{', $buffer);
$infoEvent .= '}';
$debugEvent = '{' . $debugEvent;

$parsedDebugEvent = json_decode($debugEvent, true);
$this->assertEquals($event->clientId, $parsedDebugEvent['clientId']);
Expand Down

0 comments on commit 3bbac24

Please sign in to comment.