|
Lines 76-164
my $itemtype = $builder->build(
Link Here
|
| 76 |
value => { notforloan => undef, rentalcharge => 0 } |
76 |
value => { notforloan => undef, rentalcharge => 0 } |
| 77 |
} |
77 |
} |
| 78 |
)->{itemtype}; |
78 |
)->{itemtype}; |
| 79 |
|
79 |
my $branchcode_1 = $builder->build({ source => 'Branch' })->{branchcode}; |
| 80 |
#Add Dates |
80 |
my $branchcode_2 = $builder->build({ source => 'Branch' })->{branchcode}; |
| 81 |
|
81 |
my $categorycode = $builder->build({ |
| 82 |
my $dt_today = dt_from_string; |
82 |
source => 'Category', |
| 83 |
my $today = output_pref({ dt => $dt_today, dateformat => 'iso', timeformat => '24hr', dateonly => 1 }); |
83 |
value => { enrolmentfee => undef } |
|
|
84 |
})->{categorycode}; |
| 85 |
|
| 86 |
# Add Dates |
| 87 |
my $dt_today = dt_from_string; |
| 88 |
my $today = output_pref( |
| 89 |
{ dt => $dt_today, |
| 90 |
dateformat => 'iso', |
| 91 |
timeformat => '24hr', |
| 92 |
dateonly => 1 |
| 93 |
} |
| 94 |
); |
| 84 |
|
95 |
|
| 85 |
my $dt_today2 = dt_from_string; |
96 |
my $dt_today2 = dt_from_string; |
| 86 |
my $dur10 = DateTime::Duration->new( days => -10 ); |
97 |
my $dur10 = DateTime::Duration->new( days => -10 ); |
| 87 |
$dt_today2->add_duration($dur10); |
98 |
$dt_today2->add_duration($dur10); |
| 88 |
my $daysago10 = output_pref({ dt => $dt_today2, dateformat => 'iso', timeformat => '24hr', dateonly => 1 }); |
99 |
my $daysago10 = output_pref( |
| 89 |
|
100 |
{ dt => $dt_today2, |
| 90 |
#Add branch and category |
101 |
dateformat => 'iso', |
| 91 |
my $samplebranch1 = { |
102 |
timeformat => '24hr', |
| 92 |
branchcode => 'CPL', |
103 |
dateonly => 1 |
| 93 |
branchname => 'Sample Branch', |
104 |
} |
| 94 |
branchaddress1 => 'sample adr1', |
|
|
| 95 |
branchaddress2 => 'sample adr2', |
| 96 |
branchaddress3 => 'sample adr3', |
| 97 |
branchzip => 'sample zip', |
| 98 |
branchcity => 'sample city', |
| 99 |
branchstate => 'sample state', |
| 100 |
branchcountry => 'sample country', |
| 101 |
branchphone => 'sample phone', |
| 102 |
branchfax => 'sample fax', |
| 103 |
branchemail => 'sample email', |
| 104 |
branchurl => 'sample url', |
| 105 |
branchip => 'sample ip', |
| 106 |
branchprinter => undef, |
| 107 |
opac_info => 'sample opac', |
| 108 |
}; |
| 109 |
my $samplebranch2 = { |
| 110 |
branchcode => 'MPL', |
| 111 |
branchname => 'Sample Branch2', |
| 112 |
branchaddress1 => 'sample adr1_2', |
| 113 |
branchaddress2 => 'sample adr2_2', |
| 114 |
branchaddress3 => 'sample adr3_2', |
| 115 |
branchzip => 'sample zip2', |
| 116 |
branchcity => 'sample city2', |
| 117 |
branchstate => 'sample state2', |
| 118 |
branchcountry => 'sample country2', |
| 119 |
branchphone => 'sample phone2', |
| 120 |
branchfax => 'sample fax2', |
| 121 |
branchemail => 'sample email2', |
| 122 |
branchurl => 'sample url2', |
| 123 |
branchip => 'sample ip2', |
| 124 |
branchprinter => undef, |
| 125 |
opac_info => 'sample opac2', |
| 126 |
}; |
| 127 |
Koha::Library->new($samplebranch1)->store; |
| 128 |
Koha::Library->new($samplebranch2)->store; |
| 129 |
|
| 130 |
my $samplecat = { |
| 131 |
categorycode => 'CAT1', |
| 132 |
description => 'Description1', |
| 133 |
enrolmentperiod => 'Null', |
| 134 |
enrolmentperioddate => 'Null', |
| 135 |
dateofbirthrequired => 'Null', |
| 136 |
finetype => 'Null', |
| 137 |
bulk => 'Null', |
| 138 |
enrolmentfee => 'Null', |
| 139 |
overduenoticerequired => 'Null', |
| 140 |
issuelimit => 'Null', |
| 141 |
reservefee => 'Null', |
| 142 |
hidelostitems => 0, |
| 143 |
category_type => 'Null' |
| 144 |
}; |
| 145 |
my $query = |
| 146 |
"INSERT INTO categories (categorycode,description,enrolmentperiod,enrolmentperioddate,dateofbirthrequired ,finetype,bulk,enrolmentfee,overduenoticerequired,issuelimit ,reservefee ,hidelostitems ,category_type) VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
| 147 |
$dbh->do( |
| 148 |
$query, {}, |
| 149 |
$samplecat->{categorycode}, $samplecat->{description}, |
| 150 |
$samplecat->{enrolmentperiod}, $samplecat->{enrolmentperioddate}, |
| 151 |
$samplecat->{dateofbirthrequired}, $samplecat->{finetype}, |
| 152 |
$samplecat->{bulk}, $samplecat->{enrolmentfee}, |
| 153 |
$samplecat->{overduenoticerequired}, $samplecat->{issuelimit}, |
| 154 |
$samplecat->{reservefee}, $samplecat->{hidelostitems}, |
| 155 |
$samplecat->{category_type} |
| 156 |
); |
105 |
); |
| 157 |
|
106 |
|
| 158 |
#Add biblio and item |
107 |
# Add biblio and item |
| 159 |
my $record = MARC::Record->new(); |
108 |
my $record = MARC::Record->new(); |
| 160 |
$record->append_fields( |
109 |
$record->append_fields( |
| 161 |
MARC::Field->new( '952', '0', '0', a => $samplebranch1->{branchcode} ) ); |
110 |
MARC::Field->new( '952', '0', '0', a => $branchcode_1 ) ); |
|
|
111 |
|
| 162 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); |
112 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio( $record, '' ); |
| 163 |
|
113 |
|
| 164 |
my $barcode_1 = 'barcode_1'; |
114 |
my $barcode_1 = 'barcode_1'; |
|
Lines 167-174
my @sampleitem1 = C4::Items::AddItem(
Link Here
|
| 167 |
{ |
117 |
{ |
| 168 |
barcode => $barcode_1, |
118 |
barcode => $barcode_1, |
| 169 |
itemcallnumber => 'callnumber1', |
119 |
itemcallnumber => 'callnumber1', |
| 170 |
homebranch => $samplebranch1->{branchcode}, |
120 |
homebranch => $branchcode_1, |
| 171 |
holdingbranch => $samplebranch1->{branchcode}, |
121 |
holdingbranch => $branchcode_1, |
| 172 |
issue => 1, |
122 |
issue => 1, |
| 173 |
reserve => 1, |
123 |
reserve => 1, |
| 174 |
itype => $itemtype |
124 |
itype => $itemtype |
|
Lines 180-187
my @sampleitem2 = C4::Items::AddItem(
Link Here
|
| 180 |
{ |
130 |
{ |
| 181 |
barcode => $barcode_2, |
131 |
barcode => $barcode_2, |
| 182 |
itemcallnumber => 'callnumber2', |
132 |
itemcallnumber => 'callnumber2', |
| 183 |
homebranch => $samplebranch2->{branchcode}, |
133 |
homebranch => $branchcode_2, |
| 184 |
holdingbranch => $samplebranch2->{branchcode}, |
134 |
holdingbranch => $branchcode_2, |
| 185 |
notforloan => 1, |
135 |
notforloan => 1, |
| 186 |
issue => 1, |
136 |
issue => 1, |
| 187 |
itype => $itemtype |
137 |
itype => $itemtype |
|
Lines 194-215
my $item_id2 = $sampleitem2[2];
Link Here
|
| 194 |
my $borrower_id1 = C4::Members::AddMember( |
144 |
my $borrower_id1 = C4::Members::AddMember( |
| 195 |
firstname => 'firstname1', |
145 |
firstname => 'firstname1', |
| 196 |
surname => 'surname1 ', |
146 |
surname => 'surname1 ', |
| 197 |
categorycode => $samplecat->{categorycode}, |
147 |
categorycode => $categorycode, |
| 198 |
branchcode => $samplebranch1->{branchcode}, |
148 |
branchcode => $branchcode_1 |
| 199 |
); |
149 |
); |
| 200 |
my $borrower_1 = C4::Members::GetMember(borrowernumber => $borrower_id1); |
150 |
my $borrower_1 = C4::Members::GetMember(borrowernumber => $borrower_id1); |
| 201 |
my $borrower_id2 = C4::Members::AddMember( |
151 |
my $borrower_id2 = C4::Members::AddMember( |
| 202 |
firstname => 'firstname2', |
152 |
firstname => 'firstname2', |
| 203 |
surname => 'surname2 ', |
153 |
surname => 'surname2 ', |
| 204 |
categorycode => $samplecat->{categorycode}, |
154 |
categorycode => $categorycode, |
| 205 |
branchcode => $samplebranch2->{branchcode}, |
155 |
branchcode => $branchcode_2, |
| 206 |
); |
156 |
); |
| 207 |
my $borrower_2 = C4::Members::GetMember(borrowernumber => $borrower_id2); |
157 |
my $borrower_2 = C4::Members::GetMember(borrowernumber => $borrower_id2); |
| 208 |
|
158 |
|
| 209 |
# NEED TO BE FIXED !!! |
159 |
my @USERENV = ( |
| 210 |
# The first parameter for set_userenv is the class ref |
160 |
$borrower_id1, 'test', 'MASTERTEST', 'firstname', $branchcode_1, |
| 211 |
#my @USERENV = ( $borrower_id1, 'test', 'MASTERTEST', 'firstname', 'username', 'CPL', 'CPL', 'email@example.org' ); |
161 |
$branchcode_1, 'email@example.org' |
| 212 |
my @USERENV = ( $borrower_id1, 'test', 'MASTERTEST', 'firstname', 'CPL', 'CPL', 'email@example.org' ); |
162 |
); |
|
|
163 |
|
| 213 |
|
164 |
|
| 214 |
C4::Context->_new_userenv('DUMMY_SESSION_ID'); |
165 |
C4::Context->_new_userenv('DUMMY_SESSION_ID'); |
| 215 |
C4::Context->set_userenv(@USERENV); |
166 |
C4::Context->set_userenv(@USERENV); |
|
Lines 220-226
my $userenv = C4::Context->userenv
Link Here
|
| 220 |
#Begin Tests |
171 |
#Begin Tests |
| 221 |
|
172 |
|
| 222 |
#Test AddIssue |
173 |
#Test AddIssue |
| 223 |
$query = " SELECT count(*) FROM issues"; |
174 |
my $query = " SELECT count(*) FROM issues"; |
| 224 |
my $sth = $dbh->prepare($query); |
175 |
my $sth = $dbh->prepare($query); |
| 225 |
$sth->execute; |
176 |
$sth->execute; |
| 226 |
my $countissue = $sth -> fetchrow_array; |
177 |
my $countissue = $sth -> fetchrow_array; |
|
Lines 259-265
is ($countaccount,1,"1 accountline has been added");
Link Here
|
| 259 |
|
210 |
|
| 260 |
#Test AddRenewal |
211 |
#Test AddRenewal |
| 261 |
my $datedue3 = |
212 |
my $datedue3 = |
| 262 |
AddRenewal( $borrower_id1, $item_id1, $samplebranch1->{branchcode}, |
213 |
AddRenewal( $borrower_id1, $item_id1, $branchcode_1, |
| 263 |
$datedue1, $daysago10 ); |
214 |
$datedue1, $daysago10 ); |
| 264 |
like( |
215 |
like( |
| 265 |
$datedue3, |
216 |
$datedue3, |
|
Lines 356-362
is_deeply(
Link Here
|
| 356 |
"With issuing rules (renewal allowed) and with a valid parameter, Getrenewcount of item1 returns 3 renews left" |
307 |
"With issuing rules (renewal allowed) and with a valid parameter, Getrenewcount of item1 returns 3 renews left" |
| 357 |
); |
308 |
); |
| 358 |
|
309 |
|
| 359 |
AddRenewal( $borrower_id1, $item_id1, $samplebranch1->{branchcode}, |
310 |
AddRenewal( $borrower_id1, $item_id1, $branchcode_1, |
| 360 |
$datedue3, $daysago10 ); |
311 |
$datedue3, $daysago10 ); |
| 361 |
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1); |
312 |
@renewcount = C4::Circulation::GetRenewCount($borrower_id1, $item_id1); |
| 362 |
is_deeply( |
313 |
is_deeply( |
|
Lines 381-388
my $itemnumber;
Link Here
|
| 381 |
{ |
332 |
{ |
| 382 |
barcode => 'barcode_3', |
333 |
barcode => 'barcode_3', |
| 383 |
itemcallnumber => 'callnumber3', |
334 |
itemcallnumber => 'callnumber3', |
| 384 |
homebranch => $samplebranch1->{branchcode}, |
335 |
homebranch => $branchcode_1, |
| 385 |
holdingbranch => $samplebranch1->{branchcode}, |
336 |
holdingbranch => $branchcode_1, |
| 386 |
notforloan => 1, |
337 |
notforloan => 1, |
| 387 |
itype => $itemtype |
338 |
itype => $itemtype |
| 388 |
}, |
339 |
}, |
|
Lines 390-410
my $itemnumber;
Link Here
|
| 390 |
); |
341 |
); |
| 391 |
|
342 |
|
| 392 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
343 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
| 393 |
AddReturn( 'barcode_3', $samplebranch1->{branchcode} ); |
344 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 394 |
my $item = GetItem( $itemnumber ); |
345 |
my $item = GetItem( $itemnumber ); |
| 395 |
ok( $item->{notforloan} eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
346 |
ok( $item->{notforloan} eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
| 396 |
|
347 |
|
| 397 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9' ); |
348 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', '1: 9' ); |
| 398 |
AddReturn( 'barcode_3', $samplebranch1->{branchcode} ); |
349 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 399 |
$item = GetItem( $itemnumber ); |
350 |
$item = GetItem( $itemnumber ); |
| 400 |
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9"} ); |
351 |
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin updates notforloan value from 1 to 9 with setting "1: 9"} ); |
| 401 |
|
352 |
|
| 402 |
AddReturn( 'barcode_3', $samplebranch1->{branchcode} ); |
353 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 403 |
$item = GetItem( $itemnumber ); |
354 |
$item = GetItem( $itemnumber ); |
| 404 |
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); |
355 |
ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); |
| 405 |
|
356 |
|
| 406 |
# Bug 14640 - Cancel the hold on checking out if asked |
357 |
# Bug 14640 - Cancel the hold on checking out if asked |
| 407 |
my $reserve_id = AddReserve('CPL', $borrower_id1, $biblionumber, |
358 |
my $reserve_id = AddReserve($branchcode_1, $borrower_id1, $biblionumber, |
| 408 |
undef, 1, undef, undef, "a note", "a title", undef, ''); |
359 |
undef, 1, undef, undef, "a note", "a title", undef, ''); |
| 409 |
ok( $reserve_id, 'The reserve should have been inserted' ); |
360 |
ok( $reserve_id, 'The reserve should have been inserted' ); |
| 410 |
AddIssue( $borrower_2, $barcode_1, dt_from_string, 'cancel' ); |
361 |
AddIssue( $borrower_2, $barcode_1, dt_from_string, 'cancel' ); |
| 411 |
- |
|
|