|
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 => 6; |
| 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 |
- |
278 |
subtest 'display_value() tests' => sub { |
|
|
279 |
|
| 280 |
plan tests => 2; |
| 281 |
|
| 282 |
$schema->storage->txn_begin; |
| 283 |
|
| 284 |
my $borrower = $builder->build({ source => 'Borrower' }); |
| 285 |
|
| 286 |
{ |
| 287 |
my $category = $builder->build({ source => 'AuthorisedValueCategory' }); |
| 288 |
my $attr_type = $builder->build({ |
| 289 |
source => 'BorrowerAttributeType', |
| 290 |
value => { authorised_value_category => $category->{category_name} }, |
| 291 |
}); |
| 292 |
my $authorisedvalue = $builder->build({ |
| 293 |
source => 'AuthorisedValue', |
| 294 |
value => { category => $category->{category_name} }, |
| 295 |
}); |
| 296 |
my $attribute = Koha::Patron::Attribute->new( |
| 297 |
{ borrowernumber => $borrower->{borrowernumber}, |
| 298 |
code => $attr_type->{code}, |
| 299 |
attribute => $authorisedvalue->{authorised_value}, |
| 300 |
} |
| 301 |
)->store; |
| 302 |
|
| 303 |
is($attribute->display_value, $authorisedvalue->{lib}, 'display_value() returns the authorised value description'); |
| 304 |
} |
| 305 |
|
| 306 |
{ |
| 307 |
my $attr_type = $builder->build({ source => 'BorrowerAttributeType' }); |
| 308 |
my $attr = $builder->build({ source => 'BorrowerAttribute' }); |
| 309 |
my $attribute = Koha::Patron::Attributes->find($attr->{id}); |
| 310 |
|
| 311 |
is($attribute->display_value, $attr->{attribute}, "display_value() returns the raw attribute's value"); |
| 312 |
} |
| 313 |
|
| 314 |
$schema->storage->txn_rollback; |
| 315 |
}; |