Example #1
0
 /**
  * Any logs sent in the GET request will be removed from the data property and added through the Console class.
  * The returned array will be all original key/value pairs minus logs
  *
  * @param array $data
  * @return array
  */
 private function setLogsFromData($data)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         foreach ($data as $key => $value) {
             if ($key == 'logs' && is_array($value)) {
                 foreach ($value as $key => $log) {
                     if (isset($log['type']) && isset($log['message']) && isset($log['file']) && isset($log['line'])) {
                         switch ($log['type']) {
                             case Console::ALERT:
                                 Console::alert($log['message']);
                                 unset($data[$key]);
                                 break;
                             case Console::LOG:
                                 Console::log($log['message'], $log['file'], $log['line']);
                                 unset($data[$key]);
                                 break;
                             case Console::ERROR:
                                 Console::logError($log['message'], $log['file'], $log['line']);
                                 unset($data[$key]);
                                 break;
                             default:
                                 break;
                         }
                     }
                 }
             }
         }
     }
     return $data;
 }
Example #2
0
 /**
  *
  */
 public function testGetAlerts()
 {
     Console::alert('hello');
     $logs = Console::getAlerts();
     $this->assertEquals('hello', $logs[0]['message']);
 }