Bugzilla – Attachment 139937 Details for
Bug 31051
Show patron's 'savings' on the OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31051: (follow-up) Tests for get_savings and more
Bug-31051-follow-up-Tests-for-getsavings-and-more.patch (text/plain), 5.22 KB, created by
Aleisha Amohia
on 2022-08-29 04:32:07 UTC
(
hide
)
Description:
Bug 31051: (follow-up) Tests for get_savings and more
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2022-08-29 04:32:07 UTC
Size:
5.22 KB
patch
obsolete
>From 9222bdfa14d19e4737dd7ebefc405492ed2dc1c3 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Mon, 29 Aug 2022 16:30:01 +1200 >Subject: [PATCH] Bug 31051: (follow-up) Tests for get_savings and more > >- Added tests in t/db_dependent/Koha/Patron.t >- Added wording to OPACShowSavings syspref about anonymised checkout >history >- Added IDs to the savings messages on the OPAC > >Sponsored-by: Horowhenua Libraries Trust >--- > .../prog/en/modules/admin/preferences/opac.pref | 1 + > .../bootstrap/en/modules/opac-readingrecord.tt | 2 +- > .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 2 +- > t/db_dependent/Koha/Patron.t | 31 +++++++++++++++++++++- > 4 files changed, 33 insertions(+), 3 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 5c430c944b..71ae54bf7d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -550,6 +550,7 @@ OPAC: > checkouthistory: "on patron's checkout history page (the system preference <em>opacreadinghistory</em> must be enabled)" > summary: "in user summary box on OPAC homepage (the system preference <em>OPACUserSummary</em> must be enabled)" > user: "on patron's 'your summary' page" >+ - ". Note that displayed savings may be inaccurate if checkout history is anonymized." > OpenURL: > - > - 'Complete URL of OpenURL resolver (starting with <code>http://</code> or <code>https://</code>):' >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >index 10c00819be..27fe3f257d 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt >@@ -56,7 +56,7 @@ > <div id="opac-user-readingrec"> > > [% IF savings %] >- <div class="alert alert-info"> >+ <div class="alert alert-info" id="savings"> > Congratulations, you have saved a total of [% savings | $Price with_symbol => 1 %] by using the library. > </div> > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >index aedfebb923..88a26ab9eb 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >@@ -163,7 +163,7 @@ > [% END # / IF patron_flagged %] > > [% IF savings %] >- <div class="alert alert-info"> >+ <div class="alert alert-info" id="savings"> > Congratulations, you have saved a total of [% savings | $Price with_symbol => 1 %] by using the library. > </div> > [% END %] >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 977ec261d6..0c0f3c8ba4 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 => 18; >+use Test::More tests => 19; > use Test::Exception; > use Test::Warn; > >@@ -29,6 +29,7 @@ use Koha::DateUtils qw(dt_from_string); > use Koha::ArticleRequests; > use Koha::Patrons; > use Koha::Patron::Relationships; >+use C4::Circulation qw( AddIssue AddReturn ); > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -1292,3 +1293,31 @@ subtest 'encode_secret and decoded_secret' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'get_savings tests' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }, { value => { branchcode => $library->branchcode } }); >+ >+ t::lib::Mocks::mock_userenv({ patron => $patron, branchcode => $library->branchcode }); >+ >+ my $biblio1 = $builder->build_object({ class => 'Koha::Biblios' }); >+ my $item1 = $builder->build_object({ class => 'Koha::Items' }, { value => { biblionumber => $biblio1->biblionumber, replacementprice => '5.00', holdingbranch => $library->branchcode, homebranch => $library->branchcode } }); >+ my $item2 = $builder->build_object({ class => 'Koha::Items' }, { value => { biblionumber => $biblio1->biblionumber, replacementprice => '5.00', holdingbranch => $library->branchcode, homebranch => $library->branchcode } }); >+ >+ AddIssue( $patron->unblessed, $item1->barcode ); >+ AddIssue( $patron->unblessed, $item2->barcode ); >+ >+ my $savings = $patron->get_savings; >+ is( $savings, $item1->replacementprice + $item2->replacementprice, "Savings correctly calculated from current issues" ); >+ >+ AddReturn( $item2->barcode, $item2->homebranch ); >+ >+ $savings = $patron->get_savings; >+ is( $savings, $item1->replacementprice + $item2->replacementprice, "Savings correctly calculated from current and old issues" ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.11.0
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 31051
:
136564
|
136664
|
136698
|
136699
|
136770
|
136772
|
136773
|
136779
|
136781
|
139100
|
139101
|
139102
|
139408
|
139409
|
139410
|
139911
|
139912
|
139913
|
139914
|
139937
|
143384
|
144082
|
144759
|
144760
|
144761
|
144762
|
144763
|
146431
|
146432
|
147189
|
147190