From c4a57c0a797c545c784066e2495ebbb06e9c7ee0 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Wed, 2 Feb 2022 09:32:37 -0300 Subject: [PATCH] Bug 29759: (follow-up) Fix TemplateToolkit.t This patch makes the tests set debit_id to undef instead of random data. This way tests don't break when $article_request->cancel is invoked and a refund is tried. To test: 1. Run: $ kshell k$ prove t/db_dependent/Letters/TemplateToolkit.t => FAIL: Boo, tests fail, random garbage is not a debit 2. Apply this patch 3. Repeat 1 => SUCCESS: Tests pass! 4. Sign off :-D Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Letters/TemplateToolkit.t | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t index 127a98bd11..b69ebe118e 100755 --- a/t/db_dependent/Letters/TemplateToolkit.t +++ b/t/db_dependent/Letters/TemplateToolkit.t @@ -379,8 +379,13 @@ Chapters: <> Notes: <> |; reset_template( { template => $template, code => $code, module => 'circulation' } ); - my $article_request = $builder->build({ source => 'ArticleRequest' }); - Koha::ArticleRequests->find( $article_request->{id} )->cancel; + my $article_request = $builder->build_object( + { + class => 'Koha::ArticleRequests', + value => { debit_id => undef } + } + ); + $article_request->cancel; my $letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; my $tt_template = q| @@ -401,7 +406,7 @@ Chapters: [% article_request.chapters %] Notes: [% article_request.patron_notes %] |; reset_template( { template => $tt_template, code => $code, module => 'circulation' } ); - Koha::ArticleRequests->find( $article_request->{id} )->cancel; + $article_request->cancel; my $tt_letter = Koha::Notice::Messages->search( {}, { order_by => { -desc => 'message_id' } } )->next; is( $tt_letter->content, $letter->content, 'Compare AR_* notices' ); isnt( $tt_letter->message_id, $letter->message_id, 'Comparing AR_* notices should compare 2 different messages' ); -- 2.32.0