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 => 33;
22
use Test::More tests => 34;
23
use Test::Warn;
23
use Test::Warn;
24
use Test::Exception;
24
use Test::Exception;
25
use Test::MockModule;
25
use Test::MockModule;
Lines 1395-1400 subtest 'generate_userid' => sub { Link Here
1395
    $patron_2->delete;
1395
    $patron_2->delete;
1396
};
1396
};
1397
1397
1398
subtest 'attributes' => sub {
1399
    plan tests => 2;
1400
1401
    my $library1 = Koha::Library->new({
1402
        branchcode => 'LIBPATRON',
1403
        branchname => 'Library of testing patron',
1404
    })->store;
1405
1406
    my $library2 = Koha::Library->new({
1407
        branchcode => 'LIBATTR',
1408
        branchname => 'Library for testing attribute',
1409
    })->store;
1410
1411
    my $category = Koha::Patron::Category->new({
1412
        categorycode => 'CAT1',
1413
        description => 'Category 1',
1414
    })->store;
1415
1416
    my $patron = Koha::Patron->new({
1417
        firstname => 'Patron',
1418
        surname => 'with attributes',
1419
        branchcode => 'LIBPATRON',
1420
        categorycode => 'CAT1',
1421
    })->store;
1422
1423
    my $attribute_type1 = Koha::Patron::Attribute::Type->new({
1424
        code => 'CODE_A',
1425
        description => 'Code A desciption',
1426
    })->store;
1427
1428
    my $attribute_type2 = Koha::Patron::Attribute::Type->new({
1429
        code => 'CODE_B',
1430
        description => 'Code A desciption',
1431
    })->store;
1432
1433
    $attribute_type2->library_limits ( [ $library2->branchcode ] );
1434
1435
    Koha::Patron::Attribute->new({ borrowernumber => $patron->borrowernumber, code => $attribute_type1->code, attribute => 'value 1' } )->store();
1436
    Koha::Patron::Attribute->new({ borrowernumber => $patron->borrowernumber, code => $attribute_type2->code, attribute => 'value 2' } )->store();
1437
1438
    is( $patron->attributes->count, 1, 'There should be one attribute');
1439
1440
    $attribute_type2->library_limits ( [ $library1->branchcode ] );
1441
1442
    is( $patron->attributes->count, 2, 'There should be 2 attributes');
1443
1444
    $patron->delete;
1445
};
1446
1398
$nb_of_patrons = Koha::Patrons->search->count;
1447
$nb_of_patrons = Koha::Patrons->search->count;
1399
$retrieved_patron_1->delete;
1448
$retrieved_patron_1->delete;
1400
is( Koha::Patrons->search->count, $nb_of_patrons - 1, 'Delete should have deleted the patron' );
1449
is( Koha::Patrons->search->count, $nb_of_patrons - 1, 'Delete should have deleted the patron' );
1401
- 

Return to bug 12159