From df285ecbe02c1f86b37145f0119e739a014f84c4 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 13 Jun 2019 14:20:25 +0000 Subject: [PATCH] Bug 22142: Highlight the issue Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer --- t/db_dependent/CourseReserves/CourseItems.t | 69 +++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/t/db_dependent/CourseReserves/CourseItems.t b/t/db_dependent/CourseReserves/CourseItems.t index aca171571c..38ceaa39e3 100644 --- a/t/db_dependent/CourseReserves/CourseItems.t +++ b/t/db_dependent/CourseReserves/CourseItems.t @@ -167,6 +167,75 @@ DelCourseReserve( cr_id => $cr_id2 ); $item = Koha::Items->find($itemnumber); is($item->ccode, '', 'Item ccode should be set back to empty'); +subtest 'Ensure item info is preserved' => sub { + plan tests => 8; + + my $course = $builder->build({ + source => 'Course', + value => { + enabled => 'no', + } + }); + my $item = $builder->build_sample_item({ ccode=>"grasshopper", location=>"transylvania"}); + #Add course item but change nothing + my $course_item_id = ModCourseItem( + itemnumber => $item->itemnumber, + itype => '', + ccode => '', + holdingbranch => '', + location => '', + ); + #Add course reserve + my $course_reserve_id = ModCourseReserve( + course_id => $course->{course_id}, + ci_id => $course_item_id, + staff_note => '', + public_note => '', + ); + #Remove course reservei + DelCourseReserve( cr_id => $course_reserve_id ); + my $item_after = Koha::Items->find( $item->itemnumber ); + is( $item->itype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course"); + is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course"); + is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course"); + is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course"); + + $course = $builder->build({ + source => 'Course', + value => { + enabled => 'yes', + } + }); + $item = $builder->build_sample_item({ ccode=>"grasshopper", location=>"transylvania"}); + #Add course item but change nothing + $course_item_id = ModCourseItem( + itemnumber => $item->itemnumber, + itype => '', + ccode => '', + holdingbranch => '', + location => '', + ); + #Add course reserve + $course_reserve_id = ModCourseReserve( + course_id => $course->{course_id}, + ci_id => $course_item_id, + staff_note => '', + public_note => '', + ); + #Remove course reserve + DelCourseReserve( cr_id => $course_reserve_id ); + $item_after = Koha::Items->find( $item->itemnumber ); + is( $item->itype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course"); + is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course"); + is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course"); + is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course"); + +}; + + + + + $schema->storage->txn_rollback; sub create_dependent_objects { -- 2.11.0