From 1478751f3ef62544fe9feb40d6048196e7036370 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Fri, 3 Mar 2017 16:43:14 +0200 Subject: [PATCH] Bug 18205: Unit tests To test: 1. prove t/db_dependent/Log.t --- t/db_dependent/Log.t | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Log.t b/t/db_dependent/Log.t index dbdf0e2..f96b439 100644 --- a/t/db_dependent/Log.t +++ b/t/db_dependent/Log.t @@ -93,7 +93,7 @@ subtest "GetLogs should return all logs if dates are not set" => sub { subtest 'logaction(): interface is correctly logged' => sub { - plan tests => 4; + plan tests => 5; # No interface passed, using C4::Context->interface $dbh->do("DELETE FROM action_logs;"); @@ -122,11 +122,19 @@ subtest 'logaction(): interface is correctly logged' => sub { logaction( "MEMBERS", "MODIFY", 1, 'test info', 'sip'); $logs = GetLogs(); is( @{$logs}[0]->{ interface }, 'sip', 'Passed interface is respected (sip)'); + + # Explicit interfaces + $dbh->do("DELETE FROM action_logs;"); + C4::Context->interface( 'rest' ); + logaction( "MEMBERS", "MODIFY", 1, 'test info', 'rest'); + $logs = GetLogs(); + is( @{$logs}[0]->{ interface }, 'rest', 'Passed interface is respected (rest)'); + }; subtest 'GetLogs() respects interface filters' => sub { - plan tests => 5; + plan tests => 6; $dbh->do("DELETE FROM action_logs;"); @@ -134,9 +142,10 @@ subtest 'GetLogs() respects interface filters' => sub { logaction( 'MEMBERS', 'MODIFY', 1, 'sip info', 'sip'); logaction( 'MEMBERS', 'MODIFY', 1, 'intranet info', 'intranet'); logaction( 'MEMBERS', 'MODIFY', 1, 'commandline info', 'commandline'); + logaction( 'MEMBERS', 'MODIFY', 1, 'rest info', 'rest'); my $logs = scalar @{ GetLogs() }; - is( $logs, 4, 'If no filter on interfaces is passed, all logs are returned'); + is( $logs, 5, '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)'); @@ -149,6 +158,10 @@ subtest 'GetLogs() respects interface filters' => sub { $logs = GetLogs(undef,undef,undef,undef,undef,undef,undef,['commandline']); is( @{$logs}[0]->{ interface }, 'commandline', 'Interface correctly filtered (commandline)'); + + $logs = GetLogs(undef,undef,undef,undef,undef,undef,undef,['rest']); + is( @{$logs}[0]->{ interface }, 'rest', 'Interface correctly filtered (rest)'); + }; $schema->storage->txn_rollback; -- 2.7.4