|
Lines 16-22
Link Here
|
| 16 |
|
16 |
|
| 17 |
use Modern::Perl; |
17 |
use Modern::Perl; |
| 18 |
|
18 |
|
| 19 |
use Test::More tests => 4; |
19 |
use Test::More tests => 3; |
| 20 |
|
20 |
|
| 21 |
use t::lib::Mocks qw(mock_preference); |
21 |
use t::lib::Mocks qw(mock_preference); |
| 22 |
use t::lib::TestBuilder; |
22 |
use t::lib::TestBuilder; |
|
Lines 33-44
use Koha::Old::Holds;
Link Here
|
| 33 |
use Koha::Patrons; |
33 |
use Koha::Patrons; |
| 34 |
|
34 |
|
| 35 |
BEGIN { |
35 |
BEGIN { |
| 36 |
use_ok('C4::UsageStats', qw( NeedUpdate BuildReport ReportToCommunity _count )); |
36 |
use_ok('C4::UsageStats', qw( BuildReport ReportToCommunity _count )); |
| 37 |
} |
37 |
} |
| 38 |
|
38 |
|
| 39 |
can_ok( |
39 |
can_ok( |
| 40 |
'C4::UsageStats', qw( |
40 |
'C4::UsageStats', qw( |
| 41 |
NeedUpdate |
|
|
| 42 |
BuildReport |
41 |
BuildReport |
| 43 |
ReportToCommunity |
42 |
ReportToCommunity |
| 44 |
_count ) |
43 |
_count ) |
|
Lines 47-71
can_ok(
Link Here
|
| 47 |
my $builder = t::lib::TestBuilder->new; |
46 |
my $builder = t::lib::TestBuilder->new; |
| 48 |
my $schema = Koha::Database->new->schema; |
47 |
my $schema = Koha::Database->new->schema; |
| 49 |
|
48 |
|
| 50 |
subtest 'NeedUpdate() tests' => sub { |
|
|
| 51 |
|
| 52 |
plan tests => 2; |
| 53 |
|
| 54 |
#Mocking C4::Context->preference("UsageStatsLastUpdateTime") to 0 |
| 55 |
my $now = strftime( "%s", localtime ); |
| 56 |
t::lib::Mocks::mock_preference( "UsageStatsLastUpdateTime", 0 ); |
| 57 |
|
| 58 |
my $update = C4::UsageStats->NeedUpdate; |
| 59 |
is( $update, 1, "There is no last update, update needed" ); |
| 60 |
|
| 61 |
#Mocking C4::Context->preference("UsageStatsLastUpdateTime") to now |
| 62 |
$now = strftime( "%s", localtime ); |
| 63 |
t::lib::Mocks::mock_preference( "UsageStatsLastUpdateTime", $now ); |
| 64 |
|
| 65 |
$update = C4::UsageStats->NeedUpdate; |
| 66 |
is( $update, 0, "Last update just be done, no update needed " ); |
| 67 |
}; |
| 68 |
|
| 69 |
subtest 'BuildReport() tests' => sub { |
49 |
subtest 'BuildReport() tests' => sub { |
| 70 |
|
50 |
|
| 71 |
plan tests => 30; |
51 |
plan tests => 30; |
| 72 |
- |
|
|