Bug 14285: Bengali locale needs to be re-defined
[koha.git] / t / db_dependent / Log.t
blobcbd893749f6ad8b3be38f237be305685652dc308
1 #!/usr/bin/perl
3 # Copyright 2011 MJ Ray and software.coop
4 # This Koha test module is a stub!
5 # Add more tests here!!!
7 use strict;
8 use warnings;
9 use Test::More tests => 7;
11 # We need C4::Dates to handle the dates
12 use C4::Dates;
13 use C4::Context;
14 use t::lib::Mocks qw/mock_preference/; # to mock CronjobLog
15 use Data::Dumper;
17 $| = 1;
19 BEGIN {
20 use_ok('C4::Log');
22 my $success;
24 eval {
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");
28 $success = 1;
29 } or do {
30 diag($@);
31 $success = 0;
33 ok($success, "logaction seemed to work");
35 eval {
36 # FIXME: US formatted date hardcoded into test for now
37 $success = scalar(@{GetLogs("","","",undef,undef,"","")});
38 } or do {
39 diag($@);
40 $success = 0;
42 ok($success, "GetLogs returns results for an open search");
44 eval {
45 # FIXME: US formatted date hardcoded into test for now
46 my $date = C4::Dates->new();
47 $success = scalar(@{GetLogs($date->today(),$date->today(),"",undef,undef,"","")});
48 } or do {
49 diag($@);
50 $success = 0;
52 ok($success, "GetLogs accepts dates in an All-matching search");
54 eval {
55 $success = scalar(@{GetLogs("","","",["MEMBERS"],["MODIFY"],1,"")});
56 } or do {
57 diag($@);
58 $success = 0;
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);
71 cronlogaction();
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);
76 cronlogaction();
77 $cronJobCount = $dbh->selectrow_array("SELECT COUNT(*) FROM action_logs WHERE module='CRONJOBS';",{});
78 is($cronJobCount,1,"Cronjob logged as expected.");
80 $dbh->rollback();