Browse Source

Add test.

Mark Scherer 11 years ago
parent
commit
a5885a9caa
1 changed files with 39 additions and 0 deletions
  1. 39 0
      tests/TestCase/Log/LogTest.php

+ 39 - 0
tests/TestCase/Log/LogTest.php

@@ -369,6 +369,45 @@ class LogTest extends TestCase
     }
 
     /**
+     * Test scoped logging without the default loggers catching everything
+     *
+     * @return void
+     */
+    public function testScopedLoggingStrict()
+    {
+        $this->_deleteLogs();
+
+        Log::config('debug', [
+            'engine' => 'File',
+            'path' => LOGS,
+            'types' => ['notice', 'info', 'debug'],
+            'file' => 'debug',
+            'scopes' => false
+        ]);
+        Log::config('shops', [
+            'engine' => 'File',
+            'path' => LOGS,
+            'types' => ['info', 'debug', 'warning'],
+            'file' => 'shops',
+            'scopes' => ['transactions', 'orders'],
+        ]);
+
+        Log::write('debug', 'debug message');
+        $this->assertFileNotExists(LOGS . 'shops.log');
+        $this->assertFileExists(LOGS . 'debug.log');
+
+        $this->_deleteLogs();
+
+        Log::write('debug', 'debug message', 'orders');
+        $this->assertFileExists(LOGS . 'shops.log');
+        $this->assertFileNotExists(LOGS . 'debug.log');
+
+        $this->_deleteLogs();
+
+        Log::drop('shops');
+    }
+
+    /**
      * test scoped logging with convenience methods
      */
     public function testConvenienceScopedLogging()