Bugzilla – Attachment 35345 Details for
Bug 12973
Allow passing code to XSLT_Handler instead of filename
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12973: (QA followup) warnings are features, test them
Bug-12973-QA-followup-warnings-are-features-test-t.patch (text/plain), 5.04 KB, created by
Tomás Cohen Arazi (tcohen)
on 2015-01-18 13:26:00 UTC
(
hide
)
Description:
Bug 12973: (QA followup) warnings are features, test them
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2015-01-18 13:26:00 UTC
Size:
5.04 KB
patch
obsolete
>From d4de1e403057eef5a72cd2f2cfed7b9eac459e0e Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@gmail.com> >Date: Sat, 17 Jan 2015 23:23:47 -0300 >Subject: [PATCH] Bug 12973: (QA followup) warnings are features, test them > >This patch makes the test look for the warnings Koha::XSLT_Handler raises >instead of just throwing them to STDERR. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com> >--- > t/db_dependent/XSLT_Handler.t | 53 +++++++++++++++++++++++++++++++++---------- > 1 file changed, 41 insertions(+), 12 deletions(-) > >diff --git a/t/db_dependent/XSLT_Handler.t b/t/db_dependent/XSLT_Handler.t >index 770568c..9a6c2dc 100644 >--- a/t/db_dependent/XSLT_Handler.t >+++ b/t/db_dependent/XSLT_Handler.t >@@ -21,19 +21,23 @@ use Modern::Perl; > > use FindBin; > use File::Slurp; >-use Test::More tests => 27; >+use Test::More tests => 37; >+use Test::Warn; > > use Koha::XSLT_Handler; > > my $engine=Koha::XSLT_Handler->new; > is( ref $engine, 'Koha::XSLT_Handler', 'Testing creation of handler object' ); > >-$engine->transform(''); #we passed no file at first time >+warning_is { $engine->transform('') } #we passed no file at first time >+ "No XSLT file passed.", >+ "No XSLT warning correctly displayed"; > is( $engine->err, 1, 'Engine returns error on no file' ); > >-$engine->transform( '', 'thisfileshouldnotexist.%$#@' ); >+warning_is { $engine->transform( '', 'thisfileshouldnotexist.%$#@' ) } >+ "XSLT file not found.", >+ "No XSLT warning correctly displayed"; > is( $engine->err, 2, 'Engine returns error on bad file' ); >- > is( $engine->refresh( 'asdjhaskjh'), 0, 'Test on invalid refresh' ); > > #check first test xsl >@@ -44,13 +48,30 @@ exit if !-e $path.$xsltfile_1; > $xsltfile_1= $path.$xsltfile_1; > > #Testing not-xml strings (undef, empty, some text, malformed xml >-my $output= $engine->transform( undef, $xsltfile_1 ); >+my $output; >+ >+# Undefined text tests >+warning_is { $output = $engine->transform( undef, $xsltfile_1 ) } >+ "No string to transform.", >+ "No string warning correctly displayed"; > is( $engine->err, 7, 'Engine returns error on undefined text' ); >-$output= $engine->transform( '', $xsltfile_1 ); >+ >+# Empty string tests >+warning_is { $output = $engine->transform( '', $xsltfile_1 ) } >+ "Error while parsing input: Empty String", >+ "Empty string warning correctly displayed"; > is( $engine->err, 5, 'Engine returns error on empty string' ); >-$output= $engine->transform( 'abcdef', $xsltfile_1 ); >+ >+# Non-XML tests >+warning_like { $output = $engine->transform( 'abcdef', $xsltfile_1 ) } >+ qr{^Error while parsing input: :1: parser error : Start tag expected, '<' not found}, >+ "Non-XML warning correctly displayed"; > is( $engine->err, 5, 'Engine returns error on non-xml' ); >-$output= $engine->transform( '<a></b>', $xsltfile_1 ); >+ >+# Malformed XML tests >+warning_like { $output = $engine->transform( '<a></b>', $xsltfile_1 ) } >+ qr{^Error while parsing input: :1: parser error : Opening and ending tag mismatch: a line 1 and b}, >+ "Malformed XML warning correctly displayed"; > is( $engine->err, 5, 'Engine returns error on malformed xml' ); > > #Test not returning source on failure when asked for >@@ -60,13 +81,19 @@ my $secondengine=Koha::XSLT_Handler->new( { > some_unknown_attrib => 'just_for_fun', > }); > $engine->do_not_return_source(1); >-$output= $engine->transform( '<a></b>', $xsltfile_1 ); >+warning_like { $output = $engine->transform( '<a></b>', $xsltfile_1 ) } >+ qr{^Error while parsing input: :1: parser error : Opening and ending tag mismatch: a line 1 and b}, >+ "Malformed XML warning correctly displayed"; > is( defined $output? 1: 0, 0, 'Engine respects do_not_return_source==1'); >-$output= $secondengine->transform( '<a></b>', $xsltfile_1 ); >+warning_like { $output = $secondengine->transform( '<a></b>', $xsltfile_1 ) } >+ qr{^Error while parsing input: :1: parser error : Opening and ending tag mismatch: a line 1 and b}, >+ "Malformed XML warning correctly displayed"; > is( defined $output? 1: 0, 0, 'Second engine respects it too'); > undef $secondengine; #bye > $engine->do_not_return_source(0); >-$output= $engine->transform( '<a></b>', $xsltfile_1 ); >+warning_like { $output = $engine->transform( '<a></b>', $xsltfile_1 ) } >+ qr{^Error while parsing input: :1: parser error : Opening and ending tag mismatch: a line 1 and b}, >+ "Malformed XML warning correctly displayed"; > is( defined $output? 1: 0, 1, 'Engine respects do_not_return_source==0'); > > #Testing valid refresh now >@@ -114,7 +141,9 @@ is( -e $path.$xsltfile_2, 1, "Found my test stylesheet $xsltfile_2" ); > exit if !-e $path.$xsltfile_2; > $xsltfile_2= $path.$xsltfile_2; > >-$output= $engine->transform( $xml_2, $xsltfile_2 ); >+warning_like { $output = $engine->transform( $xml_2, $xsltfile_2 ) } >+ qr{^Error while parsing stylesheet:}, >+ "Bad XSL warning correctly displayed"; > is( $engine->err, 4, 'Engine returned error for parsing bad xsl' ); > is( defined($engine->errstr), 1, 'Error string contains text'); > >-- >1.9.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 12973
:
31864
|
31865
|
33553
|
33554
|
34352
|
34353
|
34354
| 35345