lithium\test\Unit::_message()
Returns a basic message for the data returned from _result()
.
Parameters
-
array
$data
The data to use for creating the message.
-
string
$message
The string prepended to the generate message in the current scope.
Returns
stringSource
protected function _message(&$data = [], $message = null) {
if (!empty($data[0])) {
foreach ($data as $key => $value) {
$message = (!empty($data[$key][0])) ? $message : null;
$message .= $this->_message($value, $message);
unset($data[$key]);
}
return $message;
}
$defaults = ['trace' => null, 'expected' => null, 'result' => null];
$data = (array) $data + $defaults;
$message = null;
if (!empty($data['trace'])) {
$message = sprintf("trace: %s\n", $data['trace']);
}
if (is_object($data['expected'])) {
$data['expected'] = get_object_vars($data['expected']);
}
if (is_object($data['result'])) {
$data['result'] = get_object_vars($data['result']);
}
return $message . sprintf("expected: %s\nresult: %s\n",
print_r($data['expected'], true),
print_r($data['result'], true)
);
}