From bf54aebe290d97e30e3e54f6e52f29dc3c43f853 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Mon, 18 Feb 2019 14:01:44 +0000 Subject: [PATCH] Bug 22363: Add tests Signed-off-by: Andrew Isherwood Signed-off-by: Katrin Fischer --- t/db_dependent/Koha/ActionLogs.t | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 t/db_dependent/Koha/ActionLogs.t diff --git a/t/db_dependent/Koha/ActionLogs.t b/t/db_dependent/Koha/ActionLogs.t new file mode 100644 index 0000000000..894c8afd5d --- /dev/null +++ b/t/db_dependent/Koha/ActionLogs.t @@ -0,0 +1,70 @@ +#!/usr/bin/perl +# This file is part of Koha. +# +# Copyright 2019 Koha Development Team +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Test::More tests => 3; + +use C4::Context; +use C4::Log; +use Koha::Database; + +use t::lib::TestBuilder; + +BEGIN { + use_ok('Koha::ActionLogs'); +} + +my $schema = Koha::Database->new->schema; +my $builder = t::lib::TestBuilder->new; + +subtest 'store() tests' => sub { + plan tests => 2; + + $schema->storage->txn_begin; + + my $logs_count = Koha::ActionLogs->count; + my $log = Koha::ActionLog->new({ + module => 'CIRCULATION', + action => 'ISSUE', + interface => 'intranet', + })->store; + $log->discard_changes; + + is( ref($log), 'Koha::ActionLog', 'Log object creation success'); + is( Koha::ActionLogs->count, $logs_count + 1, 'Exactly one log was saved'); + + $schema->storage->txn_rollback; +}; + +subtest 'search() tests' => sub { + plan tests => 1; + + $schema->storage->txn_begin; + + my $patron1 = $builder->build_object({ + class => 'Koha::Patrons', + }); + + logaction("MEMBERS", "MODIFY", $patron1->borrowernumber, "test"); + + is(Koha::ActionLogs->search({ object => $patron1->borrowernumber })->count, 1, 'search() return right number of action logs'); + + $schema->storage->txn_rollback; +}; + +1; -- 2.11.0