Bug 17578: GetMemberDetails - Remove GetMemberDetails
[koha.git] / t / db_dependent / rollingloans.t
1
2 use strict;
3 use warnings;
4 use 5.010;
5 use C4::Context;
6 use C4::Circulation;
7 use C4::Members;
8 use C4::Items;
9 use Koha::DateUtils;
10
11 use Test::More tests => 8;
12 C4::Context->_new_userenv(1234567);
13 C4::Context->set_userenv(91, 'CLIstaff', '23529001223661', 'CPL',
14                          'CPL', 'CPL', '', 'cc@cscnet.co.uk');
15
16
17 my $test_patron = '23529001223651';
18 my $test_item_fic = '502326000402';
19 my $test_item_24 = '502326000404';
20 my $test_item_48 = '502326000403';
21
22 my $borrower1 =  GetMember(cardnumber => $test_patron);
23 my $item1 = GetItem (undef,$test_item_fic);
24
25 SKIP: {
26     skip 'Missing test borrower or item, skipping tests', 8
27       unless ( defined $borrower1 && defined $item1 );
28
29     for my $item_barcode ( $test_item_fic, $test_item_24, $test_item_48 ) {
30         my $duedate = try_issue( $test_patron, $item_barcode );
31         isa_ok( $duedate, 'DateTime' );
32         if ( $item_barcode eq $test_item_fic ) {
33             is( $duedate->hour(),   23, "daily loan hours = 23" );
34             is( $duedate->minute(), 59, "daily loan mins = 59" );
35         }
36         my $ret_ok = try_return($item_barcode);
37         is( $ret_ok, 1, 'Return succeeded' );
38     }
39 }
40
41 sub try_issue {
42     my ($cardnumber, $item ) = @_;
43     my $issuedate = '2011-05-16';
44     my $borrower = GetMember( cardnumber => $cardnumber );
45     my ($issuingimpossible,$needsconfirmation) = CanBookBeIssued( $borrower, $item );
46     my $issue = AddIssue($borrower, $item, undef, 0, $issuedate);
47     return dt_from_string( $issue->due_date() );
48 }
49
50 sub try_return {
51     my $barcode = shift;
52     my ($ret, $messages, $iteminformation, $borrower) = AddReturn($barcode);
53     return $ret;
54 }