use POSIX qw(strftime);
-use Test::More tests => 66;
+use Test::More tests => 67;
use t::lib::Mocks;
use Koha::Database;
use Koha::DateUtils qw(dt_from_string output_pref);
use MARC::File::XML ( BinaryEncoding => 'utf8', RecordFormat => 'MARC21' );
BEGIN {
- use_ok('C4::Acquisition');
- use_ok('C4::Biblio');
- use_ok('C4::Budgets');
+ use_ok('C4::Acquisition', qw( NewBasket GetBasket AddInvoice GetInvoice ModReceiveOrder SearchOrders GetOrder GetHistory ModOrder get_rounding_sql get_rounded_price ReopenBasket ModBasket ModBasketHeader ModBasketUsers ));
+ use_ok('C4::Biblio', qw( AddBiblio GetMarcSubfieldStructure ));
+ use_ok('C4::Budgets', qw( AddBudgetPeriod AddBudget GetBudget GetBudgetByOrderNumber GetBudgetsReport GetBudgets GetBudgetReport ));
use_ok('Koha::Acquisition::Orders');
use_ok('Koha::Acquisition::Booksellers');
use_ok('t::lib::TestBuilder');
};
+subtest 'Acquisition logging' => sub {
+
+ plan tests => 5;
+
+ t::lib::Mocks::mock_preference('AcquisitionLog', 1);
+
+ Koha::ActionLogs->delete;
+ my $basketno = NewBasket( $booksellerid, 1 );
+ 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::ReopenBasket($basketno);
+ my @reopen_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'REOPEN_BASKET', object => $basketno });
+ is (scalar @reopen_logs, 1, 'Basket reopen is logged');
+
+ Koha::ActionLogs->delete;
+ C4::Acquisition::ModBasket({
+ basketno => $basketno,
+ booksellerid => $booksellerid
+ });
+ my @mod_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET', object => $basketno });
+ is (scalar @mod_logs, 1, 'Basket modify is logged');
+
+ Koha::ActionLogs->delete;
+ C4::Acquisition::ModBasketHeader($basketno,"Test","","","",$booksellerid);
+ my @mod_header_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET_HEADER', object => $basketno });
+ is (scalar @mod_header_logs, 1, 'Basket header modify is logged');
+
+ Koha::ActionLogs->delete;
+ C4::Acquisition::ModBasketUsers($basketno,(1));
+ my @mod_users_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET_USERS', object => $basketno });
+ is (scalar @mod_users_logs, 1, 'Basket users modify is logged');
+
+ t::lib::Mocks::mock_preference('AcquisitionLog', 0);
+};
+
$schema->storage->txn_rollback();