|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
include_once __DIR__ . '/../lib/xmlrpc.inc'; |
|
4
|
|
|
include_once __DIR__ . '/../lib/xmlrpcs.inc'; |
|
5
|
|
|
|
|
6
|
|
|
include_once __DIR__ . '/parse_args.php'; |
|
7
|
|
|
|
|
8
|
|
|
include_once __DIR__ . '/PolyfillTestCase.php'; |
|
9
|
|
|
|
|
10
|
|
|
use PHPUnit\Runner\BaseTestRunner; |
|
11
|
|
|
|
|
12
|
|
|
abstract class PhpXmlRpc_LoggerAwareTestCase extends PhpXmlRpc_PolyfillTestCase |
|
13
|
|
|
{ |
|
14
|
|
|
protected $args = array(); |
|
15
|
|
|
|
|
16
|
|
|
protected $buffer = ''; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Hide debug messages and errors unless we either are in debug mode or the test fails. |
|
20
|
|
|
* @return void |
|
21
|
|
|
*/ |
|
22
|
|
|
protected function set_up() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->args = argParser::getArgs(); |
|
25
|
|
|
|
|
26
|
|
|
if ($this->args['DEBUG'] == 0) { |
|
27
|
|
|
$this->debugBuffer = ''; |
|
|
|
|
|
|
28
|
|
|
$this->errorBuffer = ''; |
|
|
|
|
|
|
29
|
|
|
\PhpXmlRpc\PhpXmlRpc::setLogger($this); |
|
30
|
|
|
} |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
protected function tear_down() |
|
34
|
|
|
{ |
|
35
|
|
|
if ($this->args['DEBUG'] > 0) { |
|
36
|
|
|
return; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
// reset the logger to the default |
|
40
|
|
|
\PhpXmlRpc\PhpXmlRpc::setLogger(\PhpXmlRpc\Helper\Logger::instance()); |
|
41
|
|
|
|
|
42
|
|
|
$status = $this->getStatus(); |
|
43
|
|
|
if ($status == BaseTestRunner::STATUS_ERROR |
|
44
|
|
|
|| $status == BaseTestRunner::STATUS_FAILURE) { |
|
45
|
|
|
echo $this->buffer; |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
// logger API implementation |
|
50
|
|
|
|
|
51
|
|
|
public function debug($message, $context = array()) |
|
|
|
|
|
|
52
|
|
|
{ |
|
53
|
|
|
$this->buffer .= $message . "\n"; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function error($message, $context = array()) |
|
|
|
|
|
|
57
|
|
|
{ |
|
58
|
|
|
$this->buffer .= $message . "\n"; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function warning($message, $context = array()) |
|
|
|
|
|
|
62
|
|
|
{ |
|
63
|
|
|
$this->buffer .= $message . "\n"; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|