Browse Source

Bug 23971: (follow-up) Add unit tests

This commit adds unit tests for the logging done in Acquisitions.pm

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Andrew Isherwood 4 years ago
committed by Jonathan Druart
parent
commit
e7aeda0e34
  1. 28
      t/db_dependent/Acquisition.t

28
t/db_dependent/Acquisition.t

@ -19,7 +19,7 @@ use Modern::Perl;
use POSIX qw(strftime);
use Test::More tests => 66;
use Test::More tests => 73;
use t::lib::Mocks;
use Koha::Database;
use Koha::DateUtils qw(dt_from_string output_pref);
@ -125,6 +125,8 @@ sub _check_fields_of_orders {
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
t::lib::Mocks::mock_preference('AcqLog', 1);
# Creating some orders
my $bookseller = Koha::Acquisition::Bookseller->new(
{
@ -148,6 +150,9 @@ ok(
);
ok( $basket = GetBasket($basketno), "GetBasket($basketno) returns $basket" );
my @create_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'ADD_BASKET', object => $basketno });
ok( scalar @create_logs == 1, 'Basket creation is logged');
my $bpid=AddBudgetPeriod({
budget_period_startdate => '2008-01-01'
, budget_period_enddate => '2008-12-31'
@ -411,6 +416,27 @@ $search_orders = SearchOrders({
});
is( scalar (@$search_orders), 4, "SearchOrders with pending and ordered params gets only pending ordered orders. After closing the basket, orders are marked as 'ordered' (bug 11170)" );
my @close_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'CLOSE_BASKET', object => $basketno });
ok( scalar @close_logs == 1, 'Basket closure is logged');
C4::Acquisition::ReopenBasket($basketno);
my @reopen_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'REOPEN_BASKET', object => $basketno });
ok( scalar @reopen_logs == 1, 'Basket reopen is logged');
C4::Acquisition::CloseBasket($basketno, 1);
my @approve_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'APPROVE_BASKET', object => $basketno });
ok( scalar @approve_logs == 1, 'Basket approval is logged');
C4::Acquisition::ModBasket({
basketno => $basketno,
booksellerid => $booksellerid
});
my @mod_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET', object => $basketno });
ok( scalar @mod_logs == 1, 'Basket modify is logged');
C4::Acquisition::ModBasketHeader($basketno,"Test","","","",$booksellerid);
my @mod_header_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET_HEADER', object => $basketno });
ok( scalar @mod_header_logs == 1, 'Basket header modify is logged');
C4::Acquisition::ModBasketUsers($basketno,(1));
my @mod_users_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET_USERS', object => $basketno });
ok( scalar @mod_users_logs == 1, 'Basket users modify is logged');
#
# Test AddClaim
#

Loading…
Cancel
Save