|
Lines 1-4
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
|
|
2 |
use Carp::Always; |
| 2 |
|
3 |
|
| 3 |
# This file is part of Koha. |
4 |
# This file is part of Koha. |
| 4 |
# |
5 |
# |
|
Lines 38-54
create_dependent_objects();
Link Here
|
| 38 |
my ($biblionumber, $itemnumber) = create_bib_and_item(); |
39 |
my ($biblionumber, $itemnumber) = create_bib_and_item(); |
| 39 |
|
40 |
|
| 40 |
my $ci_id = ModCourseItem( |
41 |
my $ci_id = ModCourseItem( |
| 41 |
itemnumber => $itemnumber, |
42 |
itemnumber => $itemnumber, |
| 42 |
itype => 'BK_foo', |
43 |
itype_enabled => 1, |
| 43 |
ccode => 'BOOK', |
44 |
ccode_enabled => 1, |
| 44 |
holdingbranch => 'B2', |
45 |
holdingbranch_enabled => 1, |
| 45 |
location => 'TH', |
46 |
location_enabled => 1, |
|
|
47 |
itype => 'BK_foo', |
| 48 |
ccode => 'BOOK', |
| 49 |
holdingbranch => 'B2', |
| 50 |
location => 'TH', |
| 46 |
); |
51 |
); |
| 47 |
|
52 |
|
| 48 |
my $course = $builder->build({ |
53 |
my $course = $builder->build({ |
| 49 |
source => 'CourseReserve', |
54 |
source => 'CourseReserve', |
| 50 |
value => { |
55 |
value => { |
| 51 |
ci_id => $ci_id, |
56 |
ci_id => $ci_id, |
|
|
57 |
enabled => 'no', |
| 52 |
} |
58 |
} |
| 53 |
}); |
59 |
}); |
| 54 |
|
60 |
|
|
Lines 60-82
my $cr_id = ModCourseReserve(
Link Here
|
| 60 |
); |
66 |
); |
| 61 |
|
67 |
|
| 62 |
my $course_item = GetCourseItem( ci_id => $ci_id ); |
68 |
my $course_item = GetCourseItem( ci_id => $ci_id ); |
| 63 |
is($course_item->{itype}, 'CD_foo', 'Course item itype should be CD_foo'); |
69 |
is($course_item->{itype_storage}, 'CD_foo', 'Course item itype storage should be CD_foo'); |
| 64 |
is($course_item->{ccode}, 'CD', 'Course item ccode should be CD'); |
70 |
is($course_item->{ccode_storage}, 'CD', 'Course item ccode storage should be CD'); |
| 65 |
is($course_item->{holdingbranch}, 'B1', 'Course item holding branch should be B1'); |
71 |
is($course_item->{holdingbranch_storage}, 'B1', 'Course item holding branch storage should be B1'); |
| 66 |
is($course_item->{location}, 'HR', 'Course item location should be HR'); |
72 |
is($course_item->{location_storage}, 'HR', 'Course item location storage should be HR'); |
| 67 |
|
73 |
|
| 68 |
my $item = Koha::Items->find($itemnumber); |
74 |
my $item = Koha::Items->find($itemnumber); |
| 69 |
is($item->itype, 'BK_foo', 'Item type in course should be BK_foo'); |
75 |
is($item->effective_itemtype, 'BK_foo', 'Item type in course should be BK_foo'); |
| 70 |
is($item->ccode, 'BOOK', 'Item ccode in course should be BOOK'); |
76 |
is($item->ccode, 'BOOK', 'Item ccode in course should be BOOK'); |
| 71 |
is($item->holdingbranch, 'B2', 'Item holding branch in course should be B2'); |
77 |
is($item->holdingbranch, 'B2', 'Item holding branch in course should be B2'); |
| 72 |
is($item->location, 'TH', 'Item location in course should be TH'); |
78 |
is($item->location, 'TH', 'Item location in course should be TH'); |
| 73 |
|
79 |
|
| 74 |
ModCourseItem( |
80 |
ModCourseItem( |
| 75 |
itemnumber => $itemnumber, |
81 |
itemnumber => $itemnumber, |
| 76 |
itype => 'BK_foo', |
82 |
itype_enabled => 1, |
| 77 |
ccode => 'DVD', |
83 |
ccode_enabled => 1, |
| 78 |
holdingbranch => 'B3', |
84 |
holdingbranch_enabled => 1, |
| 79 |
location => 'TH', |
85 |
location_enabled => 1, |
|
|
86 |
itype => 'BK_foo', |
| 87 |
ccode => 'DVD', |
| 88 |
holdingbranch => 'B3', |
| 89 |
location => 'TH', |
| 80 |
); |
90 |
); |
| 81 |
|
91 |
|
| 82 |
ModCourseReserve( |
92 |
ModCourseReserve( |
|
Lines 87-106
ModCourseReserve(
Link Here
|
| 87 |
); |
97 |
); |
| 88 |
|
98 |
|
| 89 |
$course_item = GetCourseItem( ci_id => $ci_id ); |
99 |
$course_item = GetCourseItem( ci_id => $ci_id ); |
| 90 |
is($course_item->{itype}, 'CD_foo', 'Course item itype should be CD_foo'); |
100 |
is($course_item->{itype_storage}, 'CD_foo', 'Course item itype storage should be CD_foo'); |
| 91 |
is($course_item->{ccode}, 'CD', 'Course item ccode should be CD'); |
101 |
is($course_item->{ccode_storage}, 'CD', 'Course item ccode storage should be CD'); |
| 92 |
is($course_item->{holdingbranch}, 'B1', 'Course item holding branch should be B1'); |
102 |
is($course_item->{holdingbranch_storage}, 'B1', 'Course item holding branch storage should be B1'); |
| 93 |
is($course_item->{location}, 'HR', 'Course item location should be HR'); |
103 |
is($course_item->{location_storage}, 'HR', 'Course item location storage should be HR'); |
| 94 |
|
104 |
|
| 95 |
$item = Koha::Items->find($itemnumber); |
105 |
$item = Koha::Items->find($itemnumber); |
| 96 |
is($item->itype, 'BK_foo', 'Item type in course should be BK_foo'); |
106 |
is($item->effective_itemtype, 'BK_foo', 'Item type in course should be BK_foo'); |
| 97 |
is($item->ccode, 'DVD', 'Item ccode in course should be DVD'); |
107 |
is($item->ccode, 'DVD', 'Item ccode in course should be DVD'); |
| 98 |
is($item->holdingbranch, 'B3', 'Item holding branch in course should be B3'); |
108 |
is($item->holdingbranch, 'B3', 'Item holding branch in course should be B3'); |
| 99 |
is($item->location, 'TH', 'Item location in course should be TH'); |
109 |
is($item->location, 'TH', 'Item location in course should be TH'); |
| 100 |
|
110 |
|
| 101 |
DelCourseReserve( cr_id => $cr_id ); |
111 |
DelCourseReserve( cr_id => $cr_id ); |
| 102 |
$item = Koha::Items->find($itemnumber); |
112 |
$item = Koha::Items->find($itemnumber); |
| 103 |
is($item->itype, 'CD_foo', 'Item type removed from course should be set back to CD_foo'); |
113 |
is($item->effective_itemtype, 'CD_foo', 'Item type removed from course should be set back to CD_foo'); |
| 104 |
is($item->ccode, 'CD', 'Item ccode removed from course should be set back to CD'); |
114 |
is($item->ccode, 'CD', 'Item ccode removed from course should be set back to CD'); |
| 105 |
is($item->holdingbranch, 'B1', 'Item holding branch removed from course should be set back B1'); |
115 |
is($item->holdingbranch, 'B1', 'Item holding branch removed from course should be set back B1'); |
| 106 |
is($item->location, 'HR', 'Item location removed from course should be TH'); |
116 |
is($item->location, 'HR', 'Item location removed from course should be TH'); |
|
Lines 112-122
$item = Koha::Items->find($itemnumber);
Link Here
|
| 112 |
is($item->ccode, '', 'Item ccode should be empty'); |
122 |
is($item->ccode, '', 'Item ccode should be empty'); |
| 113 |
|
123 |
|
| 114 |
my $ci_id2 = ModCourseItem( |
124 |
my $ci_id2 = ModCourseItem( |
| 115 |
itemnumber => $itemnumber, |
125 |
itemnumber => $itemnumber, |
| 116 |
itype => 'CD_foo', |
126 |
itype_enabled => 1, |
| 117 |
ccode => 'BOOK', |
127 |
ccode_enabled => 1, |
| 118 |
holdingbranch => 'B1', |
128 |
holdingbranch_enabled => 1, |
| 119 |
location => 'HR', |
129 |
location_enabled => 1, |
|
|
130 |
itype => 'CD_foo', |
| 131 |
ccode => 'BOOK', |
| 132 |
holdingbranch => 'B1', |
| 133 |
location => 'HR', |
| 120 |
); |
134 |
); |
| 121 |
|
135 |
|
| 122 |
my $cr_id2 = ModCourseReserve( |
136 |
my $cr_id2 = ModCourseReserve( |
|
Lines 130-143
$item = Koha::Items->find($itemnumber);
Link Here
|
| 130 |
is($item->ccode, 'BOOK', 'Item ccode should be BOOK'); |
144 |
is($item->ccode, 'BOOK', 'Item ccode should be BOOK'); |
| 131 |
|
145 |
|
| 132 |
my $course_item2 = GetCourseItem( ci_id => $ci_id2 ); |
146 |
my $course_item2 = GetCourseItem( ci_id => $ci_id2 ); |
| 133 |
is($course_item2->{ccode}, '', 'Course item ccode should be empty'); |
147 |
is($course_item2->{ccode_storage}, '', 'Course item ccode storage should be empty'); |
| 134 |
|
148 |
|
| 135 |
ModCourseItem( |
149 |
ModCourseItem( |
| 136 |
itemnumber => $itemnumber, |
150 |
itemnumber => $itemnumber, |
| 137 |
itype => 'CD_foo', |
151 |
itype_enabled => 1, |
| 138 |
ccode => 'DVD', |
152 |
ccode_enabled => 1, |
| 139 |
holdingbranch => 'B1', |
153 |
holdingbranch_enabled => 1, |
| 140 |
location => 'HR', |
154 |
location_enabled => 1, |
|
|
155 |
itype => 'CD_foo', |
| 156 |
ccode => 'DVD', |
| 157 |
holdingbranch => 'B1', |
| 158 |
location => 'HR', |
| 141 |
); |
159 |
); |
| 142 |
|
160 |
|
| 143 |
ModCourseReserve( |
161 |
ModCourseReserve( |
|
Lines 151-167
$item = Koha::Items->find($itemnumber);
Link Here
|
| 151 |
is($item->ccode, 'DVD', 'Item ccode should be DVD'); |
169 |
is($item->ccode, 'DVD', 'Item ccode should be DVD'); |
| 152 |
|
170 |
|
| 153 |
ModCourseItem( |
171 |
ModCourseItem( |
| 154 |
itemnumber => $itemnumber, |
172 |
itemnumber => $itemnumber, |
| 155 |
itype => 'BK', |
173 |
itype_enabled => 1, |
| 156 |
ccode => 'BOOK', |
174 |
ccode_enabled => 1, |
| 157 |
holdingbranch => '', # LEAVE UNCHANGED |
175 |
holdingbranch_enabled => 0, # LEAVE UNCHANGED |
| 158 |
location => 'TH', |
176 |
location_enabled => 1, |
|
|
177 |
itype => 'BK', |
| 178 |
ccode => 'BOOK', |
| 179 |
holdingbranch => undef, # LEAVE UNCHANGED |
| 180 |
location => 'TH', |
| 159 |
); |
181 |
); |
| 160 |
$item = Koha::Items->find($itemnumber); |
182 |
$item = Koha::Items->find($itemnumber); |
| 161 |
is($item->ccode, 'BOOK', 'Item ccode should be BOOK'); |
183 |
is($item->ccode, 'BOOK', 'Item ccode should be BOOK'); |
| 162 |
|
184 |
|
| 163 |
$course_item2 = GetCourseItem( ci_id => $ci_id2 ); |
185 |
$course_item2 = GetCourseItem( ci_id => $ci_id2 ); |
| 164 |
is($course_item2->{ccode}, '', 'Course item ccode should be empty'); |
186 |
is($course_item2->{ccode_storage}, '', 'Course item ccode storage should be empty'); |
| 165 |
|
187 |
|
| 166 |
DelCourseReserve( cr_id => $cr_id2 ); |
188 |
DelCourseReserve( cr_id => $cr_id2 ); |
| 167 |
$item = Koha::Items->find($itemnumber); |
189 |
$item = Koha::Items->find($itemnumber); |
|
Lines 195-201
subtest 'Ensure item info is preserved' => sub {
Link Here
|
| 195 |
#Remove course reservei |
217 |
#Remove course reservei |
| 196 |
DelCourseReserve( cr_id => $course_reserve_id ); |
218 |
DelCourseReserve( cr_id => $course_reserve_id ); |
| 197 |
my $item_after = Koha::Items->find( $item->itemnumber ); |
219 |
my $item_after = Koha::Items->find( $item->itemnumber ); |
| 198 |
is( $item->itype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course"); |
220 |
is( $item->effective_itemtype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course"); |
| 199 |
is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course"); |
221 |
is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course"); |
| 200 |
is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course"); |
222 |
is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course"); |
| 201 |
is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course"); |
223 |
is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course"); |
|
Lines 225-231
subtest 'Ensure item info is preserved' => sub {
Link Here
|
| 225 |
#Remove course reserve |
247 |
#Remove course reserve |
| 226 |
DelCourseReserve( cr_id => $course_reserve_id ); |
248 |
DelCourseReserve( cr_id => $course_reserve_id ); |
| 227 |
$item_after = Koha::Items->find( $item->itemnumber ); |
249 |
$item_after = Koha::Items->find( $item->itemnumber ); |
| 228 |
is( $item->itype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course"); |
250 |
is( $item->effective_itemtype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course"); |
| 229 |
is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course"); |
251 |
is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course"); |
| 230 |
is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course"); |
252 |
is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course"); |
| 231 |
is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course"); |
253 |
is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course"); |
| 232 |
- |
|
|