[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [1223] trunk/t/13-log.t
- Subject: SF.net SVN: ledger-smb: [1223] trunk/t/13-log.t
- From: ..hidden..
- Date: Sat, 19 May 2007 21:41:27 -0700
Revision: 1223
http://svn.sourceforge.net/ledger-smb/?rev=1223&view=rev
Author: tetragon
Date: 2007-05-19 21:41:26 -0700 (Sat, 19 May 2007)
Log Message:
-----------
Adding some tests for LedgerSMB::Log
Added Paths:
-----------
trunk/t/13-log.t
Added: trunk/t/13-log.t
===================================================================
--- trunk/t/13-log.t (rev 0)
+++ trunk/t/13-log.t 2007-05-20 04:41:26 UTC (rev 1223)
@@ -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;
..hidden.. = 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;
..hidden.. = 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');
..hidden.. = trap{LedgerSMB::Log->emerg('test')};
+like($trap->stderr, qr/^\[.*?\] \[emerg\] $$ test/,
+ 'emerg: Outputs correct grouping');
..hidden.. = trap{LedgerSMB::Log->alert('test')};
+like($trap->stderr, qr/^\[.*?\] \[alert\] $$ test/,
+ 'alert: Outputs correct grouping');
..hidden.. = trap{LedgerSMB::Log->crit('test')};
+like($trap->stderr, qr/^\[.*?\] \[crit\] $$ test/,
+ 'crit: Outputs correct grouping');
..hidden.. = trap{LedgerSMB::Log->error('test')};
+like($trap->stderr, qr/^\[.*?\] \[error\] $$ test/,
+ 'error: Outputs correct grouping');
..hidden.. = trap{LedgerSMB::Log->warn('test')};
+like($trap->stderr, qr/^\[.*?\] \[warn\] $$ test/,
+ 'warn: Outputs correct grouping');
..hidden.. = trap{LedgerSMB::Log->notice('test')};
+like($trap->stderr, qr/^\[.*?\] \[notice\] $$ test/,
+ 'notice: Outputs correct grouping');
..hidden.. = trap{LedgerSMB::Log->info('test')};
+like($trap->stderr, qr/^\[.*?\] \[info\] $$ test/,
+ 'info: Outputs correct grouping');
..hidden.. = trap{LedgerSMB::Log->debug('test')};
+like($trap->stderr, qr/^\[.*?\] \[debug\] $$ test/,
+ 'debug: Outputs correct grouping');
..hidden.. = trap{LedgerSMB::Log->dump('test')};
+like($trap->stderr, qr/^\[.*?\] \[debug\] $$ \$VAR1 = 'test'/,
+ 'dump: Simple dump correct');
..hidden.. = trap{LedgerSMB::Log->longmess('test')};
+like($trap->stderr, qr/^\[.*?\] \[debug\] $$ test at /,
+ 'longmess: Outputs correct data');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.