add test for deprecation logging
authorgggeek <giunta.gaetano@gmail.com>
Mon, 30 Jan 2023 22:37:05 +0000 (22:37 +0000)
committergggeek <giunta.gaetano@gmail.com>
Mon, 30 Jan 2023 22:37:05 +0000 (22:37 +0000)
tests/05LoggerTest.php
tests/LoggerAwareTestCase.php

index 12c10f1..319744f 100644 (file)
@@ -10,11 +10,13 @@ class LoggerTest extends PhpXmlRpc_PolyfillTestCase
 {
     protected $debugBuffer = '';
     protected $errorBuffer = '';
+    protected $warningBuffer = '';
 
     protected function set_up()
     {
         $this->debugBuffer = '';
         $this->errorBuffer = '';
+        $this->warningBuffer = '';
     }
 
     public function testCharsetAltLogger()
@@ -65,6 +67,18 @@ class LoggerTest extends PhpXmlRpc_PolyfillTestCase
         XMLParser::setLogger($l);
     }
 
+    public function testDeprecations()
+    {
+        $v = new \PhpXmlRpc\Value(array(), \PhpXmlRpc\Value::$xmlrpcStruct);
+        $l = $v->getLogger();
+        \PhpXmlRpc\Value::setLogger($this);
+        \PhpXmlRpc\PhpXmlRpc::$xmlrpc_silence_deprecations = false;
+        $c = $v->structSize();
+        \PhpXmlRpc\PhpXmlRpc::$xmlrpc_silence_deprecations = true;
+        \PhpXmlRpc\Value::setLogger($l);
+        $this->assertStringContainsString("Method PhpXmlRpc\Value::structSize is deprecated", $this->warningBuffer);
+    }
+
     // logger API
 
     public function debug($message, $context = array())
@@ -76,4 +90,9 @@ class LoggerTest extends PhpXmlRpc_PolyfillTestCase
     {
         $this->errorBuffer .= $message;
     }
+
+    public function warning($message, $context = array())
+    {
+        $this->warningBuffer .= $message;
+    }
 }
index 4c3051e..a23d935 100644 (file)
@@ -57,4 +57,9 @@ abstract class PhpXmlRpc_LoggerAwareTestCase extends PhpXmlRpc_PolyfillTestCase
     {
         $this->buffer .= $message . "\n";
     }
+
+    public function warning($message, $context = array())
+    {
+        $this->buffer .= $message . "\n";
+    }
 }