Bugzilla – Attachment 122043 Details for
Bug 24190
Add additional Acquisition logging
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24190: (follow-up) Add tests
Bug-24190-follow-up-Add-tests.patch (text/plain), 4.47 KB, created by
Andrew Isherwood
on 2021-06-16 13:29:44 UTC
(
hide
)
Description:
Bug 24190: (follow-up) Add tests
Filename:
MIME Type:
Creator:
Andrew Isherwood
Created:
2021-06-16 13:29:44 UTC
Size:
4.47 KB
patch
obsolete
>From 3b80918e5c9f15d41c8eca19e160a71c0e427440 Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Mon, 28 Sep 2020 15:12:45 +0100 >Subject: [PATCH] Bug 24190: (follow-up) Add tests > >In response to Jonathan's request for tests, I have now added additional >tests for the methods in C4/Budgets.pm that do logging >--- > t/db_dependent/Budgets.t | 38 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 36 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t >index c7eec725f9..17f09880a8 100755 >--- a/t/db_dependent/Budgets.t >+++ b/t/db_dependent/Budgets.t >@@ -1,6 +1,7 @@ > #!/usr/bin/perl > use Modern::Perl; >-use Test::More tests => 144; >+use Test::More tests => 147; >+use JSON; > > BEGIN { > use_ok('C4::Budgets') >@@ -9,6 +10,7 @@ use C4::Context; > use C4::Biblio; > use C4::Acquisition; > >+use Koha::ActionLogs; > use Koha::Acquisition::Booksellers; > use Koha::Acquisition::Orders; > use Koha::Acquisition::Funds; >@@ -22,6 +24,7 @@ use Koha::DateUtils; > > use t::lib::Mocks; > t::lib::Mocks::mock_preference('OrderPriceRounding',''); >+t::lib::Mocks::mock_preference('AcqLog','1'); > > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -125,10 +128,11 @@ $bpid = AddBudgetPeriod($my_budgetperiod); #this is an active budget > my $my_budget = { > budget_code => 'ABCD', > budget_amount => '123.132000', >+ budget_expend => '789', > budget_name => 'Periodiques', > budget_notes => 'This is a note', > budget_period_id => $bpid, >- budget_encumb => '', # Bug 21604 >+ budget_encumb => '456', # Bug 21604 > }; > my $budget_id = AddBudget($my_budget); > isnt( $budget_id, undef, 'AddBudget does not returns undef' ); >@@ -139,10 +143,25 @@ is( $budget->{budget_name}, $my_budget->{budget_name}, 'AddBudget stores the bud > is( $budget->{budget_notes}, $my_budget->{budget_notes}, 'AddBudget stores the budget notes correctly' ); > is( $budget->{budget_period_id}, $my_budget->{budget_period_id}, 'AddBudget stores the budget period id correctly' ); > >+my @create_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'CREATE_FUND', object => $budget->{budget_id} }); >+ >+my $expected_create_payload = { >+ budget_amount => $my_budget->{budget_amount}, >+ budget_expend => $my_budget->{budget_expend}, >+ budget_encumb => $my_budget->{budget_encumb}, >+}; >+ >+my $actual_create_payload = from_json($create_logs[0]->info); >+ >+is_deeply ($actual_create_payload, $expected_create_payload, 'ModBudget logs a budget creation with the correct payload'); >+ >+my $before = $budget; > > $my_budget = { > budget_code => 'EFG', > budget_amount => '321.231000', >+ budget_encumb => '567', >+ budget_expend => '890', > budget_name => 'Modified name', > budget_notes => 'This is a modified note', > budget_period_id => $bpid, >@@ -160,6 +179,18 @@ is( $budget->{budget_name}, $my_budget->{budget_name}, 'ModBudget updates the bu > is( $budget->{budget_notes}, $my_budget->{budget_notes}, 'ModBudget updates the budget notes correctly' ); > is( $budget->{budget_period_id}, $my_budget->{budget_period_id}, 'ModBudget updates the budget period id correctly' ); > >+my @mod_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'MODIFY_FUND', object => $budget->{budget_id} }); >+my $expected_mod_payload = { >+ budget_amount_new => $my_budget->{budget_amount}, >+ budget_encumb_new => $my_budget->{budget_encumb}, >+ budget_expend_new => $my_budget->{budget_expend}, >+ budget_amount_old => $before->{budget_amount}, >+ budget_encumb_old => $before->{budget_encumb}, >+ budget_expend_old => $before->{budget_expend}, >+ budget_amount_change => 0 - ($before->{budget_amount} - $my_budget->{budget_amount}) >+}; >+my $actual_mod_payload = from_json($mod_logs[0]->info); >+is_deeply ($actual_mod_payload, $expected_mod_payload, 'ModBudget logs a budget modification with the correct payload'); > > $budgets = GetBudgets(); > is( @$budgets, 1, 'GetBudgets returns the correct number of budgets' ); >@@ -219,6 +250,9 @@ is( DelBudget($budget_id), 1, 'DelBudget returns true' ); > $budgets = GetBudgets(); > is( @$budgets, 2, 'GetBudgets returns the correct number of budget periods' ); > >+my @delete_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'DELETE_FUND', object => $budget_id }); >+ >+is (scalar @delete_logs, 1, 'DelBudget logs a budget deletion'); > > # GetBudgetHierarchySpent and GetBudgetHierarchyOrdered > my $budget_period_total = 10_000; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24190
:
96364
|
96369
|
100243
|
105082
|
105083
|
106096
|
106097
|
106098
|
106099
|
111080
|
111081
|
111082
|
111083
|
111084
|
112509
|
112510
|
112511
|
112512
|
112513
|
112514
|
116148
|
116149
|
116150
|
116151
|
116152
|
116153
|
122040
|
122041
|
122042
|
122043
|
122044
|
122045
|
123385
|
123386
|
123387
|
123388
|
123389
|
123390
|
123391
|
125119