@@ -, +, @@ - Move basket closure logging from C4::Acquisision::CloseBasket to Koha::Acquisition::Basket::close - Move basket closure unit test from t/db_dependent/Acquisition.t to --- Koha/Acquisition/Basket.pm | 10 ++++++++++ t/db_dependent/Acquisition.t | 7 +------ t/db_dependent/Koha/Acquisition/Basket.t | 9 ++++++++- 3 files changed, 19 insertions(+), 7 deletions(-) --- a/Koha/Acquisition/Basket.pm +++ a/Koha/Acquisition/Basket.pm @@ -25,6 +25,7 @@ use Koha::Acquisition::BasketGroups; use Koha::Acquisition::Orders; use Koha::Exceptions::Acquisition::Basket; use Koha::Patrons; +use C4::Log qw(logaction); use base qw( Koha::Object Koha::Object::Mixin::AdditionalFields ); @@ -201,6 +202,15 @@ sub close { } ); + # Log the closure + if (C4::Context->preference("AcqLog")) { + logaction( + 'ACQUISITIONS', + 'CLOSE_BASKET', + $self->id + ); + } + return $self; } --- a/t/db_dependent/Acquisition.t +++ a/t/db_dependent/Acquisition.t @@ -901,7 +901,7 @@ subtest 'GetHistory - is_standing' => sub { subtest 'Acquisition logging' => sub { - plan tests => 6; + plan tests => 5; t::lib::Mocks::mock_preference('AcqLog', 1); @@ -910,11 +910,6 @@ subtest 'Acquisition logging' => sub { my @create_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'ADD_BASKET', object => $basketno }); is (scalar @create_logs, 1, 'Basket creation is logged'); - Koha::ActionLogs->delete; - C4::Acquisition::CloseBasket($basketno); - my @close_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'CLOSE_BASKET', object => $basketno }); - is (scalar @close_logs, 1, 'Basket closure is logged'); - Koha::ActionLogs->delete; C4::Acquisition::ReopenBasket($basketno); my @reopen_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'REOPEN_BASKET', object => $basketno }); --- a/t/db_dependent/Koha/Acquisition/Basket.t +++ a/t/db_dependent/Koha/Acquisition/Basket.t @@ -335,7 +335,11 @@ subtest 'is_closed() tests' => sub { subtest 'close() tests' => sub { - plan tests => 3; + plan tests => 4; + + # Turn on acquisitions logging and ensure the logs are empty + t::lib::Mocks::mock_preference('AcqLog', 1); + Koha::ActionLogs->delete; $schema->storage->txn_begin; @@ -372,5 +376,8 @@ subtest 'close() tests' => sub { 'Koha::Exceptions::Acquisition::Basket::AlreadyClosed', 'Trying to close an already closed basket throws an exception'; + my @close_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'CLOSE_BASKET', object => $basket->id }); + is (scalar @close_logs, 1, 'Basket closure is logged'); + $schema->storage->txn_rollback; }; --