Skip to content
Permalink
Browse files

Switch `types` for `levels` in the LogTest

  • Loading branch information...
HavokInspiration committed Jan 4, 2017
1 parent 1a250ac commit 44a1f2d1c18ac77cc60f72150aff0cf97ff60ac8
Showing with 59 additions and 11 deletions.
  1. +59 −11 tests/TestCase/Log/LogTest.php
@@ -245,6 +245,54 @@ public function testLogFileWriting()
* @return void
*/
public function testSelectiveLoggingByLevel()
{
if (file_exists(LOGS . 'spam.log')) {
unlink(LOGS . 'spam.log');
}
if (file_exists(LOGS . 'eggs.log')) {
unlink(LOGS . 'eggs.log');
}
Log::config('spam', [
'engine' => 'File',
'path' => LOGS,
'levels' => 'debug',
'file' => 'spam',
]);
Log::config('eggs', [
'engine' => 'File',
'path' => LOGS,
'levels' => ['eggs', 'debug', 'error', 'warning'],
'file' => 'eggs',
]);
$testMessage = 'selective logging';
Log::write('warning', $testMessage);
$this->assertFileExists(LOGS . 'eggs.log');
$this->assertFileNotExists(LOGS . 'spam.log');
Log::write('debug', $testMessage);
$this->assertFileExists(LOGS . 'spam.log');
$contents = file_get_contents(LOGS . 'spam.log');
$this->assertContains('Debug: ' . $testMessage, $contents);
$contents = file_get_contents(LOGS . 'eggs.log');
$this->assertContains('Debug: ' . $testMessage, $contents);
if (file_exists(LOGS . 'spam.log')) {
unlink(LOGS . 'spam.log');
}
if (file_exists(LOGS . 'eggs.log')) {
unlink(LOGS . 'eggs.log');
}
}
/**
* test selective logging by level using the `types` attribute
*
* @return void
*/
public function testSelectiveLoggingByLevelUsingTypes()
{
if (file_exists(LOGS . 'spam.log')) {
unlink(LOGS . 'spam.log');
@@ -292,13 +340,13 @@ protected function _resetLogConfig()
Log::config('debug', [
'engine' => 'File',
'path' => LOGS,
'types' => ['notice', 'info', 'debug'],
'levels' => ['notice', 'info', 'debug'],
'file' => 'debug',
]);
Log::config('error', [
'engine' => 'File',
'path' => LOGS,
'types' => ['warning', 'error', 'critical', 'alert', 'emergency'],
'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
'file' => 'error',
]);
}
@@ -337,7 +385,7 @@ public function testScopedLogging()
Log::config('shops', [
'engine' => 'File',
'path' => LOGS,
'types' => ['info', 'debug', 'warning'],
'levels' => ['info', 'debug', 'warning'],
'scopes' => ['transactions', 'orders'],
'file' => 'shops',
]);
@@ -378,14 +426,14 @@ public function testScopedLoggingStrict()
Log::config('debug', [
'engine' => 'File',
'path' => LOGS,
'types' => ['notice', 'info', 'debug'],
'levels' => ['notice', 'info', 'debug'],
'file' => 'debug',
'scopes' => false
]);
Log::config('shops', [
'engine' => 'File',
'path' => LOGS,
'types' => ['info', 'debug', 'warning'],
'levels' => ['info', 'debug', 'warning'],
'file' => 'shops',
'scopes' => ['transactions', 'orders'],
]);
@@ -424,7 +472,7 @@ public function testConvenienceScopedLogging()
Log::config('shops', [
'engine' => 'File',
'path' => LOGS,
'types' => ['info', 'debug', 'notice', 'warning'],
'levels' => ['info', 'debug', 'notice', 'warning'],
'scopes' => ['transactions', 'orders'],
'file' => 'shops',
]);
@@ -465,14 +513,14 @@ public function testScopedLoggingExclusive()
Log::config('shops', [
'engine' => 'File',
'path' => LOGS,
'types' => ['debug', 'notice', 'warning'],
'levels' => ['debug', 'notice', 'warning'],
'scopes' => ['transactions', 'orders'],
'file' => 'shops.log',
]);
Log::config('eggs', [
'engine' => 'File',
'path' => LOGS,
'types' => ['debug', 'notice', 'warning'],
'levels' => ['debug', 'notice', 'warning'],
'scopes' => ['eggs'],
'file' => 'eggs.log',
]);
@@ -500,7 +548,7 @@ public function testPassingScopeToEngine()
Log::config('scope_test', [
'engine' => 'TestApp',
'path' => LOGS,
'types' => ['notice', 'info', 'debug'],
'levels' => ['notice', 'info', 'debug'],
'scopes' => ['foo', 'bar'],
]);
@@ -527,13 +575,13 @@ public function testConvenienceMethods()
Log::config('debug', [
'engine' => 'File',
'path' => LOGS,
'types' => ['notice', 'info', 'debug'],
'levels' => ['notice', 'info', 'debug'],
'file' => 'debug',
]);
Log::config('error', [
'engine' => 'File',
'path' => LOGS,
'types' => ['emergency', 'alert', 'critical', 'error', 'warning'],
'levels' => ['emergency', 'alert', 'critical', 'error', 'warning'],
'file' => 'error',
]);

0 comments on commit 44a1f2d

Please sign in to comment.
You can’t perform that action at this time.