Bug 31080: Unit tests
Unit tests for add_to_bundle functionality that prevents bundle nesting. Test plan 1) Run t/db_dependent/Koha/Item.t 2) The test should fail 3) Apply the second patch 4) Re-run the test and watch it pass. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
dc08b53376
commit
158ddef999
1 changed files with 13 additions and 1 deletions
|
@ -213,7 +213,7 @@ subtest 'bundle_host tests' => sub {
|
|||
};
|
||||
|
||||
subtest 'add_to_bundle tests' => sub {
|
||||
plan tests => 3;
|
||||
plan tests => 6;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
@ -223,6 +223,10 @@ subtest 'add_to_bundle tests' => sub {
|
|||
my $bundle_item1 = $builder->build_sample_item();
|
||||
my $bundle_item2 = $builder->build_sample_item();
|
||||
|
||||
throws_ok { $host_item->add_to_bundle($host_item) }
|
||||
'Koha::Exceptions::Item::Bundle::IsBundle',
|
||||
'Exception thrown if you try to add the item to itself';
|
||||
|
||||
ok($host_item->add_to_bundle($bundle_item1), 'bundle_item1 added to bundle');
|
||||
is($bundle_item1->notforloan, 1, 'add_to_bundle sets notforloan to BundleNotLoanValue');
|
||||
|
||||
|
@ -230,6 +234,14 @@ subtest 'add_to_bundle tests' => sub {
|
|||
'Koha::Exceptions::Object::DuplicateID',
|
||||
'Exception thrown if you try to add the same item twice';
|
||||
|
||||
throws_ok { $bundle_item1->add_to_bundle($bundle_item2) }
|
||||
'Koha::Exceptions::Item::Bundle::IsBundle',
|
||||
'Exception thrown if you try to add an item to a bundled item';
|
||||
|
||||
throws_ok { $bundle_item2->add_to_bundle($host_item) }
|
||||
'Koha::Exceptions::Item::Bundle::IsBundle',
|
||||
'Exception thrown if you try to add a bundle host to a bundle item';
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue