| Total Complexity | 9 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 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 |
||
| 50 | |||
| 51 | public function debug($message, $context = array()) |
||
| 52 | { |
||
| 53 | $this->buffer .= $message . "\n"; |
||
| 54 | } |
||
| 55 | |||
| 56 | public function error($message, $context = array()) |
||
| 59 | } |
||
| 60 | |||
| 61 | public function warning($message, $context = array()) |
||
| 62 | { |
||
| 66 |