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

(-)a/Koha/Suggestion.pm (+18 lines)
Lines 22-27 use Modern::Perl; Link Here
22
use Carp;
22
use Carp;
23
23
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::DateUtils qw(dt_from_string);
25
26
26
use base qw(Koha::Object);
27
use base qw(Koha::Object);
27
28
Lines 35-40 Koha::Suggestion - Koha Suggestion object class Link Here
35
36
36
=cut
37
=cut
37
38
39
=head3 store
40
41
Override the default store behavior so that new suggestions have
42
a suggesteddate of today
43
44
=cut
45
46
sub store {
47
    my ($self) = @_;
48
49
    unless ( $self->suggesteddate() ) {
50
        $self->suggesteddate( dt_from_string()->ymd );
51
    }
52
53
    return $self->SUPER::store();
54
}
55
38
=head3 type
56
=head3 type
39
57
40
=cut
58
=cut
(-)a/t/db_dependent/Koha/Suggestions.t (-2 / +4 lines)
Lines 19-29 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 4;
22
use Test::More tests => 5;
23
23
24
use Koha::Suggestion;
24
use Koha::Suggestion;
25
use Koha::Suggestions;
25
use Koha::Suggestions;
26
use Koha::Database;
26
use Koha::Database;
27
use Koha::DateUtils;
27
28
28
use t::lib::TestBuilder;
29
use t::lib::TestBuilder;
29
30
Lines 46-51 my $new_suggestion_2 = Koha::Suggestion->new( Link Here
46
    }
47
    }
47
)->store;
48
)->store;
48
49
50
is( $new_suggestion_1->suggesteddate, dt_from_string()->ymd, "If suggesteddate not passed in, it will default to today" );
51
49
like( $new_suggestion_1->suggestionid, qr|^\d+$|, 'Adding a new suggestion should have set the suggestionid' );
52
like( $new_suggestion_1->suggestionid, qr|^\d+$|, 'Adding a new suggestion should have set the suggestionid' );
50
is( Koha::Suggestions->search->count, $nb_of_suggestions + 2, 'The 2 suggestions should have been added' );
53
is( Koha::Suggestions->search->count, $nb_of_suggestions + 2, 'The 2 suggestions should have been added' );
51
54
52
- 

Return to bug 13012