|
Lines 20-31
Link Here
|
| 20 |
|
20 |
|
| 21 |
use Modern::Perl; |
21 |
use Modern::Perl; |
| 22 |
|
22 |
|
| 23 |
use Test::More tests => 9; |
23 |
use Test::More tests => 10; |
|
|
24 |
|
| 25 |
use t::lib::TestBuilder; |
| 26 |
use t::lib::Mocks; |
| 27 |
|
| 28 |
use C4::Reserves; |
| 29 |
use Koha::CirculationRules; |
| 30 |
use Koha::Database; |
| 24 |
|
31 |
|
| 25 |
BEGIN { |
32 |
BEGIN { |
| 26 |
use_ok('C4::SIP::ILS'); |
33 |
use_ok('C4::SIP::ILS'); |
| 27 |
} |
34 |
} |
| 28 |
|
35 |
|
|
|
36 |
my $schema = Koha::Database->new->schema; |
| 37 |
$schema->storage->txn_begin; |
| 38 |
|
| 39 |
my $builder = t::lib::TestBuilder->new(); |
| 40 |
|
| 29 |
my $class = 'C4::SIP::ILS'; |
41 |
my $class = 'C4::SIP::ILS'; |
| 30 |
my $institution = { id => 'CPL', }; |
42 |
my $institution = { id => 'CPL', }; |
| 31 |
|
43 |
|
|
Lines 56-58
is( $ils->test_cardnumber_compare( 'A1234', 'a1234' ),
Link Here
|
| 56 |
|
68 |
|
| 57 |
is( $ils->test_cardnumber_compare( 'A1234', 'b1234' ), |
69 |
is( $ils->test_cardnumber_compare( 'A1234', 'b1234' ), |
| 58 |
q{}, 'borrower bc test identifies difference' ); |
70 |
q{}, 'borrower bc test identifies difference' ); |
| 59 |
- |
71 |
|
|
|
72 |
subtest cancel_hold => sub { |
| 73 |
plan tests => 5; |
| 74 |
|
| 75 |
my $library = $builder->build_object ({ class => 'Koha::Libraries' }); |
| 76 |
my $patron = $builder->build_object( |
| 77 |
{ |
| 78 |
class => 'Koha::Patrons', |
| 79 |
value => { |
| 80 |
branchcode => $library->branchcode, |
| 81 |
} |
| 82 |
} |
| 83 |
); |
| 84 |
t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode, flags => 1 }); |
| 85 |
|
| 86 |
my $item = $builder->build_sample_item({ |
| 87 |
library => $library->branchcode, |
| 88 |
}); |
| 89 |
|
| 90 |
Koha::CirculationRules->set_rules( |
| 91 |
{ |
| 92 |
categorycode => $patron->categorycode, |
| 93 |
branchcode => $library->branchcode, |
| 94 |
itemtype => $item->effective_itemtype, |
| 95 |
rules => { |
| 96 |
onshelfholds => 1, |
| 97 |
reservesallowed => 3, |
| 98 |
holds_per_record => 3, |
| 99 |
issuelength => 5, |
| 100 |
lengthunit => 'days', |
| 101 |
} |
| 102 |
} |
| 103 |
); |
| 104 |
|
| 105 |
my $reserve1 = AddReserve( |
| 106 |
{ |
| 107 |
branchcode => $library->branchcode, |
| 108 |
borrowernumber => $patron->borrowernumber, |
| 109 |
biblionumber => $item->biblio->biblionumber, |
| 110 |
itemnumber => $item->itemnumber, |
| 111 |
} |
| 112 |
); |
| 113 |
is( $item->biblio->holds->count(), 1, "Hold was placed on bib"); |
| 114 |
is( $item->holds->count(),1,"Hold was placed on specific item"); |
| 115 |
|
| 116 |
my $ils = C4::SIP::ILS->new({ id => $library->branchcode }); |
| 117 |
my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber ); |
| 118 |
my $transaction = $ils->cancel_hold($patron->cardnumber,undef,$item->barcode,undef); |
| 119 |
|
| 120 |
is( $transaction->{screen_msg},"Hold Cancelled.","We get a success message when hold cancelled"); |
| 121 |
|
| 122 |
is( $item->biblio->holds->count(), 0, "Bib has 0 holds remaining"); |
| 123 |
is( $item->holds->count(), 0, "Item has 0 holds remaining"); |
| 124 |
}; |
| 125 |
$schema->storage->txn_rollback; |