Bugzilla – Attachment 112150 Details for
Bug 18595
Move C4::Members::Messaging to Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18595: Unit tests preparing for GetMessagingPreferences move
0004-Bug-18595-Unit-tests-preparing-for-GetMessagingPrefe.patch (text/plain), 5.38 KB, created by
Emmi Takkinen
on 2020-10-22 08:14:50 UTC
(
hide
)
Description:
Bug 18595: Unit tests preparing for GetMessagingPreferences move
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2020-10-22 08:14:50 UTC
Size:
5.38 KB
patch
obsolete
>From 8df36978eef979da119f4b63ec98434fe687989a Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Wed, 2 Nov 2016 16:20:12 +0200 >Subject: [PATCH 4/9] Bug 18595: Unit tests preparing for > GetMessagingPreferences move >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch prepares removing GetMessagingPreferences by adding some useful unit >tests for subroutines that the move targets. > >Reserves.t already covers print notice, but this patch adds tests for a set >transport type. > >To test: >1. Run t/db_dependent/Circulation.t >2. Run t/db_dependent/Reserves.t >3. Observe test pass > >Works together with followup patch >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: David Bourgault <david.bourgault@inlibro.com> >Rebased-by: Emmi Takkinen <emmi.takkinen@outlook.com> >--- > t/db_dependent/Circulation.t | 48 +++++++++++++++++++++++++++++++++++- > t/db_dependent/Reserves.t | 23 ++++++++--------- > 2 files changed, 57 insertions(+), 14 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index a51349b186..1d9dba1f49 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 50; >+use Test::More tests => 51; > use Test::Exception; > use Test::MockModule; > use Test::Deep qw( cmp_deeply ); >@@ -36,6 +36,7 @@ use C4::Circulation; > use C4::Biblio; > use C4::Items; > use C4::Log; >+use C4::Message; > use C4::Reserves; > use C4::Overdues qw(UpdateFine CalcFine); > use Koha::DateUtils; >@@ -46,6 +47,8 @@ use Koha::Checkouts; > use Koha::Patrons; > use Koha::Holds; > use Koha::CirculationRules; >+use Koha::Patron::Message::Attributes; >+use Koha::Patron::Message::Preferences; > use Koha::Subscriptions; > use Koha::Account::Lines; > use Koha::Account::Offsets; >@@ -3038,6 +3041,49 @@ subtest 'ItemsDeniedRenewal preference' => sub { > is( $idr_mayrenew, 0, 'Renewal blocked for empty string when "" in pref' ); > }; > >+subtest 'SendCirculationAlert test' => sub { >+ plan tests => 4; >+ >+ my $library = $builder->build( { source => 'Branch' } ); >+ my $patron = $builder->build( { source => 'Borrower' } ); >+ my $attribute = Koha::Patron::Message::Attributes->find({ >+ message_name => 'Item_Checkout', >+ }); >+ Koha::Patron::Message::Preference->new({ >+ borrowernumber => $patron->{'borrowernumber'}, >+ message_attribute_id => $attribute->message_attribute_id, >+ days_in_advance => undef, >+ wants_digest => 0, >+ message_transport_types => ['email'], >+ })->store; >+ my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); >+ my $item_1 = $builder->build( >+ { source => 'Item', >+ value => { >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ notforloan => 0, >+ itemlost => 0, >+ withdrawn => 0, >+ biblionumber => $biblioitem_1->{biblionumber} >+ } >+ } >+ ); >+ >+ my $old_message = C4::Message->find_last_message($patron, 'CHECKOUT', 'email'); >+ $old_message->{'message_id'} = 0 unless $old_message; >+ is(C4::Circulation::SendCirculationAlert({ >+ type => 'CHECKOUT', >+ item => $item_1, >+ borrower => $patron, >+ branch => $library->{'branchcode'}, >+ }), undef, "SendCirculationAlert called."); >+ my $new_message = C4::Message->find_last_message($patron, 'CHECKOUT', 'email'); >+ ok($old_message->{'message_id'} != $new_message->{'message_id'}, "New message has appeared."); >+ is($new_message->{'letter_code'}, 'CHECKOUT', "New message letter code is CHECKOUT."); >+ is($new_message->{'borrowernumber'}, $patron->{'borrowernumber'}, "New message is to our test patron."); >+}; >+ > subtest 'CanBookBeIssued | item-level_itypes=biblio' => sub { > plan tests => 2; > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index c1c4758c86..63c9843758 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -40,6 +40,7 @@ use Koha::Libraries; > use Koha::Notice::Templates; > use Koha::Patrons; > use Koha::Patron::Categories; >+use Koha::Patron::Message::Preference; > use Koha::CirculationRules; > > BEGIN { >@@ -731,19 +732,6 @@ subtest '_koha_notify_reserve() tests' => sub { > > plan tests => 2; > >- my $wants_hold_and_email = { >- wants_digest => '0', >- transports => { >- sms => 'HOLD', >- email => 'HOLD', >- }, >- letter_code => 'HOLD' >- }; >- >- my $mp = Test::MockModule->new( 'C4::Members::Messaging' ); >- >- $mp->mock("GetMessagingPreferences",$wants_hold_and_email); >- > $dbh->do('DELETE FROM letter'); > > my $email_hold_notice = $builder->build({ >@@ -784,6 +772,15 @@ subtest '_koha_notify_reserve() tests' => sub { > } > ); > >+ my $message_attr_id = Koha::Patron::Message::Attributes->find({ >+ message_name => 'Hold_Filled' >+ })->message_attribute_id; >+ Koha::Patron::Message::Preference->new({ >+ borrowernumber => $hold_borrower, >+ message_attribute_id => $message_attr_id, >+ message_transport_types => ['sms', 'email'], >+ wants_digest => 0, >+ })->store; > ModReserveAffect($item->itemnumber, $hold_borrower, 0); > my $sms_message_address = $schema->resultset('MessageQueue')->search({ > letter_code => 'HOLD', >-- >2.17.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 18595
:
63435
|
63436
|
63437
|
63438
|
63439
|
63440
|
63441
|
63794
|
63795
|
63796
|
63797
|
63798
|
63799
|
63800
|
63813
|
63815
|
63816
|
63817
|
63818
|
63819
|
63820
|
63821
|
63822
|
63823
|
63824
|
63825
|
63826
|
63827
|
63828
|
63829
|
69441
|
69442
|
69443
|
69444
|
69445
|
69446
|
69447
|
69448
|
69449
|
69450
|
69451
|
69452
|
69453
|
69667
|
69668
|
69669
|
69670
|
69671
|
69672
|
69673
|
69674
|
93873
|
93874
|
93875
|
93876
|
93877
|
93878
|
93879
|
93880
|
93908
|
94753
|
94754
|
103444
|
103445
|
103446
|
103447
|
103448
|
103449
|
103450
|
103451
|
103452
|
110151
|
110152
|
110153
|
110154
|
110155
|
110156
|
110157
|
110158
|
110159
|
112147
|
112148
|
112149
|
112150
|
112151
|
112152
|
112153
|
112154
|
112155
|
112690
|
113126
|
113192
|
113221
|
113222
|
113769
|
146541
|
146542
|
146543
|
146544
|
146545
|
146546
|
146547
|
146548
|
146549
|
146550
|
146551
|
146552