Bug 31086: (QA follow-up) Add unit tests
This patch adds the unit tests for the change to Koha::Hold::store. We test for and catch the exception introduced for both the create and update cases. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
bdddc7ee0a
commit
f0685f0f40
1 changed files with 31 additions and 1 deletions
|
@ -19,7 +19,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 6;
|
||||
use Test::More tests => 7;
|
||||
|
||||
use Test::Exception;
|
||||
use Test::MockModule;
|
||||
|
@ -36,6 +36,36 @@ use Koha::Old::Holds;
|
|||
my $schema = Koha::Database->new->schema;
|
||||
my $builder = t::lib::TestBuilder->new;
|
||||
|
||||
subtest 'store() tests' => sub {
|
||||
plan tests => 2;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
my $item = $builder->build_sample_item;
|
||||
throws_ok {
|
||||
Koha::Hold->new(
|
||||
{
|
||||
borrowernumber => $patron->borrowernumber,
|
||||
biblionumber => $item->biblionumber,
|
||||
priority => 1,
|
||||
itemnumber => $item->itemnumber,
|
||||
}
|
||||
)->store
|
||||
}
|
||||
'Koha::Exceptions::Hold::MissingPickupLocation',
|
||||
'Exception thrown because branchcode was not passed';
|
||||
|
||||
my $hold = $builder->build_object( { class => 'Koha::Holds' } );
|
||||
throws_ok {
|
||||
$hold->branchcode(undef)->store;
|
||||
}
|
||||
'Koha::Exceptions::Hold::MissingPickupLocation',
|
||||
'Exception thrown if one tries to set branchcode to null';
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'fill() tests' => sub {
|
||||
|
||||
plan tests => 13;
|
||||
|
|
Loading…
Reference in a new issue