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

(-)a/t/db_dependent/Koha/Patron/Attributes.t (-1 / +63 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 5;
22
use Test::More tests => 7;
23
23
24
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
25
use Test::Exception;
25
use Test::Exception;
Lines 275-277 subtest 'type() tests' => sub { Link Here
275
    $schema->storage->txn_rollback;
275
    $schema->storage->txn_rollback;
276
};
276
};
277
277
278
subtest 'display_checkout() tests' => sub {
279
280
    plan tests => 2;
281
282
    $schema->storage->txn_begin;
283
284
    my $patron = $builder->build( { source => 'Borrower' } )->{borrowernumber};
285
    my $attribute_type_1 = $builder->build(
286
        {   source => 'BorrowerAttributeType',
287
            value  => { display_checkout => 1 }
288
        }
289
    );
290
291
    my $attribute_1 = Koha::Patron::Attribute->new(
292
        {   borrowernumber => $patron,
293
            code           => $attribute_type_1->{code},
294
            attribute      => $patron
295
        }
296
    );
297
    is( $attribute_1->display_checkout, 1, '->display_checkout returns 1' );
298
299
    my $attribute_type_2 = $builder->build(
300
        {   source => 'BorrowerAttributeType',
301
            value  => { display_checkout => 0 }
302
        }
303
    );
304
305
    my $attribute_2 = Koha::Patron::Attribute->new(
306
        {   borrowernumber => $patron,
307
            code           => $attribute_type_2->{code},
308
            attribute      => $patron
309
        }
310
    );
311
    is( $attribute_2->display_checkout, 0, '->display_checkout returns 0' );
312
313
    $schema->storage->txn_rollback;
314
};
315
316
subtest 'type_description() and value_description tests' => sub {
317
318
    plan tests => 2;
319
320
    $schema->storage->txn_begin;
321
322
    my $patron = $builder->build( { source => 'Borrower' } )->{borrowernumber};
323
    my $attribute_type_1 = $builder->build(
324
        {   source => 'BorrowerAttributeType',
325
            value  => { description => "Type 1" }
326
        }
327
    );
328
329
    my $attribute_1 = Koha::Patron::Attribute->new(
330
        {   borrowernumber => $patron,
331
            code           => $attribute_type_1->{code},
332
            attribute      => "Attribute 1"
333
        }
334
    );
335
    is( $attribute_1->type_description, "Type 1" , '->type_description returns right value' );
336
    is( $attribute_1->value_description, "Attribute 1" , '->value_description returns right value' );
337
338
    $schema->storage->txn_rollback;
339
};
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +50 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 25;
22
use Test::More tests => 26;
23
use Test::Warn;
23
use Test::Warn;
24
use Time::Fake;
24
use Time::Fake;
25
use DateTime;
25
use DateTime;
Lines 1118-1123 subtest 'is_child | is_adult' => sub { Link Here
1118
    $patron_other->delete;
1118
    $patron_other->delete;
1119
};
1119
};
1120
1120
1121
subtest 'attributes' => sub {
1122
    plan tests => 2;
1123
1124
    my $library1 = Koha::Library->new({
1125
        branchcode => 'LIBPATRON',
1126
        branchname => 'Library of testing patron',
1127
    })->store;
1128
1129
    my $library2 = Koha::Library->new({
1130
        branchcode => 'LIBATTR',
1131
        branchname => 'Library for testing attribute',
1132
    })->store;
1133
1134
    my $category = Koha::Patron::Category->new({
1135
        categorycode => 'CAT1',
1136
        description => 'Category 1',
1137
    })->store;
1138
1139
    my $patron = Koha::Patron->new({
1140
        firstname => 'Patron',
1141
        surname => 'with attributes',
1142
        branchcode => 'LIBPATRON',
1143
        categorycode => 'CAT1',
1144
    })->store;
1145
1146
    my $attribute_type1 = Koha::Patron::Attribute::Type->new({
1147
        code => 'CODE_A',
1148
        description => 'Code A desciption',
1149
    })->store;
1150
1151
    my $attribute_type2 = Koha::Patron::Attribute::Type->new({
1152
        code => 'CODE_B',
1153
        description => 'Code A desciption',
1154
    })->store;
1155
1156
    $attribute_type2->library_limits ( [ $library2->branchcode ] );
1157
1158
    Koha::Patron::Attribute->new({ borrowernumber => $patron->borrowernumber, code => $attribute_type1->code, attribute => 'value 1' } )->store();
1159
    Koha::Patron::Attribute->new({ borrowernumber => $patron->borrowernumber, code => $attribute_type2->code, attribute => 'value 2' } )->store();
1160
1161
    is( $patron->attributes->count, 1, 'There should be one attribute');
1162
1163
    $attribute_type2->library_limits ( [ $library1->branchcode ] );
1164
1165
    is( $patron->attributes->count, 2, 'There should be 2 attributes');
1166
1167
    $patron->delete;
1168
};
1169
1121
$retrieved_patron_1->delete;
1170
$retrieved_patron_1->delete;
1122
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
1171
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
1123
1172
1124
- 

Return to bug 12159