Bug 31005: Unit test

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 39c3943076)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2022-06-23 17:22:53 +00:00 committed by Lucas Gass
parent 5c600f65e8
commit 2dbf1bf80f

View file

@ -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;
@ -643,14 +643,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 }
}
);
@ -683,6 +683,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 {