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