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

(-)a/C4/Members/AttributeTypes.pm (-16 lines)
Lines 90-111 sub GetAttributeTypes_hashref { Link Here
90
    return \%hash;
90
    return \%hash;
91
}
91
}
92
92
93
=head2 AttributeTypeExists
94
95
  my $have_attr_xyz = C4::Members::AttributeTypes::AttributeTypeExists($code)
96
97
Returns true if we have attribute type C<$code>
98
in the database.
99
100
=cut
101
102
sub AttributeTypeExists {
103
    my ($code) = @_;
104
    my $dbh = C4::Context->dbh;
105
    my $exists = $dbh->selectrow_array("SELECT code FROM borrower_attribute_types WHERE code = ?", undef, $code);
106
    return $exists;
107
}
108
109
=head1 METHODS 
93
=head1 METHODS 
110
94
111
  my $attr_type = C4::Members::AttributeTypes->new($code, $description);
95
  my $attr_type = C4::Members::AttributeTypes->new($code, $description);
(-)a/t/Members_AttributeTypes.t (-10 / +1 lines)
Lines 24-30 use Module::Load::Conditional qw/check_install/; Link Here
24
24
25
BEGIN {
25
BEGIN {
26
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
26
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
27
        plan tests => 10;
27
        plan tests => 8;
28
    } else {
28
    } else {
29
        plan skip_all => "Need Test::DBIx::Class"
29
        plan skip_all => "Need Test::DBIx::Class"
30
    }
30
    }
Lines 74-87 is( $members_attributetypes[0]->{'class'}, Link Here
74
is( $members_attributetypes[1]->{'class'},
74
is( $members_attributetypes[1]->{'class'},
75
    'silver', 'Second class value is silver' );
75
    'silver', 'Second class value is silver' );
76
76
77
ok( C4::Members::AttributeTypes::AttributeTypeExists('one'),
78
    'checking an attribute type exists' );
79
80
ok(
81
    !C4::Members::AttributeTypes::AttributeTypeExists('three'),
82
    "checking a attribute that isn't in the code doesn't exist"
83
);
84
85
ok( C4::Members::AttributeTypes->fetch('one'), "testing fetch feature" );
77
ok( C4::Members::AttributeTypes->fetch('one'), "testing fetch feature" );
86
78
87
ok( !C4::Members::AttributeTypes->fetch('FAKE'),
79
ok( !C4::Members::AttributeTypes->fetch('FAKE'),
88
- 

Return to bug 17825