View | Details | Raw Unified | Return to bug 22001
Collapse All | Expand All

(-)a/t/db_dependent/Reports/Guided.t (-6 / +8 lines)
Lines 253-261 subtest 'get_saved_reports' => sub { Link Here
253
    );
253
    );
254
254
255
    # for next test, we want to let execute_query capture any SQL errors
255
    # for next test, we want to let execute_query capture any SQL errors
256
    $dbh->{RaiseError} = 0;
257
    my $errors;
256
    my $errors;
258
    warning_like { ($sth, $errors) = execute_query(
257
    warning_like {local $dbh->{RaiseError} = 0; ($sth, $errors) = execute_query(
259
            'SELECT surname FRM borrowers',  # error in the query is intentional
258
            'SELECT surname FRM borrowers',  # error in the query is intentional
260
            0, 10 ) }
259
            0, 10 ) }
261
            qr/^DBD::mysql::st execute failed: You have an error in your SQL syntax;/,
260
            qr/^DBD::mysql::st execute failed: You have an error in your SQL syntax;/,
Lines 264-270 subtest 'get_saved_reports' => sub { Link Here
264
        defined($errors) && exists($errors->{queryerr}),
263
        defined($errors) && exists($errors->{queryerr}),
265
        'attempting to run a report with an SQL syntax error returns error message (Bug 12214)'
264
        'attempting to run a report with an SQL syntax error returns error message (Bug 12214)'
266
    );
265
    );
267
    $dbh->{RaiseError} = 1;
268
266
269
    is_deeply( get_report_areas(), [ 'CIRC', 'CAT', 'PAT', 'ACQ', 'ACC', 'SER' ],
267
    is_deeply( get_report_areas(), [ 'CIRC', 'CAT', 'PAT', 'ACQ', 'ACC', 'SER' ],
270
        "get_report_areas returns the correct array of report areas");
268
        "get_report_areas returns the correct array of report areas");
Lines 367-372 count(h.reservedate) AS 'holds' Link Here
367
subtest 'Email report test' => sub {
365
subtest 'Email report test' => sub {
368
366
369
    plan tests => 12;
367
    plan tests => 12;
368
    my $dbh = C4::Context->dbh;
370
369
371
    my $id1 = $builder->build({ source => 'Borrower',value => { surname => 'mailer', email => 'a@b.com', emailpro => 'b@c.com' } })->{ borrowernumber };
370
    my $id1 = $builder->build({ source => 'Borrower',value => { surname => 'mailer', email => 'a@b.com', emailpro => 'b@c.com' } })->{ borrowernumber };
372
    my $id2 = $builder->build({ source => 'Borrower',value => { surname => 'nomailer', email => undef, emailpro => 'd@e.com' } })->{ borrowernumber };
371
    my $id2 = $builder->build({ source => 'Borrower',value => { surname => 'nomailer', email => undef, emailpro => 'd@e.com' } })->{ borrowernumber };
Lines 399-405 subtest 'Email report test' => sub { Link Here
399
    ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report1, module => $letter1->{module}, code => $letter2->{code}});
398
    ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report1, module => $letter1->{module}, code => $letter2->{code}});
400
    is( $errors->[0]{FATAL}, 'NO_LETTER', "Must have a letter that exists");
399
    is( $errors->[0]{FATAL}, 'NO_LETTER', "Must have a letter that exists");
401
400
402
    warning_like { ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report2, module => $letter1->{module} , code => $letter1->{code} }) }
401
    # for next test, we want to let execute_query capture any SQL errors
402
    warning_like { local $dbh->{RaiseError} = 0; ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report2, module => $letter1->{module} , code => $letter1->{code} }) }
403
        qr/^DBD::mysql::st execute failed/,
403
        qr/^DBD::mysql::st execute failed/,
404
        'Error from bad report';
404
        'Error from bad report';
405
    is( $errors->[0]{FATAL}, 'REPORT_FAIL', "Bad report returns failure");
405
    is( $errors->[0]{FATAL}, 'REPORT_FAIL', "Bad report returns failure");
Lines 429-434 subtest 'nb_rows() tests' => sub { Link Here
429
429
430
    plan tests => 3;
430
    plan tests => 3;
431
431
432
    my $dbh = C4::Context->dbh;
432
    $schema->storage->txn_begin;
433
    $schema->storage->txn_begin;
433
434
434
    my $items_count = Koha::Items->search->count;
435
    my $items_count = Koha::Items->search->count;
Lines 448-455 subtest 'nb_rows() tests' => sub { Link Here
448
        SELECT * items xxx
449
        SELECT * items xxx
449
    };
450
    };
450
451
452
    # for next test, we want to let execute_query capture any SQL errors
453
    
451
    warning_like
454
    warning_like
452
        { $nb_rows = nb_rows( $bad_query ) }
455
        { local $dbh->{RaiseError} = 0; $nb_rows = nb_rows( $bad_query ) }
453
        qr/^DBD::mysql::st execute failed:/,
456
        qr/^DBD::mysql::st execute failed:/,
454
        'Bad queries raise a warning';
457
        'Bad queries raise a warning';
455
458
456
- 

Return to bug 22001