Bugzilla – Attachment 73512 Details for
Bug 19223
Avoid encoding issues in plugins by providing helper methods to output headers correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19223: Unit tests for output and output_html methods
Bug-19223-Unit-tests-for-output-and-outputhtml-met.patch (text/plain), 2.30 KB, created by
Katrin Fischer
on 2018-03-31 09:39:51 UTC
(
hide
)
Description:
Bug 19223: Unit tests for output and output_html methods
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2018-03-31 09:39:51 UTC
Size:
2.30 KB
patch
obsolete
>From 129fcd600766af38e317409589dc86d3fb74f50d Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 27 Mar 2018 15:56:41 -0300 >Subject: [PATCH] Bug 19223: Unit tests for output and output_html methods > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > t/Koha/Plugin/Test.pm | 10 ++++++++++ > t/db_dependent/Plugins.t | 30 +++++++++++++++++++++++++++++- > 2 files changed, 39 insertions(+), 1 deletion(-) > >diff --git a/t/Koha/Plugin/Test.pm b/t/Koha/Plugin/Test.pm >index 636554d..0f51f73 100644 >--- a/t/Koha/Plugin/Test.pm >+++ b/t/Koha/Plugin/Test.pm >@@ -72,3 +72,13 @@ sub uninstall { > my ( $self, $args ) = @_; > return "Koha::Plugin::Test::uninstall"; > } >+ >+sub test_output { >+ my ( $self ) = @_; >+ $self->output( '¡Hola output!', 'json' ); >+} >+ >+sub test_output_html { >+ my ( $self ) = @_; >+ $self->output_html( '¡Hola output_html!' ); >+} >diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t >index 4fa327f..106eb91 100755 >--- a/t/db_dependent/Plugins.t >+++ b/t/db_dependent/Plugins.t >@@ -2,7 +2,7 @@ > > use Modern::Perl; > >-use Test::More tests => 32; >+use Test::More tests => 33; > use CGI; > use File::Basename; > use File::Spec; >@@ -121,3 +121,31 @@ for my $pass ( 1 .. 2 ) { > is( @$info, 0, "Table $table does no longer exist" ); > ok( !( -f $full_pm_path ), "Koha::Plugins::Handler::delete works correctly." ); > } >+ >+subtest 'output and output_html tests' => sub { >+ >+ plan tests => 6; >+ >+ # Trick stdout to be able to test >+ local *STDOUT; >+ my $stdout; >+ open STDOUT, '>', \$stdout; >+ >+ my $plugin = Koha::Plugin::Test->new({ enable_plugins => 1, cgi => CGI->new }); >+ $plugin->test_output; >+ >+ like($stdout, qr/Cache-control: no-cache/, 'force_no_caching sets Cache-control as desired'); >+ like($stdout, qr{Content-Type: application/json; charset=UTF-8}, 'Correct content-type'); >+ like($stdout, qr{¡Hola output!}, 'Correct data'); >+ >+ # reset the stdout buffer >+ $stdout = ''; >+ close STDOUT; >+ open STDOUT, '>', \$stdout; >+ >+ $plugin->test_output_html; >+ >+ like($stdout, qr/Cache-control: no-cache/, 'force_no_caching sets Cache-control as desired'); >+ like($stdout, qr{Content-Type: text/html; charset=UTF-8}, 'Correct content-type'); >+ like($stdout, qr{¡Hola output_html!}, 'Correct data'); >+}; >-- >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 19223
:
68057
|
73348
|
73349
|
73512
|
73513
|
73589
|
73590