|
Lines 19-25
use Modern::Perl;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use DateTime::Duration; |
20 |
use DateTime::Duration; |
| 21 |
use Test::NoWarnings; |
21 |
use Test::NoWarnings; |
| 22 |
use Test::More tests => 69; |
22 |
use Test::More tests => 55; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
|
24 |
|
| 25 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
|
Lines 38-44
use Koha::Suggestions;
Link Here
|
| 38 |
BEGIN { |
38 |
BEGIN { |
| 39 |
use_ok( |
39 |
use_ok( |
| 40 |
'C4::Suggestions', |
40 |
'C4::Suggestions', |
| 41 |
qw( ModSuggestion GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) |
41 |
qw( ModSuggestion ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) |
| 42 |
); |
42 |
); |
| 43 |
} |
43 |
} |
| 44 |
|
44 |
|
|
Lines 310-356
$messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber2
Link Here
|
| 310 |
|
310 |
|
| 311 |
is( scalar(@$messages), 1, 'No new letter should have been generated if the update raised an error' ); |
311 |
is( scalar(@$messages), 1, 'No new letter should have been generated if the update raised an error' ); |
| 312 |
|
312 |
|
| 313 |
my $suggestions = GetSuggestionByStatus(); |
|
|
| 314 |
is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' ); |
| 315 |
$suggestions = GetSuggestionByStatus('CHECKED'); |
| 316 |
is( @$suggestions, 2, 'GetSuggestionByStatus returns the correct number of suggestions' ); |
| 317 |
is( $suggestions->[0]->{suggestionid}, $my_suggestionid, 'GetSuggestionByStatus returns the suggestion id correctly' ); |
| 318 |
is( $suggestions->[0]->{title}, $mod_suggestion1->{title}, 'GetSuggestionByStatus returns the title correctly' ); |
| 319 |
is( $suggestions->[0]->{author}, $mod_suggestion1->{author}, 'GetSuggestionByStatus returns the author correctly' ); |
| 320 |
is( |
| 321 |
$suggestions->[0]->{publishercode}, $mod_suggestion1->{publishercode}, |
| 322 |
'GetSuggestionByStatus returns the publisher code correctly' |
| 323 |
); |
| 324 |
is( |
| 325 |
$suggestions->[0]->{suggestedby}, $my_suggestion->{suggestedby}, |
| 326 |
'GetSuggestionByStatus returns the borrower number correctly' |
| 327 |
); |
| 328 |
is( |
| 329 |
$suggestions->[0]->{biblionumber}, $my_suggestion->{biblionumber}, |
| 330 |
'GetSuggestionByStatus returns the biblio number correctly' |
| 331 |
); |
| 332 |
is( $suggestions->[0]->{STATUS}, $mod_suggestion3->{STATUS}, 'GetSuggestionByStatus returns the status correctly' ); |
| 333 |
is( |
| 334 |
$suggestions->[0]->{surnamesuggestedby}, $member->{surname}, |
| 335 |
'GetSuggestionByStatus returns the surname correctly' |
| 336 |
); |
| 337 |
is( |
| 338 |
$suggestions->[0]->{firstnamesuggestedby}, $member->{firstname}, |
| 339 |
'GetSuggestionByStatus returns the firstname correctly' |
| 340 |
); |
| 341 |
is( |
| 342 |
$suggestions->[0]->{branchcodesuggestedby}, $member->{branchcode}, |
| 343 |
'GetSuggestionByStatus returns the branch code correctly' |
| 344 |
); |
| 345 |
is( |
| 346 |
$suggestions->[0]->{borrnumsuggestedby}, $my_suggestion->{suggestedby}, |
| 347 |
'GetSuggestionByStatus returns the borrower number correctly' |
| 348 |
); |
| 349 |
is( |
| 350 |
$suggestions->[0]->{categorycodesuggestedby}, $member->{categorycode}, |
| 351 |
'GetSuggestionByStatus returns the category code correctly' |
| 352 |
); |
| 353 |
|
| 354 |
is( ConnectSuggestionAndBiblio(), '0E0', 'ConnectSuggestionAndBiblio without arguments returns 0E0' ); |
313 |
is( ConnectSuggestionAndBiblio(), '0E0', 'ConnectSuggestionAndBiblio without arguments returns 0E0' ); |
| 355 |
my $biblio_2 = $builder->build_object( { class => 'Koha::Biblios' } ); |
314 |
my $biblio_2 = $builder->build_object( { class => 'Koha::Biblios' } ); |
| 356 |
my $connect_suggestion_and_biblio = ConnectSuggestionAndBiblio( $my_suggestionid, $biblio_2->biblionumber ); |
315 |
my $connect_suggestion_and_biblio = ConnectSuggestionAndBiblio( $my_suggestionid, $biblio_2->biblionumber ); |
|
Lines 378-386
is(
Link Here
|
| 378 |
$suggestion = DelSuggestion( $borrowernumber, $my_suggestionid ); |
337 |
$suggestion = DelSuggestion( $borrowernumber, $my_suggestionid ); |
| 379 |
is( $suggestion, 1, 'DelSuggestion deletes one suggestion' ); |
338 |
is( $suggestion, 1, 'DelSuggestion deletes one suggestion' ); |
| 380 |
|
339 |
|
| 381 |
$suggestions = GetSuggestionByStatus('CHECKED'); |
340 |
my $suggestions = Koha::Suggestions->search( { STATUS => 'CHECKED' } )->as_list; |
| 382 |
is( @$suggestions, 2, 'DelSuggestion deletes one suggestion' ); |
341 |
is( @$suggestions, 2, 'DelSuggestion deletes one suggestion' ); |
| 383 |
is( $suggestions->[1]->{title}, $del_suggestion->{title}, 'DelSuggestion deletes the correct suggestion' ); |
342 |
is( $suggestions->[1]->unblessed()->{title}, $del_suggestion->{title}, 'DelSuggestion deletes the correct suggestion' ); |
| 384 |
|
343 |
|
| 385 |
# Test budgetid fk |
344 |
# Test budgetid fk |
| 386 |
$my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB |
345 |
$my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB |
| 387 |
- |
|
|