Bugzilla – Attachment 90051 Details for
Bug 22982
Paying lost fee does not always remove lost item from checkouts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22982: Add unit tests
Bug-22982-Add-unit-tests.patch (text/plain), 5.23 KB, created by
Liz Rea
on 2019-05-23 18:42:27 UTC
(
hide
)
Description:
Bug 22982: Add unit tests
Filename:
MIME Type:
Creator:
Liz Rea
Created:
2019-05-23 18:42:27 UTC
Size:
5.23 KB
patch
obsolete
>From a790d090eb28d6bfd7b31e4434c0e9eb037d98d6 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 23 May 2019 14:14:06 -0400 >Subject: [PATCH] Bug 22982: Add unit tests > >Signed-off-by: Liz Rea <wizzyrea@gmail.com> >--- > t/db_dependent/Koha/Account.t | 146 +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 145 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index d295b340a2..d376c58416 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 8; >+use Test::More tests => 10; > use Test::MockModule; > use Test::Exception; > >@@ -586,3 +586,147 @@ subtest 'pay() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'pay() handles lost items when paying a specific lost fee' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $account = $patron->account; >+ >+ my $context = Test::MockModule->new('C4::Context'); >+ $context->mock( 'userenv', { branch => $library->id } ); >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $item = >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); >+ >+ my $checkout = Koha::Checkout->new( >+ { >+ borrowernumber => $patron->id, >+ itemnumber => $item->id, >+ date_due => \'NOW()', >+ branchcode => $patron->branchcode, >+ issuedate => \'NOW()', >+ } >+ )->store(); >+ >+ $item->itemlost('1')->store(); >+ >+ my $accountline = Koha::Account::Line->new( >+ { >+ issue_id => $checkout->id, >+ borrowernumber => $patron->id, >+ itemnumber => $item->id, >+ date => \'NOW()', >+ accounttype => 'L', >+ interface => 'cli', >+ amount => '1', >+ amountoutstanding => '1', >+ } >+ )->store(); >+ >+ $account->pay( >+ { >+ amount => "0.500000", >+ library_id => $library->id, >+ lines => [$accountline], >+ } >+ ); >+ >+ $accountline = Koha::Account::Lines->find( $accountline->id ); >+ is( $accountline->amountoutstanding, '0.500000', 'Account line was paid down by half' ); >+ >+ $checkout = Koha::Checkouts->find( $checkout->id ); >+ ok( $checkout, 'Item still checked out to patron' ); >+ >+ $account->pay( >+ { >+ amount => "0.500000", >+ library_id => $library->id, >+ lines => [$accountline], >+ } >+ ); >+ >+ $accountline = Koha::Account::Lines->find( $accountline->id ); >+ is( $accountline->amountoutstanding, '0.000000', 'Account line was paid down by half' ); >+ >+ $checkout = Koha::Checkouts->find( $checkout->id ); >+ ok( !$checkout, 'Item was removed from patron account' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'pay() handles lost items when paying by amount ( not specifying the lost fee )' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $account = $patron->account; >+ >+ my $context = Test::MockModule->new('C4::Context'); >+ $context->mock( 'userenv', { branch => $library->id } ); >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $item = >+ $builder->build_sample_item( { biblionumber => $biblio->biblionumber } ); >+ >+ my $checkout = Koha::Checkout->new( >+ { >+ borrowernumber => $patron->id, >+ itemnumber => $item->id, >+ date_due => \'NOW()', >+ branchcode => $patron->branchcode, >+ issuedate => \'NOW()', >+ } >+ )->store(); >+ >+ $item->itemlost('1')->store(); >+ >+ my $accountline = Koha::Account::Line->new( >+ { >+ issue_id => $checkout->id, >+ borrowernumber => $patron->id, >+ itemnumber => $item->id, >+ date => \'NOW()', >+ accounttype => 'L', >+ interface => 'cli', >+ amount => '1', >+ amountoutstanding => '1', >+ } >+ )->store(); >+ >+ $account->pay( >+ { >+ amount => "0.500000", >+ library_id => $library->id, >+ } >+ ); >+ >+ $accountline = Koha::Account::Lines->find( $accountline->id ); >+ is( $accountline->amountoutstanding, '0.500000', 'Account line was paid down by half' ); >+ >+ $checkout = Koha::Checkouts->find( $checkout->id ); >+ ok( $checkout, 'Item still checked out to patron' ); >+ >+ $account->pay( >+ { >+ amount => "0.500000", >+ library_id => $library->id, >+ } >+ ); >+ >+ $accountline = Koha::Account::Lines->find( $accountline->id ); >+ is( $accountline->amountoutstanding, '0.000000', 'Account line was paid down by half' ); >+ >+ $checkout = Koha::Checkouts->find( $checkout->id ); >+ ok( !$checkout, 'Item was removed from patron account' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.11.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 22982
:
90046
|
90047
|
90050
|
90051
|
90152
|
90243
|
90244
|
90245
|
90327
|
90328
|
90329