Bugzilla – Attachment 40653 Details for
Bug 14167
Add Koha::Logger based on Log4perl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14167: Add a unit test for Koha::Logger
Bug-14167-Add-a-unit-test-for-KohaLogger.patch (text/plain), 2.05 KB, created by
Marcel de Rooy
on 2015-06-26 12:23:07 UTC
(
hide
)
Description:
Bug 14167: Add a unit test for Koha::Logger
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2015-06-26 12:23:07 UTC
Size:
2.05 KB
patch
obsolete
>From 08d013f71a66c49df7b90f89274b60a0b020f73a Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 26 Jun 2015 14:22:04 +0200 >Subject: [PATCH] Bug 14167: Add a unit test for Koha::Logger >Content-Type: text/plain; charset=utf-8 > >Test plan: >Run the test. >--- > t/Logger.t | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 48 insertions(+) > create mode 100644 t/Logger.t > >diff --git a/t/Logger.t b/t/Logger.t >new file mode 100644 >index 0000000..a375b20 >--- /dev/null >+++ b/t/Logger.t >@@ -0,0 +1,48 @@ >+use Modern::Perl; >+ >+use C4::Context; >+use Koha::Logger; >+ >+use File::Temp qw/tempfile/; >+use Test::MockModule; >+use Test::More tests => 1; >+ >+subtest 'Test01 -- Simple tests for Koha::Logger' => sub { >+ plan tests => 6; >+ test01(); >+}; >+ >+sub test01 { >+ my $mContext = new Test::MockModule('C4::Context'); >+ $mContext->mock( 'config', sub { return; } ); >+ >+ my $logger= Koha::Logger->get; >+ is( exists $logger->{logger}, '', 'No log4perl config'); >+ my $d= $logger->debug('Message 1'); >+ is( $d, undef, 'No return value for debug call'); >+ >+ my $log = mytempfile(); >+ my $conf = mytempfile( <<"HERE" >+log4perl.logger.intranet = WARN, INTRANET >+log4perl.appender.INTRANET=Log::Log4perl::Appender::File >+log4perl.appender.INTRANET.filename=$log >+log4perl.appender.INTRANET.mode=append >+log4perl.appender.INTRANET.layout=PatternLayout >+log4perl.appender.INTRANET.layout.ConversionPattern=[%d] [%p] %m %l %n >+HERE >+ ); >+ $mContext->mock( 'config', sub { return $conf; } ); >+ $logger= Koha::Logger->get({ interface => 'intranet' }); >+ is( exists $logger->{logger}, 1, 'Log4perl config found'); >+ is( $logger->warn('Message 2'), 1, 'Message 2 returned a value' ); >+ is( $logger->catastrophe, undef, 'catastrophe undefined'); >+ system("chmod 400 $log"); >+ is( $logger->warn('Message 3'), undef, 'Message 3 returned undef' ); >+} >+ >+sub mytempfile { >+ my ( $fh, $fn ) = tempfile( SUFFIX => '.logger.test', UNLINK => 1 ); >+ print $fh $_[0]//''; >+ close $fh; >+ return $fn; >+} >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14167
:
38953
|
38954
|
38980
|
38981
|
38993
|
39103
|
39180
|
39886
|
39887
|
39888
|
39889
|
39890
|
39891
|
39892
|
39893
|
39894
|
39895
|
40200
|
40652
|
40653
|
40657
|
40658
|
40659
|
40660
|
40661
|
40662
|
40663
|
40664
|
41109
|
41111
|
41145
|
41146