From 985c8f1da93192622b9fdc6c9a1c410391bb983f Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 23 Apr 2020 18:50:18 +0000 Subject: [PATCH] Bug 23495: Add SMS provider to moremember.tt To test: 1 - Enable SMS using the Email driver 2 - Add an SMS provider under admimistration 3 - Add an SMS number and provider to a patron 4 - Note on the patron details you don't see the provider :-( 5 - Apply patch 6 - Reload 7 - Note you do see the provider :-) 8 - prove t/db_dependent/Koha/Patrons.t 9 - Sign off! Signed-off-by: Lisette Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- Koha/Patron.pm | 11 +++++++++++ .../prog/en/modules/members/moremember.tt | 4 ++++ t/db_dependent/Koha/Patrons.t | 10 +++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index fe3e80aebb..486406842a 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -431,6 +431,17 @@ sub library { return Koha::Library->_new_from_dbic($self->_result->branchcode); } +=head3 sms_provider + +Returns a Koha::SMS::Provider object representing the patron's SMS provider. + +=cut + +sub sms_provider { + my ( $self ) = @_; + return Koha::SMS::Provider->_new_from_dbic($self->_result->sms_provider); +} + =head3 guarantor_relationships Returns Koha::Patron::Relationships object for this patron's guarantors diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 07d8b7c7ff..8321edef92 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -414,6 +414,10 @@ SMS number: [% patron.smsalertnumber | html %] +
  • + SMS provider: + [% patron.sms_provider.name | html %] +
  • [% END %] diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 0ca5faa717..3461bee9f4 100644 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 40; +use Test::More tests => 41; use Test::Warn; use Test::Exception; use Test::MockModule; @@ -88,6 +88,14 @@ subtest 'library' => sub { is( ref($retrieved_patron_1->library), 'Koha::Library', 'Koha::Patron->library should return a Koha::Library object' ); }; +subtest 'sms_provider' => sub { + plan tests => 2; + my $sms_provider = $builder->build({source => 'SmsProvider' }); + $retrieved_patron_1->sms_provider_id( $sms_provider->{id} )->store; + is_deeply( $retrieved_patron_1->sms_provider->unblessed, $sms_provider, 'Koha::Patron->sms_provider returns the correct SMS provider' ); + is( ref($retrieved_patron_1->sms_provider), 'Koha::SMS::Provider', 'Koha::Patron->sms_provider should return a Koha::SMS::Provider object' ); +}; + subtest 'guarantees' => sub { plan tests => 13; -- 2.39.5