Bugzilla – Attachment 101991 Details for
Bug 22001
Add RaiseError and PrintError flags for all tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22001: Fix Reports/Guided.t tests
Bug-22001-Fix-ReportsGuidedt-tests.patch (text/plain), 4.36 KB, created by
Jonathan Druart
on 2020-03-27 11:34:01 UTC
(
hide
)
Description:
Bug 22001: Fix Reports/Guided.t tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-27 11:34:01 UTC
Size:
4.36 KB
patch
obsolete
>From ed8c4d3a888dfb1425edf8424eb7de2bbd2d844f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 27 Mar 2020 12:32:45 +0100 >Subject: [PATCH] Bug 22001: Fix Reports/Guided.t tests > >--- > t/db_dependent/Reports/Guided.t | 42 ++++++++++++++++++++------------- > 1 file changed, 25 insertions(+), 17 deletions(-) > >diff --git a/t/db_dependent/Reports/Guided.t b/t/db_dependent/Reports/Guided.t >index f9c2b738f7..52eb619b20 100644 >--- a/t/db_dependent/Reports/Guided.t >+++ b/t/db_dependent/Reports/Guided.t >@@ -252,19 +252,19 @@ subtest 'get_saved_reports' => sub { > 'running a query with a parameter returned the expected result' > ); > >- # for next test, we want to let execute_query capture any SQL errors >- $dbh->{RaiseError} = 0; >- my $errors; >- warning_like { ($sth, $errors) = execute_query( >- 'SELECT surname FRM borrowers', # error in the query is intentional >- 0, 10 ) } >- qr/^DBD::mysql::st execute failed: You have an error in your SQL syntax;/, >- "Wrong SQL syntax raises warning"; >- ok( >- defined($errors) && exists($errors->{queryerr}), >- 'attempting to run a report with an SQL syntax error returns error message (Bug 12214)' >- ); >- $dbh->{RaiseError} = 1; >+ { >+ local $dbh->{RaiseError} = 0; >+ my $errors; >+ warning_like { ($sth, $errors) = execute_query( >+ 'SELECT surname FRM borrowers', # error in the query is intentional >+ 0, 10 ) } >+ qr/^DBD::mysql::st execute failed: You have an error in your SQL syntax;/, >+ "Wrong SQL syntax raises warning"; >+ ok( >+ defined($errors) && exists($errors->{queryerr}), >+ 'attempting to run a report with an SQL syntax error returns error message (Bug 12214)' >+ ); >+ } > > is_deeply( get_report_areas(), [ 'CIRC', 'CAT', 'PAT', 'ACQ', 'ACC', 'SER' ], > "get_report_areas returns the correct array of report areas"); >@@ -367,6 +367,7 @@ count(h.reservedate) AS 'holds' > subtest 'Email report test' => sub { > > plan tests => 12; >+ my $dbh = C4::Context->dbh; > > my $id1 = $builder->build({ source => 'Borrower',value => { surname => 'mailer', email => 'a@b.com', emailpro => 'b@c.com' } })->{ borrowernumber }; > my $id2 = $builder->build({ source => 'Borrower',value => { surname => 'nomailer', email => undef, emailpro => 'd@e.com' } })->{ borrowernumber }; >@@ -399,10 +400,13 @@ subtest 'Email report test' => sub { > ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report1, module => $letter1->{module}, code => $letter2->{code}}); > is( $errors->[0]{FATAL}, 'NO_LETTER', "Must have a letter that exists"); > >- warning_like { ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report2, module => $letter1->{module} , code => $letter1->{code} }) } >- qr/^DBD::mysql::st execute failed/, >- 'Error from bad report'; >- is( $errors->[0]{FATAL}, 'REPORT_FAIL', "Bad report returns failure"); >+ { >+ local $dbh->{RaiseError} = 0; >+ warning_like { ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report2, module => $letter1->{module} , code => $letter1->{code} }) } >+ qr/^DBD::mysql::st execute failed/, >+ 'Error from bad report'; >+ is( $errors->[0]{FATAL}, 'REPORT_FAIL', "Bad report returns failure"); >+ } > > ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report1, module => $letter1->{module} , code => $letter1->{code} }); > is( $errors->[0]{NO_FROM_COL} == 1 && $errors->[1]{NO_EMAIL_COL} == 2 && $errors->[2]{NO_FROM_COL} == 2, 1, "Correct warnings from the routine"); >@@ -429,6 +433,7 @@ subtest 'nb_rows() tests' => sub { > > plan tests => 3; > >+ my $dbh = C4::Context->dbh; > $schema->storage->txn_begin; > > my $items_count = Koha::Items->search->count; >@@ -448,12 +453,15 @@ subtest 'nb_rows() tests' => sub { > SELECT * items xxx > }; > >+ # for next test, we want to let execute_query capture any SQL errors >+ $dbh->{RaiseError} = 0; > warning_like > { $nb_rows = nb_rows( $bad_query ) } > qr/^DBD::mysql::st execute failed:/, > 'Bad queries raise a warning'; > > is( $nb_rows, 0, 'nb_rows returns 0 on bad queries' ); >+ $dbh->{RaiseError} = 0; > > $schema->storage->txn_rollback; > }; >-- >2.20.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 22001
:
83230
|
83231
|
83232
|
98910
|
98911
|
98912
|
99589
|
99590
|
99591
|
101989
|
101990
| 101991 |
102070
|
102140
|
102147
|
102149
|
102150
|
102151
|
102152