Explorar o código

Add SoapFault exception formatting test

andyexeter %!s(int64=7) %!d(string=hai) anos
pai
achega
897fca0d9b
Modificáronse 1 ficheiros con 21 adicións e 0 borrados
  1. 21 0
      tests/Monolog/Formatter/LineFormatterTest.php

+ 21 - 0
tests/Monolog/Formatter/LineFormatterTest.php

@@ -173,6 +173,27 @@ class LineFormatterTest extends \PHPUnit\Framework\TestCase
         $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__ - 8).')\n[previous exception] [object] (LogicException(code: 0): Wut? at '.substr($path, 1, -1).':'.(__LINE__ - 12).')"} []'."\n", $message);
         $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__ - 8).')\n[previous exception] [object] (LogicException(code: 0): Wut? at '.substr($path, 1, -1).':'.(__LINE__ - 12).')"} []'."\n", $message);
     }
     }
 
 
+    public function testDefFormatWithSoapFaultException()
+    {
+        if (!class_exists('SoapFault')) {
+            $this->markTestSkipped('Requires the soap extension');
+        }
+
+        $formatter = new LineFormatter(null, 'Y-m-d');
+        $message = $formatter->format([
+            'level_name' => 'CRITICAL',
+            'channel' => 'core',
+            'context' => ['exception' => new \SoapFault('foo', 'bar', 'hello', '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: world): bar at '.substr($path, 1, -1).':'.(__LINE__ - 8).')"} []'."\n", $message);
+    }
+
     public function testBatchFormat()
     public function testBatchFormat()
     {
     {
         $formatter = new LineFormatter(null, 'Y-m-d');
         $formatter = new LineFormatter(null, 'Y-m-d');