|
Lines 13-19
use Test::More tests => 8;
Link Here
|
| 13 |
use DateTime::Format::MySQL; |
13 |
use DateTime::Format::MySQL; |
| 14 |
|
14 |
|
| 15 |
BEGIN { |
15 |
BEGIN { |
| 16 |
use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote GetItemTypesByCategory GetItemTypesCategorized)); |
16 |
use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote GetItemTypesCategorized)); |
| 17 |
use_ok('C4::Members'); |
17 |
use_ok('C4::Members'); |
| 18 |
} |
18 |
} |
| 19 |
|
19 |
|
|
Lines 239-245
subtest 'ISBN tests' => sub {
Link Here
|
| 239 |
|
239 |
|
| 240 |
}; |
240 |
}; |
| 241 |
|
241 |
|
| 242 |
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{ |
242 |
subtest 'GetItemTypesCategorized test' => sub{ |
| 243 |
plan tests => 7; |
243 |
plan tests => 7; |
| 244 |
|
244 |
|
| 245 |
my $avc = Koha::AuthorisedValueCategories->find('ITEMTYPECAT'); |
245 |
my $avc = Koha::AuthorisedValueCategories->find('ITEMTYPECAT'); |
|
Lines 259-270
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
Link Here
|
| 259 |
$insertSth->execute('BKghjklo3', 'Yet another type of book', 'Qwertyware', 0); |
259 |
$insertSth->execute('BKghjklo3', 'Yet another type of book', 'Qwertyware', 0); |
| 260 |
|
260 |
|
| 261 |
# Azertyware should not exist. |
261 |
# Azertyware should not exist. |
| 262 |
my @results = GetItemTypesByCategory('Azertyware'); |
262 |
my @itemtypes = Koha::ItemTypes->search({ searchcategory => 'Azertyware' }); |
| 263 |
is(scalar @results, 0, 'GetItemTypesByCategory: Invalid category returns nothing'); |
263 |
is( @itemtypes, 0, 'Search item types by searchcategory: Invalid category returns nothing'); |
| 264 |
|
264 |
|
| 265 |
@results = GetItemTypesByCategory('Qwertyware'); |
265 |
@itemtypes = Koha::ItemTypes->search({ searchcategory => 'Qwertyware' }); |
|
|
266 |
my @got = map { $_->itemtype } @itemtypes; |
| 266 |
my @expected = ( 'BKghjklo2', 'BKghjklo3' ); |
267 |
my @expected = ( 'BKghjklo2', 'BKghjklo3' ); |
| 267 |
is_deeply(\@results,\@expected,'GetItemTypesByCategory: valid category returns itemtypes'); |
268 |
is_deeply(\@got,\@expected,'Search item types by searchcategory: valid category returns itemtypes'); |
| 268 |
|
269 |
|
| 269 |
# add more data since GetItemTypesCategorized's search is more subtle |
270 |
# add more data since GetItemTypesCategorized's search is more subtle |
| 270 |
$insertGroup = Koha::AuthorisedValue->new( |
271 |
$insertGroup = Koha::AuthorisedValue->new( |
|
Lines 285-291
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
Link Here
|
| 285 |
ok(exists $hrCat->{Qwertyware}, 'GetItemTypesCategorized: partially visible category exists'); |
286 |
ok(exists $hrCat->{Qwertyware}, 'GetItemTypesCategorized: partially visible category exists'); |
| 286 |
|
287 |
|
| 287 |
my @only = ( 'BKghjklo1', 'BKghjklo2', 'BKghjklo3', 'BKghjklo4', 'BKghjklo5', 'Qwertyware', 'Veryheavybook' ); |
288 |
my @only = ( 'BKghjklo1', 'BKghjklo2', 'BKghjklo3', 'BKghjklo4', 'BKghjklo5', 'Qwertyware', 'Veryheavybook' ); |
| 288 |
@results = (); |
289 |
my @results = (); |
| 289 |
foreach my $key (@only) { |
290 |
foreach my $key (@only) { |
| 290 |
push @results, $key if exists $hrCat->{$key}; |
291 |
push @results, $key if exists $hrCat->{$key}; |
| 291 |
} |
292 |
} |
| 292 |
- |
|
|