Bugzilla – Attachment 42578 Details for
Bug 12252
OAI-PMH GetRecord result doesn't include item data
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12252: Add tests for EmbedItemsInMarcBiblio
Bug-12252-Add-tests-for-EmbedItemsInMarcBiblio.patch (text/plain), 4.44 KB, created by
Jonathan Druart
on 2015-09-16 09:53:15 UTC
(
hide
)
Description:
Bug 12252: Add tests for EmbedItemsInMarcBiblio
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-09-16 09:53:15 UTC
Size:
4.44 KB
patch
obsolete
>From 49d9fee987109554bd6de3d7882a812f07aaf603 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Fri, 2 Jan 2015 15:46:03 +0100 >Subject: [PATCH] Bug 12252: Add tests for EmbedItemsInMarcBiblio > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> > >Signed-off-by: Signed-off-by: Gaetan Boisson <gaetan.boisson@biblibre.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/Items.t | 91 +++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 90 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t >index 47afb41..ea42d95 100755 >--- a/t/db_dependent/Items.t >+++ b/t/db_dependent/Items.t >@@ -23,7 +23,10 @@ use C4::Biblio; > use C4::Branch; > use Koha::Database; > >-use Test::More tests => 8; >+use t::lib::Mocks; >+ >+use Test::More tests => 9; >+ > use Test::Warn; > > BEGIN { >@@ -431,6 +434,92 @@ subtest 'Koha::Item(s) tests' => sub { > is( $holdingbranch->branchcode(), $branch2, "Home branch code matches holdingbranch" ); > }; > >+subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { >+ plan tests => 7; >+ >+ $dbh->{AutoCommit} = 0; >+ $dbh->{RaiseError} = 1; >+ >+ my ( $biblionumber, $biblioitemnumber ) = get_biblio(); >+ my $item_infos = [ >+ { homebranch => 'CPL', holdingbranch => 'CPL' }, >+ { homebranch => 'CPL', holdingbranch => 'CPL' }, >+ { homebranch => 'CPL', holdingbranch => 'CPL' }, >+ { homebranch => 'MPL', holdingbranch => 'MPL' }, >+ { homebranch => 'MPL', holdingbranch => 'MPL' }, >+ { homebranch => 'CPL', holdingbranch => 'MPL' }, >+ { homebranch => 'CPL', holdingbranch => 'MPL' }, >+ { homebranch => 'CPL', holdingbranch => 'MPL' }, >+ ]; >+ my $number_of_items = scalar @$item_infos; >+ my $number_of_items_with_homebranch_is_CPL = >+ grep { $_->{homebranch} eq 'CPL' } @$item_infos; >+ >+ my @itemnumbers; >+ for my $item_info (@$item_infos) { >+ my ( undef, undef, $itemnumber ) = AddItem( >+ { >+ homebranch => $item_info->{homebranch}, >+ holdingbranch => $item_info->{holdingbanch} >+ }, >+ $biblionumber >+ ); >+ push @itemnumbers, $itemnumber; >+ } >+ >+ # Emptied the OpacHiddenItems pref >+ t::lib::Mocks::mock_preference( 'OpacHiddenItems', '' ); >+ >+ my ($itemfield) = >+ C4::Biblio::GetMarcFromKohaField( 'items.itemnumber', '' ); >+ my $record = C4::Biblio::GetMarcBiblio($biblionumber); >+ warning_is { C4::Biblio::EmbedItemsInMarcBiblio() } >+ { carped => 'EmbedItemsInMarcBiblio: No MARC record passed' }, >+ 'Should crap is no record passed.'; >+ >+ C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber ); >+ my @items = $record->field($itemfield); >+ is( scalar @items, $number_of_items, 'Should return all items' ); >+ >+ C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, >+ [ $itemnumbers[1], $itemnumbers[3] ] ); >+ @items = $record->field($itemfield); >+ is( scalar @items, 2, 'Should return all items present in the list' ); >+ >+ C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, undef, 1 ); >+ @items = $record->field($itemfield); >+ is( scalar @items, $number_of_items, 'Should return all items for opac' ); >+ >+ my $opachiddenitems = " >+ homebranch: ['CPL']"; >+ t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems ); >+ >+ C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber ); >+ @items = $record->field($itemfield); >+ is( scalar @items, >+ $number_of_items, >+ 'Even with OpacHiddenItems set, all items should have been embeded' ); >+ >+ C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, undef, 1 ); >+ @items = $record->field($itemfield); >+ is( >+ scalar @items, >+ $number_of_items - $number_of_items_with_homebranch_is_CPL, >+'For OPAC, the pref OpacHiddenItems should have been take into account. Only items with homebranch ne CPL should have been embeded' >+ ); >+ >+ $opachiddenitems = " >+ homebranch: ['CPL', 'MPL']"; >+ t::lib::Mocks::mock_preference( 'OpacHiddenItems', $opachiddenitems ); >+ C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, undef, 1 ); >+ @items = $record->field($itemfield); >+ is( >+ scalar @items, >+ 0, >+'For OPAC, If all items are hidden, no item should have been embeded' >+ ); >+}; >+ > # Helper method to set up a Biblio. > sub get_biblio { > my $bib = MARC::Record->new(); >-- >2.1.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 12252
:
28228
|
28229
|
28243
|
28344
|
28345
|
29159
|
29160
|
33120
|
33121
|
33122
|
34890
|
35006
|
35007
|
35008
|
35009
|
35010
|
35011
|
41135
|
41136
|
41137
|
41138
|
41139
|
41140
|
41175
|
41176
|
41177
|
41178
|
41179
|
41180
|
42018
|
42019
|
42020
|
42021
|
42022
|
42023
|
42024
|
42314
|
42575
|
42576
|
42577
| 42578 |
42579
|
42580
|
42581