From 97a9d0a19b1770b0ed05932439e58080f818be11 Mon Sep 17 00:00:00 2001 From: gggeek Date: Mon, 30 Jan 2023 22:37:05 +0000 Subject: [PATCH] add test for deprecation logging --- tests/05LoggerTest.php | 19 +++++++++++++++++++ tests/LoggerAwareTestCase.php | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/tests/05LoggerTest.php b/tests/05LoggerTest.php index 12c10f11..319744f6 100644 --- a/tests/05LoggerTest.php +++ b/tests/05LoggerTest.php @@ -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; + } } diff --git a/tests/LoggerAwareTestCase.php b/tests/LoggerAwareTestCase.php index 4c3051ea..a23d9355 100644 --- a/tests/LoggerAwareTestCase.php +++ b/tests/LoggerAwareTestCase.php @@ -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"; + } } -- 2.47.0