Lines 4-15
Link Here
|
4 |
# Current state is very rudimentary. Please help to extend it! |
4 |
# Current state is very rudimentary. Please help to extend it! |
5 |
|
5 |
|
6 |
use Modern::Perl; |
6 |
use Modern::Perl; |
7 |
use Test::More tests => 3; |
7 |
use Test::More tests => 4; |
8 |
|
8 |
|
9 |
use Koha::Database; |
9 |
use Koha::Database; |
10 |
use t::lib::TestBuilder; |
10 |
use t::lib::TestBuilder; |
|
|
11 |
use t::lib::Mocks; |
11 |
use C4::SIP::ILS::Patron; |
12 |
use C4::SIP::ILS::Patron; |
12 |
use C4::SIP::ILS::Transaction::RenewAll; |
13 |
use C4::SIP::ILS::Transaction::RenewAll; |
|
|
14 |
use C4::SIP::ILS::Transaction::Checkout; |
15 |
|
16 |
use C4::Reserves; |
17 |
use Koha::IssuingRules; |
13 |
|
18 |
|
14 |
my $schema = Koha::Database->new->schema; |
19 |
my $schema = Koha::Database->new->schema; |
15 |
$schema->storage->txn_begin; |
20 |
$schema->storage->txn_begin; |
Lines 25-28
is( ref $transaction, "C4::SIP::ILS::Transaction::RenewAll", "New transaction cr
Link Here
|
25 |
is( $transaction->patron( $sip_patron ), $sip_patron, "Patron assigned to transaction" ); |
30 |
is( $transaction->patron( $sip_patron ), $sip_patron, "Patron assigned to transaction" ); |
26 |
isnt( $transaction->do_renew_all, undef, "RenewAll on zero items" ); |
31 |
isnt( $transaction->do_renew_all, undef, "RenewAll on zero items" ); |
27 |
|
32 |
|
|
|
33 |
subtest fill_holds_at_checkout => sub { |
34 |
plan tests => 5; |
35 |
|
36 |
|
37 |
my $category = $builder->build({ source => 'Category' }); |
38 |
my $branch = $builder->build({ source => 'Branch' }); |
39 |
my $borrower = $builder->build({ source => 'Borrower', value =>{ |
40 |
branchcode => $branch->{branchcode}, |
41 |
categorycode=>$category->{categorycode} |
42 |
} |
43 |
}); |
44 |
t::lib::Mocks::mock_userenv({ branchcode => $branch->{branchcode}, flags => 1 }); |
45 |
|
46 |
my $itype = $builder->build({ source => 'Itemtype', value =>{notforloan=>0} }); |
47 |
my $biblio = $builder->build({ source => 'Biblio' }); |
48 |
my $biblioitem = $builder->build({ source => 'Biblioitem', value=>{biblionumber=>$biblio->{biblionumber}} }); |
49 |
my $item1 = $builder->build({ source => 'Item', value => { |
50 |
homebranch => $branch->{branchcode}, |
51 |
holdingbranch => $branch->{branchcode}, |
52 |
biblionumber => $biblio->{biblionumber}, |
53 |
itype => $itype->{itemtype}, |
54 |
notforloan => 0, |
55 |
} |
56 |
}); |
57 |
my $item2 = $builder->build({ source => 'Item', value => { |
58 |
homebranch => $branch->{branchcode}, |
59 |
holdingbranch => $branch->{branchcode}, |
60 |
biblionumber => $biblio->{biblionumber}, |
61 |
itype => $itype->{itemtype}, |
62 |
notforloan => 0, |
63 |
} |
64 |
}); |
65 |
|
66 |
Koha::IssuingRule->new({ |
67 |
categorycode => $borrower->{categorycode}, |
68 |
itemtype => $itype->{itemtype}, |
69 |
branchcode => $branch->{branchcode}, |
70 |
onshelfholds => 1, |
71 |
reservesallowed => 3, |
72 |
holds_per_record => 3, |
73 |
issuelength => 5, |
74 |
lengthunit => 'days', |
75 |
maxissueqty => 10. |
76 |
})->store; |
77 |
|
78 |
my $reserve1 = AddReserve($branch->{branchcode},$borrower->{borrowernumber},$biblio->{biblionumber}); |
79 |
my $reserve2 = AddReserve($branch->{branchcode},$borrower->{borrowernumber},$biblio->{biblionumber}); |
80 |
my $bib = Koha::Biblios->find( $biblio->{biblionumber} ); |
81 |
is( $bib->holds->count(), 2, "Bib has 2 holds"); |
82 |
|
83 |
my $sip_patron = C4::SIP::ILS::Patron->new( $borrower->{cardnumber} ); |
84 |
my $sip_item = C4::SIP::ILS::Item->new( $item1->{barcode} ); |
85 |
my $transaction = C4::SIP::ILS::Transaction::Checkout->new(); |
86 |
is( ref $transaction, "C4::SIP::ILS::Transaction::Checkout", "New transaction created" ); |
87 |
is( $transaction->patron( $sip_patron ), $sip_patron, "Patron assigned to transaction" ); |
88 |
is( $transaction->item( $sip_item ), $sip_item, "Item assigned to transaction" ); |
89 |
$transaction->do_checkout(); |
90 |
is( $bib->holds->count(), 1, "Bib has 1 holds remaining"); |
91 |
|
92 |
|
93 |
}; |
28 |
$schema->storage->txn_rollback; |
94 |
$schema->storage->txn_rollback; |
29 |
- |
|
|