|
Lines 4-10
Link Here
|
| 4 |
# Current state is very rudimentary. Please help to extend it! |
4 |
# Current state is very rudimentary. Please help to extend it! |
| 5 |
|
5 |
|
| 6 |
use Modern::Perl; |
6 |
use Modern::Perl; |
| 7 |
use Test::More tests => 7; |
7 |
use Test::More tests => 8; |
| 8 |
|
8 |
|
| 9 |
use Koha::Database; |
9 |
use Koha::Database; |
| 10 |
use t::lib::TestBuilder; |
10 |
use t::lib::TestBuilder; |
|
Lines 14-22
use C4::SIP::ILS::Transaction::RenewAll;
Link Here
|
| 14 |
use C4::SIP::ILS::Transaction::Checkout; |
14 |
use C4::SIP::ILS::Transaction::Checkout; |
| 15 |
use C4::SIP::ILS::Transaction::FeePayment; |
15 |
use C4::SIP::ILS::Transaction::FeePayment; |
| 16 |
use C4::SIP::ILS::Transaction::Hold; |
16 |
use C4::SIP::ILS::Transaction::Hold; |
|
|
17 |
use C4::SIP::ILS::Transaction::Checkout; |
| 18 |
use C4::SIP::ILS::Transaction::Checkin; |
| 17 |
|
19 |
|
| 18 |
use C4::Reserves; |
20 |
use C4::Reserves; |
| 19 |
use Koha::IssuingRules; |
21 |
use Koha::IssuingRules; |
|
|
22 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
| 20 |
|
23 |
|
| 21 |
my $schema = Koha::Database->new->schema; |
24 |
my $schema = Koha::Database->new->schema; |
| 22 |
$schema->storage->txn_begin; |
25 |
$schema->storage->txn_begin; |
|
Lines 243-246
subtest do_hold => sub {
Link Here
|
| 243 |
is( $patron_2->holds->next->priority, 2, 'Hold placed from SIP should have a correct priority of 2'); |
246 |
is( $patron_2->holds->next->priority, 2, 'Hold placed from SIP should have a correct priority of 2'); |
| 244 |
}; |
247 |
}; |
| 245 |
|
248 |
|
|
|
249 |
subtest do_checkin => sub { |
| 250 |
plan tests => 8; |
| 251 |
|
| 252 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 253 |
my $patron = $builder->build_object( |
| 254 |
{ |
| 255 |
class => 'Koha::Patrons', |
| 256 |
value => { |
| 257 |
branchcode => $library->branchcode, |
| 258 |
} |
| 259 |
} |
| 260 |
); |
| 261 |
|
| 262 |
t::lib::Mocks::mock_userenv( |
| 263 |
{ branchcode => $library->branchcode, flags => 1 } ); |
| 264 |
|
| 265 |
my $item = $builder->build_sample_item( |
| 266 |
{ |
| 267 |
library => $library->branchcode, |
| 268 |
} |
| 269 |
); |
| 270 |
|
| 271 |
|
| 272 |
# Checkout |
| 273 |
my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); |
| 274 |
my $sip_item = C4::SIP::ILS::Item->new( $item->barcode ); |
| 275 |
my $co_transaction = C4::SIP::ILS::Transaction::Checkout->new(); |
| 276 |
is( $co_transaction->patron($sip_patron), |
| 277 |
$sip_patron, "Patron assigned to transaction" ); |
| 278 |
is( $co_transaction->item($sip_item), |
| 279 |
$sip_item, "Item assigned to transaction" ); |
| 280 |
my $checkout = $co_transaction->do_checkout(); |
| 281 |
is( $patron->checkouts->count, 1, 'Checkout should have been done successfully'); |
| 282 |
|
| 283 |
# Checkin |
| 284 |
my $ci_transaction = C4::SIP::ILS::Transaction::Checkin->new(); |
| 285 |
is( $ci_transaction->patron($sip_patron), |
| 286 |
$sip_patron, "Patron assigned to transaction" ); |
| 287 |
is( $ci_transaction->item($sip_item), |
| 288 |
$sip_item, "Item assigned to transaction" ); |
| 289 |
|
| 290 |
my $checkin = $ci_transaction->do_checkin($library->branchcode, C4::SIP::Sip::timestamp); |
| 291 |
is( $patron->checkouts->count, 0, 'Checkin should have been done successfully'); |
| 292 |
|
| 293 |
# Test checkin without return date |
| 294 |
$co_transaction->do_checkout; |
| 295 |
is( $patron->checkouts->count, 1, 'Checkout should have been done successfully'); |
| 296 |
$ci_transaction->do_checkin($library->branchcode, undef); |
| 297 |
is( $patron->checkouts->count, 0, 'Checkin should have been done successfully'); |
| 298 |
}; |
| 299 |
|
| 246 |
$schema->storage->txn_rollback; |
300 |
$schema->storage->txn_rollback; |
| 247 |
- |
|
|