Bug 27857: (follow-up) Use a more fine-grained exception for mandatory attributes

On using this dev for the API, I found that the original FKConstraint
exception was too generic, and could be confused with those risen by
Koha::Patron->store. So this patch changes the exception that is thrown
in Koha::Patron->extended_attributes

The change is reflected on the test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Patron.t
=> SUCCESS: Tests pass, and they include the new exception
3. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Tomás Cohen Arazi 2021-03-30 11:03:09 -03:00 committed by Jonathan Druart
parent 0d59e57508
commit e453ff963a
2 changed files with 3 additions and 4 deletions

View file

@ -1578,9 +1578,8 @@ sub extended_attributes {
{ join => 'borrower_attribute_types_branches' }
)->get_column('code');
for my $type ( @required_attribute_types ) {
Koha::Exceptions::Object::FKConstraint->throw(
broken_fk => "$type",
value => "$type",
Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute->throw(
type => $type,
) if !$new_types->{$type};
}
}

View file

@ -644,7 +644,7 @@ subtest 'extended_attributes' => sub {
]
);
}
'Koha::Exceptions::Object::FKConstraint',
'Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute',
'Exception thrown on missing mandatory attribute type';
is( $@->value, $attribute_type_1->code, 'Exception parameters are correct' );