Bugzilla – Attachment 158962 Details for
Bug 35285
Centralise notice content wrapping for HTML output
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35285: Unit tests
Bug-35285-Unit-tests.patch (text/plain), 4.48 KB, created by
David Nind
on 2023-11-15 09:16:27 UTC
(
hide
)
Description:
Bug 35285: Unit tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-11-15 09:16:27 UTC
Size:
4.48 KB
patch
obsolete
>From 2ba983012c94b4e4173e843e02d0d5bf462b0cf7 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 13 Nov 2023 16:46:17 +0000 >Subject: [PATCH] Bug 35285: Unit tests > >This patch adds unit tests for the new 'is_html' function introduced in >Koha::Notice::Message and update the tests to include the new plaintext >handling of html_content. > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/Koha/Notice/Message.t | 107 ++++++++++++++++++++++++++- > 1 file changed, 105 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/Notice/Message.t b/t/db_dependent/Koha/Notice/Message.t >index 72192655f9..0912b813f9 100755 >--- a/t/db_dependent/Koha/Notice/Message.t >+++ b/t/db_dependent/Koha/Notice/Message.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > > use C4::Letters qw( GetPreparedLetter EnqueueLetter ); > >@@ -29,11 +29,83 @@ use t::lib::TestBuilder; > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >-subtest 'html_content() tests' => sub { >+subtest 'is_html() 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 => '0', >+ 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); >+ >+ ok( !$message->is_html, "Non html template yields a non html message" ); >+ >+ $template->is_html(1)->store; >+ $prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST', >+ tables => { >+ borrowers => $patron->id, >+ }, >+ ) >+ ); >+ >+ $message_id = EnqueueLetter( >+ { >+ letter => $prepared_letter, >+ borrowernumber => $patron->id, >+ message_transport_type => 'email' >+ } >+ ); >+ >+ $message = Koha::Notice::Messages->find($message_id); >+ ok( $message->is_html, "HTML template yields a html message" ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'html_content() tests' => sub { >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ > my $template = $builder->build_object( > { > class => 'Koha::Notice::Templates', >@@ -116,6 +188,37 @@ WRAPPED > "html_content returned the correct html wrapped letter including stylesheet" > ); > >+ $template->is_html(0)->store; >+ $prepared_letter = GetPreparedLetter( >+ ( >+ module => 'test', >+ letter_code => 'TEST', >+ tables => { >+ borrowers => $patron->id, >+ }, >+ ) >+ ); >+ >+ $message_id = EnqueueLetter( >+ { >+ letter => $prepared_letter, >+ borrowernumber => $patron->id, >+ message_transport_type => 'email' >+ } >+ ); >+ >+ $wrapped_compare = <<"WRAPPED"; >+<div style="white-space: pre-wrap;"> >+This is a test template using borrower $borrowernumber >+</div> >+WRAPPED >+ >+ $message = Koha::Notice::Messages->find($message_id); >+ is( >+ $message->html_content, $wrapped_compare, >+ "html_content returned the correct html wrapped letter for a plaintext template" >+ ); >+ > $schema->storage->txn_rollback; > }; > >-- >2.30.2
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 35285
:
158657
|
158658
|
158889
|
158890
|
158891
|
158960
|
158961
|
158962
|
166329
|
166330
|
166331
|
166332
|
166333
|
166334
|
166348
|
166349
|
166350
|
166356
|
166357
|
166358
|
166719
|
166720
|
166721
|
166722