Bugzilla – Attachment 75876 Details for
Bug 20889
Items marked as not for loan can be checked out
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20889: Add tests - not for loan items cannot be checked out
Bug-20889-Add-tests---not-for-loan-items-cannot-be.patch (text/plain), 5.88 KB, created by
Marcel de Rooy
on 2018-06-07 13:40:24 UTC
(
hide
)
Description:
Bug 20889: Add tests - not for loan items cannot be checked out
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-06-07 13:40:24 UTC
Size:
5.88 KB
patch
obsolete
>From c5225687e77e43db88a705fd25f4df281e2251fe Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 6 Jun 2018 14:24:33 -0300 >Subject: [PATCH] Bug 20889: Add tests - not for loan items cannot be checked > out >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Circulation.t | 113 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 112 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 02c10c7..eca91fd 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 117; >+use Test::More tests => 118; > > use DateTime; > use POSIX qw( floor ); >@@ -2227,6 +2227,117 @@ subtest 'CanBookBeIssued | item-level_itypes=biblio' => sub { > is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' ); > }; > >+subtest 'CanBookBeIssued | notforloan' => sub { >+ plan tests => 2; >+ >+ t::lib::Mocks::mock_preference('AllowNotForLoanOverride', 0); >+ >+ my $library = $builder->build( { source => 'Branch' } ); >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patron_category->{categorycode} } } )->store; >+ >+ my $itemtype = $builder->build( >+ { >+ source => 'Itemtype', >+ value => { notforloan => undef, } >+ } >+ ); >+ >+ my $biblioitem = $builder->build( { source => 'Biblioitem' } ); >+ my $item = $builder->build_object( >+ { >+ class => 'Koha::Items', >+ value => { >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ notforloan => 0, >+ itemlost => 0, >+ withdrawn => 0, >+ itype => $itemtype->{itemtype}, >+ biblionumber => $biblioitem->{biblionumber}, >+ biblioitemnumber => $biblioitem->{biblioitemnumber}, >+ } >+ } >+ )->store; >+ >+ my ( $issuingimpossible, $needsconfirmation ); >+ >+ >+ subtest 'item-level_itypes = 1' => sub { >+ plan tests => 6; >+ >+ t::lib::Mocks::mock_preference('item-level_itypes', 1); # item >+ # Is for loan at item type and item level >+ ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); >+ is_deeply( $needsconfirmation, {}, 'Item can be issued to this patron' ); >+ is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' ); >+ >+ # not for loan at item type level >+ Koha::ItemTypes->find( $itemtype->{itemtype} )->notforloan(1)->store; >+ ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); >+ is_deeply( $needsconfirmation, {}, 'No confirmation needed, AllowNotForLoanOverride=0' ); >+ is_deeply( >+ $issuingimpossible, >+ { NOT_FOR_LOAN => 1, itemtype_notforloan => $itemtype->{itemtype} }, >+ 'Item can not be issued, not for loan at item type level' >+ ); >+ >+ # not for loan at item level >+ Koha::ItemTypes->find( $itemtype->{itemtype} )->notforloan(undef)->store; >+ $item->notforloan( 1 )->store; >+ ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); >+ is_deeply( $needsconfirmation, {}, 'No confirmation needed, AllowNotForLoanOverride=0' ); >+ is_deeply( >+ $issuingimpossible, >+ { NOT_FOR_LOAN => 1, item_notforloan => 1 }, >+ 'Item can not be issued, not for loan at item type level' >+ ); >+ }; >+ >+ subtest 'item-level_itypes = 0' => sub { >+ plan tests => 6; >+ >+ t::lib::Mocks::mock_preference('item-level_itypes', 0); # biblio >+ >+ # We set another itemtype for biblioitem >+ my $itemtype = $builder->build( >+ { >+ source => 'Itemtype', >+ value => { notforloan => undef, } >+ } >+ ); >+ >+ # for loan at item type and item level >+ $item->notforloan(undef)->store; >+ $item->biblioitem->itemtype($itemtype->{itemtype})->store; >+ ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); >+ is_deeply( $needsconfirmation, {}, 'Item can be issued to this patron' ); >+ is_deeply( $issuingimpossible, {}, 'Item can be issued to this patron' ); >+ >+ # not for loan at item type level >+ Koha::ItemTypes->find( $itemtype->{itemtype} )->notforloan(1)->store; >+ ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); >+ is_deeply( $needsconfirmation, {}, 'No confirmation needed, AllowNotForLoanOverride=0' ); >+ is_deeply( >+ $issuingimpossible, >+ { NOT_FOR_LOAN => 1, itemtype_notforloan => $itemtype->{itemtype} }, >+ 'Item can not be issued, not for loan at item type level' >+ ); >+ >+ # not for loan at item level >+ Koha::ItemTypes->find( $itemtype->{itemtype} )->notforloan(undef)->store; >+ $item->notforloan( 1 )->store; >+ ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron, $item->barcode, undef, undef, undef, undef ); >+ is_deeply( $needsconfirmation, {}, 'No confirmation needed, AllowNotForLoanOverride=0' ); >+ is_deeply( >+ $issuingimpossible, >+ { NOT_FOR_LOAN => 1, item_notforloan => 1 }, >+ 'Item can not be issued, not for loan at item type level' >+ ); >+ }; >+ >+ # TODO test with AllowNotForLoanOverride = 1 >+}; >+ > $schema->storage->txn_rollback; > $cache->clear_from_cache('single_holidays'); > >-- >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 20889
:
75859
|
75860
|
75865
|
75866
| 75876 |
75877