Bugzilla – Attachment 114863 Details for
Bug 23971
Add logging for basket related actions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23971: (follow-up) Fix tests
Bug-23971-follow-up-Fix-tests.patch (text/plain), 5.78 KB, created by
Andrew Isherwood
on 2021-01-05 11:41:50 UTC
(
hide
)
Description:
Bug 23971: (follow-up) Fix tests
Filename:
MIME Type:
Creator:
Andrew Isherwood
Created:
2021-01-05 11:41:50 UTC
Size:
5.78 KB
patch
obsolete
>From a1d3aa379801e821d41990bb971584981974650a Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Fri, 23 Oct 2020 15:14:28 +0100 >Subject: [PATCH] Bug 23971: (follow-up) Fix tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Following a discussion with Tomás on Slack, this commit implements the >following suggestions: > >- Switch from ->find to ->search in tests. ->find is only ever going to return 0 >or 1 rows, which doesn't help us if there is breakage which results in >more than 1 row being returned, the test would fail due to ->find not >expecting more than 1 row, but we should be testing for it. So switching >to ->search returns all matching rows. >- Moved tests into their own subtest, they had the potential to pollute >surrounding tests >- Remove all action logs before each test, this ensures we're only >testing the result of the current test > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Acquisition.t | 70 ++++++++++++++++++++++-------------- > 1 file changed, 43 insertions(+), 27 deletions(-) > >diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t >index 8a8a57517b..8237996c0a 100755 >--- a/t/db_dependent/Acquisition.t >+++ b/t/db_dependent/Acquisition.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use POSIX qw(strftime); > >-use Test::More tests => 73; >+use Test::More tests => 67; > use t::lib::Mocks; > use Koha::Database; > use Koha::DateUtils qw(dt_from_string output_pref); >@@ -125,8 +125,6 @@ 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( > { >@@ -150,9 +148,6 @@ 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' >@@ -416,27 +411,6 @@ $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 > # >@@ -925,4 +899,46 @@ subtest 'GetHistory - is_standing' => sub { > > }; > >+subtest 'Acquisition logging' => sub { >+ >+ plan tests => 6; >+ >+ t::lib::Mocks::mock_preference('AcqLog', 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::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 }); >+ 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('AcqLog', 0); >+}; >+ > $schema->storage->txn_rollback(); >-- >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 23971
:
95285
|
95286
|
95885
|
95888
|
96063
|
96064
|
100239
|
100240
|
100241
|
103911
|
103912
|
103913
|
103945
|
108962
|
111300
|
111301
|
111302
|
111303
|
111304
|
111955
|
111956
|
111957
|
111958
|
111959
|
111960
|
112277
|
112278
|
112279
|
112280
|
112281
|
112282
|
112283
|
112284
|
112285
|
112286
|
112287
|
112288
|
112289
|
112290
|
112291
|
112298
|
112299
|
112300
|
112301
|
112302
|
112303
|
112304
|
112305
|
112306
|
112307
|
113384
|
113385
|
113386
|
113387
|
113388
|
113389
|
113390
|
113391
|
113392
|
113393
|
114857
|
114858
|
114859
|
114860
|
114861
|
114862
|
114863
|
114864
|
114865
|
114866
|
114867
|
114905
|
114906
|
114907
|
114908
|
114909
|
114910
|
114911
|
114912
|
114913
|
114914
|
114915
|
114916
|
115976
|
115977
|
115978
|
115979
|
115980
|
115981
|
115982
|
115983
|
115984
|
115985
|
115986
|
119401
|
119402
|
119403
|
119404
|
119405
|
119406
|
119407
|
119408
|
119409
|
119410
|
119411
|
119412
|
119944
|
119946
|
120048