Bug 12214: add regression test for reporting error when running report with SQL error
authorGalen Charlton <gmc@esilibrary.com>
Thu, 8 May 2014 16:09:07 +0000 (16:09 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Fri, 9 May 2014 14:39:54 +0000 (14:39 +0000)
To test:

[1] Run prove -v t/db_dependent/Reports_Guided.t. Last test should
    fail.
[2] Apply the main patch.
[3] Run step 1 again.  This time, all tests should pass.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
t/db_dependent/Reports_Guided.t

index ad34dbd..6633c2f 100755 (executable)
@@ -5,7 +5,7 @@
 
 use Modern::Perl;
 
-use Test::More tests => 14;
+use Test::More tests => 15;
 
 use C4::Context;
 
@@ -85,6 +85,19 @@ is_deeply(
     '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;
+($sth, $errors) = execute_query(
+    'SELECT surname FRM borrowers',  # error in the query is intentional
+    0,
+    10,
+);
+ok(
+    defined($errors) && exists($errors->{queryerr}),
+    'attempting to run a report with an SQL syntax error returns error message (Bug 12214)'
+);
+
 #End transaction
 $dbh->rollback;