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 / +49 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 31;
22
use Test::More tests => 32;
23
use Test::Warn;
23
use Test::Warn;
24
use Time::Fake;
24
use Time::Fake;
25
use DateTime;
25
use DateTime;
Lines 1356-1361 subtest 'generate_userid' => sub { Link Here
1356
    $patron_2->delete;
1356
    $patron_2->delete;
1357
};
1357
};
1358
1358
1359
subtest 'attributes' => sub {
1360
    plan tests => 2;
1361
1362
    my $library1 = Koha::Library->new({
1363
        branchcode => 'LIBPATRON',
1364
        branchname => 'Library of testing patron',
1365
    })->store;
1366
1367
    my $library2 = Koha::Library->new({
1368
        branchcode => 'LIBATTR',
1369
        branchname => 'Library for testing attribute',
1370
    })->store;
1371
1372
    my $category = Koha::Patron::Category->new({
1373
        categorycode => 'CAT1',
1374
        description => 'Category 1',
1375
    })->store;
1376
1377
    my $patron = Koha::Patron->new({
1378
        firstname => 'Patron',
1379
        surname => 'with attributes',
1380
        branchcode => 'LIBPATRON',
1381
        categorycode => 'CAT1',
1382
    })->store;
1383
1384
    my $attribute_type1 = Koha::Patron::Attribute::Type->new({
1385
        code => 'CODE_A',
1386
        description => 'Code A desciption',
1387
    })->store;
1388
1389
    my $attribute_type2 = Koha::Patron::Attribute::Type->new({
1390
        code => 'CODE_B',
1391
        description => 'Code A desciption',
1392
    })->store;
1393
1394
    $attribute_type2->library_limits ( [ $library2->branchcode ] );
1395
1396
    Koha::Patron::Attribute->new({ borrowernumber => $patron->borrowernumber, code => $attribute_type1->code, attribute => 'value 1' } )->store();
1397
    Koha::Patron::Attribute->new({ borrowernumber => $patron->borrowernumber, code => $attribute_type2->code, attribute => 'value 2' } )->store();
1398
1399
    is( $patron->attributes->count, 1, 'There should be one attribute');
1400
1401
    $attribute_type2->library_limits ( [ $library1->branchcode ] );
1402
1403
    is( $patron->attributes->count, 2, 'There should be 2 attributes');
1404
1405
    $patron->delete;
1406
};
1359
1407
1360
$retrieved_patron_1->delete;
1408
$retrieved_patron_1->delete;
1361
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
1409
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' );
1362
- 

Return to bug 12159