summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-20 04:41:26 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-20 04:41:26 +0000
commit979ebcc1fb4704f95e6e362db497ceba53770cfc (patch)
tree7f46346531b36a30d2b7d3d57cf0eae4c702cb86 /t
parent2e7f04b73c73bc5726c0835b881a2b155c5c2ede (diff)
Adding some tests for LedgerSMB::Log
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1223 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 't')
-rw-r--r--t/13-log.t58
1 files changed, 58 insertions, 0 deletions
diff --git a/t/13-log.t b/t/13-log.t
new file mode 100644
index 00000000..f055f800
--- /dev/null
+++ b/t/13-log.t
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+$ENV{TMPDIR} = 't/var';
+
+use Test::More tests => 13;
+use Test::Trap qw(trap $trap);
+
+use Data::Dumper;
+
+use LedgerSMB::Sysconfig;
+use LedgerSMB::Log;
+
+my @r;
+
+$LedgerSMB::Sysconfig::logging = 0;
+@r = trap{LedgerSMB::Log->print('test', 'message')};
+#is(LedgerSMB::Log->print('test', 'message'), 0);
+ok(!$trap->stderr,
+ 'print: Unsetting LedgerSMB::Sysconfig::logging disables printing');
+$LedgerSMB::Sysconfig::logging = 1;
+@r = trap{LedgerSMB::Log->print('test', 'message')};
+ok($trap->stderr,
+ 'print: Setting LedgerSMB::Sysconfig::logging enables printing');
+like($trap->stderr, qr/^\[.*?\] \[test\] $$ message/,
+ 'print: Outputs correct message');
+@r = trap{LedgerSMB::Log->emerg('test')};
+like($trap->stderr, qr/^\[.*?\] \[emerg\] $$ test/,
+ 'emerg: Outputs correct grouping');
+@r = trap{LedgerSMB::Log->alert('test')};
+like($trap->stderr, qr/^\[.*?\] \[alert\] $$ test/,
+ 'alert: Outputs correct grouping');
+@r = trap{LedgerSMB::Log->crit('test')};
+like($trap->stderr, qr/^\[.*?\] \[crit\] $$ test/,
+ 'crit: Outputs correct grouping');
+@r = trap{LedgerSMB::Log->error('test')};
+like($trap->stderr, qr/^\[.*?\] \[error\] $$ test/,
+ 'error: Outputs correct grouping');
+@r = trap{LedgerSMB::Log->warn('test')};
+like($trap->stderr, qr/^\[.*?\] \[warn\] $$ test/,
+ 'warn: Outputs correct grouping');
+@r = trap{LedgerSMB::Log->notice('test')};
+like($trap->stderr, qr/^\[.*?\] \[notice\] $$ test/,
+ 'notice: Outputs correct grouping');
+@r = trap{LedgerSMB::Log->info('test')};
+like($trap->stderr, qr/^\[.*?\] \[info\] $$ test/,
+ 'info: Outputs correct grouping');
+@r = trap{LedgerSMB::Log->debug('test')};
+like($trap->stderr, qr/^\[.*?\] \[debug\] $$ test/,
+ 'debug: Outputs correct grouping');
+@r = trap{LedgerSMB::Log->dump('test')};
+like($trap->stderr, qr/^\[.*?\] \[debug\] $$ \$VAR1 = 'test'/,
+ 'dump: Simple dump correct');
+@r = trap{LedgerSMB::Log->longmess('test')};
+like($trap->stderr, qr/^\[.*?\] \[debug\] $$ test at /,
+ 'longmess: Outputs correct data');