|
Line 0
Link Here
|
| 0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
# Copyright 2016 Koha Development team |
| 4 |
# |
| 5 |
# This file is part of Koha |
| 6 |
# |
| 7 |
# Koha is free software; you can redistribute it and/or modify it |
| 8 |
# under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation; either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# Koha is distributed in the hope that it will be useful, but |
| 13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
| 20 |
use Modern::Perl; |
| 21 |
|
| 22 |
use Test::More tests => 2; |
| 23 |
|
| 24 |
use t::lib::TestBuilder; |
| 25 |
|
| 26 |
use Koha::Database; |
| 27 |
use Koha::Patron::Attribute; |
| 28 |
|
| 29 |
my $schema = Koha::Database->new->schema; |
| 30 |
my $builder = t::lib::TestBuilder->new; |
| 31 |
|
| 32 |
subtest 'opac_display() tests' => sub { |
| 33 |
|
| 34 |
plan tests => 2; |
| 35 |
|
| 36 |
$schema->storage->txn_begin; |
| 37 |
|
| 38 |
my $patron |
| 39 |
= $builder->build( { source => 'Borrower' } )->{borrowernumber}; |
| 40 |
my $attribute_type_1 = $builder->build( |
| 41 |
{ source => 'BorrowerAttributeType', |
| 42 |
value => { opac_display => 1 } |
| 43 |
} |
| 44 |
); |
| 45 |
|
| 46 |
my $attribute_1 = Koha::Patron::Attribute->new( |
| 47 |
{ borrowernumber => $patron, |
| 48 |
code => $attribute_type_1->{code}, |
| 49 |
attribute => $patron |
| 50 |
} |
| 51 |
); |
| 52 |
is( $attribute_1->opac_display, 1, '->opac_display returns 1' ); |
| 53 |
|
| 54 |
my $attribute_type_2 = $builder->build( |
| 55 |
{ source => 'BorrowerAttributeType', |
| 56 |
value => { opac_display => 0 } |
| 57 |
} |
| 58 |
); |
| 59 |
|
| 60 |
my $attribute_2 = Koha::Patron::Attribute->new( |
| 61 |
{ borrowernumber => $patron, |
| 62 |
code => $attribute_type_2->{code}, |
| 63 |
attribute => $patron |
| 64 |
} |
| 65 |
); |
| 66 |
is( $attribute_2->opac_display, 0, '->opac_display returns 0' ); |
| 67 |
|
| 68 |
$schema->storage->txn_rollback; |
| 69 |
}; |
| 70 |
|
| 71 |
subtest 'opac_editable() tests' => sub { |
| 72 |
|
| 73 |
plan tests => 2; |
| 74 |
|
| 75 |
$schema->storage->txn_begin; |
| 76 |
|
| 77 |
my $patron |
| 78 |
= $builder->build( { source => 'Borrower' } )->{borrowernumber}; |
| 79 |
my $attribute_type_1 = $builder->build( |
| 80 |
{ source => 'BorrowerAttributeType', |
| 81 |
value => { opac_editable => 1 } |
| 82 |
} |
| 83 |
); |
| 84 |
|
| 85 |
my $attribute_1 = Koha::Patron::Attribute->new( |
| 86 |
{ borrowernumber => $patron, |
| 87 |
code => $attribute_type_1->{code}, |
| 88 |
attribute => $patron |
| 89 |
} |
| 90 |
); |
| 91 |
is( $attribute_1->opac_editable, 1, '->opac_editable returns 1' ); |
| 92 |
|
| 93 |
my $attribute_type_2 = $builder->build( |
| 94 |
{ source => 'BorrowerAttributeType', |
| 95 |
value => { opac_editable => 0 } |
| 96 |
} |
| 97 |
); |
| 98 |
|
| 99 |
my $attribute_2 = Koha::Patron::Attribute->new( |
| 100 |
{ borrowernumber => $patron, |
| 101 |
code => $attribute_type_2->{code}, |
| 102 |
attribute => $patron |
| 103 |
} |
| 104 |
); |
| 105 |
is( $attribute_2->opac_editable, 0, '->opac_editable returns 0' ); |
| 106 |
|
| 107 |
$schema->storage->txn_rollback; |
| 108 |
}; |
| 109 |
|
| 110 |
1; |