Bugzilla – Attachment 53203 Details for
Bug 16829
action_logs should have an 'interface' column
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16829: Unit tests for logaction's 'interface parameter'
Bug-16829-Unit-tests-for-logactions-interface-para.patch (text/plain), 3.82 KB, created by
Nicole C. Engard
on 2016-07-07 19:19:41 UTC
(
hide
)
Description:
Bug 16829: Unit tests for logaction's 'interface parameter'
Filename:
MIME Type:
Creator:
Nicole C. Engard
Created:
2016-07-07 19:19:41 UTC
Size:
3.82 KB
patch
obsolete
>From 2a38d5e04b878003bad01b2307fce5c918739a37 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 1 Jul 2016 18:53:00 -0300 >Subject: [PATCH] Bug 16829: Unit tests for logaction's 'interface parameter' > >This patch introduces tests for the new 'interface' parameter for the >C4::Log::logaction and C4::Log::GetLogs functions. > >In logaction, it falls back to C4::Context->interface if ommited. > >To test: >- Run > $ prove t/db_dependent/Log.t >=> SUCCESS: Tests pass >- Sign off > >Sponsored-by: NEKLS > >Signed-off-by: Nicole C Engard <nengard@bywatersolutions.com> >--- > t/db_dependent/Log.t | 69 +++++++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 66 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Log.t b/t/db_dependent/Log.t >index 3904cf0..3d878bd 100644 >--- a/t/db_dependent/Log.t >+++ b/t/db_dependent/Log.t >@@ -5,13 +5,12 @@ > # Add more tests here!!! > > use Modern::Perl; >-use Test::More tests => 8; >+use Test::More tests => 10; > > use C4::Context; > use Koha::DateUtils; > > use t::lib::Mocks qw/mock_preference/; # to mock CronjobLog >-use Data::Dumper; > > $| = 1; > >@@ -92,4 +91,68 @@ subtest "GetLogs should return all logs if dates are not set" => sub { > is( scalar(@$logs), 1, 'GetLogs should return the logs for today' ); > }; > >-$dbh->rollback(); >+subtest 'logaction(): interface is correctly logged' => sub { >+ >+ plan tests => 4; >+ >+ # No interface passed, using C4::Context->interface >+ $dbh->do("DELETE FROM action_logs;"); >+ C4::Context->interface( 'commandline' ); >+ logaction( "MEMBERS", "MODIFY", 1, "test operation"); >+ my $logs = GetLogs(); >+ is( @{$logs}[0]->{ interface }, 'commandline', 'Interface correctly deduced (commandline)'); >+ >+ # No interface passed, using C4::Context->interface >+ $dbh->do("DELETE FROM action_logs;"); >+ C4::Context->interface( 'opac' ); >+ logaction( "MEMBERS", "MODIFY", 1, "test operation"); >+ $logs = GetLogs(); >+ is( @{$logs}[0]->{ interface }, 'opac', 'Interface correctly deduced (opac)'); >+ >+ # Explicit interfaces >+ $dbh->do("DELETE FROM action_logs;"); >+ C4::Context->interface( 'intranet' ); >+ logaction( "MEMBERS", "MODIFY", 1, 'test info', 'intranet'); >+ $logs = GetLogs(); >+ is( @{$logs}[0]->{ interface }, 'intranet', 'Passed interface is respected (intranet)'); >+ >+ # Explicit interfaces >+ $dbh->do("DELETE FROM action_logs;"); >+ C4::Context->interface( 'sip' ); >+ logaction( "MEMBERS", "MODIFY", 1, 'test info', 'sip'); >+ $logs = GetLogs(); >+ is( @{$logs}[0]->{ interface }, 'sip', 'Passed interface is respected (sip)'); >+ >+ $dbh->rollback; >+}; >+ >+subtest 'GetLogs() respects interface filters' => sub { >+ >+ plan tests => 5; >+ >+ $dbh->do("DELETE FROM action_logs;"); >+ >+ logaction( 'MEMBERS', 'MODIFY', 1, 'opac info', 'opac'); >+ logaction( 'MEMBERS', 'MODIFY', 1, 'sip info', 'sip'); >+ logaction( 'MEMBERS', 'MODIFY', 1, 'intranet info', 'intranet'); >+ logaction( 'MEMBERS', 'MODIFY', 1, 'commandline info', 'commandline'); >+ >+ my $logs = scalar @{ GetLogs() }; >+ is( $logs, 4, 'If no filter on interfaces is passed, all logs are returned'); >+ >+ $logs = GetLogs(undef,undef,undef,undef,undef,undef,undef,['opac']); >+ is( @{$logs}[0]->{ interface }, 'opac', 'Interface correctly filtered (opac)'); >+ >+ $logs = GetLogs(undef,undef,undef,undef,undef,undef,undef,['sip']); >+ is( @{$logs}[0]->{ interface }, 'sip', 'Interface correctly filtered (sip)'); >+ >+ $logs = GetLogs(undef,undef,undef,undef,undef,undef,undef,['intranet']); >+ is( @{$logs}[0]->{ interface }, 'intranet', 'Interface correctly filtered (intranet)'); >+ >+ $logs = GetLogs(undef,undef,undef,undef,undef,undef,undef,['commandline']); >+ is( @{$logs}[0]->{ interface }, 'commandline', 'Interface correctly filtered (commandline)'); >+ >+ $dbh->rollback; >+}; >+ >+$dbh->rollback; >-- >2.1.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 16829
:
53060
|
53061
|
53062
|
53063
|
53064
|
53199
|
53200
|
53201
|
53202
|
53203
|
54294
|
54295
|
54296
|
54297
|
54298