Bugzilla – Attachment 52925 Details for
Bug 14757
Allow the use of Template Toolkit syntax for slips and notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14757 [QA Followup] - Add Unit Tests
Bug-14757-QA-Followup---Add-Unit-Tests.patch (text/plain), 7.77 KB, created by
Jonathan Druart
on 2016-06-28 13:46:33 UTC
(
hide
)
Description:
Bug 14757 [QA Followup] - Add Unit Tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-06-28 13:46:33 UTC
Size:
7.77 KB
patch
obsolete
>From 9a1d6d255c5c87a1249b7ab5d7b24e9059a69002 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 22 Jan 2016 12:43:12 +0000 >Subject: [PATCH] Bug 14757 [QA Followup] - Add Unit Tests > >Signed-off-by: Sean McGarvey <seanm@pascolibraries.org> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/Letters/TemplateToolkit.t | 249 +++++++++++++++++++++++++++++++ > 1 file changed, 249 insertions(+) > create mode 100644 t/db_dependent/Letters/TemplateToolkit.t > >diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t >new file mode 100644 >index 0000000..c4ecc5f >--- /dev/null >+++ b/t/db_dependent/Letters/TemplateToolkit.t >@@ -0,0 +1,249 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright (C) 2016 ByWater Solutions >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use Test::More tests => 13; >+ >+use MARC::Record; >+ >+use t::lib::TestBuilder; >+ >+use C4::Letters; >+use C4::Members; >+use C4::Biblio; >+use Koha::Database; >+use Koha::DateUtils; >+use Koha::Biblio; >+use Koha::Biblioitem; >+use Koha::Item; >+use Koha::Hold; >+use Koha::NewsItem; >+use Koha::Serial; >+use Koha::Subscription; >+use Koha::Suggestion; >+use Koha::Checkout; >+use Koha::Patron::Modification; >+ >+my $schema = Koha::Database->schema; >+$schema->storage->txn_begin(); >+ >+my $builder = t::lib::TestBuilder->new(); >+ >+my $dbh = C4::Context->dbh; >+$dbh->{RaiseError} = 1; >+ >+$dbh->do(q|DELETE FROM letter|); >+ >+my $date = dt_from_string; >+ >+my $library = $builder->build( { source => 'Branch' } ); >+my $patron = $builder->build( { source => 'Borrower' } ); >+my $patron2 = $builder->build( { source => 'Borrower' } ); >+ >+my $biblio = Koha::Biblio->new( >+ { >+ title => 'Test Biblio' >+ } >+)->store(); >+ >+my $biblioitem = Koha::Biblioitem->new( >+ { >+ biblionumber => $biblio->id() >+ } >+)->store(); >+ >+my $item = Koha::Item->new( >+ { >+ biblionumber => $biblio->id(), >+ biblioitemnumber => $biblioitem->id() >+ } >+)->store(); >+ >+my $hold = Koha::Hold->new( >+ { >+ borrowernumber => $patron->{borrowernumber}, >+ biblionumber => $biblio->id() >+ } >+)->store(); >+ >+my $news = Koha::NewsItem->new()->store(); >+my $serial = Koha::Serial->new()->store(); >+my $subscription = Koha::Subscription->new()->store(); >+my $suggestion = Koha::Suggestion->new()->store(); >+my $checkout = Koha::Checkout->new( { itemnumber => $item->id() } )->store(); >+my $modification = Koha::Patron::Modification->new( { verification_token => "TEST" } )->store(); >+ >+my $prepared_letter; >+ >+my $sth = >+ $dbh->prepare(q{INSERT INTO letter (module, code, name, title, content) VALUES ('test',?,'Test','Test',?)}); >+ >+$sth->execute( "TEST_PATRON", "[% borrower.id %]" ); >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_PATRON', >+ tables => { >+ borrowers => $patron->{borrowernumber}, >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $patron->{borrowernumber}, 'Patron object used correctly with scalar' ); >+ >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_PATRON', >+ tables => { >+ borrowers => $patron, >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $patron->{borrowernumber}, 'Patron object used correctly with hashref' ); >+ >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_PATRON', >+ tables => { >+ borrowers => [ $patron->{borrowernumber} ], >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $patron->{borrowernumber}, 'Patron object used correctly with arrayref' ); >+ >+$sth->execute( "TEST_BIBLIO", "[% biblio.id %]" ); >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_BIBLIO', >+ tables => { >+ biblio => $biblio->id(), >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $biblio->id, 'Biblio object used correctly' ); >+ >+$sth->execute( "TEST_LIBRARY", "[% branch.id %]" ); >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_LIBRARY', >+ tables => { >+ branches => $library->{branchcode} >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $library->{branchcode}, 'Library object used correctly' ); >+ >+$sth->execute( "TEST_ITEM", "[% item.id %]" ); >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_ITEM', >+ tables => { >+ items => $item->id() >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $item->id(), 'Item object used correctly' ); >+ >+$sth->execute( "TEST_NEWS", "[% news.id %]" ); >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_NEWS', >+ tables => { >+ opac_news => $news->id() >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $news->id(), 'News object used correctly' ); >+ >+$sth->execute( "TEST_HOLD", "[% hold.id %]" ); >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_HOLD', >+ tables => { >+ reserves => [ $patron->{borrowernumber}, $biblio->id() ] >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $hold->id(), 'Hold object used correctly' ); >+ >+$sth->execute( "TEST_SERIAL", "[% serial.id %]" ); >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_SERIAL', >+ tables => { >+ serial => $serial->id() >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $serial->id(), 'Serial object used correctly' ); >+ >+$sth->execute( "TEST_SUBSCRIPTION", "[% subscription.id %]" ); >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_SUBSCRIPTION', >+ tables => { >+ subscription => $subscription->id() >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $subscription->id(), 'Subscription object used correctly' ); >+ >+$sth->execute( "TEST_SUGGESTION", "[% suggestion.id %]" ); >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_SUGGESTION', >+ tables => { >+ suggestions => $suggestion->id() >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $suggestion->id(), 'Suggestion object used correctly' ); >+ >+$sth->execute( "TEST_ISSUE", "[% checkout.id %]" ); >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_ISSUE', >+ tables => { >+ issues => $item->id() >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $checkout->id(), 'Checkout object used correctly' ); >+ >+$sth->execute( "TEST_MODIFICATION", "[% patron_modification.id %]" ); >+$prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST_MODIFICATION', >+ tables => { >+ borrower_modifications => $modification->verification_token, >+ }, >+ ) >+); >+is( $prepared_letter->{content}, $modification->id(), 'Patron modification object used correctly' ); >-- >2.8.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 14757
:
45325
|
45884
|
47123
|
47131
|
47176
|
47177
|
47865
|
47866
|
48498
|
48499
|
48500
|
48619
|
48620
|
48621
|
48622
|
48805
|
48806
|
48807
|
48808
|
48809
|
48810
|
52758
|
52759
|
52760
|
52761
|
52805
|
52806
|
52807
|
52895
|
52924
| 52925 |
52926
|
52927
|
52928