Bugzilla – Attachment 128874 Details for
Bug 29759
Refund credit when cancelling an article request
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29759: Unit tests
Bug-29759-Unit-tests.patch (text/plain), 2.41 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-12-22 21:21:04 UTC
(
hide
)
Description:
Bug 29759: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-12-22 21:21:04 UTC
Size:
2.41 KB
patch
obsolete
>From 544a6a4b44d4fa5fa059a9baaa7980f0b431fcbe Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 22 Dec 2021 18:17:10 -0300 >Subject: [PATCH] Bug 29759: Unit tests > >--- > t/db_dependent/Koha/ArticleRequest.t | 31 ++++++++++++++++++++++++---- > 1 file changed, 27 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Koha/ArticleRequest.t b/t/db_dependent/Koha/ArticleRequest.t >index dfa5ec3f6c..b7bceb382e 100755 >--- a/t/db_dependent/Koha/ArticleRequest.t >+++ b/t/db_dependent/Koha/ArticleRequest.t >@@ -156,19 +156,40 @@ subtest 'complete() tests' => sub { > > subtest 'cancel() tests' => sub { > >- plan tests => 4; >+ plan tests => 11; > > $schema->storage->txn_begin; > >+ my $amount = 11; >+ >+ my $patron_mock = Test::MockModule->new('Koha::Patron'); >+ $patron_mock->mock( 'article_request_fee', sub { return $amount; } ); >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $item = $builder->build_sample_item; >+ > my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); > $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); > >- my $ar = $builder->build_object( >- { class => 'Koha::ArticleRequests', >- value => { status => Koha::ArticleRequest::Status::Requested } >+ my $ar = Koha::ArticleRequest->new( >+ { >+ borrowernumber => $patron->id, >+ biblionumber => $item->biblionumber, >+ itemnumber => $item->id, > } > ); > >+ $ar->request()->discard_changes; >+ >+ is( $ar->status, Koha::ArticleRequest::Status::Requested ); >+ is( $ar->itemnumber, $item->id, 'itemnumber set' ); >+ ok( defined $ar->debit_id, 'Fee linked' ); >+ is( $patron->account->balance, $amount, 'Outstanding fees with the right value' ); >+ >+ my $payed_amount = 5; >+ $patron->account->pay({ amount => $payed_amount, interface => 'intranet', lines => [ $ar->debit ] }); >+ is( $patron->account->balance, $amount - $payed_amount, 'Outstanding fees with the right value' ); >+ > my $reason = "Hey, ho"; > my $notes = "Let's go!"; > >@@ -178,5 +199,7 @@ subtest 'cancel() tests' => sub { > is( $ar->cancellation_reason, $reason, 'Cancellation reason stored correctly' ); > is( $ar->notes, $notes, 'Notes stored correctly' ); > >+ is( abs $patron->account->balance, $payed_amount, 'The patron has been refunded the right value' ); >+ > $schema->storage->txn_rollback; > }; >-- >2.32.0
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 29759
:
128874
|
128875
|
129162
|
129163
|
129181
|
129182
|
129297
|
129298
|
129302
|
129303
|
129304
|
130093
|
130094
|
130095
|
130096