Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 6; |
22 |
use Test::More tests => 7; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
|
24 |
|
25 |
use Koha::Database; |
25 |
use Koha::Database; |
Lines 365-367
subtest 'is_superlibrarian() tests' => sub {
Link Here
|
365 |
|
365 |
|
366 |
$schema->storage->txn_rollback; |
366 |
$schema->storage->txn_rollback; |
367 |
}; |
367 |
}; |
368 |
- |
368 |
|
|
|
369 |
subtest 'guarantor requirements tests' => sub { |
370 |
|
371 |
plan tests => 3; |
372 |
|
373 |
$schema->storage->txn_begin; |
374 |
|
375 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
376 |
my $child_category = $builder->build({ source => 'Category', value => { category_type => 'C' }})->{categorycode}; |
377 |
my $patron_category = $builder->build({ source => 'Category', value => { category_type => 'A' }})->{categorycode}; |
378 |
|
379 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
380 |
|
381 |
my $child = Koha::Patron->new({ branchcode => $branchcode, categorycode => $child_category, contactname => ''}); |
382 |
$child->store(); |
383 |
|
384 |
ok(Koha::Patrons->find($child->id), 'Child patron can be stored without guarantor when ChildNeedsGuarantor is off.'); |
385 |
|
386 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 1 ); |
387 |
|
388 |
my $child2 = Koha::Patron->new({ branchcode => $branchcode, categorycode => $child_category, contactname => ''}); |
389 |
my $child3 = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $child_category }}); |
390 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $patron_category }}); |
391 |
|
392 |
throws_ok { $child2->store(); } |
393 |
'Koha::Exceptions::Patron::Relationship::NoGuarantor', |
394 |
'Exception thrown when guarantor is required but not provided.'; |
395 |
|
396 |
my @guarantor_ids = ( $patron->id, $child3->id ); |
397 |
throws_ok { $child2->store({ guarantor_ids => \@guarantor_ids }); } |
398 |
'Koha::Exceptions::Patron::Relationship::InvalidRelationship', |
399 |
'Exception thrown when child patron is added as guarantor.'; |
400 |
|
401 |
$schema->storage->txn_rollback; |
402 |
}; |