View | Details | Raw Unified | Return to bug 36169
Collapse All | Expand All

(-)a/Koha/Patron.pm (-2 / +2 lines)
Lines 1998-2010 sub is_superlibrarian { Link Here
1998
1998
1999
my $is_adult = $patron->is_adult
1999
my $is_adult = $patron->is_adult
2000
2000
2001
Return true if the patron has a category with a type Adult (A) or Organization (I)
2001
Return true if the patron has a category with a type Adult (A), Organization (I) or Staff (S)
2002
2002
2003
=cut
2003
=cut
2004
2004
2005
sub is_adult {
2005
sub is_adult {
2006
    my ( $self ) = @_;
2006
    my ( $self ) = @_;
2007
    return $self->category->category_type =~ /^(A|I)$/ ? 1 : 0;
2007
    return $self->category->category_type =~ /^(A|I|S)$/ ? 1 : 0;
2008
}
2008
}
2009
2009
2010
=head3 is_child
2010
=head3 is_child
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +16 lines)
Lines 1414-1420 subtest 'account_locked' => sub { Link Here
1414
};
1414
};
1415
1415
1416
subtest 'is_child | is_adult' => sub {
1416
subtest 'is_child | is_adult' => sub {
1417
    plan tests => 8;
1417
    plan tests => 10;
1418
    my $category = $builder->build_object(
1418
    my $category = $builder->build_object(
1419
        {
1419
        {
1420
            class => 'Koha::Patron::Categories',
1420
            class => 'Koha::Patron::Categories',
Lines 1463-1483 subtest 'is_child | is_adult' => sub { Link Here
1463
            value => { categorycode => $category->categorycode }
1463
            value => { categorycode => $category->categorycode }
1464
        }
1464
        }
1465
    );
1465
    );
1466
    $category = $builder->build_object(
1467
        {
1468
           class => 'Koha::Patron::Categories',
1469
           value => { category_type => 'S' }
1470
        }
1471
    );
1472
    my $patron_staff = $builder->build_object(
1473
        {
1474
           class => 'Koha::Patrons',
1475
           value => { categorycode => $category->categorycode }
1476
        }
1477
    );
1466
    is( $patron_adult->is_adult, 1, 'Patron from category A should be considered adult' );
1478
    is( $patron_adult->is_adult, 1, 'Patron from category A should be considered adult' );
1467
    is( $patron_adult_i->is_adult, 1, 'Patron from category I should be considered adult' );
1479
    is( $patron_adult_i->is_adult, 1, 'Patron from category I should be considered adult' );
1468
    is( $patron_child->is_adult, 0, 'Patron from category C should not be considered adult' );
1480
    is( $patron_child->is_adult, 0, 'Patron from category C should not be considered adult' );
1469
    is( $patron_other->is_adult, 0, 'Patron from category O should not be considered adult' );
1481
    is( $patron_other->is_adult, 0, 'Patron from category O should not be considered adult' );
1482
    is( $patron_staff->is_adult, 1, 'Patron from category S should be considered adult' );
1470
1483
1471
    is( $patron_adult->is_child, 0, 'Patron from category A should be considered child' );
1484
    is( $patron_adult->is_child, 0, 'Patron from category A should be considered child' );
1472
    is( $patron_adult_i->is_child, 0, 'Patron from category I should be considered child' );
1485
    is( $patron_adult_i->is_child, 0, 'Patron from category I should be considered child' );
1473
    is( $patron_child->is_child, 1, 'Patron from category C should not be considered child' );
1486
    is( $patron_child->is_child, 1, 'Patron from category C should not be considered child' );
1474
    is( $patron_other->is_child, 0, 'Patron from category O should not be considered child' );
1487
    is( $patron_other->is_child, 0, 'Patron from category O should not be considered child' );
1488
    is( $patron_staff->is_child, 0, 'Patron from category S should not be considered child' );
1475
1489
1476
    # Clean up
1490
    # Clean up
1477
    $patron_adult->delete;
1491
    $patron_adult->delete;
1478
    $patron_adult_i->delete;
1492
    $patron_adult_i->delete;
1479
    $patron_child->delete;
1493
    $patron_child->delete;
1480
    $patron_other->delete;
1494
    $patron_other->delete;
1495
    $patron_staff->delete;
1481
};
1496
};
1482
1497
1483
subtest 'overdues' => sub {
1498
subtest 'overdues' => sub {
1484
- 

Return to bug 36169