Skip to content

Commit

Permalink
Assert SoapFail can handle a structured detail
Browse files Browse the repository at this point in the history
  • Loading branch information
neclimdul committed May 15, 2020
1 parent 438b898 commit 93ac064
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions tests/Monolog/Formatter/LineFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ public function testDefFormatWithSoapFaultException()
$path = str_replace('\\/', '/', json_encode(__FILE__));

$this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (SoapFault(code: 0 faultcode: foo faultactor: hello detail: world): bar at '.substr($path, 1, -1).':'.(__LINE__ - 8).')"} []'."\n", $message);

$message = $formatter->format([
'level_name' => 'CRITICAL',
'channel' => 'core',
'context' => ['exception' => new \SoapFault('foo', 'bar', 'hello', (object) ['bar' => ['biz' => 'baz'], 'foo' => 'world'])],
'datetime' => new \DateTimeImmutable,
'extra' => [],
'message' => 'foobar',
]);

$path = str_replace('\\/', '/', json_encode(__FILE__));

$this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (SoapFault(code: 0 faultcode: foo faultactor: hello detail: {\"bar\":{\"biz\":\"baz\"},\"foo\":\"world\"}): bar at '.substr($path, 1, -1).':'.(__LINE__ - 8).')"} []'."\n", $message);
}

public function testBatchFormat()
Expand Down
4 changes: 2 additions & 2 deletions tests/Monolog/Formatter/NormalizerFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function testFormatSoapFaultException()
}

$formatter = new NormalizerFormatter('Y-m-d');
$e = new \SoapFault('foo', 'bar', 'hello', (object) ['foo' => 'world']);
$e = new \SoapFault('foo', 'bar', 'hello', (object) ['bar' => ['biz' => 'baz'], 'foo' => 'world']);
$formatted = $formatter->format([
'exception' => $e,
]);
Expand All @@ -102,7 +102,7 @@ public function testFormatSoapFaultException()
'file' => $e->getFile().':'.$e->getLine(),
'faultcode' => 'foo',
'faultactor' => 'hello',
'detail' => 'world',
'detail' => '{"bar":{"biz":"baz"},"foo":"world"}',
],
], $formatted);
}
Expand Down

0 comments on commit 93ac064

Please sign in to comment.