|
Lines 1184-1206
subtest 'store' => sub {
Link Here
|
| 1184 |
}; |
1184 |
}; |
| 1185 |
|
1185 |
|
| 1186 |
subtest 'get_transfer' => sub { |
1186 |
subtest 'get_transfer' => sub { |
| 1187 |
plan tests => 3; |
1187 |
plan tests => 6; |
| 1188 |
|
1188 |
|
| 1189 |
my $transfer = $new_item_1->get_transfer(); |
1189 |
my $transfer = $new_item_1->get_transfer(); |
| 1190 |
is( $transfer, undef, 'Koha::Item->get_transfer should return undef if the item is not in transit' ); |
1190 |
is( $transfer, undef, 'Koha::Item->get_transfer should return undef if the item is not in transit' ); |
| 1191 |
|
1191 |
|
| 1192 |
my $library_to = $builder->build( { source => 'Branch' } ); |
1192 |
my $library_to = $builder->build( { source => 'Branch' } ); |
| 1193 |
|
1193 |
|
| 1194 |
C4::Circulation::transferbook({ |
1194 |
my $transfer_1 = $builder->build_object( |
| 1195 |
from_branch => $new_item_1->holdingbranch, |
1195 |
{ |
| 1196 |
to_branch => $library_to->{branchcode}, |
1196 |
class => 'Koha::Item::Transfers', |
| 1197 |
barcode => $new_item_1->barcode, |
1197 |
value => { |
| 1198 |
}); |
1198 |
itemnumber => $new_item_1->itemnumber, |
|
|
1199 |
frombranch => $new_item_1->holdingbranch, |
| 1200 |
tobranch => $library_to->{branchcode}, |
| 1201 |
reason => 'Manual', |
| 1202 |
datesent => undef, |
| 1203 |
datearrived => undef, |
| 1204 |
daterequested => \'NOW()' |
| 1205 |
} |
| 1206 |
} |
| 1207 |
); |
| 1199 |
|
1208 |
|
| 1200 |
$transfer = $new_item_1->get_transfer(); |
1209 |
$transfer = $new_item_1->get_transfer(); |
| 1201 |
is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' ); |
1210 |
is( ref($transfer), 'Koha::Item::Transfer', 'Koha::Item->get_transfer should return a Koha::Item::Transfers object' ); |
| 1202 |
|
1211 |
|
| 1203 |
is( $transfer->itemnumber, $new_item_1->itemnumber, 'Koha::Item->get_transfer should return a valid Koha::Item::Transfers object' ); |
1212 |
my $transfer_2 = $builder->build_object( |
|
|
1213 |
{ |
| 1214 |
class => 'Koha::Item::Transfers', |
| 1215 |
value => { |
| 1216 |
itemnumber => $new_item_1->itemnumber, |
| 1217 |
frombranch => $new_item_1->holdingbranch, |
| 1218 |
tobranch => $library_to->{branchcode}, |
| 1219 |
reason => 'Manual', |
| 1220 |
datesent => undef, |
| 1221 |
datearrived => undef, |
| 1222 |
daterequested => \'NOW()' |
| 1223 |
} |
| 1224 |
} |
| 1225 |
); |
| 1226 |
|
| 1227 |
$transfer = $new_item_1->get_transfer(); |
| 1228 |
is( $transfer->branchtransfer_id, $transfer_1->branchtransfer_id, 'Koha::Item->get_transfer returns the oldest transfer request'); |
| 1229 |
|
| 1230 |
$transfer_2->datesent(\'NOW()')->store; |
| 1231 |
$transfer = $new_item_1->get_transfer(); |
| 1232 |
is( $transfer->branchtransfer_id, $transfer_2->branchtransfer_id, 'Koha::Item->get_transfer returns the in_transit transfer'); |
| 1233 |
|
| 1234 |
my $transfer_3 = $builder->build_object( |
| 1235 |
{ |
| 1236 |
class => 'Koha::Item::Transfers', |
| 1237 |
value => { |
| 1238 |
itemnumber => $new_item_1->itemnumber, |
| 1239 |
frombranch => $new_item_1->holdingbranch, |
| 1240 |
tobranch => $library_to->{branchcode}, |
| 1241 |
reason => 'Manual', |
| 1242 |
datesent => undef, |
| 1243 |
datearrived => undef, |
| 1244 |
daterequested => \'NOW()' |
| 1245 |
} |
| 1246 |
} |
| 1247 |
); |
| 1248 |
|
| 1249 |
$transfer_2->datearrived(\'NOW()')->store; |
| 1250 |
$transfer = $new_item_1->get_transfer(); |
| 1251 |
is( $transfer->branchtransfer_id, $transfer_1->branchtransfer_id, 'Koha::Item->get_transfer returns the next queued transfer'); |
| 1252 |
is( $transfer->itemnumber, $new_item_1->itemnumber, 'Koha::Item->get_transfer returns the right items transfer' ); |
| 1204 |
}; |
1253 |
}; |
| 1205 |
|
1254 |
|
| 1206 |
subtest 'holds' => sub { |
1255 |
subtest 'holds' => sub { |
| 1207 |
- |
|
|