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

(-)a/Koha/Patron/Attribute.pm (-2 / +17 lines)
Lines 79-84 sub opac_editable { Link Here
79
    return Koha::Patron::Attribute::Types->find( $self->code )->opac_editable;
79
    return Koha::Patron::Attribute::Types->find( $self->code )->opac_editable;
80
}
80
}
81
81
82
=head3 type
83
84
    my $attribute_type = $attribute->type;
85
86
Returns a C<Koha::Patron::Attribute::Type> object corresponding to the current patron attribute
87
88
=cut
89
90
sub type {
91
92
    my $self = shift;
93
94
    return Koha::Patron::Attribute::Types->find( $self->code );
95
}
96
82
=head2 Internal methods
97
=head2 Internal methods
83
98
84
=head3 _check_repeatable
99
=head3 _check_repeatable
Lines 93-99 sub _check_repeatable { Link Here
93
108
94
    my $self = shift;
109
    my $self = shift;
95
110
96
    if ( !Koha::Patron::Attribute::Types->find( $self->code )->repeatable ) {
111
    if ( !$self->type->repeatable ) {
97
        my $attr_count
112
        my $attr_count
98
            = Koha::Database->new->schema->resultset( $self->_type )->search(
113
            = Koha::Database->new->schema->resultset( $self->_type )->search(
99
            {   borrowernumber => $self->borrowernumber,
114
            {   borrowernumber => $self->borrowernumber,
Lines 119-125 sub _check_unique_id { Link Here
119
134
120
    my $self = shift;
135
    my $self = shift;
121
136
122
    if ( Koha::Patron::Attribute::Types->find( $self->code )->unique_id ) {
137
    if ( $self->type->unique_id ) {
123
        my $unique_count
138
        my $unique_count
124
            = Koha::Database->new->schema->resultset( $self->_type )
139
            = Koha::Database->new->schema->resultset( $self->_type )
125
            ->search( { code => $self->code, attribute => $self->attribute } )
140
            ->search( { code => $self->code, attribute => $self->attribute } )
(-)a/t/db_dependent/Koha/Patron/Attributes.t (-2 / +41 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 4;
22
use Test::More tests => 5;
23
23
24
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
25
use Test::Exception;
25
use Test::Exception;
Lines 235-238 subtest 'opac_editable() tests' => sub { Link Here
235
    $schema->storage->txn_rollback;
235
    $schema->storage->txn_rollback;
236
};
236
};
237
237
238
subtest 'type() tests' => sub {
239
240
    plan tests => 4;
241
242
    $schema->storage->txn_begin;
243
244
    my $patron
245
        = $builder->build( { source => 'Borrower' } )->{borrowernumber};
246
    my $attr_type = $builder->build( { source => 'BorrowerAttributeType' } );
247
    my $attribute = Koha::Patron::Attribute->new(
248
        {   borrowernumber => $patron,
249
            code           => $attr_type->{code},
250
            attribute      => $patron
251
        }
252
    );
253
254
    my $attribute_type = $attribute->type;
255
256
    is( ref($attribute_type),
257
        'Koha::Patron::Attribute::Type',
258
        '->type returns a Koha::Patron::Attribute::Type object'
259
    );
260
261
    is( $attribute_type->code,
262
        $attr_type->{code},
263
        '->type returns the right Koha::Patron::Attribute::Type object' );
264
265
    is( $attribute_type->opac_editable,
266
        $attr_type->{opac_editable},
267
        '->type returns the right Koha::Patron::Attribute::Type object'
268
    );
269
270
    is( $attribute_type->opac_display,
271
        $attr_type->{opac_display},
272
        '->type returns the right Koha::Patron::Attribute::Type object'
273
    );
274
275
    $schema->storage->txn_rollback;
276
};
277
238
1;
278
1;
239
- 

Return to bug 17828