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

(-)a/C4/Suggestions.pm (-26 lines)
Lines 35-41 our @EXPORT = qw( Link Here
35
  DelSuggestion
35
  DelSuggestion
36
  GetSuggestion
36
  GetSuggestion
37
  GetSuggestionByStatus
37
  GetSuggestionByStatus
38
  GetSuggestionFromBiblionumber
39
  GetSuggestionInfo
38
  GetSuggestionInfo
40
  ModStatus
39
  ModStatus
41
  ModSuggestion
40
  ModSuggestion
Lines 93-123 sub GetSuggestion { Link Here
93
    return ( $sth->fetchrow_hashref );
92
    return ( $sth->fetchrow_hashref );
94
}
93
}
95
94
96
=head2 GetSuggestionFromBiblionumber
97
98
$ordernumber = &GetSuggestionFromBiblionumber($biblionumber)
99
100
Get a suggestion from it's biblionumber.
101
102
return :
103
the id of the suggestion which is related to the biblionumber given on input args.
104
105
=cut
106
107
sub GetSuggestionFromBiblionumber {
108
    my ($biblionumber) = @_;
109
    my $query = q{
110
        SELECT suggestionid
111
        FROM   suggestions
112
        WHERE  biblionumber=? LIMIT 1
113
    };
114
    my $dbh = C4::Context->dbh;
115
    my $sth = $dbh->prepare($query);
116
    $sth->execute($biblionumber);
117
    my ($suggestionid) = $sth->fetchrow;
118
    return $suggestionid;
119
}
120
121
=head2 GetSuggestionInfo
95
=head2 GetSuggestionInfo
122
96
123
Get a suggestion and borrower's informations from it's suggestionid
97
Get a suggestion and borrower's informations from it's suggestionid
(-)a/t/db_dependent/Suggestions.t (-8 / +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 => 79;
21
use Test::More tests => 76;
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( GetSuggestion ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ));
37
    use_ok('C4::Suggestions', qw( GetSuggestion ModSuggestion GetSuggestionInfo 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 293-303 is( $suggestion->{firstnamesuggestedby}, $member->{firstname}, 'GetSuggestionInf Link Here
293
is( $suggestion->{borrnumsuggestedby}, $my_suggestion->{suggestedby}, 'GetSuggestionInfo returns the borrower number correctly' );
293
is( $suggestion->{borrnumsuggestedby}, $my_suggestion->{suggestedby}, 'GetSuggestionInfo returns the borrower number correctly' );
294
294
295
295
296
is( GetSuggestionFromBiblionumber(), undef, 'GetSuggestionFromBiblionumber without the biblio number returns undef' );
297
is( GetSuggestionFromBiblionumber(2), undef, 'GetSuggestionFromBiblionumber with an invalid biblio number returns undef' );
298
is( GetSuggestionFromBiblionumber($biblio_1->biblionumber), $my_suggestionid, 'GetSuggestionFromBiblionumber functions correctly' );
299
300
301
my $suggestions = GetSuggestionByStatus();
296
my $suggestions = GetSuggestionByStatus();
302
is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' );
297
is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' );
303
$suggestions = GetSuggestionByStatus('CHECKED');
298
$suggestions = GetSuggestionByStatus('CHECKED');
304
- 

Return to bug 28844