Lines 25-31
use C4::Budgets;
Link Here
|
25 |
|
25 |
|
26 |
use Koha::DateUtils qw( dt_from_string ); |
26 |
use Koha::DateUtils qw( dt_from_string ); |
27 |
|
27 |
|
28 |
use Test::More tests => 104; |
28 |
use Test::More tests => 109; |
|
|
29 |
use Test::MockModule; |
29 |
use Test::Warn; |
30 |
use Test::Warn; |
30 |
|
31 |
|
31 |
BEGIN { |
32 |
BEGIN { |
Lines 40-45
my $sql;
Link Here
|
40 |
$dbh->{AutoCommit} = 0; |
41 |
$dbh->{AutoCommit} = 0; |
41 |
$dbh->{RaiseError} = 1; |
42 |
$dbh->{RaiseError} = 1; |
42 |
|
43 |
|
|
|
44 |
my $koha = new Test::MockModule('C4::Koha'); |
45 |
$koha->mock( |
46 |
'GetAuthorisedValues', |
47 |
sub { |
48 |
my $category = shift; |
49 |
|
50 |
my $ret = []; |
51 |
if ($category eq 'ccode') { |
52 |
$ret = [ |
53 |
{ |
54 |
'imageurl' => '', |
55 |
'authorised_value' => 'TH', |
56 |
'lib_opac' => "Thesis", |
57 |
'lib' => "Thesis", |
58 |
'category' => 'CCODE', |
59 |
'id' => '3810', |
60 |
'selected' => 0 |
61 |
}, |
62 |
{ |
63 |
'imageurl' => '', |
64 |
'authorised_value' => 'BOOK', |
65 |
'lib_opac' => 'Book', |
66 |
'lib' => 'Book', |
67 |
'category' => 'CCODE', |
68 |
'id' => '3807', |
69 |
'selected' => 0 |
70 |
}, |
71 |
|
72 |
]; |
73 |
} |
74 |
|
75 |
return $ret; |
76 |
} |
77 |
); |
78 |
|
79 |
$koha->mock( |
80 |
'GetKohaAuthorisedValueLib', |
81 |
sub { |
82 |
return 'Thesis'; |
83 |
} |
84 |
); |
85 |
|
43 |
# Reset item types to only the default ones |
86 |
# Reset item types to only the default ones |
44 |
$dbh->do(q|DELETE FROM itemtypes;|); |
87 |
$dbh->do(q|DELETE FROM itemtypes;|); |
45 |
$sql = " |
88 |
$sql = " |
Lines 341-356
$suggestions = GetSuggestionByStatus('CHECKED');
Link Here
|
341 |
is( @$suggestions, 1, 'DelSuggestion deletes one suggestion' ); |
384 |
is( @$suggestions, 1, 'DelSuggestion deletes one suggestion' ); |
342 |
is( $suggestions->[0]->{title}, $del_suggestion->{title}, 'DelSuggestion deletes the correct suggestion' ); |
385 |
is( $suggestions->[0]->{title}, $del_suggestion->{title}, 'DelSuggestion deletes the correct suggestion' ); |
343 |
|
386 |
|
344 |
## Bug 11466, making sure GetSupportList() returns itemtypes, even if AdvancedSearchTypes has multiple values |
387 |
C4::Context->set_preference('SuggestionsUseValues', 'itemtypes'); |
345 |
C4::Context->set_preference("AdvancedSearchTypes", 'itemtypes|loc|ccode'); |
|
|
346 |
my $itemtypes1 = C4::Koha::GetSupportList(); |
388 |
my $itemtypes1 = C4::Koha::GetSupportList(); |
347 |
is(@$itemtypes1, 8, "Purchase suggestion itemtypes collected, multiple AdvancedSearchTypes"); |
389 |
is(@$itemtypes1, 8, "Purchase suggestion itemtypes collected, SuggestionsUseValues is itemtypes"); |
|
|
390 |
my $mp_description = C4::Koha::GetSupportName('MP'); |
391 |
is($mp_description, 'Maps', 'Purchase suggestion itemtypes collected, itemtype MP description should be Maps'); |
392 |
|
393 |
is($itemtypes1->[0]{'authorised_value'},'BK', "Purchase suggestion itemtypes collected, SuggestionsUseValues is itemtypes first authorized value is BK"); |
394 |
is($itemtypes1->[0]{'lib'},'Books', "Purchase suggestion itemtypes collected, SuggestionsUseValues is itemtypes first lib is books"); |
395 |
is($itemtypes1->[0]{'imageurl'},'bridge/book.gif', "Purchase suggestion itemtypes collected, SuggestionsUseValues is itemtypes, first imageurl is bridge/book.gif"); |
396 |
|
397 |
C4::Context->set_preference('SuggestionsUseValues', 'ccode'); |
398 |
my $ccodes = C4::Koha::GetSupportList(); |
399 |
is(@$ccodes, 2, "Purchase suggestion itemtypes collected, SuggestionsUseValues is ccode"); |
400 |
my $th_description = C4::Koha::GetSupportName('TH'); |
401 |
is($th_description, 'Thesis', 'Purchase suggestion itemtypes collected, ccode TH description should be Thesis'); |
348 |
|
402 |
|
349 |
C4::Context->set_preference("AdvancedSearchTypes", 'itemtypes'); |
|
|
350 |
my $itemtypes2 = C4::Koha::GetSupportList(); |
351 |
is(@$itemtypes2, 8, "Purchase suggestion itemtypes collected, default AdvancedSearchTypes"); |
352 |
|
403 |
|
353 |
is_deeply($itemtypes1, $itemtypes2, 'same set of purchase suggestion formats retrieved'); |
404 |
C4::Context->set_preference('SuggestionsUseValues', 'none'); |
|
|
405 |
my $empty = C4::Koha::GetSupportList(); |
406 |
is(@$empty, 0, "Purchase suggestion itemtypes collected, SuggestionsUseValues is None"); |
354 |
|
407 |
|
355 |
# Test budgetid fk |
408 |
# Test budgetid fk |
356 |
$my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB |
409 |
$my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB |
357 |
- |
|
|