Browse Source
This patch introduces a Koha::Patron::Attribute->store method that does the required check for the corresponding Koha::Patron::Attribute::Type and raises an exception if trying to store more than one unique attribute code/value combination, and another exception for non-repeatable attribute types being stored while already existing on the DB. This patch introduces exception definitions for that purpose. To test: - Apply the unit tests patches - Run: $ prove t/db_dependent/Koha/Patron/Attributes.t => FAIL: Tests fail - Apply this patch - Run: $ prove t/db_dependent/Koha/Patron/Attributes.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>17.05.x
2 changed files with 90 additions and 0 deletions
@ -0,0 +1,20 @@ |
|||
package Koha::Exceptions::Patron::Attribute; |
|||
|
|||
use Modern::Perl; |
|||
|
|||
use Exception::Class ( |
|||
|
|||
'Koha::Exceptions::Patron::Attribute' => { |
|||
description => 'Something went wrong' |
|||
}, |
|||
'Koha::Exceptions::Patron::Attribute::NonRepeatable' => { |
|||
isa => 'Koha::Exceptions::Patron::Attribute', |
|||
description => "repeatable not set for attribute type and tried to add a new attribute for the same code" |
|||
}, |
|||
'Koha::Exceptions::Patron::Attribute::UniqueIDConstraint' => { |
|||
isa => 'Koha::Exceptions::Patron::Attribute', |
|||
description => "unique_id set for attribute type and tried to add a new with the same code and value" |
|||
} |
|||
); |
|||
|
|||
1; |
Loading…
Reference in new issue