9 use t::lib::TestBuilder;
11 use Test::More tests => 8;
13 my $schema = Koha::Database->new->schema;
14 $schema->storage->txn_begin;
16 C4::Context->_new_userenv(1234567);
17 C4::Context->set_userenv(91, 'CLIstaff', '23529001223661', 'CPL',
18 'CPL', 'CPL', '', 'cc@cscnet.co.uk');
21 my $test_patron = '23529001223651';
22 my $test_item_fic = '502326000402';
23 my $test_item_24 = '502326000404';
24 my $test_item_48 = '502326000403';
26 my $builder = t::lib::TestBuilder->new;
27 my $borrower1 = $builder->build_object({ class => 'Koha::Patrons', value => { cardnumber => $test_patron } });
28 my $item1 = GetItem (undef,$test_item_fic);
31 skip 'Missing test borrower or item, skipping tests', 8
32 unless ( defined $borrower1 && defined $item1 );
34 for my $item_barcode ( $test_item_fic, $test_item_24, $test_item_48 ) {
35 my $duedate = try_issue( $test_patron, $item_barcode );
36 isa_ok( $duedate, 'DateTime' );
37 if ( $item_barcode eq $test_item_fic ) {
38 is( $duedate->hour(), 23, "daily loan hours = 23" );
39 is( $duedate->minute(), 59, "daily loan mins = 59" );
41 my $ret_ok = try_return($item_barcode);
42 is( $ret_ok, 1, 'Return succeeded' );
47 my ($cardnumber, $item ) = @_;
48 my $issuedate = '2011-05-16';
49 my $borrower = Koha::Patrons->find( { cardnumber => $cardnumber } )->unblessed;
50 my ($issuingimpossible,$needsconfirmation) = CanBookBeIssued( $borrower, $item );
51 my $issue = AddIssue($borrower, $item, undef, 0, $issuedate);
52 return dt_from_string( $issue->due_date() );
57 my ($ret, $messages, $iteminformation, $borrower) = AddReturn($barcode);