|
Lines 20-29
use Modern::Perl;
Link Here
|
| 20 |
use C4::Context; |
20 |
use C4::Context; |
| 21 |
use C4::Members; |
21 |
use C4::Members; |
| 22 |
use C4::Letters; |
22 |
use C4::Letters; |
|
|
23 |
use C4::Budgets; |
| 23 |
|
24 |
|
| 24 |
use Koha::DateUtils qw( dt_from_string ); |
25 |
use Koha::DateUtils qw( dt_from_string ); |
| 25 |
|
26 |
|
| 26 |
use Test::More tests => 97; |
27 |
use Test::More tests => 101; |
| 27 |
use Test::Warn; |
28 |
use Test::Warn; |
| 28 |
|
29 |
|
| 29 |
BEGIN { |
30 |
BEGIN { |
|
Lines 65-70
my $my_suggestion = {
Link Here
|
| 65 |
note => 'my note', |
66 |
note => 'my note', |
| 66 |
}; |
67 |
}; |
| 67 |
|
68 |
|
|
|
69 |
my $budgetperiod_id = AddBudgetPeriod({ |
| 70 |
budget_period_startdate => '2008-01-01', |
| 71 |
budget_period_enddate => '2008-12-31', |
| 72 |
budget_period_description => 'MAPERI', |
| 73 |
budget_period_active => 1, |
| 74 |
}); |
| 75 |
|
| 76 |
my $budget_id = AddBudget({ |
| 77 |
budget_code => 'ABCD', |
| 78 |
budget_amount => '123.132000', |
| 79 |
budget_name => 'ABCD', |
| 80 |
budget_notes => 'This is a note', |
| 81 |
budget_period_id => $budgetperiod_id, |
| 82 |
}); |
| 83 |
my $my_suggestion_with_budget = { |
| 84 |
title => 'my title 2', |
| 85 |
author => 'my author 2', |
| 86 |
publishercode => 'my publishercode 2', |
| 87 |
suggestedby => $borrowernumber, |
| 88 |
biblionumber => $biblionumber1, |
| 89 |
managedby => '', |
| 90 |
manageddate => '', |
| 91 |
accepteddate => dt_from_string, |
| 92 |
note => 'my note', |
| 93 |
budgetid => $budget_id, |
| 94 |
}; |
| 95 |
|
| 68 |
|
96 |
|
| 69 |
is( CountSuggestion(), 0, 'CountSuggestion without the status returns 0' ); |
97 |
is( CountSuggestion(), 0, 'CountSuggestion without the status returns 0' ); |
| 70 |
is( CountSuggestion('ASKED'), 0, 'CountSuggestion returns the correct number of suggestions' ); |
98 |
is( CountSuggestion('ASKED'), 0, 'CountSuggestion returns the correct number of suggestions' ); |
|
Lines 74-79
is( CountSuggestion('REJECTED'), 0, 'CountSuggestion returns the correct number
Link Here
|
| 74 |
|
102 |
|
| 75 |
my $my_suggestionid = NewSuggestion($my_suggestion); |
103 |
my $my_suggestionid = NewSuggestion($my_suggestion); |
| 76 |
isnt( $my_suggestionid, 0, 'NewSuggestion returns an not null id' ); |
104 |
isnt( $my_suggestionid, 0, 'NewSuggestion returns an not null id' ); |
|
|
105 |
my $my_suggestionid_with_budget = NewSuggestion($my_suggestion_with_budget); |
| 77 |
|
106 |
|
| 78 |
is( GetSuggestion(), undef, 'GetSuggestion without the suggestion id returns undef' ); |
107 |
is( GetSuggestion(), undef, 'GetSuggestion without the suggestion id returns undef' ); |
| 79 |
my $suggestion = GetSuggestion($my_suggestionid); |
108 |
my $suggestion = GetSuggestion($my_suggestionid); |
|
Lines 85-91
is( $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, 'NewSuggestion
Link Here
|
| 85 |
is( $suggestion->{STATUS}, 'ASKED', 'NewSuggestion stores a suggestion with the status ASKED by default' ); |
114 |
is( $suggestion->{STATUS}, 'ASKED', 'NewSuggestion stores a suggestion with the status ASKED by default' ); |
| 86 |
is( $suggestion->{managedby}, undef, 'NewSuggestion stores empty string as undef for non existent foreign key (integer)' ); |
115 |
is( $suggestion->{managedby}, undef, 'NewSuggestion stores empty string as undef for non existent foreign key (integer)' ); |
| 87 |
is( $suggestion->{manageddate}, undef, 'NewSuggestion stores empty string as undef for date' ); |
116 |
is( $suggestion->{manageddate}, undef, 'NewSuggestion stores empty string as undef for date' ); |
| 88 |
is( CountSuggestion('ASKED'), 1, 'CountSuggestion returns the correct number of suggestions' ); |
117 |
is( CountSuggestion('ASKED'), 2, 'CountSuggestion returns the correct number of suggestions' ); |
| 89 |
|
118 |
|
| 90 |
|
119 |
|
| 91 |
is( ModSuggestion(), undef, 'ModSuggestion without the suggestion returns undef' ); |
120 |
is( ModSuggestion(), undef, 'ModSuggestion without the suggestion returns undef' ); |
|
Lines 201-209
is( $connect_suggestion_and_biblio, '1', 'ConnectSuggestionAndBiblio returns 1'
Link Here
|
| 201 |
$suggestion = GetSuggestion($my_suggestionid); |
230 |
$suggestion = GetSuggestion($my_suggestionid); |
| 202 |
is( $suggestion->{biblionumber}, $biblionumber2, 'ConnectSuggestionAndBiblio updates the biblio number correctly' ); |
231 |
is( $suggestion->{biblionumber}, $biblionumber2, 'ConnectSuggestionAndBiblio updates the biblio number correctly' ); |
| 203 |
|
232 |
|
| 204 |
|
|
|
| 205 |
my $search_suggestion = SearchSuggestion(); |
233 |
my $search_suggestion = SearchSuggestion(); |
| 206 |
is( @$search_suggestion, 1, 'SearchSuggestion without arguments returns all suggestions' ); |
234 |
is( @$search_suggestion, 2, 'SearchSuggestion without arguments returns all suggestions' ); |
| 207 |
|
235 |
|
| 208 |
$search_suggestion = SearchSuggestion({ |
236 |
$search_suggestion = SearchSuggestion({ |
| 209 |
title => $mod_suggestion1->{title}, |
237 |
title => $mod_suggestion1->{title}, |
|
Lines 224-230
$search_suggestion = SearchSuggestion({
Link Here
|
| 224 |
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' ); |
252 |
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' ); |
| 225 |
|
253 |
|
| 226 |
$search_suggestion = SearchSuggestion({ |
254 |
$search_suggestion = SearchSuggestion({ |
| 227 |
publishercode => $mod_suggestion3->{publishercode}, |
255 |
publishercode => $mod_suggestion1->{publishercode}, |
| 228 |
}); |
256 |
}); |
| 229 |
is( @$search_suggestion, 1, 'SearchSuggestion returns the correct number of suggestions' ); |
257 |
is( @$search_suggestion, 1, 'SearchSuggestion returns the correct number of suggestions' ); |
| 230 |
$search_suggestion = SearchSuggestion({ |
258 |
$search_suggestion = SearchSuggestion({ |
|
Lines 241-246
$search_suggestion = SearchSuggestion({
Link Here
|
| 241 |
}); |
269 |
}); |
| 242 |
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' ); |
270 |
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' ); |
| 243 |
|
271 |
|
|
|
272 |
$search_suggestion = SearchSuggestion({ |
| 273 |
budgetid => '', |
| 274 |
}); |
| 275 |
is( @$search_suggestion, 2, 'SearchSuggestion (budgetid = "") returns the correct number of suggestions' ); |
| 276 |
$search_suggestion = SearchSuggestion({ |
| 277 |
budgetid => $budget_id, |
| 278 |
}); |
| 279 |
is( @$search_suggestion, 1, 'SearchSuggestion (budgetid = $budgetid) returns the correct number of suggestions' ); |
| 280 |
$search_suggestion = SearchSuggestion({ |
| 281 |
budgetid => '__NONE__', |
| 282 |
}); |
| 283 |
is( @$search_suggestion, 1, 'SearchSuggestion (budgetid = "__NONE__") returns the correct number of suggestions' ); |
| 284 |
$search_suggestion = SearchSuggestion({ |
| 285 |
budgetid => '__ANY__', |
| 286 |
}); |
| 287 |
is( @$search_suggestion, 2, 'SearchSuggestion (budgetid = "__ANY__") returns the correct number of suggestions' ); |
| 244 |
|
288 |
|
| 245 |
my $del_suggestion = { |
289 |
my $del_suggestion = { |
| 246 |
title => 'my deleted title', |
290 |
title => 'my deleted title', |
|
Lines 273-275
is(@$itemtypes2, 8, "Purchase suggestion itemtypes collected, default AdvancedSe
Link Here
|
| 273 |
is_deeply($itemtypes1, $itemtypes2, 'same set of purchase suggestion formats retrieved'); |
317 |
is_deeply($itemtypes1, $itemtypes2, 'same set of purchase suggestion formats retrieved'); |
| 274 |
|
318 |
|
| 275 |
$dbh->rollback; |
319 |
$dbh->rollback; |
| 276 |
- |
320 |
|
|
|
321 |
done_testing; |