|
Lines 1-7
Link Here
|
| 1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
| 2 |
|
2 |
|
| 3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
| 4 |
use Test::More tests => 15; |
4 |
use Test::More tests => 17; |
| 5 |
|
5 |
|
| 6 |
use C4::Context; |
6 |
use C4::Context; |
| 7 |
use Koha::AuthorisedValue; |
7 |
use Koha::AuthorisedValue; |
|
Lines 20-25
$dbh->do("DELETE FROM authorised_value_categories");
Link Here
|
| 20 |
Koha::AuthorisedValueCategory->new({ category_name => 'av_for_testing' })->store; |
20 |
Koha::AuthorisedValueCategory->new({ category_name => 'av_for_testing' })->store; |
| 21 |
Koha::AuthorisedValueCategory->new({ category_name => 'aaav_for_testing' })->store; |
21 |
Koha::AuthorisedValueCategory->new({ category_name => 'aaav_for_testing' })->store; |
| 22 |
Koha::AuthorisedValueCategory->new({ category_name => 'restricted_for_testing' })->store; |
22 |
Koha::AuthorisedValueCategory->new({ category_name => 'restricted_for_testing' })->store; |
|
|
23 |
Koha::AuthorisedValueCategory->new({ category_name => 'CCODE' })->store; |
| 24 |
|
| 23 |
my $av1 = Koha::AuthorisedValue->new( |
25 |
my $av1 = Koha::AuthorisedValue->new( |
| 24 |
{ |
26 |
{ |
| 25 |
category => 'av_for_testing', |
27 |
category => 'av_for_testing', |
|
Lines 76-81
my $av_0 = Koha::AuthorisedValue->new(
Link Here
|
| 76 |
} |
78 |
} |
| 77 |
)->store(); |
79 |
)->store(); |
| 78 |
|
80 |
|
|
|
81 |
my $CatAuthValue = Koha::AuthorisedValue->new( |
| 82 |
{ |
| 83 |
category => 'CCODE', |
| 84 |
authorised_value => 'value 5', |
| 85 |
} |
| 86 |
)->store(); |
| 87 |
|
| 79 |
ok( $av1->id(), 'AV 1 is inserted' ); |
88 |
ok( $av1->id(), 'AV 1 is inserted' ); |
| 80 |
ok( $av2->id(), 'AV 2 is inserted' ); |
89 |
ok( $av2->id(), 'AV 2 is inserted' ); |
| 81 |
ok( $av3->id(), 'AV 3 is inserted' ); |
90 |
ok( $av3->id(), 'AV 3 is inserted' ); |
|
Lines 114-120
my $limits = $av1->branch_limitations;
Link Here
|
| 114 |
is( @$limits, 2, 'branch_limitations functions correctly both as setter and getter' ); |
123 |
is( @$limits, 2, 'branch_limitations functions correctly both as setter and getter' ); |
| 115 |
|
124 |
|
| 116 |
my @categories = Koha::AuthorisedValues->new->categories; |
125 |
my @categories = Koha::AuthorisedValues->new->categories; |
| 117 |
is( @categories, 3, 'There should have 2 categories inserted' ); |
126 |
is( @categories, 4, 'There should have 4 categories inserted' ); |
| 118 |
is( $categories[0], $av4->category, 'The first category should be correct (ordered by category name)' ); |
127 |
is( $categories[0], $av4->category, 'The first category should be correct (ordered by category name)' ); |
| 119 |
is( $categories[1], $av1->category, 'The second category should be correct (ordered by category name)' ); |
128 |
is( $categories[1], $av1->category, 'The second category should be correct (ordered by category name)' ); |
| 120 |
|
129 |
|
|
Lines 225-227
subtest 'search_by_*_field + find_by_koha_field + get_description' => sub {
Link Here
|
| 225 |
); |
234 |
); |
| 226 |
}; |
235 |
}; |
| 227 |
}; |
236 |
}; |
|
|
237 |
|
| 238 |
ok( $CatAuthValue->id(), 'CatAuthValue is inserted' ); |
| 239 |
|
| 240 |
sub GetCatAuthValues { |
| 241 |
my $dbh = C4::Context->dbh; |
| 242 |
my $sth = $dbh->prepare('SELECT authorised_value AS ccode FROM authorised_values WHERE category = "CCODE"'); |
| 243 |
$sth->execute(); |
| 244 |
return $sth->rows; |
| 245 |
} |
| 246 |
|
| 247 |
my $AuthValues = GetCatAuthValues(); |
| 248 |
is($AuthValues, 1, "Correct number of authorised_value's with category=CCODE"); |
| 249 |
|
| 250 |
|