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 t::lib::TestBuilder; |
6 |
use t::lib::TestBuilder; |
7 |
|
7 |
|
Lines 23-28
Koha::AuthorisedValueCategories->delete;
Link Here
|
23 |
Koha::AuthorisedValueCategory->new({ category_name => 'av_for_testing' })->store; |
23 |
Koha::AuthorisedValueCategory->new({ category_name => 'av_for_testing' })->store; |
24 |
Koha::AuthorisedValueCategory->new({ category_name => 'aaav_for_testing' })->store; |
24 |
Koha::AuthorisedValueCategory->new({ category_name => 'aaav_for_testing' })->store; |
25 |
Koha::AuthorisedValueCategory->new({ category_name => 'restricted_for_testing' })->store; |
25 |
Koha::AuthorisedValueCategory->new({ category_name => 'restricted_for_testing' })->store; |
|
|
26 |
Koha::AuthorisedValueCategory->new({ category_name => 'CCODE' })->store; |
27 |
|
26 |
my $av1 = Koha::AuthorisedValue->new( |
28 |
my $av1 = Koha::AuthorisedValue->new( |
27 |
{ |
29 |
{ |
28 |
category => 'av_for_testing', |
30 |
category => 'av_for_testing', |
Lines 79-84
my $av_0 = Koha::AuthorisedValue->new(
Link Here
|
79 |
} |
81 |
} |
80 |
)->store(); |
82 |
)->store(); |
81 |
|
83 |
|
|
|
84 |
my $CatAuthValue = Koha::AuthorisedValue->new( |
85 |
{ |
86 |
category => 'CCODE', |
87 |
authorised_value => 'value 5', |
88 |
} |
89 |
)->store(); |
90 |
|
82 |
ok( $av1->id(), 'AV 1 is inserted' ); |
91 |
ok( $av1->id(), 'AV 1 is inserted' ); |
83 |
ok( $av2->id(), 'AV 2 is inserted' ); |
92 |
ok( $av2->id(), 'AV 2 is inserted' ); |
84 |
ok( $av3->id(), 'AV 3 is inserted' ); |
93 |
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 226-229
subtest 'search_by_*_field + find_by_koha_field + get_description' => sub {
Link Here
|
226 |
}; |
235 |
}; |
227 |
}; |
236 |
}; |
228 |
|
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 |
|
229 |
$schema->storage->txn_rollback; |
250 |
$schema->storage->txn_rollback; |