10 use t::lib::TestBuilder;
11 use t::lib::Mocks qw(mock_preference);
13 use Test::More tests => 8;
15 my $schema = Koha::Database->new->schema;
16 $schema->storage->txn_begin;
18 C4::Context->_new_userenv(1234567);
19 C4::Context->set_userenv(91, 'CLIstaff', '23529001223661', 'CPL',
20 'CPL', 'CPL', '', 'cc@cscnet.co.uk');
22 t::lib::Mocks::mock_preference('BlockReturnOfWithdrawnItems',0);
23 my $test_patron = '23529001223651';
24 my $test_item_fic = '502326000402';
25 my $test_item_24 = '502326000404';
26 my $test_item_48 = '502326000403';
28 my $builder = t::lib::TestBuilder->new;
29 my $borrower1 = $builder->build_object({ class => 'Koha::Patrons', value => { cardnumber => $test_patron } });
30 my $item1 = $builder->build_object({
31 class => 'Koha::Items',
33 barcode => $test_item_fic,
36 my $item2 = $builder->build_object({
37 class => 'Koha::Items',
39 barcode => $test_item_24,
42 my $item3 = $builder->build_object({
43 class => 'Koha::Items',
45 barcode => $test_item_48,
50 skip 'Missing test borrower or item, skipping tests', 8
51 unless ( defined $borrower1 && defined $item1 );
53 for my $item_barcode ( $test_item_fic, $test_item_24, $test_item_48 ) {
54 my $duedate = try_issue( $test_patron, $item_barcode );
55 isa_ok( $duedate, 'DateTime' );
56 if ( $item_barcode eq $test_item_fic ) {
57 is( $duedate->hour(), 23, "daily loan hours = 23" );
58 is( $duedate->minute(), 59, "daily loan mins = 59" );
60 my $ret_ok = try_return($item_barcode);
61 is( $ret_ok, 1, 'Return succeeded' );
66 my ($cardnumber, $item ) = @_;
67 my $issuedate = '2011-05-16';
68 my $patron = Koha::Patrons->find( { cardnumber => $cardnumber } );
69 my ($issuingimpossible,$needsconfirmation) = CanBookBeIssued( $patron, $item );
70 my $issue = AddIssue($patron->unblessed, $item, undef, 0, $issuedate);
71 return dt_from_string( $issue->date_due );
76 my ($ret, $messages, $iteminformation, $borrower) = AddReturn($barcode);