View | Details | Raw Unified | Return to bug 23991
Collapse All | Expand All

(-)a/t/db_dependent/Suggestions.t (-70 / +2 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use DateTime::Duration;
20
use DateTime::Duration;
21
use Test::More tests => 106;
21
use Test::More tests => 90;
22
use Test::Warn;
22
use Test::Warn;
23
23
24
use t::lib::Mocks;
24
use t::lib::Mocks;
Lines 34-40 use Koha::Patrons; Link Here
34
use Koha::Suggestions;
34
use Koha::Suggestions;
35
35
36
BEGIN {
36
BEGIN {
37
    use_ok('C4::Suggestions', qw( NewSuggestion GetSuggestion ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio SearchSuggestion DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ));
37
    use_ok('C4::Suggestions', qw( NewSuggestion GetSuggestion ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ));
38
}
38
}
39
39
40
my $schema  = Koha::Database->new->schema;
40
my $schema  = Koha::Database->new->schema;
Lines 329-401 is( $connect_suggestion_and_biblio, '1', 'ConnectSuggestionAndBiblio returns 1' Link Here
329
$suggestion = GetSuggestion($my_suggestionid);
329
$suggestion = GetSuggestion($my_suggestionid);
330
is( $suggestion->{biblionumber}, $biblio_2->biblionumber, 'ConnectSuggestionAndBiblio updates the biblio number correctly' );
330
is( $suggestion->{biblionumber}, $biblio_2->biblionumber, 'ConnectSuggestionAndBiblio updates the biblio number correctly' );
331
331
332
my $search_suggestion = SearchSuggestion();
333
is( @$search_suggestion, 3, 'SearchSuggestion without arguments returns all suggestions' );
334
335
$search_suggestion = SearchSuggestion({
336
    title => $mod_suggestion1->{title},
337
});
338
is( @$search_suggestion, 1, 'SearchSuggestion returns the correct number of suggestions' );
339
$search_suggestion = SearchSuggestion({
340
    title => 'another title',
341
});
342
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
343
344
$search_suggestion = SearchSuggestion({
345
    author => $mod_suggestion1->{author},
346
});
347
is( @$search_suggestion, 1, 'SearchSuggestion returns the correct number of suggestions' );
348
$search_suggestion = SearchSuggestion({
349
    author => 'another author',
350
});
351
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
352
353
$search_suggestion = SearchSuggestion({
354
    publishercode => $mod_suggestion1->{publishercode},
355
});
356
is( @$search_suggestion, 1, 'SearchSuggestion returns the correct number of suggestions' );
357
$search_suggestion = SearchSuggestion({
358
    publishercode => 'another publishercode',
359
});
360
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
361
362
$search_suggestion = SearchSuggestion({
363
    STATUS => $mod_suggestion3->{STATUS},
364
});
365
is( @$search_suggestion, 2, 'SearchSuggestion returns the correct number of suggestions' );
366
367
$search_suggestion = SearchSuggestion({
368
    STATUS => q||
369
});
370
is( @$search_suggestion, 0, 'SearchSuggestion should not return all suggestions if we want the suggestions with a STATUS=""' );
371
$search_suggestion = SearchSuggestion({
372
    STATUS => 'REJECTED',
373
});
374
is( @$search_suggestion, 0, 'SearchSuggestion returns the correct number of suggestions' );
375
376
$search_suggestion = SearchSuggestion({
377
    budgetid => '',
378
});
379
is( @$search_suggestion, 3, 'SearchSuggestion (budgetid = "") returns the correct number of suggestions' );
380
$search_suggestion = SearchSuggestion({
381
    budgetid => $budget_id,
382
});
383
is( @$search_suggestion, 2, 'SearchSuggestion (budgetid = $budgetid) returns the correct number of suggestions' );
384
$search_suggestion = SearchSuggestion({
385
    budgetid => '__NONE__',
386
});
387
is( @$search_suggestion, 1, 'SearchSuggestion (budgetid = "__NONE__") returns the correct number of suggestions' );
388
$search_suggestion = SearchSuggestion({
389
    budgetid => '__ANY__',
390
});
391
is( @$search_suggestion, 3, 'SearchSuggestion (budgetid = "__ANY__") returns the correct number of suggestions' );
392
393
$search_suggestion = SearchSuggestion({ budgetid => $budget_id });
394
is( @$search_suggestion[0]->{budget_name}, GetBudget($budget_id)->{budget_name}, 'SearchSuggestion returns the correct budget name');
395
$search_suggestion = SearchSuggestion({ budgetid => "__NONE__" });
396
is( @$search_suggestion[0]->{budget_name}, undef, 'SearchSuggestion returns the correct budget name');
397
398
399
my $del_suggestion = {
332
my $del_suggestion = {
400
    title => 'my deleted title',
333
    title => 'my deleted title',
401
    STATUS => 'CHECKED',
334
    STATUS => 'CHECKED',
402
- 

Return to bug 23991