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

(-)a/t/db_dependent/Koha/Suggestions.t (-2 / +19 lines)
Lines 47-53 my $new_suggestion_2 = Koha::Suggestion->new( Link Here
47
    }
47
    }
48
)->store;
48
)->store;
49
49
50
is( $new_suggestion_1->suggesteddate, dt_from_string()->ymd, "If suggesteddate not passed in, it will default to today" );
50
subtest 'store' => sub {
51
    plan tests => 3;
52
    my $suggestion  = Koha::Suggestion->new(
53
        {   suggestedby  => $patron->{borrowernumber},
54
            biblionumber => $biblio_1->{biblionumber},
55
        }
56
    )->store;
57
58
    is( $suggestion->suggesteddate, dt_from_string()->ymd, "If suggesteddate not passed in, it will default to today" );
59
    my $two_days_ago = dt_from_string->subtract( days => 2 );
60
    my $two_days_ago_sql = output_pref({dt => $two_days_ago, dateformat => 'sql', dateonly => 1 });
61
    $suggestion->suggesteddate($two_days_ago)->store;
62
    $suggestion = Koha::Suggestions->find( $suggestion->suggestionid );
63
    is( $suggestion->suggesteddate, $two_days_ago_sql, 'If suggesteddate passed in, it should be taken into account' );
64
    $suggestion->reason('because!')->store;
65
    $suggestion = Koha::Suggestions->find( $suggestion->suggestionid );
66
    is( $suggestion->suggesteddate, $two_days_ago_sql, 'If suggestion id modified, suggesteddate should not be modified' );
67
    $suggestion->delete;
68
};
51
69
52
like( $new_suggestion_1->suggestionid, qr|^\d+$|, 'Adding a new suggestion should have set the suggestionid' );
70
like( $new_suggestion_1->suggestionid, qr|^\d+$|, 'Adding a new suggestion should have set the suggestionid' );
53
is( Koha::Suggestions->search->count, $nb_of_suggestions + 2, 'The 2 suggestions should have been added' );
71
is( Koha::Suggestions->search->count, $nb_of_suggestions + 2, 'The 2 suggestions should have been added' );
54
- 

Return to bug 13012