Bugzilla – Attachment 116070 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]
[20.05.x] Bug 24254: Unit tests
2005x-Bug-24254-Unit-tests.patch (text/plain), 4.33 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-01-29 18:34:30 UTC
(
hide
)
Description:
[20.05.x] Bug 24254: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-01-29 18:34:30 UTC
Size:
4.33 KB
patch
obsolete
>From f8b874fccd0462cdcb4d075f4b9dfef4f537b692 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] [20.05.x] 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 878862991d2..b6b7b5b19d0 100644 >--- 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 => 11; >+use Test::More tests => 13; > use Test::Exception; > > use C4::Circulation; >@@ -241,3 +241,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.30.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 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