View | Details | Raw Unified | Return to bug 25444
Collapse All | Expand All

(-)a/t/db_dependent/CourseReserves/CourseItems.t (-2 / +132 lines)
Lines 23-29 use C4::CourseReserves qw/ModCourseItem ModCourseReserve DelCourseReserve GetCou Link Here
23
use C4::Context;
23
use C4::Context;
24
use Koha::Items;
24
use Koha::Items;
25
25
26
use Test::More tests => 34;
26
use Test::More tests => 35;
27
27
28
BEGIN {
28
BEGIN {
29
    require_ok('C4::CourseReserves');
29
    require_ok('C4::CourseReserves');
Lines 202-207 DelCourseReserve( cr_id => $cr_id2 ); Link Here
202
$item = Koha::Items->find($itemnumber);
202
$item = Koha::Items->find($itemnumber);
203
is($item->ccode, '', 'Item ccode should be set back to empty');
203
is($item->ccode, '', 'Item ccode should be set back to empty');
204
204
205
subtest 'Ensure modifying fields on existing course items updates the item and course item' => sub {
206
    plan tests => 60;
207
208
    my ($biblionumber, $itemnumber) = create_bib_and_item();
209
    my $ci_id = ModCourseItem(
210
        itemnumber            => $itemnumber,
211
        itype_enabled         => 0,
212
        ccode_enabled         => 0,
213
        homebranch_enabled    => 0,
214
        holdingbranch_enabled => 0,
215
        location_enabled      => 0,
216
    );
217
218
    my $course = $builder->build({
219
        source => 'CourseReserve',
220
        value => {
221
            ci_id => $ci_id,
222
            enabled => 'no',
223
        }
224
    });
225
226
    my $cr_id = ModCourseReserve(
227
        course_id   => $course->{course_id},
228
        ci_id       => $ci_id,
229
        staff_note  => '',
230
        public_note => '',
231
    );
232
233
    my $course_item = GetCourseItem( ci_id => $ci_id );
234
    is($course_item->{itype_storage}, undef, 'Course item itype storage should be undef');
235
    is($course_item->{ccode_storage}, undef, 'Course item ccode storage should be undef');
236
    is($course_item->{homebranch_storage}, undef, 'Course item holding branch storage should be undef');
237
    is($course_item->{holdingbranch_storage}, undef, 'Course item holding branch storage should be undef');
238
    is($course_item->{location_storage}, undef, 'Course item location storage should be undef');
239
240
    is($course_item->{itype}, undef, 'Course item itype should be undef');
241
    is($course_item->{ccode}, undef, 'Course item ccode should be undef');
242
    is($course_item->{homebranch}, undef, 'Course item holding branch should be undef');
243
    is($course_item->{holdingbranch}, undef, 'Course item holding branch should be undef');
244
    is($course_item->{location}, undef, 'Course item location should be undef');
245
246
    is($course_item->{itype_enabled}, 0, 'Course item itype enabled should be 0');
247
    is($course_item->{ccode_enabled}, 0, 'Course item ccode enabled should be 0');
248
    is($course_item->{homebranch_enabled}, 0, 'Course item holding branch enabled should be 0');
249
    is($course_item->{holdingbranch_enabled}, 0, 'Course item holding branch enabled should be 0');
250
    is($course_item->{location_enabled}, 0, 'Course item location enabled should be 0');
251
252
    my $item = Koha::Items->find($itemnumber);
253
    is($item->effective_itemtype, 'CD_foo', 'Item type in course should be CD_foo');
254
    is($item->ccode, 'CD', 'Item ccode in course should be CD');
255
    is($item->homebranch, 'B1', 'Item home branch in course should be B1');
256
    is($item->holdingbranch, 'B1', 'Item holding branch in course should be B1');
257
    is($item->location, 'HR', 'Item location in course should be HR');
258
259
    ModCourseItem(
260
        itemnumber            => $itemnumber,
261
        itype_enabled         => 1,
262
        ccode_enabled         => 1,
263
        homebranch_enabled    => 1,
264
        holdingbranch_enabled => 1,
265
        location_enabled      => 1,
266
        itype                 => 'BK_foo',
267
        ccode                 => 'BOOK',
268
        homebranch            => 'B2',
269
        holdingbranch         => 'B2',
270
        location              => 'TH',
271
    );
272
273
    $course_item = GetCourseItem( ci_id => $ci_id );
274
    is($course_item->{itype_storage}, 'CD_foo', 'Course item itype storage should be CD_foo');
275
    is($course_item->{ccode_storage}, 'CD', 'Course item ccode storage should be CD');
276
    is($course_item->{homebranch_storage}, 'B1', 'Course item holding branch storage should be B1');
277
    is($course_item->{holdingbranch_storage}, 'B1', 'Course item holding branch storage should be B1');
278
    is($course_item->{location_storage}, 'HR', 'Course item location storage should be HR');
279
280
    is($course_item->{itype}, 'BK_foo', 'Course item itype should be BK_foo');
281
    is($course_item->{ccode}, 'BOOK', 'Course item ccode should be BOOK');
282
    is($course_item->{homebranch}, 'B2', 'Course item holding branch should be B2');
283
    is($course_item->{holdingbranch}, 'B2', 'Course item holding branch should be B2');
284
    is($course_item->{location}, 'TH', 'Course item location should be TH');
285
286
    is($course_item->{itype_enabled}, 1, 'Course item itype enabled should be 1');
287
    is($course_item->{ccode_enabled}, 1, 'Course item ccode enabled should be 1');
288
    is($course_item->{homebranch_enabled}, 1, 'Course item holding branch enabled should be 1');
289
    is($course_item->{holdingbranch_enabled}, 1, 'Course item holding branch enabled should be 1');
290
    is($course_item->{location_enabled}, 1, 'Course item location enabled should be 1');
291
292
    $item = Koha::Items->find($itemnumber);
293
    is($item->effective_itemtype, 'BK_foo', 'Item type in course should be BK_foo');
294
    is($item->ccode, 'BOOK', 'Item ccode in course should be BOOK');
295
    is($item->homebranch, 'B2', 'Item home branch in course should be B2');
296
    is($item->holdingbranch, 'B2', 'Item holding branch in course should be B2');
297
    is($item->location, 'TH', 'Item location in course should be TH');
298
299
    # Test removing fields from an active course item
300
    ModCourseItem(
301
        itemnumber            => $itemnumber,
302
        itype_enabled         => 0,
303
        ccode_enabled         => 0,
304
        homebranch_enabled    => 0,
305
        holdingbranch_enabled => 0,
306
        location_enabled      => 0,
307
    );
308
309
    $course_item = GetCourseItem( ci_id => $ci_id );
310
    is($course_item->{itype_storage}, undef, 'Course item itype storage should be undef');
311
    is($course_item->{ccode_storage}, undef, 'Course item ccode storage should be undef');
312
    is($course_item->{homebranch_storage}, undef, 'Course item holding branch storage should be undef');
313
    is($course_item->{holdingbranch_storage}, undef, 'Course item holding branch storage should be undef');
314
    is($course_item->{location_storage}, undef, 'Course item location storage should be undef');
315
316
    is($course_item->{itype}, undef, 'Course item itype should be undef');
317
    is($course_item->{ccode}, undef, 'Course item ccode should be undef');
318
    is($course_item->{homebranch}, undef, 'Course item holding branch should be undef');
319
    is($course_item->{holdingbranch}, undef, 'Course item holding branch should be undef');
320
    is($course_item->{location}, undef, 'Course item location should be undef');
321
322
    is($course_item->{itype_enabled}, 0, 'Course item itype enabled should be 0');
323
    is($course_item->{ccode_enabled}, 0, 'Course item ccode enabled should be 0');
324
    is($course_item->{homebranch_enabled}, 0, 'Course item holding branch enabled should be 0');
325
    is($course_item->{holdingbranch_enabled}, 0, 'Course item holding branch enabled should be 0');
326
    is($course_item->{location_enabled}, 0, 'Course item location enabled should be 0');
327
328
    $item = Koha::Items->find($itemnumber);
329
    is($item->effective_itemtype, 'CD_foo', 'Item type in course should be CD_foo');
330
    is($item->ccode, 'CD', 'Item ccode in course should be CD');
331
    is($item->homebranch, 'B1', 'Item home branch in course should be B1');
332
    is($item->holdingbranch, 'B1', 'Item holding branch in course should be B1');
333
    is($item->location, 'HR', 'Item location in course should be HR');
334
};
335
205
subtest 'Ensure item info is preserved' => sub {
336
subtest 'Ensure item info is preserved' => sub {
206
    plan tests => 8;
337
    plan tests => 8;
207
338
208
- 

Return to bug 25444