11 use t
::lib
::TestBuilder
;
12 use t
::lib
::Mocks
qw(mock_preference);
14 use Test
::More tests
=> 8;
16 my $schema = Koha
::Database
->new->schema;
17 $schema->storage->txn_begin;
19 my $builder = t
::lib
::TestBuilder
->new;
20 $builder->build({ source
=> 'Branch', value
=> { branchcode
=> 'CPL' } })
21 unless Koha
::Libraries
->find('CPL');
23 t
::lib
::Mocks
::mock_userenv
({ branchcode
=> 'CPL' });
25 t
::lib
::Mocks
::mock_preference
('BlockReturnOfWithdrawnItems',0);
26 my $test_patron = '23529001223651';
27 my $test_item_fic = '502326000402';
28 my $test_item_24 = '502326000404';
29 my $test_item_48 = '502326000403';
31 my $borrower1 = $builder->build_object({ class => 'Koha::Patrons', value
=> { cardnumber
=> $test_patron } });
32 my $item1 = $builder->build_object({
33 class => 'Koha::Items',
35 barcode
=> $test_item_fic,
36 biblionumber
=> $builder->build( { source
=> 'Biblioitem' } )->{biblionumber
},
39 my $item2 = $builder->build_object({
40 class => 'Koha::Items',
42 barcode
=> $test_item_24,
43 biblionumber
=> $builder->build( { source
=> 'Biblioitem' } )->{biblionumber
},
46 my $item3 = $builder->build_object({
47 class => 'Koha::Items',
49 barcode
=> $test_item_48,
50 biblionumber
=> $builder->build( { source
=> 'Biblioitem' } )->{biblionumber
},
55 skip
'Missing test borrower or item, skipping tests', 8
56 unless ( defined $borrower1 && defined $item1 );
58 for my $item_barcode ( $test_item_fic, $test_item_24, $test_item_48 ) {
59 my $duedate = try_issue
( $test_patron, $item_barcode );
60 isa_ok
( $duedate, 'DateTime' );
61 if ( $item_barcode eq $test_item_fic ) {
62 is
( $duedate->hour(), 23, "daily loan hours = 23" );
63 is
( $duedate->minute(), 59, "daily loan mins = 59" );
65 my $ret_ok = try_return
($item_barcode);
66 is
( $ret_ok, 1, 'Return succeeded' );
71 my ($cardnumber, $item ) = @_;
72 my $issuedate = '2011-05-16';
73 my $patron = Koha
::Patrons
->find( { cardnumber
=> $cardnumber } );
74 my ($issuingimpossible,$needsconfirmation) = CanBookBeIssued
( $patron, $item );
75 my $issue = AddIssue
($patron->unblessed, $item, undef, 0, $issuedate);
76 return dt_from_string
( $issue->date_due );
81 my ($ret, $messages, $iteminformation, $borrower) = AddReturn
($barcode);