Bugzilla – Attachment 118453 Details for
Bug 17499
Koha objects for messaging preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17499: (follow-up) Add $patron->messaging_preferences accessor
Bug-17499-follow-up-Add-patron-messagingpreference.patch (text/plain), 3.31 KB, created by
Lari Taskula
on 2021-03-18 03:47:56 UTC
(
hide
)
Description:
Bug 17499: (follow-up) Add $patron->messaging_preferences accessor
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2021-03-18 03:47:56 UTC
Size:
3.31 KB
patch
obsolete
>From 94e7efdb6139efd1f6f3f21afc4a6087ad546df5 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Thu, 18 Mar 2021 03:16:11 +0000 >Subject: [PATCH] Bug 17499: (follow-up) Add $patron->messaging_preferences > accessor > >To test: >1. prove t/db_dependent/Koha/Patron.t > >Sponsored-by: The National Library of Finland >--- > Koha/Patron.pm | 14 ++++++++++ > t/db_dependent/Koha/Patron.t | 53 +++++++++++++++++++++++++++++++++++- > 2 files changed, 66 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 80c88e9716..16806d4cb0 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -647,6 +647,20 @@ sub merge_with { > } > > >+=head3 messaging_preferences >+ >+ my $patron = Koha::Patrons->find($id); >+ $patron->messaging_preferences(); >+ >+=cut >+ >+sub messaging_preferences { >+ my ( $self ) = @_; >+ >+ return Koha::Patron::MessagePreferences->search({ >+ borrowernumber => $self->borrowernumber, >+ }); >+} > > =head3 wants_check_for_previous_checkout > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 1b0d24552a..7f3578af73 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 6; >+use Test::More tests => 7; > use Test::Exception; > > use Koha::Database; >@@ -283,6 +283,57 @@ subtest 'add_enrolment_fee_if_needed() tests' => sub { > }; > }; > >+subtest 'messaging_preferences() tests' => sub { >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $mtt = $builder->build_object({ >+ class => 'Koha::Patron::MessagePreference::Transport::Types' >+ }); >+ my $attribute = $builder->build_object({ >+ class => 'Koha::Patron::MessagePreference::Attributes' >+ }); >+ my $branchcode = $builder->build({ >+ source => 'Branch' })->{branchcode}; >+ my $letter = $builder->build_object({ >+ class => 'Koha::Notice::Templates', >+ value => { >+ branchcode => '', >+ is_html => 0, >+ message_transport_type => $mtt->message_transport_type >+ } >+ }); >+ >+ Koha::Patron::MessagePreference::Transport->new({ >+ message_attribute_id => $attribute->message_attribute_id, >+ message_transport_type => $mtt->message_transport_type, >+ is_digest => 0, >+ letter_module => $letter->module, >+ letter_code => $letter->code, >+ })->store; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ >+ my $preference = Koha::Patron::MessagePreference->new({ >+ borrowernumber => $patron->borrowernumber, >+ message_attribute_id => $attribute->message_attribute_id, >+ wants_digest => 0, >+ days_in_advance => undef, >+ })->store; >+ >+ my $messaging_preferences = $patron->messaging_preferences(); >+ is($messaging_preferences->count, 1, 'Found one preference'); >+ >+ my $messaging_preference = $messaging_preferences->next; >+ is($messaging_preference->borrowernumber, $patron->borrowernumber); >+ is($messaging_preference->message_attribute_id, $attribute->message_attribute_id); >+ is($messaging_preference->wants_digest, 0); >+ is($messaging_preference->days_in_advance, undef); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'to_api() tests' => sub { > > plan tests => 6; >-- >2.25.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 17499
:
63427
|
63428
|
63429
|
63430
|
63431
|
63432
|
63433
|
63434
|
63786
|
63787
|
63788
|
63789
|
63790
|
63791
|
63792
|
63793
|
63801
|
63802
|
63803
|
63804
|
63805
|
63806
|
63807
|
63808
|
63809
|
63810
|
63811
|
63812
|
63878
|
63895
|
64035
|
64036
|
64037
|
64038
|
64039
|
64040
|
64041
|
64042
|
64043
|
64044
|
64795
|
66686
|
69434
|
69435
|
69458
|
91864
|
93863
|
93865
|
93872
|
94748
|
99479
|
99634
|
99668
|
99669
|
99670
|
103441
|
103442
|
103443
|
106653
|
106654
|
106655
|
106656
|
106657
|
107612
|
107613
|
107614
|
107615
|
107616
|
113010
|
113011
|
113127
|
113129
|
113686
|
113687
|
113765
|
113766
|
113767
|
113768
|
118452
|
118453
|
119470
|
119471
|
119472
|
119473
|
119474
|
119475
|
119476
|
119477
|
119478
|
119479
|
119480
|
119481
|
119482
|
119483
|
119484
|
119485
|
119486
|
119487
|
119488
|
119489
|
119490
|
119491
|
141408
|
141409
|
141410
|
141411
|
141412
|
141413
|
141414
|
141415
|
141416
|
141417
|
141418
|
146529
|
146530
|
146531
|
146532
|
146533
|
146534
|
146535
|
146536
|
146537
|
146538
|
146539
|
146540
|
151900
|
151901
|
151902
|
151903
|
151904
|
151905
|
151906
|
151907
|
151908
|
151909
|
151910
|
151911
|
151937
|
151938
|
151939
|
151940
|
151941
|
151942
|
151943
|
151944
|
151945
|
151946
|
151947
|
151948
|
155365
|
155366
|
155367
|
155368
|
155369
|
155370
|
155371
|
155372
|
155373
|
155374
|
155375
|
155376