3 # Copyright 2011 MJ Ray and software.coop
4 # This Koha test module is a stub!
5 # Add more tests here!!!
9 use Test::More tests => 7;
14 use t::lib::Mocks qw/mock_preference/; # to mock CronjobLog
25 # FIXME: are we sure there is an member number 1?
26 # FIXME: can we remove this log entry somehow?
27 logaction("MEMBERS","MODIFY",1,"test operation");
33 ok($success, "logaction seemed to work");
36 # FIXME: US formatted date hardcoded into test for now
37 $success = scalar(@{GetLogs("","","",undef,undef,"","")});
42 ok($success, "GetLogs returns results for an open search");
45 # FIXME: US formatted date hardcoded into test for now
46 my $date = output_pref( { dt => dt_from_string, datenonly => 1, dateformat => 'iso' } );
47 $success = scalar(@{GetLogs( $date, $date, "", undef, undef, "", "") } );
52 ok($success, "GetLogs accepts dates in an All-matching search");
55 $success = scalar(@{GetLogs("","","",["MEMBERS"],["MODIFY"],1,"")});
60 ok($success, "GetLogs seemed to find ".$success." like our test record in a tighter search");
62 # Make sure we can rollback.
63 my $dbh = C4::Context->dbh;
64 $dbh->{AutoCommit} = 0;
65 $dbh->{RaiseError} = 1;
67 # We want numbers to be the same between runs.
68 $dbh->do("DELETE FROM action_logs;");
70 t::lib::Mocks::mock_preference('CronjobLog',0);
72 my $cronJobCount = $dbh->selectrow_array("SELECT COUNT(*) FROM action_logs WHERE module='CRONJOBS';",{});
73 is($cronJobCount,0,"Cronjob not logged as expected.");
75 t::lib::Mocks::mock_preference('CronjobLog',1);
77 $cronJobCount = $dbh->selectrow_array("SELECT COUNT(*) FROM action_logs WHERE module='CRONJOBS';",{});
78 is($cronJobCount,1,"Cronjob logged as expected.");