Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 16; |
22 |
use Test::More tests => 17; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
use Test::Warn; |
24 |
use Test::Warn; |
25 |
|
25 |
|
Lines 1137-1139
subtest 'recalls() tests' => sub {
Link Here
|
1137 |
|
1137 |
|
1138 |
$schema->storage->txn_rollback; |
1138 |
$schema->storage->txn_rollback; |
1139 |
}; |
1139 |
}; |
1140 |
- |
1140 |
|
|
|
1141 |
subtest 'guarantor requirements tests' => sub { |
1142 |
|
1143 |
plan tests => 3; |
1144 |
|
1145 |
$schema->storage->txn_begin; |
1146 |
|
1147 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
1148 |
my $child_category = $builder->build({ source => 'Category', value => { category_type => 'C' }})->{categorycode}; |
1149 |
my $patron_category = $builder->build({ source => 'Category', value => { category_type => 'A' }})->{categorycode}; |
1150 |
|
1151 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 0 ); |
1152 |
|
1153 |
my $child = Koha::Patron->new({ branchcode => $branchcode, categorycode => $child_category, contactname => ''}); |
1154 |
$child->store(); |
1155 |
|
1156 |
ok(Koha::Patrons->find($child->id), 'Child patron can be stored without guarantor when ChildNeedsGuarantor is off.'); |
1157 |
|
1158 |
t::lib::Mocks::mock_preference( 'ChildNeedsGuarantor', 1 ); |
1159 |
|
1160 |
my $child2 = Koha::Patron->new({ branchcode => $branchcode, categorycode => $child_category, contactname => ''}); |
1161 |
my $child3 = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $child_category }}); |
1162 |
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $patron_category }}); |
1163 |
|
1164 |
throws_ok { $child2->store(); } |
1165 |
'Koha::Exceptions::Patron::Relationship::NoGuarantor', |
1166 |
'Exception thrown when guarantor is required but not provided.'; |
1167 |
|
1168 |
my @guarantor_ids = ( $patron->id, $child3->id ); |
1169 |
throws_ok { $child2->store({ guarantor_ids => \@guarantor_ids }); } |
1170 |
'Koha::Exceptions::Patron::Relationship::InvalidRelationship', |
1171 |
'Exception thrown when child patron is added as guarantor.'; |
1172 |
|
1173 |
$schema->storage->txn_rollback; |
1174 |
}; |