View | Details | Raw Unified | Return to bug 15939
Collapse All | Expand All

(-)a/C4/Log.pm (-2 / +2 lines)
Lines 220-227 sub GetLogs { Link Here
220
    my $object   = shift;
220
    my $object   = shift;
221
    my $info     = shift;
221
    my $info     = shift;
222
   
222
   
223
    my $iso_datefrom = output_pref({ dt => dt_from_string( $datefrom ), dateformat => 'iso', dateonly => 1 });
223
    my $iso_datefrom = $datefrom ? output_pref({ dt => dt_from_string( $datefrom ), dateformat => 'iso', dateonly => 1 }) : undef;
224
    my $iso_dateto = output_pref({ dt => dt_from_string( $dateto ), dateformat => 'iso', dateonly => 1 });
224
    my $iso_dateto = $dateto ? output_pref({ dt => dt_from_string( $dateto ), dateformat => 'iso', dateonly => 1 }) : undef;
225
225
226
    my $dbh = C4::Context->dbh;
226
    my $dbh = C4::Context->dbh;
227
    my $query = "
227
    my $query = "
(-)a/t/db_dependent/Log.t (-4 / +18 lines)
Lines 4-12 Link Here
4
# This Koha test module is a stub!  
4
# This Koha test module is a stub!  
5
# Add more tests here!!!
5
# Add more tests here!!!
6
6
7
use strict;
7
use Modern::Perl;
8
use warnings;
8
use Test::More tests => 8;
9
use Test::More tests => 7;
10
9
11
use C4::Context;
10
use C4::Context;
12
use Koha::DateUtils;
11
use Koha::DateUtils;
Lines 77-80 cronlogaction(); Link Here
77
$cronJobCount = $dbh->selectrow_array("SELECT COUNT(*) FROM action_logs WHERE module='CRONJOBS';",{});
76
$cronJobCount = $dbh->selectrow_array("SELECT COUNT(*) FROM action_logs WHERE module='CRONJOBS';",{});
78
is($cronJobCount,1,"Cronjob logged as expected.");
77
is($cronJobCount,1,"Cronjob logged as expected.");
79
78
79
subtest "GetLogs should return all logs if dates are not set" => sub {
80
    plan tests => 2;
81
    my $today = dt_from_string->add(minutes => -1);
82
    my $yesterday = dt_from_string->add( days => -1 );
83
    $dbh->do(q|
84
        INSERT INTO action_logs (timestamp, user, module, action, object, info)
85
        VALUES
86
        (?, 42, 'CATALOGUING', 'MODIFY', 4242, 'Record 42 has been modified by patron 4242 yesterday'),
87
        (?, 43, 'CATALOGUING', 'MODIFY', 4242, 'Record 43 has been modified by patron 4242 today')
88
    |, undef, output_pref({dt =>$yesterday, dateformat => 'iso'}), output_pref({dt => $today, dateformat => 'iso'}));
89
    my $logs = GetLogs( undef, undef, undef, ['CATALOGUING'], ['MODIFY'], 4242 );
90
    is( scalar(@$logs), 2, 'GetLogs should return all logs regardless the dates' );
91
    $logs = GetLogs( output_pref($today), undef, undef, ['CATALOGUING'], ['MODIFY'], 4242 );
92
    is( scalar(@$logs), 1, 'GetLogs should return the logs for today' );
93
};
94
80
$dbh->rollback();
95
$dbh->rollback();
81
- 

Return to bug 15939