Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 35; |
22 |
use Test::More tests => 36; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
use Test::Warn; |
24 |
use Test::Warn; |
25 |
use Time::Fake; |
25 |
use Time::Fake; |
Lines 410-415
subtest 'add_guarantor() tests' => sub {
Link Here
|
410 |
$schema->storage->txn_rollback; |
410 |
$schema->storage->txn_rollback; |
411 |
}; |
411 |
}; |
412 |
|
412 |
|
|
|
413 |
subtest 'guarantor checks on patron creation / update tests' => sub { |
414 |
|
415 |
plan tests => 2; |
416 |
|
417 |
$schema->storage->txn_begin; |
418 |
|
419 |
t::lib::Mocks::mock_preference( 'borrowerRelationship', 'guarantor' ); |
420 |
my $category = $builder->build_object( |
421 |
{ class => 'Koha::Patron::Categories', value => { can_be_guarantee => 1, category_type => 'A' } } ); |
422 |
|
423 |
my $guarantor = |
424 |
$builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $category->categorycode } } ); |
425 |
my $guarantee = |
426 |
$builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $category->categorycode } } ); |
427 |
|
428 |
subtest 'patron update tests' => sub { |
429 |
plan tests => 4; |
430 |
ok( |
431 |
$guarantee->add_guarantor( { guarantor_id => $guarantor->borrowernumber, relationship => 'guarantor' } ), |
432 |
"Relationship is added, no problem" |
433 |
); |
434 |
is( $guarantor->guarantee_relationships->count, 1, 'Relationship added' ); |
435 |
ok( $guarantor->surname("Duck")->store(), "Updating guarantor is okay" ); |
436 |
ok( $guarantee->surname("Duck")->store(), "Updating guarantee is okay" ); |
437 |
}; |
438 |
|
439 |
subtest 'patron update tests' => sub { |
440 |
plan tests => 1; |
441 |
|
442 |
my $new_guarantee = $builder->build_object( |
443 |
{ class => 'Koha::Patrons', value => { categorycode => $category->categorycode } } ); |
444 |
my $new_guarantee_hash = $new_guarantee->unblessed; |
445 |
$new_guarantee->delete(); |
446 |
|
447 |
delete $new_guarantee_hash->{borrowernumber}; |
448 |
|
449 |
ok( |
450 |
Koha::Patron->new($new_guarantee_hash)->store( { guarantors => [$guarantor] } ), |
451 |
"We can add the new patron and indicate guarantor" |
452 |
); |
453 |
}; |
454 |
|
455 |
$schema->storage->txn_rollback; |
456 |
}; |
457 |
|
413 |
subtest 'relationships_debt() tests' => sub { |
458 |
subtest 'relationships_debt() tests' => sub { |
414 |
|
459 |
|
415 |
plan tests => 168; |
460 |
plan tests => 168; |
416 |
- |
|
|