Bugzilla – Attachment 115147 Details for
Bug 24254
Add Koha::Items->filter_by_visible_in_opac
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24254: Unit tests
Bug-24254-Unit-tests.patch (text/plain), 4.32 KB, created by
Martin Renvoize (ashimema)
on 2021-01-14 11:47:19 UTC
(
hide
)
Description:
Bug 24254: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-01-14 11:47:19 UTC
Size:
4.32 KB
patch
obsolete
>From 72b33600c10e60908bb8ac74264fda6c13565d50 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 3 Dec 2020 15:11:00 -0300 >Subject: [PATCH] Bug 24254: Unit tests > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/Items.t | 111 +++++++++++++++++++++++++++++++++++- > 1 file changed, 110 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 0737881609..eca3909853 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 12; >+use Test::More tests => 13; > use Test::Exception; > use Time::Fake; > >@@ -1318,3 +1318,112 @@ $retrieved_item_1->delete; > is( Koha::Items->search->count, $nb_of_items - 1, 'Delete should have deleted the item' ); > > $schema->storage->txn_rollback; >+ >+subtest 'filter_by_visible_in_opac() tests' => sub { >+ >+ plan tests => 8; >+ >+ $schema->storage->txn_begin; >+ >+ # have a fresh biblio >+ my $biblio = $builder->build_sample_biblio; >+ # have two itemtypes >+ my $itype_1 = $builder->build_object({ class => 'Koha::ItemTypes' }); >+ my $itype_2 = $builder->build_object({ class => 'Koha::ItemTypes' }); >+ # have 5 items on that biblio >+ my $item_1 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ itemlost => -1, >+ itype => $itype_1->itemtype, >+ withdrawn => 1 >+ } >+ ); >+ my $item_2 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ itemlost => 0, >+ itype => $itype_2->itemtype, >+ withdrawn => 2 >+ } >+ ); >+ my $item_3 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ itemlost => 1, >+ itype => $itype_1->itemtype, >+ withdrawn => 3 >+ } >+ ); >+ my $item_4 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ itemlost => 0, >+ itype => $itype_2->itemtype, >+ withdrawn => 4 >+ } >+ ); >+ my $item_5 = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ itemlost => undef, >+ itype => $itype_1->itemtype, >+ withdrawn => 5 >+ } >+ ); >+ >+ my $rules = {}; >+ >+ t::lib::Mocks::mock_preference( 'hidelostitems', 0 ); >+ is( $biblio->items->filter_by_visible_in_opac->count, >+ 5, 'No rules passed, hidelostitems unset' ); >+ >+ t::lib::Mocks::mock_preference( 'hidelostitems', 1 ); >+ is( >+ $biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, >+ 4, >+ 'No rules passed, hidelostitems set' >+ ); >+ >+ $rules = { withdrawn => [ 1, 2 ] }; >+ is( >+ $biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, >+ 2, >+ 'Rules on withdrawn, hidelostitems set' >+ ); >+ >+ $rules = { itype => [ $itype_1->itemtype ] }; >+ is( >+ $biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, >+ 2, >+ 'Rules on itype, hidelostitems set' >+ ); >+ >+ $rules = { withdrawn => [ 1, 2 ], itype => [ $itype_1->itemtype ] }; >+ is( >+ $biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, >+ 1, >+ 'Rules on itype and withdrawn, hidelostitems set' >+ ); >+ is( >+ $biblio->items->filter_by_visible_in_opac( { rules => $rules } ) >+ ->next->itemnumber, >+ $item_4->itemnumber, >+ 'The right item is returned' >+ ); >+ >+ $rules = { withdrawn => [ 1, 2 ], itype => [ $itype_2->itemtype ] }; >+ is( >+ $biblio->items->filter_by_visible_in_opac( { rules => $rules } )->count, >+ 1, >+ 'Rules on itype and withdrawn, hidelostitems set' >+ ); >+ is( >+ $biblio->items->filter_by_visible_in_opac( { rules => $rules } ) >+ ->next->itemnumber, >+ $item_5->itemnumber, >+ 'The right item is returned' >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.20.1
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 24254
:
96373
|
114159
|
114160
|
114206
|
114207
|
114278
|
114279
|
114539
|
114540
|
114548
|
114549
|
114550
|
114551
|
114574
|
114594
|
114595
|
114596
|
114597
|
114598
|
114599
|
114664
|
114665
|
114666
|
114667
|
114668
|
115131
|
115132
| 115147 |
115148
|
115149
|
115150
|
115151
|
115152
|
115153
|
116070
|
116071
|
116072
|
116073
|
116074
|
116075