Permalink
Browse files

replaced __METHOD__ with __FUNCTION__ in several statis::_filter call…

…s, and added integration test for filtered logger write
  • Loading branch information...
1 parent 54f228d commit 279d766af8809f6c4b1b88b707653348d43bc958 @svemir svemir committed with nateabele Jan 12, 2011
@@ -109,7 +109,7 @@ public static function write($priority, $message, array $options = array()) {
foreach ($methods as $name => $method) {
$params = compact('priority', 'message', 'options');
$config = static::_config($name);
- $result = $result && static::_filter(__METHOD__, $params, $method, $config['filters']);
+ $result = $result && static::_filter(__FUNCTION__, $params, $method, $config['filters']);
}
return $methods ? $result : false;
}
@@ -187,7 +187,7 @@ protected static function _translated($id, $count, $locale, array $options = arr
$params = compact('id', 'count', 'locale', 'options');
$cache =& static::$_cachedPages;
- return static::_filter(__METHOD__, $params, function($self, $params) use (&$cache) {
+ return static::_filter(__FUNCTION__, $params, function($self, $params) use (&$cache) {
extract($params);
if (!isset($cache[$options['scope']][$locale])) {
@@ -59,7 +59,7 @@ public static function run($group = null, array $options = array()) {
$group = static::_group($items);
$report = static::_report($group, $options);
- return static::_filter(__METHOD__, compact('report'), function($self, $params, $chain) {
+ return static::_filter(__FUNCTION__, compact('report'), function($self, $params, $chain) {
$environment = Environment::get();
Environment::set('test');
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Lithium: the most rad php framework
+ *
+ * @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
+ * @license http://opensource.org/licenses/bsd-license.php The BSD License
+ */
+
+namespace lithium\tests\integration\analysis;
+
+use lithium\analysis\Logger;
+use lithium\util\Collection;
+use lithium\util\collection\Filters;
+
+/**
+ * Logger adapter integration test cases
+ */
+class LoggerTest extends \lithium\test\Unit {
+
+ public function testWriteFilter() {
+
+ $base = LITHIUM_APP_PATH . '/resources/tmp/logs';
+ $this->skipIf(!is_writable($base), "{$base} is not writable.");
+
+ Filters::apply('lithium\analysis\Logger', 'write', function($self, $params, $chain) {
+ $params['message'] = 'Filtered Message';
+
+ return $chain->next($self, $params, $chain);
+ });
+
+ $config = array('default' => array('adapter' => 'File', 'timestamp' => false));
+ Logger::config($config);
+
+ $result = Logger::write('info', 'Original Message');
+ $this->assertTrue(file_exists($base . '/info.log'));
+
+ $expected = "Filtered Message\n";
+ $result = file_get_contents($base . '/info.log');
+ $this->assertEqual($expected, $result);
+
+ unlink($base . '/info.log');
+ }
+
+}
+
+?>

0 comments on commit 279d766

Please sign in to comment.