2 # This file is part of Koha.
4 # Copyright 2019 Koha Development Team
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.
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.
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>.
20 use Test::More tests => 3;
26 use t::lib::TestBuilder;
29 use_ok('Koha::ActionLogs');
32 my $schema = Koha::Database->new->schema;
33 my $builder = t::lib::TestBuilder->new;
35 subtest 'store() tests' => sub {
38 $schema->storage->txn_begin;
40 my $logs_count = Koha::ActionLogs->count;
41 my $log = Koha::ActionLog->new({
42 module => 'CIRCULATION',
44 interface => 'intranet',
46 $log->discard_changes;
48 is( ref($log), 'Koha::ActionLog', 'Log object creation success');
49 is( Koha::ActionLogs->count, $logs_count + 1, 'Exactly one log was saved');
51 $schema->storage->txn_rollback;
54 subtest 'search() tests' => sub {
57 $schema->storage->txn_begin;
59 my $patron1 = $builder->build_object({
60 class => 'Koha::Patrons',
63 logaction("MEMBERS", "MODIFY", $patron1->borrowernumber, "test");
65 is(Koha::ActionLogs->search({ object => $patron1->borrowernumber })->count, 1, 'search() return right number of action logs');
67 $schema->storage->txn_rollback;