From 1956c085d4f68de6ff76ce69a9db42f76f256fe8 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 23 Jun 2022 17:22:53 +0000 Subject: [PATCH] Bug 31005: Unit test Signed-off-by: David Nind Signed-off-by: Martin Renvoize --- t/db_dependent/Koha/Patron.t | 41 +++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index 37214105e5..977ec261d6 100755 --- a/t/db_dependent/Koha/Patron.t +++ b/t/db_dependent/Koha/Patron.t @@ -372,7 +372,7 @@ subtest 'is_superlibrarian() tests' => sub { subtest 'extended_attributes' => sub { - plan tests => 15; + plan tests => 16; my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; @@ -649,14 +649,14 @@ subtest 'extended_attributes' => sub { my $attribute_type_1 = $builder->build_object( { class => 'Koha::Patron::Attribute::Types', - value => { mandatory => 1, class => 'a' } + value => { mandatory => 1, class => 'a', category_code => undef } } ); my $attribute_type_2 = $builder->build_object( { class => 'Koha::Patron::Attribute::Types', - value => { mandatory => 0, class => 'a' } + value => { mandatory => 0, class => 'a', category_code => undef } } ); @@ -689,6 +689,41 @@ subtest 'extended_attributes' => sub { }; + subtest 'limited category mandatory attributes tests' => sub { + + plan tests => 2; + + $schema->storage->txn_begin; + Koha::Patron::Attribute::Types->search->delete; + + my $patron = $builder->build_object({ class => 'Koha::Patrons' }); + + my $attribute_type_1 = $builder->build_object( + { + class => 'Koha::Patron::Attribute::Types', + value => { mandatory => 1, class => 'a', category_code => $patron->categorycode } + } + ); + + $patron->extended_attributes( + [ + { code => $attribute_type_1->code, attribute => 'a' } + ] + ); + + is( $patron->extended_attributes->count, 1, 'Extended attributes succeeded' ); + + $patron = $builder->build_object({ class => 'Koha::Patrons' }); + # new patron, new category - they shouldn't be required to have any attributes + + + ok( $patron->extended_attributes([]), "We can set no attributes, mandatory attribute for other category not required"); + + + }; + + + }; subtest 'can_log_into() tests' => sub { -- 2.20.1