Lines 367-372
count(h.reservedate) AS 'holds'
Link Here
|
367 |
subtest 'Email report test' => sub { |
367 |
subtest 'Email report test' => sub { |
368 |
|
368 |
|
369 |
plan tests => 12; |
369 |
plan tests => 12; |
|
|
370 |
my $dbh = C4::Context->dbh; |
370 |
|
371 |
|
371 |
my $id1 = $builder->build({ source => 'Borrower',value => { surname => 'mailer', email => 'a@b.com', emailpro => 'b@c.com' } })->{ borrowernumber }; |
372 |
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 }; |
373 |
my $id2 = $builder->build({ source => 'Borrower',value => { surname => 'nomailer', email => undef, emailpro => 'd@e.com' } })->{ borrowernumber }; |
Lines 399-408
subtest 'Email report test' => sub {
Link Here
|
399 |
($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report1, module => $letter1->{module}, code => $letter2->{code}}); |
400 |
($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"); |
401 |
is( $errors->[0]{FATAL}, 'NO_LETTER', "Must have a letter that exists"); |
401 |
|
402 |
|
|
|
403 |
# for next test, we want to let execute_query capture any SQL errors |
404 |
$dbh->{RaiseError} = 0; |
402 |
warning_like { ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report2, module => $letter1->{module} , code => $letter1->{code} }) } |
405 |
warning_like { ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report2, module => $letter1->{module} , code => $letter1->{code} }) } |
403 |
qr/^DBD::mysql::st execute failed/, |
406 |
qr/^DBD::mysql::st execute failed/, |
404 |
'Error from bad report'; |
407 |
'Error from bad report'; |
405 |
is( $errors->[0]{FATAL}, 'REPORT_FAIL', "Bad report returns failure"); |
408 |
is( $errors->[0]{FATAL}, 'REPORT_FAIL', "Bad report returns failure"); |
|
|
409 |
$dbh->{RaiseError} = 1; |
406 |
|
410 |
|
407 |
($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report1, module => $letter1->{module} , code => $letter1->{code} }); |
411 |
($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report1, module => $letter1->{module} , code => $letter1->{code} }); |
408 |
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"); |
412 |
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"); |
Lines 429-434
subtest 'nb_rows() tests' => sub {
Link Here
|
429 |
|
433 |
|
430 |
plan tests => 3; |
434 |
plan tests => 3; |
431 |
|
435 |
|
|
|
436 |
my $dbh = C4::Context->dbh; |
432 |
$schema->storage->txn_begin; |
437 |
$schema->storage->txn_begin; |
433 |
|
438 |
|
434 |
my $items_count = Koha::Items->search->count; |
439 |
my $items_count = Koha::Items->search->count; |
Lines 448-459
subtest 'nb_rows() tests' => sub {
Link Here
|
448 |
SELECT * items xxx |
453 |
SELECT * items xxx |
449 |
}; |
454 |
}; |
450 |
|
455 |
|
|
|
456 |
# for next test, we want to let execute_query capture any SQL errors |
457 |
$dbh->{RaiseError} = 0; |
451 |
warning_like |
458 |
warning_like |
452 |
{ $nb_rows = nb_rows( $bad_query ) } |
459 |
{ $nb_rows = nb_rows( $bad_query ) } |
453 |
qr/^DBD::mysql::st execute failed:/, |
460 |
qr/^DBD::mysql::st execute failed:/, |
454 |
'Bad queries raise a warning'; |
461 |
'Bad queries raise a warning'; |
455 |
|
462 |
|
456 |
is( $nb_rows, 0, 'nb_rows returns 0 on bad queries' ); |
463 |
is( $nb_rows, 0, 'nb_rows returns 0 on bad queries' ); |
|
|
464 |
$dbh->{RaiseError} = 0; |
457 |
|
465 |
|
458 |
$schema->storage->txn_rollback; |
466 |
$schema->storage->txn_rollback; |
459 |
}; |
467 |
}; |
460 |
- |
|
|