Lines 40-46
my $location = 'My Location';
Link Here
|
40 |
|
40 |
|
41 |
subtest 'General Add, Get and Del tests' => sub { |
41 |
subtest 'General Add, Get and Del tests' => sub { |
42 |
|
42 |
|
43 |
plan tests => 14; |
43 |
plan tests => 16; |
44 |
|
44 |
|
45 |
$schema->storage->txn_begin; |
45 |
$schema->storage->txn_begin; |
46 |
|
46 |
|
Lines 48-60
subtest 'General Add, Get and Del tests' => sub {
Link Here
|
48 |
my $library = $builder->build({ |
48 |
my $library = $builder->build({ |
49 |
source => 'Branch', |
49 |
source => 'Branch', |
50 |
}); |
50 |
}); |
|
|
51 |
my $itemtype = $builder->build({ |
52 |
source => 'Itemtype', |
53 |
}); |
51 |
|
54 |
|
52 |
# Create a biblio instance for testing |
55 |
# Create a biblio instance for testing |
53 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
56 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
54 |
my ($bibnum, $bibitemnum) = get_biblio(); |
57 |
my ($bibnum, $bibitemnum) = get_biblio(); |
55 |
|
58 |
|
56 |
# Add an item. |
59 |
# Add an item. |
57 |
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, location => $location } , $bibnum); |
60 |
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, location => $location, itype => $itemtype->{itemtype} } , $bibnum); |
58 |
cmp_ok($item_bibnum, '==', $bibnum, "New item is linked to correct biblionumber."); |
61 |
cmp_ok($item_bibnum, '==', $bibnum, "New item is linked to correct biblionumber."); |
59 |
cmp_ok($item_bibitemnum, '==', $bibitemnum, "New item is linked to correct biblioitemnumber."); |
62 |
cmp_ok($item_bibitemnum, '==', $bibitemnum, "New item is linked to correct biblioitemnumber."); |
60 |
|
63 |
|
Lines 75-81
subtest 'General Add, Get and Del tests' => sub {
Link Here
|
75 |
my $getdeleted = GetItem($itemnumber); |
78 |
my $getdeleted = GetItem($itemnumber); |
76 |
is($getdeleted->{'itemnumber'}, undef, "Item deleted as expected."); |
79 |
is($getdeleted->{'itemnumber'}, undef, "Item deleted as expected."); |
77 |
|
80 |
|
78 |
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, location => $location, permanent_location => 'my permanent location' } , $bibnum); |
81 |
($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode}, location => $location, permanent_location => 'my permanent location', itype => $itemtype->{itemtype} } , $bibnum); |
79 |
$getitem = GetItem($itemnumber); |
82 |
$getitem = GetItem($itemnumber); |
80 |
is( $getitem->{location}, $location, "The location should not have been modified" ); |
83 |
is( $getitem->{location}, $location, "The location should not have been modified" ); |
81 |
is( $getitem->{permanent_location}, 'my permanent location', "The permanent_location should not have modified" ); |
84 |
is( $getitem->{permanent_location}, 'my permanent location', "The permanent_location should not have modified" ); |
Lines 90-95
subtest 'General Add, Get and Del tests' => sub {
Link Here
|
90 |
is( $getitem->{location}, 'CART', "The location should have been set to CART" ); |
93 |
is( $getitem->{location}, 'CART', "The location should have been set to CART" ); |
91 |
is( $getitem->{permanent_location}, $location, "The permanent_location should not have been set to CART" ); |
94 |
is( $getitem->{permanent_location}, $location, "The permanent_location should not have been set to CART" ); |
92 |
|
95 |
|
|
|
96 |
C4::Context->set_preference('item-level_itypes', '1'); |
97 |
$getitem = GetItem($itemnumber); |
98 |
is( $getitem->{itype}, $itemtype->{itemtype}, "Itemtype set correctly when using item_level-itypes" ); |
99 |
C4::Context->set_preference('item-level_itypes', '0'); |
100 |
$getitem = GetItem($itemnumber); |
101 |
is( $getitem->{itype}, undef, "Itemtype set correctly when not using item_level-itypes" ); |
102 |
|
93 |
$schema->storage->txn_rollback; |
103 |
$schema->storage->txn_rollback; |
94 |
}; |
104 |
}; |
95 |
|
105 |
|
Lines 109-131
subtest 'GetHiddenItemnumbers tests' => sub {
Link Here
|
109 |
my $library2 = $builder->build({ |
119 |
my $library2 = $builder->build({ |
110 |
source => 'Branch', |
120 |
source => 'Branch', |
111 |
}); |
121 |
}); |
|
|
122 |
my $itemtype = $builder->build({ |
123 |
source => 'Itemtype', |
124 |
}); |
112 |
|
125 |
|
113 |
# Create a new biblio |
126 |
# Create a new biblio |
114 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
127 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
115 |
my ($biblionumber, $biblioitemnumber) = get_biblio(); |
128 |
my ($biblionumber, $biblioitemnumber) = get_biblio(); |
116 |
|
129 |
|
117 |
# Add two items |
130 |
# Add two items |
118 |
my ($item1_bibnum, $item1_bibitemnum, $item1_itemnumber) = AddItem( |
131 |
my ( $item1_bibnum, $item1_bibitemnum, $item1_itemnumber ) = AddItem( |
119 |
{ homebranch => $library1->{branchcode}, |
132 |
{ |
120 |
holdingbranch => $library1->{branchcode}, |
133 |
homebranch => $library1->{branchcode}, |
121 |
withdrawn => 1 }, |
134 |
holdingbranch => $library1->{branchcode}, |
122 |
$biblionumber |
135 |
withdrawn => 1, |
|
|
136 |
itype => $itemtype->{itemtype}, |
137 |
}, |
138 |
$biblionumber |
123 |
); |
139 |
); |
124 |
my ($item2_bibnum, $item2_bibitemnum, $item2_itemnumber) = AddItem( |
140 |
my ( $item2_bibnum, $item2_bibitemnum, $item2_itemnumber ) = AddItem( |
125 |
{ homebranch => $library2->{branchcode}, |
141 |
{ |
126 |
holdingbranch => $library2->{branchcode}, |
142 |
homebranch => $library2->{branchcode}, |
127 |
withdrawn => 0 }, |
143 |
holdingbranch => $library2->{branchcode}, |
128 |
$biblionumber |
144 |
withdrawn => 0, |
|
|
145 |
itype => $itemtype->{itemtype}, |
146 |
}, |
147 |
$biblionumber |
129 |
); |
148 |
); |
130 |
|
149 |
|
131 |
my $opachiddenitems; |
150 |
my $opachiddenitems; |
Lines 192-206
subtest 'GetItemsInfo tests' => sub {
Link Here
|
192 |
my $library2 = $builder->build({ |
211 |
my $library2 = $builder->build({ |
193 |
source => 'Branch', |
212 |
source => 'Branch', |
194 |
}); |
213 |
}); |
|
|
214 |
my $itemtype = $builder->build({ |
215 |
source => 'Itemtype', |
216 |
}); |
195 |
|
217 |
|
196 |
# Add a biblio |
218 |
# Add a biblio |
197 |
my ($biblionumber, $biblioitemnumber) = get_biblio(); |
219 |
my ($biblionumber, $biblioitemnumber) = get_biblio(); |
198 |
# Add an item |
220 |
# Add an item |
199 |
my ($item_bibnum, $item_bibitemnum, $itemnumber) |
221 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
200 |
= AddItem({ |
222 |
{ |
201 |
homebranch => $library1->{branchcode}, |
223 |
homebranch => $library1->{branchcode}, |
202 |
holdingbranch => $library2->{branchcode}, |
224 |
holdingbranch => $library2->{branchcode}, |
203 |
}, $biblionumber ); |
225 |
itype => $itemtype->{itemtype}, |
|
|
226 |
}, |
227 |
$biblionumber |
228 |
); |
204 |
|
229 |
|
205 |
my $branch = GetBranchDetail( $library1->{branchcode} ); |
230 |
my $branch = GetBranchDetail( $library1->{branchcode} ); |
206 |
$branch->{ opac_info } = "homebranch OPAC info"; |
231 |
$branch->{ opac_info } = "homebranch OPAC info"; |
Lines 279-284
subtest 'SearchItems test' => sub {
Link Here
|
279 |
my $library2 = $builder->build({ |
304 |
my $library2 = $builder->build({ |
280 |
source => 'Branch', |
305 |
source => 'Branch', |
281 |
}); |
306 |
}); |
|
|
307 |
my $itemtype = $builder->build({ |
308 |
source => 'Itemtype', |
309 |
}); |
282 |
|
310 |
|
283 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
311 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
284 |
my $cpl_items_before = SearchItemsByField( 'homebranch', $library1->{branchcode}); |
312 |
my $cpl_items_before = SearchItemsByField( 'homebranch', $library1->{branchcode}); |
Lines 291-300
subtest 'SearchItems test' => sub {
Link Here
|
291 |
my (undef, undef, $item1_itemnumber) = AddItem({ |
319 |
my (undef, undef, $item1_itemnumber) = AddItem({ |
292 |
homebranch => $library1->{branchcode}, |
320 |
homebranch => $library1->{branchcode}, |
293 |
holdingbranch => $library1->{branchcode}, |
321 |
holdingbranch => $library1->{branchcode}, |
|
|
322 |
itype => $itemtype->{itemtype}, |
294 |
}, $biblionumber); |
323 |
}, $biblionumber); |
295 |
my (undef, undef, $item2_itemnumber) = AddItem({ |
324 |
my (undef, undef, $item2_itemnumber) = AddItem({ |
296 |
homebranch => $library2->{branchcode}, |
325 |
homebranch => $library2->{branchcode}, |
297 |
holdingbranch => $library2->{branchcode}, |
326 |
holdingbranch => $library2->{branchcode}, |
|
|
327 |
itype => $itemtype->{itemtype}, |
298 |
}, $biblionumber); |
328 |
}, $biblionumber); |
299 |
|
329 |
|
300 |
my ($items, $total_results); |
330 |
my ($items, $total_results); |
Lines 442-452
subtest 'Koha::Item(s) tests' => sub {
Link Here
|
442 |
my $library2 = $builder->build({ |
472 |
my $library2 = $builder->build({ |
443 |
source => 'Branch', |
473 |
source => 'Branch', |
444 |
}); |
474 |
}); |
|
|
475 |
my $itemtype = $builder->build({ |
476 |
source => 'Itemtype', |
477 |
}); |
445 |
|
478 |
|
446 |
# Create a biblio and item for testing |
479 |
# Create a biblio and item for testing |
447 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
480 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
448 |
my ($bibnum, $bibitemnum) = get_biblio(); |
481 |
my ($bibnum, $bibitemnum) = get_biblio(); |
449 |
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $library1->{branchcode}, holdingbranch => $library2->{branchcode} } , $bibnum); |
482 |
my ( $item_bibnum, $item_bibitemnum, $itemnumber ) = AddItem( |
|
|
483 |
{ |
484 |
homebranch => $library1->{branchcode}, |
485 |
holdingbranch => $library2->{branchcode}, |
486 |
itype => $itemtype->{itemtype}, |
487 |
}, |
488 |
$bibnum |
489 |
); |
450 |
|
490 |
|
451 |
# Get item. |
491 |
# Get item. |
452 |
my $item = Koha::Items->find( $itemnumber ); |
492 |
my $item = Koha::Items->find( $itemnumber ); |
Lines 475-480
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
Link Here
|
475 |
my $library2 = $builder->build({ |
515 |
my $library2 = $builder->build({ |
476 |
source => 'Branch', |
516 |
source => 'Branch', |
477 |
}); |
517 |
}); |
|
|
518 |
my $itemtype = $builder->build({ |
519 |
source => 'Itemtype', |
520 |
}); |
478 |
|
521 |
|
479 |
my ( $biblionumber, $biblioitemnumber ) = get_biblio(); |
522 |
my ( $biblionumber, $biblioitemnumber ) = get_biblio(); |
480 |
my $item_infos = [ |
523 |
my $item_infos = [ |
Lines 496-502
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
Link Here
|
496 |
my ( undef, undef, $itemnumber ) = AddItem( |
539 |
my ( undef, undef, $itemnumber ) = AddItem( |
497 |
{ |
540 |
{ |
498 |
homebranch => $item_info->{homebranch}, |
541 |
homebranch => $item_info->{homebranch}, |
499 |
holdingbranch => $item_info->{holdingbanch} |
542 |
holdingbranch => $item_info->{holdingbanch}, |
|
|
543 |
itype => $itemtype->{itemtype}, |
500 |
}, |
544 |
}, |
501 |
$biblionumber |
545 |
$biblionumber |
502 |
); |
546 |
); |
503 |
- |
|
|