Bugzilla – Attachment 40663 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]
[SIGNED-OFF] Bug 14167: Add a unit test for Koha::Logger
SIGNED-OFF-Bug-14167-Add-a-unit-test-for-KohaLogge.patch (text/plain), 2.09 KB, created by
Kyle M Hall (khall)
on 2015-06-26 13:59:51 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 14167: Add a unit test for Koha::Logger
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-06-26 13:59:51 UTC
Size:
2.09 KB
patch
obsolete
>From 25b89715f6352ea0fa8aa5c004e482d38cb8e3fc 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] [SIGNED-OFF] Bug 14167: Add a unit test for Koha::Logger > >Test plan: >Run the test. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/Logger.t | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 48 insertions(+), 0 deletions(-) > 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.2.5
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