|
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 => 17; |
26 |
use Test::More tests => 27; |
| 27 |
|
27 |
|
| 28 |
BEGIN { |
28 |
BEGIN { |
| 29 |
require_ok('C4::CourseReserves'); |
29 |
require_ok('C4::CourseReserves'); |
|
Lines 37-46
my $builder = t::lib::TestBuilder->new();
Link Here
|
| 37 |
create_dependent_objects(); |
37 |
create_dependent_objects(); |
| 38 |
my ($biblionumber, $itemnumber) = create_bib_and_item(); |
38 |
my ($biblionumber, $itemnumber) = create_bib_and_item(); |
| 39 |
|
39 |
|
| 40 |
my $course = $builder->build({ |
|
|
| 41 |
source => 'CourseReserve', |
| 42 |
}); |
| 43 |
|
| 44 |
my $ci_id = ModCourseItem( |
40 |
my $ci_id = ModCourseItem( |
| 45 |
itemnumber => $itemnumber, |
41 |
itemnumber => $itemnumber, |
| 46 |
itype => 'BK_foo', |
42 |
itype => 'BK_foo', |
|
Lines 49-54
my $ci_id = ModCourseItem(
Link Here
|
| 49 |
location => 'TH', |
45 |
location => 'TH', |
| 50 |
); |
46 |
); |
| 51 |
|
47 |
|
|
|
48 |
my $course = $builder->build({ |
| 49 |
source => 'CourseReserve', |
| 50 |
value => { |
| 51 |
ci_id => $ci_id, |
| 52 |
} |
| 53 |
}); |
| 54 |
|
| 52 |
my $cr_id = ModCourseReserve( |
55 |
my $cr_id = ModCourseReserve( |
| 53 |
course_id => $course->{course_id}, |
56 |
course_id => $course->{course_id}, |
| 54 |
ci_id => $ci_id, |
57 |
ci_id => $ci_id, |
|
Lines 68-73
is($item->ccode, 'BOOK', 'Item ccode in course should be BOOK');
Link Here
|
| 68 |
is($item->holdingbranch, 'B2', 'Item holding branch in course should be B2'); |
71 |
is($item->holdingbranch, 'B2', 'Item holding branch in course should be B2'); |
| 69 |
is($item->location, 'TH', 'Item location in course should be TH'); |
72 |
is($item->location, 'TH', 'Item location in course should be TH'); |
| 70 |
|
73 |
|
|
|
74 |
ModCourseItem( |
| 75 |
itemnumber => $itemnumber, |
| 76 |
itype => 'BK_foo', |
| 77 |
ccode => 'DVD', |
| 78 |
holdingbranch => 'B3', |
| 79 |
location => 'TH', |
| 80 |
); |
| 81 |
|
| 82 |
ModCourseReserve( |
| 83 |
course_id => $course->{course_id}, |
| 84 |
ci_id => $ci_id, |
| 85 |
staff_note => '', |
| 86 |
public_note => '', |
| 87 |
); |
| 88 |
|
| 89 |
$course_item = GetCourseItem( ci_id => $ci_id ); |
| 90 |
is($course_item->{itype}, 'CD_foo', 'Course item itype should be CD_foo'); |
| 91 |
is($course_item->{ccode}, 'CD', 'Course item ccode should be CD'); |
| 92 |
is($course_item->{holdingbranch}, 'B1', 'Course item holding branch should be B1'); |
| 93 |
is($course_item->{location}, 'HR', 'Course item location should be HR'); |
| 94 |
|
| 95 |
$item = Koha::Items->find($itemnumber); |
| 96 |
is($item->itype, 'BK_foo', 'Item type in course should be BK_foo'); |
| 97 |
is($item->ccode, 'DVD', 'Item ccode in course should be DVD'); |
| 98 |
is($item->holdingbranch, 'B3', 'Item holding branch in course should be B3'); |
| 99 |
is($item->location, 'TH', 'Item location in course should be TH'); |
| 100 |
|
| 71 |
DelCourseReserve( cr_id => $cr_id ); |
101 |
DelCourseReserve( cr_id => $cr_id ); |
| 72 |
$item = Koha::Items->find($itemnumber); |
102 |
$item = Koha::Items->find($itemnumber); |
| 73 |
is($item->itype, 'CD_foo', 'Item type removed from course should be set back to CD_foo'); |
103 |
is($item->itype, 'CD_foo', 'Item type removed from course should be set back to CD_foo'); |
|
Lines 102-107
is($item->ccode, 'BOOK', 'Item ccode should be BOOK');
Link Here
|
| 102 |
my $course_item2 = GetCourseItem( ci_id => $ci_id2 ); |
132 |
my $course_item2 = GetCourseItem( ci_id => $ci_id2 ); |
| 103 |
is($course_item2->{ccode}, '', 'Course item ccode should be empty'); |
133 |
is($course_item2->{ccode}, '', 'Course item ccode should be empty'); |
| 104 |
|
134 |
|
|
|
135 |
ModCourseItem( |
| 136 |
itemnumber => $itemnumber, |
| 137 |
itype => 'CD_foo', |
| 138 |
ccode => 'DVD', |
| 139 |
holdingbranch => 'B1', |
| 140 |
location => 'HR', |
| 141 |
); |
| 142 |
|
| 143 |
ModCourseReserve( |
| 144 |
course_id => $course->{course_id}, |
| 145 |
ci_id => $ci_id2, |
| 146 |
staff_note => '', |
| 147 |
public_note => '', |
| 148 |
); |
| 149 |
|
| 150 |
$item = Koha::Items->find($itemnumber); |
| 151 |
is($item->ccode, 'DVD', 'Item ccode should be BOOK'); |
| 152 |
|
| 153 |
$course_item2 = GetCourseItem( ci_id => $ci_id2 ); |
| 154 |
is($course_item2->{ccode}, '', 'Course item ccode should be empty'); |
| 155 |
|
| 105 |
DelCourseReserve( cr_id => $cr_id2 ); |
156 |
DelCourseReserve( cr_id => $cr_id2 ); |
| 106 |
$item = Koha::Items->find($itemnumber); |
157 |
$item = Koha::Items->find($itemnumber); |
| 107 |
is($item->ccode, '', 'Item ccode should be set back to empty'); |
158 |
is($item->ccode, '', 'Item ccode should be set back to empty'); |
|
Lines 142-147
sub create_dependent_objects {
Link Here
|
| 142 |
}); |
193 |
}); |
| 143 |
|
194 |
|
| 144 |
$builder->build({ |
195 |
$builder->build({ |
|
|
196 |
source => 'Branch', |
| 197 |
value => { |
| 198 |
branchcode => 'B3', |
| 199 |
branchname => 'Branch 3' |
| 200 |
} |
| 201 |
}); |
| 202 |
|
| 203 |
$builder->build({ |
| 145 |
source => 'AuthorisedValue', |
204 |
source => 'AuthorisedValue', |
| 146 |
value => { |
205 |
value => { |
| 147 |
category => 'CCODE', |
206 |
category => 'CCODE', |
|
Lines 154-159
sub create_dependent_objects {
Link Here
|
| 154 |
source => 'AuthorisedValue', |
213 |
source => 'AuthorisedValue', |
| 155 |
value => { |
214 |
value => { |
| 156 |
category => 'CCODE', |
215 |
category => 'CCODE', |
|
|
216 |
authorised_value => 'DVD', |
| 217 |
lib => 'Book' |
| 218 |
} |
| 219 |
}); |
| 220 |
|
| 221 |
$builder->build({ |
| 222 |
source => 'AuthorisedValue', |
| 223 |
value => { |
| 224 |
category => 'CCODE', |
| 157 |
authorised_value => 'CD', |
225 |
authorised_value => 'CD', |
| 158 |
lib => 'Compact Disk' |
226 |
lib => 'Compact Disk' |
| 159 |
} |
227 |
} |
| 160 |
- |
|
|