Permalink
Browse files

Updating LogPanel so it doesn't clobber the automagic log configurati…

…on when it creates its own listener. Test case added.
  • Loading branch information...
1 parent 3703e57 commit 78fd15e76e24fa719877956b6812b8f1d2189859 @markstory markstory committed Jun 27, 2010
Showing with 24 additions and 1 deletion.
  1. +6 −0 controllers/components/toolbar.php
  2. +18 −1 tests/cases/controllers/components/toolbar.test.php
@@ -585,6 +585,12 @@ function __construct($settings) {
if (!class_exists('CakeLog')) {
App::import('Core', 'CakeLog');
}
+ $existing = CakeLog::configured();
+ if (empty($existing)) {
+ CakeLog::config('default', array(
+ 'engine' => 'FileLog'
+ ));
+ }
CakeLog::config('debug_kit_log_panel', array(
'engine' => 'DebugKitLogListener',
'panel' => $this
@@ -453,6 +453,24 @@ function testLogPanel() {
$this->assertPattern('/\[created\] => 2009-11-07 23:23:23/', $result['content']['error'][2][1]);
$this->assertPattern('/\[Comment\] => Array/', $result['content']['error'][2][1]);
}
+
+/**
+ * test that creating the log panel creates the default file logger if none
+ * are configured. This stops DebugKit from mucking with the default auto-magic log config
+ *
+ * @return void
+ */
+ function testLogPanelConstructCreatingDefaultLogConfiguration() {
+ CakeLog::drop('default');
+ CakeLog::drop('debug_kit_log_panel');
+
+ $panel =& new LogPanel(array());
+ $configured = CakeLog::configured();
+
+ $this->assertTrue(in_array('default', $configured));
+ $this->assertTrue(in_array('debug_kit_log_panel', $configured));
+ }
+
/**
* Test that history state urls set prefix = null and admin = null so generated urls do not
* adopt these params.
@@ -550,4 +568,3 @@ function testSqlLogPanel() {
$this->assertTrue(isset($result['content']['threshold']));
}
}
-?>

0 comments on commit 78fd15e

Please sign in to comment.