Bugzilla – Attachment 158653 Details for
Bug 30287
Notices using HTML render differently in notices.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30287: (follow-up) Unit test for html_content
Bug-30287-follow-up-Unit-test-for-htmlcontent.patch (text/plain), 4.54 KB, created by
Martin Renvoize (ashimema)
on 2023-11-08 10:06:04 UTC
(
hide
)
Description:
Bug 30287: (follow-up) Unit test for html_content
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-11-08 10:06:04 UTC
Size:
4.54 KB
patch
obsolete
>From a63ec6719131d270d1f67556128b20fe8ce135c8 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 8 Nov 2023 09:38:18 +0000 >Subject: [PATCH] Bug 30287: (follow-up) Unit test for html_content > >This patch adds a unit test for the new `html_content` method introduced >to Koha::Notice::Template in the previous patch. > >Test >1) Run the new unit test ;P >--- > t/db_dependent/Koha/Notice/Message.t | 116 +++++++++++++++++++++++++++ > 1 file changed, 116 insertions(+) > create mode 100644 t/db_dependent/Koha/Notice/Message.t > >diff --git a/t/db_dependent/Koha/Notice/Message.t b/t/db_dependent/Koha/Notice/Message.t >new file mode 100644 >index 00000000000..2d431b8f71d >--- /dev/null >+++ b/t/db_dependent/Koha/Notice/Message.t >@@ -0,0 +1,116 @@ >+#!/usr/bin/perl >+ >+# Copyright 2023 Koha Development team >+# >+# This file is part of Koha >+# >+# 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 => 1; >+ >+use C4::Letters qw( GetPreparedLetter EnqueueLetter ); >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'html_content() tests' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $template = $builder->build_object( >+ { >+ class => 'Koha::Notice::Templates', >+ value => { >+ module => 'test', >+ code => 'TEST', >+ message_transport_type => 'email', >+ is_html => '1', >+ name => 'test notice template', >+ title => '[% borrower.firstname %]', >+ content => 'This is a test template using borrower [% borrower.id %]', >+ branchcode => "", >+ lang => 'default', >+ } >+ } >+ ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $firstname = $patron->firstname; >+ my $borrowernumber = $patron->id; >+ >+ my $prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST', >+ tables => { >+ borrowers => $patron->id, >+ }, >+ ) >+ ); >+ >+ my $message_id = EnqueueLetter( >+ { >+ letter => $prepared_letter, >+ borrowernumber => $patron->id, >+ message_transport_type => 'email' >+ } >+ ); >+ >+ my $message = Koha::Notice::Messages->find($message_id); >+ my $wrapped_compare = <<"WRAPPED"; >+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >+<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> >+ <head> >+ <title>$firstname</title> >+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >+ >+ </head> >+ <body> >+ This is a test template using borrower $borrowernumber >+ </body> >+</html> >+WRAPPED >+ >+ is( $message->html_content, $wrapped_compare, "html_content returned the correct html wrapped letter" ); >+ >+ my $css_sheet = 'https://localhost/shiny.css'; >+ t::lib::Mocks::mock_preference('NoticeCSS', $css_sheet); >+ >+ $wrapped_compare = <<"WRAPPED"; >+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" >+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >+<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> >+ <head> >+ <title>$firstname</title> >+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >+ <link rel="stylesheet" type="text/css" href="$css_sheet"> >+ </head> >+ <body> >+ This is a test template using borrower $borrowernumber >+ </body> >+</html> >+WRAPPED >+ >+ is( $message->html_content, $wrapped_compare, "html_content returned the correct html wrapped letter including stylesheet" ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+1; >-- >2.41.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 30287
:
158517
|
158519
|
158520
|
158648
|
158649
|
158650
|
158651
|
158652
|
158653
|
158654
|
158655
|
158656
|
158834
|
158869
|
158870
|
158871
|
158872
|
158873
|
158892
|
158893
|
158894
|
158895
|
159431
|
159432
|
159433
|
159434