|
Lines 8-18
use warnings;
Link Here
|
| 8 |
use C4::Context; |
8 |
use C4::Context; |
| 9 |
use Koha::DateUtils qw(dt_from_string); |
9 |
use Koha::DateUtils qw(dt_from_string); |
| 10 |
|
10 |
|
| 11 |
use Test::More tests => 7; |
11 |
use Test::More tests => 8; |
| 12 |
use DateTime::Format::MySQL; |
12 |
use DateTime::Format::MySQL; |
| 13 |
|
13 |
|
| 14 |
BEGIN { |
14 |
BEGIN { |
| 15 |
use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote )); |
15 |
use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote GetItemTypesByCategory GetItemTypesCategorized)); |
| 16 |
use_ok('C4::Members'); |
16 |
use_ok('C4::Members'); |
| 17 |
} |
17 |
} |
| 18 |
|
18 |
|
|
Lines 261-263
subtest 'getFacets() tests' => sub {
Link Here
|
| 261 |
'location facet present with singleBranchMode on (bug 10078)' |
261 |
'location facet present with singleBranchMode on (bug 10078)' |
| 262 |
); |
262 |
); |
| 263 |
}; |
263 |
}; |
| 264 |
- |
264 |
|
|
|
265 |
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{ |
| 266 |
plan tests => 7; |
| 267 |
|
| 268 |
my $insertGroup = AddAuthorisedValue('DOCTYPECAT', 'Qwertyware'); |
| 269 |
ok($insertGroup, "Create group Qwertyware"); |
| 270 |
|
| 271 |
my $query = "INSERT into itemtypes (itemtype, description, searchcategory, hideinopac) values (?,?,?,?)"; |
| 272 |
my $insertSth = C4::Context->dbh->prepare($query); |
| 273 |
$insertSth->execute('BKghjklo1', 'One type of book', '', 0); |
| 274 |
$insertSth->execute('BKghjklo2', 'Another type of book', 'Qwertyware', 0); |
| 275 |
$insertSth->execute('BKghjklo3', 'Yet another type of book', 'Qwertyware', 0); |
| 276 |
# test for empty result |
| 277 |
my @results = GetItemTypesByCategory('Azertyware'); |
| 278 |
is(scalar @results, 0, 'GetItemTypesByCategory: Invalid category returns nothing'); |
| 279 |
@results = GetItemTypesByCategory('Qwertyware'); |
| 280 |
is($results[1], 'BKghjklo3', 'GetItemTypesByCategory: valid category returns itemtypes'); |
| 281 |
|
| 282 |
# add more data since GetItemTypesCategorized's search is more subtle |
| 283 |
$insertSth->execute('BKghjklo4', 'An hidden book', 'Qwertyware', 1); |
| 284 |
AddAuthorisedValue('DOCTYPECAT', 'Veryveryheavybook'); |
| 285 |
$insertSth->execute('BKghjklo5', 'Some encyclopedia', 'Veryveryheavybook', 0); |
| 286 |
$insertSth->execute('BKghjklo6', 'A collection of dictionnary', 'Veryveryheavybook', 0); |
| 287 |
# get the grouped itemtypes. |
| 288 |
my $hrCat = GetItemTypesCategorized(); |
| 289 |
ok(exists $hrCat->{Qwertyware}, 'GetItemTypesCategorized: first category exists'); |
| 290 |
ok(exists $hrCat->{Veryveryheavybook}, 'GetItemTypesCategorized: second category exists'); |
| 291 |
ok(exists $hrCat->{BKghjklo1}, 'GetItemTypesCategorized: ungrouped item exists'); |
| 292 |
ok(!exists $hrCat->{BKghjklo2}, 'GetItemTypesCategorized: grouped itemtype not returned'); |
| 293 |
} |
| 294 |
|