Bugzilla – Attachment 67393 Details for
Bug 16149
Generate and send custom notices based on report output
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16149 - Unit tests
Bug-16149---Unit-tests.patch (text/plain), 3.92 KB, created by
Nick Clemens (kidclamp)
on 2017-09-27 12:51:56 UTC
(
hide
)
Description:
Bug 16149 - Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-09-27 12:51:56 UTC
Size:
3.92 KB
patch
obsolete
>From d2924fd8b0bce4970b8e53de317c4fb173d66c87 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 12 May 2017 17:13:07 -0400 >Subject: [PATCH] Bug 16149 - Unit tests > >To test: >prove -v t/db_dependent/Reports/Guided.t >--- > t/db_dependent/Reports/Guided.t | 59 ++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 58 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Reports/Guided.t b/t/db_dependent/Reports/Guided.t >index 0c410dc..e989a38 100644 >--- a/t/db_dependent/Reports/Guided.t >+++ b/t/db_dependent/Reports/Guided.t >@@ -18,12 +18,13 @@ > > use Modern::Perl; > >-use Test::More tests => 9; >+use Test::More tests => 10; > use Test::Warn; > > use t::lib::TestBuilder; > use C4::Context; > use Koha::Database; >+use Koha::Notice::Messages; > > use_ok('C4::Reports::Guided'); > can_ok( >@@ -343,6 +344,62 @@ count(h.reservedate) AS 'holds' > is( C4::Reports::Guided::convert_sql( $sql ), $expected_converted_sql, "Query with 2 joins should have been correctly converted"); > }; > >+subtest 'Email report test' => sub { >+ >+ plan tests => 9; >+ >+ my $id1 = $builder->build({ source => 'Borrower',value => { surname => 'mailer', email => 'a@b.com' } })->{ borrowernumber }; >+ my $id2 = $builder->build({ source => 'Borrower',value => { surname => 'nomailer', email => undef } })->{ borrowernumber }; >+ my $report1 = $builder->build({ source => 'SavedSql', value => { savedsql => "SELECT surname,borrowernumber,email FROM borrowers WHERE borrowernumber IN ($id1,$id2)" } })->{ id }; >+ my $report2 = $builder->build({ source => 'SavedSql', value => { savedsql => "SELECT potato FROM mashed" } })->{ id }; >+ >+ my $letter1 = $builder->build({ >+ source => 'Letter', >+ value => { >+ content => "[% surname %]", >+ branchcode => "", >+ message_transport_type => 'email' >+ } >+ }); >+ my $letter2 = $builder->build({ >+ source => 'Letter', >+ value => { >+ content => "[% firstname %]", >+ branchcode => "", >+ message_transport_type => 'email' >+ } >+ }); >+ >+ my $message_count = Koha::Notice::Messages->search({})->count; >+ >+ my @result = C4::Reports::Guided::EmailReport(); >+ is( $result[0]{FATAL}, 'MISSING_PARAMS', "Need to enter required params"); >+ >+ @result = C4::Reports::Guided::EmailReport({report => $report1, module => $letter1->{module}, code => $letter2->{code}}); >+ is( $result[0]{FATAL}, 'NO_LETTER', "Must have a letter that exists"); >+ >+ warning_like { @result = C4::Reports::Guided::EmailReport({report => $report2, module => $letter1->{module} , code => $letter1->{code} }) } >+ qr/^DBD::mysql::st execute failed/, >+ 'Error from bad report'; >+ is( $result[0]{FATAL}, 'REPORT_FAIL', "Bad report returns failure"); >+ >+ @result = C4::Reports::Guided::EmailReport({report => $report1, module => $letter1->{module} , code => $letter1 ->{code} }); >+ is( $result[0]{NO_FROM_COL} == 1 && $result[1]{NO_EMAIL_COL} == 2 && $result[2]{NO_FROM_COL} == 2, 1, "Correct warnings from the routine"); >+ >+ @result = C4::Reports::Guided::EmailReport({report => $report1, module => $letter1->{module} , code => $letter1 ->{code}, from => 'the@future.ooh' }); >+ is( $result[0]{NO_EMAIL_COL}, 2, "Warning only for patron with no email"); >+ >+ is( $message_count, Koha::Notice::Messages->search({})->count, "Messages not added without commit"); >+ >+ @result = C4::Reports::Guided::EmailReport({report => $report1, module => $letter1->{module} , code => $letter1 ->{code}, from => 'the@future.ooh', commit => 1 }); >+ >+ my $notices = Koha::Notice::Messages->search( undef,{ order_by => { -desc => 'message_id' } } ); >+ is( $notices->count, $message_count+1, "Message added with commit option"); >+ >+ is( $notices->next()->content, "mailer", "Message has expected content"); >+ >+}; >+ > $schema->storage->txn_rollback; > > sub trim { >-- >2.1.4
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 16149
:
62217
|
63454
|
63455
|
66398
|
66399
|
67392
|
67393
|
78890
|
78891
|
78896
|
78897
|
79328
|
79329
|
79330
|
83890
|
83891
|
85116
|
85117
|
88231
|
88232