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

(-)a/t/db_dependent/CourseReserves/CourseItems.t (-2 / +70 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 => 27;
26
use Test::More tests => 28;
27
27
28
BEGIN {
28
BEGIN {
29
    require_ok('C4::CourseReserves');
29
    require_ok('C4::CourseReserves');
Lines 157-162 DelCourseReserve( cr_id => $cr_id2 ); Link Here
157
$item = Koha::Items->find($itemnumber);
157
$item = Koha::Items->find($itemnumber);
158
is($item->ccode, '', 'Item ccode should be set back to empty');
158
is($item->ccode, '', 'Item ccode should be set back to empty');
159
159
160
subtest 'Ensure item info is preserved' => sub {
161
    plan tests => 8;
162
163
    my $course = $builder->build({
164
        source => 'Course',
165
        value => {
166
            enabled => 'no',
167
        }
168
    });
169
    my $item = $builder->build_sample_item({ ccode=>"grasshopper", location=>"transylvania"});
170
    #Add course item but change nothing
171
    my $course_item_id = ModCourseItem(
172
        itemnumber    => $item->itemnumber,
173
        itype         => '',
174
        ccode         => '',
175
        holdingbranch => '',
176
        location      => '',
177
    );
178
    #Add course reserve
179
    my $course_reserve_id = ModCourseReserve(
180
        course_id   => $course->{course_id},
181
        ci_id       => $course_item_id,
182
        staff_note  => '',
183
        public_note => '',
184
    );
185
    #Remove course reservei
186
    DelCourseReserve( cr_id => $course_reserve_id );
187
    my $item_after = Koha::Items->find( $item->itemnumber );
188
    is( $item->itype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course");
189
    is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course");
190
    is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course");
191
    is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course");
192
    
193
    $course = $builder->build({
194
        source => 'Course',
195
        value => {
196
            enabled => 'yes',
197
        }
198
    });
199
    $item = $builder->build_sample_item({ ccode=>"grasshopper", location=>"transylvania"});
200
    #Add course item but change nothing
201
    $course_item_id = ModCourseItem(
202
        itemnumber    => $item->itemnumber,
203
        itype         => '',
204
        ccode         => '',
205
        holdingbranch => '',
206
        location      => '',
207
    );
208
    #Add course reserve
209
    $course_reserve_id = ModCourseReserve(
210
        course_id   => $course->{course_id},
211
        ci_id       => $course_item_id,
212
        staff_note  => '',
213
        public_note => '',
214
    );
215
    #Remove course reserve
216
    DelCourseReserve( cr_id => $course_reserve_id );
217
    $item_after = Koha::Items->find( $item->itemnumber );
218
    is( $item->itype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course");
219
    is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course");
220
    is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course");
221
    is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course");
222
    
223
};
224
225
226
227
228
160
$schema->storage->txn_rollback;
229
$schema->storage->txn_rollback;
161
230
162
sub create_dependent_objects {
231
sub create_dependent_objects {
163
- 

Return to bug 22142