Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
# This file is part of Koha. |
3 |
# |
4 |
# Copyright 2019 Koha Development Team |
5 |
# |
6 |
# Koha is free software; you can redistribute it and/or modify it |
7 |
# under the terms of the GNU General Public License as published by |
8 |
# the Free Software Foundation; either version 3 of the License, or |
9 |
# (at your option) any later version. |
10 |
# |
11 |
# Koha is distributed in the hope that it will be useful, but |
12 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
# GNU General Public License for more details. |
15 |
# |
16 |
# You should have received a copy of the GNU General Public License |
17 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
|
19 |
use Modern::Perl; |
20 |
use Test::More tests => 3; |
21 |
|
22 |
use C4::Context; |
23 |
use C4::Log; |
24 |
use Koha::Database; |
25 |
|
26 |
use t::lib::TestBuilder; |
27 |
|
28 |
BEGIN { |
29 |
use_ok('Koha::ActionLogs'); |
30 |
} |
31 |
|
32 |
my $schema = Koha::Database->new->schema; |
33 |
my $builder = t::lib::TestBuilder->new; |
34 |
|
35 |
subtest 'store() tests' => sub { |
36 |
plan tests => 2; |
37 |
|
38 |
$schema->storage->txn_begin; |
39 |
|
40 |
my $logs_count = Koha::ActionLogs->count; |
41 |
my $log = Koha::ActionLog->new({ |
42 |
module => 'CIRCULATION', |
43 |
action => 'ISSUE', |
44 |
interface => 'intranet', |
45 |
})->store; |
46 |
$log->discard_changes; |
47 |
|
48 |
is( ref($log), 'Koha::ActionLog', 'Log object creation success'); |
49 |
is( Koha::ActionLogs->count, $logs_count + 1, 'Exactly one log was saved'); |
50 |
|
51 |
$schema->storage->txn_rollback; |
52 |
}; |
53 |
|
54 |
subtest 'search() tests' => sub { |
55 |
plan tests => 1; |
56 |
|
57 |
$schema->storage->txn_begin; |
58 |
|
59 |
my $patron1 = $builder->build_object({ |
60 |
class => 'Koha::Patrons', |
61 |
}); |
62 |
|
63 |
logaction("MEMBERS", "MODIFY", $patron1->borrowernumber, "test"); |
64 |
|
65 |
is(Koha::ActionLogs->search({ object => $patron1->borrowernumber })->count, 1, 'search() return right number of action logs'); |
66 |
|
67 |
$schema->storage->txn_rollback; |
68 |
}; |
69 |
|
70 |
1; |