Bugzilla – Attachment 83525 Details for
Bug 19066
Add branchcode to accountlines
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19066: Tests for AddRenewal AddIssuingCharge and ChargeReserveFee
Bug-19066-Tests-for-AddRenewal-AddIssuingCharge-an.patch (text/plain), 6.51 KB, created by
Alex Arnaud
on 2018-12-27 14:08:42 UTC
(
hide
)
Description:
Bug 19066: Tests for AddRenewal AddIssuingCharge and ChargeReserveFee
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2018-12-27 14:08:42 UTC
Size:
6.51 KB
patch
obsolete
>From c8b4c2d54a95aad65dce99b0874c25ecb3beaa96 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 7 Nov 2018 17:05:25 -0300 >Subject: [PATCH] Bug 19066: Tests for AddRenewal AddIssuingCharge and > ChargeReserveFee > >This patch adds some tests that cover functions changed by this >patchset. A bug in ChargeReserveFee is highlighted. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Circulation.t | 88 ++++++++++++++++++++++++++++++++++++++++++++ > t/db_dependent/Reserves.t | 27 +++++++++++++- > 2 files changed, 114 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index e718224..44c9f86 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -19,6 +19,7 @@ use Modern::Perl; > use utf8; > > use Test::More tests => 123; >+use Test::MockModule; > > use Data::Dumper; > use DateTime; >@@ -2823,6 +2824,93 @@ $schema->storage->txn_rollback; > C4::Context->clear_syspref_cache(); > $cache->clear_from_cache('single_holidays'); > >+subtest 'AddRenewal and AddIssuingCharge tests' => sub { >+ >+ plan tests => 12; >+ >+ $schema->storage->txn_begin; >+ >+ my $issuing_charges = 15; >+ my $title = 'A title'; >+ my $author = 'Author, An'; >+ my $barcode = 'WHATARETHEODDS'; >+ >+ my $circ = Test::MockModule->new('C4::Circulation'); >+ $circ->mock( >+ 'GetIssuingCharges', >+ sub { >+ return $issuing_charges; >+ } >+ ); >+ >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); >+ my $patron = $builder->build_object({ >+ class => 'Koha::Patrons', >+ value => { branchcode => $library->id } >+ }); >+ >+ my ( $biblionumber, $biblioitemnumber ) = add_biblio( $title, $author ); >+ my ( undef, undef, $item_id ) = AddItem( >+ { >+ homebranch => $library->id, >+ holdingbranch => $library->id, >+ barcode => $barcode, >+ replacementprice => 23.00, >+ itype => $itemtype->id >+ }, >+ $biblionumber >+ ); >+ my $item = Koha::Items->find( $item_id ); >+ >+ my $items = Test::MockModule->new('C4::Items'); >+ $items->mock( GetItem => $item->unblessed ); >+ my $context = Test::MockModule->new('C4::Context'); >+ $context->mock( userenv => { branch => $library->id } ); >+ >+ # Check the item out >+ AddIssue( $patron->unblessed, $item->barcode ); >+ >+ t::lib::Mocks::mock_preference( 'RenewalLog', 0 ); >+ my $date = output_pref( { dt => dt_from_string(), datenonly => 1, dateformat => 'iso' } ); >+ my $old_log_size = scalar( @{ GetLogs( $date, $date, undef, ["CIRCULATION"], ["RENEWAL"] ) } ); >+ AddRenewal( $patron->id, $item->id, $library->id ); >+ my $new_log_size = scalar( @{ GetLogs( $date, $date, undef, ["CIRCULATION"], ["RENEWAL"] ) } ); >+ is( $new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog' ); >+ >+ t::lib::Mocks::mock_preference( 'RenewalLog', 1 ); >+ $date = output_pref( { dt => dt_from_string(), datenonly => 1, dateformat => 'iso' } ); >+ $old_log_size = scalar( @{ GetLogs( $date, $date, undef, ["CIRCULATION"], ["RENEWAL"] ) } ); >+ AddRenewal( $patron->id, $item->id, $library->id ); >+ $new_log_size = scalar( @{ GetLogs( $date, $date, undef, ["CIRCULATION"], ["RENEWAL"] ) } ); >+ is( $new_log_size, $old_log_size + 1, 'renew log successfully added' ); >+ >+ my $lines = Koha::Account::Lines->search({ >+ borrowernumber => $patron->id, >+ itemnumber => $item->id >+ }); >+ >+ is( $lines->count, 3 ); >+ >+ my $line = $lines->next; >+ is( $line->accounttype, 'Rent', 'The issuing charge generates an accountline' ); >+ is( $line->branchcode, $library->id, 'AddIssuingCharge correctly sets branchcode' ); >+ is( $line->description, 'Rental', 'AddIssuingCharge set a hardcoded description for the accountline' ); >+ >+ $line = $lines->next; >+ is( $line->accounttype, 'Rent', 'Fine on renewed item is closed out properly' ); >+ is( $line->branchcode, $library->id, 'AddRenewal correctly sets branchcode' ); >+ is( $line->description, "Renewal of Rental Item $title $barcode", 'AddRenewal set a hardcoded description for the accountline' ); >+ >+ $line = $lines->next; >+ is( $line->accounttype, 'Rent', 'Fine on renewed item is closed out properly' ); >+ is( $line->branchcode, $library->id, 'AddRenewal correctly sets branchcode' ); >+ is( $line->description, "Renewal of Rental Item $title $barcode", 'AddRenewal set a hardcoded description for the accountline' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+ > sub set_userenv { > my ( $library ) = @_; > C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 9fe293d..60af2ae 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 57; >+use Test::More tests => 58; > use Test::MockModule; > use Test::Warn; > >@@ -719,6 +719,31 @@ subtest 'ReservesNeedReturns' => sub { > is( $hold->found, undef, 'If ReservesNeedReturns is 1, found must not have been set waiting' ); > }; > >+subtest 'ChargeReserveFee tests' => sub { >+ >+ plan tests => 8; >+ >+ my $library = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ >+ my $fee = 20; >+ my $title = 'A title'; >+ >+ my $context = Test::MockModule->new('C4::Context'); >+ $context->mock( userenv => { branch => $library->id } ); >+ >+ my $line = C4::Reserves::ChargeReserveFee( $patron->id, $fee, $title ); >+ >+ is( ref($line), 'Koha::Account::Line' , 'Returns a Koha::Account::Line object'); >+ ok( $line->is_debit, 'Generates a debit line' ); >+ is( $line->accounttype, 'Res' , 'generates Res accounttype'); >+ is( $line->borrowernumber, $patron->id , 'generated line belongs to the passed patron'); >+ is( $line->amount, $fee , 'amount set correctly'); >+ is( $line->amountoutstanding, $fee , 'amountoutstanding set correctly'); >+ is( $line->description, "Reserve Charge - $title" , 'Hardcoded description is generated'); >+ is( $line->branchcode, $library->id , "Library id is picked from userenv and stored correctly" ); >+}; >+ > sub count_hold_print_messages { > my $message_count = $dbh->selectall_arrayref(q{ > SELECT COUNT(*) >-- >2.7.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 19066
:
65769
|
65770
|
65771
|
67756
|
67757
|
71153
|
71154
|
71155
|
73185
|
73186
|
73187
|
73595
|
77281
|
77282
|
77283
|
78900
|
78901
|
81144
|
81145
|
81146
|
81253
|
81254
|
81255
|
81684
|
81912
|
81918
|
82047
|
82048
|
82084
|
82086
|
82087
|
82469
|
82470
|
82471
|
82473
|
82474
|
82475
|
82476
|
82477
|
82478
|
83067
|
83068
|
83069
|
83070
|
83071
|
83072
|
83073
|
83074
|
83075
|
83076
|
83077
|
83078
|
83079
|
83080
|
83081
|
83082
|
83083
|
83084
|
83275
|
83519
|
83520
|
83521
|
83522
|
83523
|
83524
| 83525 |
83526
|
83527
|
83528
|
83628