Bugzilla – Attachment 59436 Details for
Bug 17964
TT syntax for notices - Prove that CHECKIN and CHECKOUT are compatible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17964: TT syntax for notices - Prove that CHECKIN and CHECKOUT are compatible
Bug-17964-TT-syntax-for-notices---Prove-that-CHECK.patch (text/plain), 12.09 KB, created by
Jonathan Druart
on 2017-01-23 16:21:42 UTC
(
hide
)
Description:
Bug 17964: TT syntax for notices - Prove that CHECKIN and CHECKOUT are compatible
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-01-23 16:21:42 UTC
Size:
12.09 KB
patch
obsolete
>From 50ddbe710ff206354f29952b73ecfd926c5d05e2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 16 Jan 2017 16:35:18 +0100 >Subject: [PATCH] Bug 17964: TT syntax for notices - Prove that CHECKIN and > CHECKOUT are compatible > >From the CHECKIN and CHECKOUT templates you should be able to access the >following information: item, biblio, biblioitem, patron and library > >Test plan: >Define CHECKIN and CHECKOUT notice templates. >You should be able to define them using the TT syntax to produce the >same generated notice messages as with the historical syntax. >--- > t/db_dependent/Letters/TemplateToolkit.t | 171 ++++++++++++++++++++++++------- > 1 file changed, 133 insertions(+), 38 deletions(-) > >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >index ae21cab..13bd13c 100644 >--- a/t/db_dependent/Letters/TemplateToolkit.t >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -25,6 +25,7 @@ use MARC::Record; > > use t::lib::TestBuilder; > >+use C4::Circulation; > use C4::Letters; > use C4::Members; > use C4::Biblio; >@@ -284,25 +285,38 @@ $prepared_letter = GetPreparedLetter( > is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' ); > > subtest 'regression tests' => sub { >- plan tests => 2; >+ plan tests => 3; > > my $library = $builder->build( { source => 'Branch' } ); > my $patron = $builder->build( { source => 'Borrower' } ); >- my $biblio = Koha::Biblio->new({title => 'Test Biblio'})->store->unblessed; >- my $biblioitem = Koha::Biblioitem->new({biblionumber => $biblio->{biblionumber}})->store()->unblessed; >+ my $biblio1 = Koha::Biblio->new({title => 'Test Biblio 1'})->store->unblessed; >+ my $biblioitem1 = Koha::Biblioitem->new({biblionumber => $biblio1->{biblionumber}})->store()->unblessed; > my $item1 = Koha::Item->new( > { >- biblionumber => $biblio->{biblionumber}, >- biblioitemnumber => $biblioitem->{biblioitemnumber}, >+ biblionumber => $biblio1->{biblionumber}, >+ biblioitemnumber => $biblioitem1->{biblioitemnumber}, >+ barcode => 'a_t_barcode', >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ itype => 'BK', > } > )->store->unblessed; >+ my $biblio2 = Koha::Biblio->new({title => 'Test Biblio 2'})->store->unblessed; >+ my $biblioitem2 = Koha::Biblioitem->new({biblionumber => $biblio2->{biblionumber}})->store()->unblessed; > my $item2 = Koha::Item->new( > { >- biblionumber => $biblio->{biblionumber}, >- biblioitemnumber => $biblioitem->{biblioitemnumber}, >+ biblionumber => $biblio2->{biblionumber}, >+ biblioitemnumber => $biblioitem2->{biblioitemnumber}, >+ barcode => 'another_t_barcode', >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ itype => 'BK', > } > )->store->unblessed; > >+ C4::Context->_new_userenv('xxx'); >+ C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Midway Public Library', '', '', ''); >+ > subtest 'ACQ_NOTIF_ON_RECEIV ' => sub { > plan tests => 1; > my $code = 'ACQ_NOTIF_ON_RECEIV'; >@@ -310,16 +324,16 @@ subtest 'regression tests' => sub { > my $order = $builder->build({ source => 'Aqorder' }); > > my $template = q| >- Dear <<borrowers.firstname>> <<borrowers.surname>>, >- The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received. >- Your library. >+Dear <<borrowers.firstname>> <<borrowers.surname>>, >+The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received. >+Your library. > |; >- my $params = { code => $code, branchcode => $branchcode, tables => { branches => $library, borrowers => $patron, biblio => $biblio, aqorders => $order } }; >+ my $params = { code => $code, branchcode => $branchcode, tables => { branches => $library, borrowers => $patron, biblio => $biblio1, aqorders => $order } }; > my $letter = process_letter( { template => $template, %$params }); > my $tt_template = q| >- Dear [% borrower.firstname %] [% borrower.surname %], >- The order [% order.ordernumber %] ([% biblio.title %]) has been received. >- Your library. >+Dear [% borrower.firstname %] [% borrower.surname %], >+The order [% order.ordernumber %] ([% biblio.title %]) has been received. >+Your library. > |; > my $tt_letter = process_letter( { template => $tt_template, %$params }); > >@@ -333,48 +347,129 @@ subtest 'regression tests' => sub { > my $branchcode = $library->{branchcode}; > > my $template = q| >- <<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>) >+<<borrowers.firstname>> <<borrowers.surname>> (<<borrowers.cardnumber>>) > >- Your request for an article from <<biblio.title>> (<<items.barcode>>) has been canceled for the following reason: >+Your request for an article from <<biblio.title>> (<<items.barcode>>) has been canceled for the following reason: > >- <<article_requests.notes>> >+<<article_requests.notes>> > >- Article requested: >- Title: <<article_requests.title>> >- Author: <<article_requests.author>> >- Volume: <<article_requests.volume>> >- Issue: <<article_requests.issue>> >- Date: <<article_requests.date>> >- Pages: <<article_requests.pages>> >- Chapters: <<article_requests.chapters>> >- Notes: <<article_requests.patron_notes>> >+Article requested: >+Title: <<article_requests.title>> >+Author: <<article_requests.author>> >+Volume: <<article_requests.volume>> >+Issue: <<article_requests.issue>> >+Date: <<article_requests.date>> >+Pages: <<article_requests.pages>> >+Chapters: <<article_requests.chapters>> >+Notes: <<article_requests.patron_notes>> > |; > reset_template( { template => $template, code => $code, module => 'circulation' } ); > Koha::ArticleRequests->find( $article_request->{id} )->cancel; > my $letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; > > my $tt_template = q| >- [% borrower.firstname %] [% borrower.surname %] ([% borrower.cardnumber %]) >+[% borrower.firstname %] [% borrower.surname %] ([% borrower.cardnumber %]) > >- Your request for an article from [% biblio.title %] ([% items.barcode %]) has been canceled for the following reason: >+Your request for an article from [% biblio.title %] ([% items.barcode %]) has been canceled for the following reason: > >- [% article_request.notes %] >+[% article_request.notes %] > >- Article requested: >- Title: [% article_request.title %] >- Author: [% article_request.author %] >- Volume: [% article_request.volume %] >- Issue: [% article_request.issue %] >- Date: [% article_request.date %] >- Pages: [% article_request.pages %] >- Chapters: [% article_request.chapters %] >- Notes: [% article_request.patron_notes %] >+Article requested: >+Title: [% article_request.title %] >+Author: [% article_request.author %] >+Volume: [% article_request.volume %] >+Issue: [% article_request.issue %] >+Date: [% article_request.date %] >+Pages: [% article_request.pages %] >+Chapters: [% article_request.chapters %] >+Notes: [% article_request.patron_notes %] > |; > reset_template( { template => $template, code => $code, module => 'circulation' } ); > Koha::ArticleRequests->find( $article_request->{id} )->cancel; > my $tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; > is( $tt_letter->{content}, $letter->{content}, ); > }; >+ >+ subtest 'CHECKOUT+CHECKIN' => sub { >+ plan tests => 4; >+ >+ my $checkout_code = 'CHECKOUT'; >+ my $checkin_code = 'CHECKIN'; >+ >+ my $dbh = C4::Context->dbh; >+ # Enable notification for CHECKOUT - Things are hardcoded here but should work with default data >+ $dbh->do(q|INSERT INTO borrower_message_preferences( borrowernumber, message_attribute_id ) VALUES ( ?, ? )|, undef, $patron->{borrowernumber}, 6 ); >+ my $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); >+ $dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); >+ # Enable notification for CHECKIN - Things are hardcoded here but should work with default data >+ $dbh->do(q|INSERT INTO borrower_message_preferences( borrowernumber, message_attribute_id ) VALUES ( ?, ? )|, undef, $patron->{borrowernumber}, 5 ); >+ $borrower_message_preference_id = $dbh->last_insert_id(undef, undef, "borrower_message_preferences", undef); >+ $dbh->do(q|INSERT INTO borrower_message_transport_preferences( borrower_message_preference_id, message_transport_type) VALUES ( ?, ? )|, undef, $borrower_message_preference_id, 'email' ); >+ >+ # historic syntax >+ my $checkout_template = q| >+The following items have been checked out: >+---- >+<<biblio.title>> >+---- >+Thank you for visiting <<branches.branchname>>. >+|; >+ reset_template( { template => $checkout_template, code => $checkout_code, module => 'circulation' } ); >+ my $checkin_template = q| >+The following items have been checkin out: >+---- >+<<biblio.title>> >+---- >+Thank you for visiting <<branches.branchname>>. >+|; >+ reset_template( { template => $checkin_template, code => $checkin_code, module => 'circulation' } ); >+ >+ C4::Circulation::AddIssue( $patron, $item1->{barcode} ); >+ my $first_checkout_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; >+ C4::Circulation::AddIssue( $patron, $item2->{barcode} ); >+ my $second_checkout_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; >+ >+ AddReturn( $item1->{barcode} ); >+ my $first_checkin_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; >+ AddReturn( $item2->{barcode} ); >+ my $second_checkin_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; >+ >+ Koha::Notice::Messages->delete; >+ >+ # TT syntax >+ $checkout_template = q| >+The following items have been checked out: >+---- >+[% biblio.title %] >+---- >+Thank you for visiting [% branch.branchname %]. >+|; >+ reset_template( { template => $checkout_template, code => $checkout_code, module => 'circulation' } ); >+ $checkin_template = q| >+The following items have been checkin out: >+---- >+[% biblio.title %] >+---- >+Thank you for visiting [% branch.branchname %]. >+|; >+ reset_template( { template => $checkin_template, code => $checkin_code, module => 'circulation' } ); >+ >+ C4::Circulation::AddIssue( $patron, $item1->{barcode} ); >+ my $first_checkout_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; >+ C4::Circulation::AddIssue( $patron, $item2->{barcode} ); >+ my $second_checkout_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; >+ >+ AddReturn( $item1->{barcode} ); >+ my $first_checkin_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; >+ AddReturn( $item2->{barcode} ); >+ my $second_checkin_tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; >+ >+ is( $first_checkout_tt_letter->content, $first_checkout_letter->content, ); >+ is( $second_checkout_tt_letter->content, $second_checkout_letter->content, ); >+ is( $first_checkin_tt_letter->content, $first_checkin_letter->content, ); >+ is( $second_checkin_tt_letter->content, $second_checkin_letter->content, ); >+ >+ }; > }; > > sub reset_template { >-- >2.1.4
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 17964
:
59436
|
59437
|
59438
|
59540
|
59541
|
59542
|
60403
|
60404
|
60405
|
61595
|
61627
|
62460
|
62461
|
62462
|
62463
|
62464