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

(-)a/t/db_dependent/Members/Attributes.t (-11 / +1 lines)
Lines 25-31 use C4::Members::AttributeTypes; Link Here
25
use Koha::Database;
25
use Koha::Database;
26
use t::lib::TestBuilder;
26
use t::lib::TestBuilder;
27
27
28
use Test::More tests => 57;
28
use Test::More tests => 53;
29
29
30
use_ok('C4::Members::Attributes');
30
use_ok('C4::Members::Attributes');
31
31
Lines 92-103 my $attributes = [ Link Here
92
    {
92
    {
93
        value => 'my attribute1',
93
        value => 'my attribute1',
94
        code => $attribute_type1->code(),
94
        code => $attribute_type1->code(),
95
        password => 'my password1',
96
    },
95
    },
97
    {
96
    {
98
        value => 'my attribute2',
97
        value => 'my attribute2',
99
        code => $attribute_type2->code(),
98
        code => $attribute_type2->code(),
100
        password => 'my password2',
101
    },
99
    },
102
    {
100
    {
103
        value => 'my attribute limited',
101
        value => 'my attribute limited',
Lines 122-132 is( @$borrower_attributes, 3, 'GetBorrowerAttributes returns the correct number Link Here
122
is( $borrower_attributes->[0]->{code}, $attributes->[0]->{code}, 'SetBorrowerAttributes stores the correct code correctly' );
120
is( $borrower_attributes->[0]->{code}, $attributes->[0]->{code}, 'SetBorrowerAttributes stores the correct code correctly' );
123
is( $borrower_attributes->[0]->{description}, $attribute_type1->description(), 'SetBorrowerAttributes stores the field description correctly' );
121
is( $borrower_attributes->[0]->{description}, $attribute_type1->description(), 'SetBorrowerAttributes stores the field description correctly' );
124
is( $borrower_attributes->[0]->{value}, $attributes->[0]->{value}, 'SetBorrowerAttributes stores the field value correctly' );
122
is( $borrower_attributes->[0]->{value}, $attributes->[0]->{value}, 'SetBorrowerAttributes stores the field value correctly' );
125
is( $borrower_attributes->[0]->{password}, $attributes->[0]->{password}, 'SetBorrowerAttributes stores the field password correctly' );
126
is( $borrower_attributes->[1]->{code}, $attributes->[1]->{code}, 'SetBorrowerAttributes stores the field code correctly' );
123
is( $borrower_attributes->[1]->{code}, $attributes->[1]->{code}, 'SetBorrowerAttributes stores the field code correctly' );
127
is( $borrower_attributes->[1]->{description}, $attribute_type2->description(), 'SetBorrowerAttributes stores the field description correctly' );
124
is( $borrower_attributes->[1]->{description}, $attribute_type2->description(), 'SetBorrowerAttributes stores the field description correctly' );
128
is( $borrower_attributes->[1]->{value}, $attributes->[1]->{value}, 'SetBorrowerAttributes stores the field value correctly' );
125
is( $borrower_attributes->[1]->{value}, $attributes->[1]->{value}, 'SetBorrowerAttributes stores the field value correctly' );
129
is( $borrower_attributes->[1]->{password}, $attributes->[1]->{password}, 'SetBorrowerAttributes stores the field password correctly' );
130
$borrower_attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
126
$borrower_attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
131
is( @$borrower_attributes, 3, 'GetBorrowerAttributes returns the correct number of borrower attributes' );
127
is( @$borrower_attributes, 3, 'GetBorrowerAttributes returns the correct number of borrower attributes' );
132
128
Lines 134-145 $attributes = [ Link Here
134
    {
130
    {
135
        value => 'my attribute1',
131
        value => 'my attribute1',
136
        code => $attribute_type1->code(),
132
        code => $attribute_type1->code(),
137
        password => 'my password1',
138
    },
133
    },
139
    {
134
    {
140
        value => 'my attribute2',
135
        value => 'my attribute2',
141
        code => $attribute_type2->code(),
136
        code => $attribute_type2->code(),
142
        password => 'my password2',
143
    }
137
    }
144
];
138
];
145
C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $attributes);
139
C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $attributes);
Lines 168-174 is( $attribute_value, $attributes->[1]->{value}, 'GetBorrowerAttributeValue retu Link Here
168
my $attribute = {
162
my $attribute = {
169
    attribute => 'my attribute3',
163
    attribute => 'my attribute3',
170
    code => $attribute_type1->code(),
164
    code => $attribute_type1->code(),
171
    password => 'my password3',
172
};
165
};
173
C4::Members::Attributes::UpdateBorrowerAttribute($borrowernumber, $attribute);
166
C4::Members::Attributes::UpdateBorrowerAttribute($borrowernumber, $attribute);
174
$borrower_attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
167
$borrower_attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
Lines 176-182 is( @$borrower_attributes, 3, 'UpdateBorrowerAttribute does not change the numbe Link Here
176
is( $borrower_attributes->[0]->{code}, $attribute->{code}, 'UpdateBorrowerAttribute updates the field code correctly' );
169
is( $borrower_attributes->[0]->{code}, $attribute->{code}, 'UpdateBorrowerAttribute updates the field code correctly' );
177
is( $borrower_attributes->[0]->{description}, $attribute_type1->description(), 'UpdateBorrowerAttribute updates the field description correctly' );
170
is( $borrower_attributes->[0]->{description}, $attribute_type1->description(), 'UpdateBorrowerAttribute updates the field description correctly' );
178
is( $borrower_attributes->[0]->{value}, $attribute->{attribute}, 'UpdateBorrowerAttribute updates the field value correctly' );
171
is( $borrower_attributes->[0]->{value}, $attribute->{attribute}, 'UpdateBorrowerAttribute updates the field value correctly' );
179
is( $borrower_attributes->[0]->{password}, $attribute->{password}, 'UpdateBorrowerAttributes updates the field password correctly' );
180
172
181
173
182
my $check_uniqueness = C4::Members::Attributes::CheckUniqueness();
174
my $check_uniqueness = C4::Members::Attributes::CheckUniqueness();
Lines 224-230 is( @$borrower_attributes, 2, 'DeleteBorrowerAttribute deletes a borrower attrib Link Here
224
is( $borrower_attributes->[0]->{code}, $attributes->[1]->{code}, 'DeleteBorrowerAttribute deletes the correct entry');
216
is( $borrower_attributes->[0]->{code}, $attributes->[1]->{code}, 'DeleteBorrowerAttribute deletes the correct entry');
225
is( $borrower_attributes->[0]->{description}, $attribute_type2->description(), 'DeleteBorrowerAttribute deletes the correct entry');
217
is( $borrower_attributes->[0]->{description}, $attribute_type2->description(), 'DeleteBorrowerAttribute deletes the correct entry');
226
is( $borrower_attributes->[0]->{value}, $attributes->[1]->{value}, 'DeleteBorrowerAttribute deletes the correct entry');
218
is( $borrower_attributes->[0]->{value}, $attributes->[1]->{value}, 'DeleteBorrowerAttribute deletes the correct entry');
227
is( $borrower_attributes->[0]->{password}, $attributes->[1]->{password}, 'DeleteBorrowerAttribute deletes the correct entry');
228
219
229
C4::Members::Attributes::DeleteBorrowerAttribute($borrowernumber, $attributes->[1]);
220
C4::Members::Attributes::DeleteBorrowerAttribute($borrowernumber, $attributes->[1]);
230
$borrower_attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
221
$borrower_attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
231
- 

Return to bug 16377