View | Details | Raw Unified | Return to bug 17941
Collapse All | Expand All

(-)a/test.pl (-1 / +51 lines)
Line 0 Link Here
0
- 
1
use C4::Context;
2
use C4::Items;
3
use C4::Members;
4
use Koha::Patron::Categories;
5
use Koha::Biblios;
6
use Koha::Libraries;
7
my $biblio          = Koha::Biblios->search->next;
8
my $library         = Koha::Libraries->search->next;
9
my $patron_category = Koha::Patron::Categories->next;
10
my $patron          = Koha::Patrons->next;
11
C4::Context->_new_userenv('DUMMY SESSION');
12
C4::Context->set_userenv( 0, 0, 0, 'firstname', 'surname',
13
    $library->{branchcode},
14
    'Library 1', 0, '', '' );
15
C4::Context->set_preference( 'AllowRenewalIfOtherItemsAvailable', 1 );
16
17
my ( @itemnumbers, @borrowernumbers );
18
for my $i ( 1 .. 20 ) {
19
    warn "Adding item $i";
20
    my ( undef, undef, $itemnumber ) = C4::Items::AddItem(
21
        {
22
            homebranch    => $library->branchcode,
23
            holdingbranch => $library->branchcode,
24
            barcode       => "barcode_$i"
25
        },
26
        $biblio->biblionumber
27
    );
28
    push @itemnumbers, $itemnumber;
29
}
30
31
for my $i ( 1 .. 201 ) {
32
    warn "Adding patron $i";
33
    my ( $borrowernumber, undef ) = C4::Members::AddMember(
34
        categorycode => $patron_category->categorycode,
35
        branchcode   => $library->branchcode
36
    );
37
    push @borrowernumbers, $borrowernumber;
38
}
39
40
C4::Circulation::AddIssue( $patron->unblessed, "barcode_1" );
41
for my $i ( 1 .. 200 ) {
42
    warn "Adding hold $i";
43
    my $patron     = Koha::Patrons->find( $borrowernumbers[ $i - 1 ] );
44
    my $itemnumber = $itemnumbers[ $i % 19 + 1 ];
45
    C4::Reserves::AddReserve( $library->branchcode, $patron->unblessed,
46
        $biblio->biblionumber, undef, undef, undef, undef, undef, undef,
47
        $itemnumber );
48
}
49
50
#my $checkout = Koha::Checkouts->search({ borrowernumber => $patron->borrowernumber })->next;
51
#C4::Circulation::CanBookBeRenewed({ $patron->borrowernumber, $checkout->itemnumber });

Return to bug 17941