From 4a7d89d4d33db85804e9fd558a973c5c2f4c4162 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 2 Mar 2021 11:06:35 -0300 Subject: [PATCH] Bug 27833: Add unit tests Signed-off-by: David Nind --- t/db_dependent/Koha/Patron/Attributes.t | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Koha/Patron/Attributes.t b/t/db_dependent/Koha/Patron/Attributes.t index e403e0d30e..92e5cd05fb 100755 --- a/t/db_dependent/Koha/Patron/Attributes.t +++ b/t/db_dependent/Koha/Patron/Attributes.t @@ -33,7 +33,7 @@ my $builder = t::lib::TestBuilder->new; subtest 'store() repeatable attributes tests' => sub { - plan tests => 4; + plan tests => 5; $schema->storage->txn_begin; @@ -84,6 +84,15 @@ subtest 'store() repeatable attributes tests' => sub { } 'Koha::Exceptions::Patron::Attribute::NonRepeatable', 'Exception thrown trying to store more than one non-repeatable attribute'; + + is( + "$@", + "Tried to add more than one non-repeatable attributes. code=" + . $attribute_type_2->{code} + . " attribute=Bar", + 'Exception stringified correctly, attribute passed correctly' + ); + my $attributes = Koha::Patron::Attributes->search( { borrowernumber => $patron, code => $attribute_type_2->{code} } ); is( $attributes->count, 1, '1 non-repeatable attribute stored' ); @@ -95,7 +104,7 @@ subtest 'store() repeatable attributes tests' => sub { subtest 'store() unique_id attributes tests' => sub { - plan tests => 4; + plan tests => 5; $schema->storage->txn_begin; @@ -148,6 +157,15 @@ subtest 'store() unique_id attributes tests' => sub { } 'Koha::Exceptions::Patron::Attribute::UniqueIDConstraint', 'Exception thrown trying to store more than one unique attribute'; + + is( + "$@", + "Your action breaks a unique constraint on the attribute. code=" + . $attribute_type_2->{code} + . " attribute=Foo", + 'Exception stringified correctly, attribute passed correctly' + ); + my $attributes = Koha::Patron::Attributes->search( { borrowernumber => $patron_1, code => $attribute_type_2->{code} } ); is( $attributes->count, 1, '1 unique attribute stored' ); -- 2.11.0