Bug 22142: Highlight the issue
authorNick Clemens <nick@bywatersolutions.com>
Thu, 13 Jun 2019 14:20:25 +0000 (14:20 +0000)
committerLucas Gass <lucas@bywatersolutions.com>
Wed, 28 Aug 2019 00:37:16 +0000 (00:37 +0000)
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 52885ff55b1cac4b09129cc504bb23d169b22c13)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 5f8bc12e592cb47bd762e5b06181331d12aeff0f)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

t/db_dependent/CourseReserves/CourseItems.t

index aca1715..38ceaa3 100644 (file)
@@ -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 {