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

(-)a/C4/Members/AttributeTypes.pm (-16 lines)
Lines 89-110 sub GetAttributeTypes_hashref { Link Here
89
    return \%hash;
89
    return \%hash;
90
}
90
}
91
91
92
=head2 AttributeTypeExists
93
94
  my $have_attr_xyz = C4::Members::AttributeTypes::AttributeTypeExists($code)
95
96
Returns true if we have attribute type C<$code>
97
in the database.
98
99
=cut
100
101
sub AttributeTypeExists {
102
    my ($code) = @_;
103
    my $dbh = C4::Context->dbh;
104
    my $exists = $dbh->selectrow_array("SELECT code FROM borrower_attribute_types WHERE code = ?", undef, $code);
105
    return $exists;
106
}
107
108
=head1 METHODS 
92
=head1 METHODS 
109
93
110
  my $attr_type = C4::Members::AttributeTypes->new($code, $description);
94
  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