Bug 28464: Add unit tests
Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Bug 28464: (QA follow-up) Correct test plan Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
601383d52e
commit
d1ad355d33
1 changed files with 63 additions and 1 deletions
|
@ -20,7 +20,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 13;
|
||||
use Test::More tests => 14;
|
||||
|
||||
use t::lib::TestBuilder;
|
||||
use t::lib::Mocks;
|
||||
|
@ -30,6 +30,7 @@ use C4::Circulation;
|
|||
use Koha::CirculationRules;
|
||||
use Koha::Database;
|
||||
use Koha::DateUtils;
|
||||
use Koha::Holds;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::SIP::ILS');
|
||||
|
@ -177,6 +178,67 @@ subtest cancel_hold => sub {
|
|||
is( $item->holds->count(), 0, "Item has 0 holds remaining");
|
||||
};
|
||||
|
||||
subtest cancel_waiting_hold => sub {
|
||||
plan tests => 7;
|
||||
|
||||
my $library = $builder->build_object ({ class => 'Koha::Libraries' });
|
||||
my $patron = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patrons',
|
||||
value => {
|
||||
branchcode => $library->branchcode,
|
||||
}
|
||||
}
|
||||
);
|
||||
t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode, flags => 1 });
|
||||
|
||||
my $item = $builder->build_sample_item({
|
||||
library => $library->branchcode,
|
||||
});
|
||||
|
||||
Koha::CirculationRules->set_rules(
|
||||
{
|
||||
categorycode => $patron->categorycode,
|
||||
branchcode => $library->branchcode,
|
||||
itemtype => $item->effective_itemtype,
|
||||
rules => {
|
||||
onshelfholds => 1,
|
||||
reservesallowed => 3,
|
||||
holds_per_record => 3,
|
||||
issuelength => 5,
|
||||
lengthunit => 'days',
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
my $reserve_id = AddReserve(
|
||||
{
|
||||
branchcode => $library->branchcode,
|
||||
borrowernumber => $patron->borrowernumber,
|
||||
biblionumber => $item->biblio->biblionumber,
|
||||
itemnumber => $item->itemnumber,
|
||||
}
|
||||
);
|
||||
is( $item->biblio->holds->count(), 1, "Hold was placed on bib");
|
||||
is( $item->holds->count(),1,"Hold was placed on specific item");
|
||||
|
||||
my $hold = Koha::Holds->find( $reserve_id );
|
||||
ok( $hold, 'Get hold object' );
|
||||
$hold->update({ found => 'W' });
|
||||
$hold->get_from_storage;
|
||||
|
||||
is( $hold->found, 'W', "Hold was correctly set to waiting." );
|
||||
|
||||
my $ils = C4::SIP::ILS->new({ id => $library->branchcode });
|
||||
my $sip_patron = C4::SIP::ILS::Patron->new( $patron->cardnumber );
|
||||
my $transaction = $ils->cancel_hold($patron->cardnumber,undef,$item->barcode,undef);
|
||||
|
||||
is( $transaction->{screen_msg},"Hold Cancelled.","We get a success message when hold cancelled");
|
||||
|
||||
is( $item->biblio->holds->count(), 0, "Bib has 0 holds remaining");
|
||||
is( $item->holds->count(), 0, "Item has 0 holds remaining");
|
||||
};
|
||||
|
||||
subtest checkout => sub {
|
||||
plan tests => 4;
|
||||
|
||||
|
|
Loading…
Reference in a new issue