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

(-)a/Koha/Object.pm (+4 lines)
Lines 345-350 Returns the (probably non-fatal) messages that were recorded on the object. Link Here
345
345
346
sub messages {
346
sub messages {
347
    my ( $self ) = @_;
347
    my ( $self ) = @_;
348
349
    $self->{_messages} = []
350
        unless defined $self->{_messages};
351
348
    return $self->{_messages};
352
    return $self->{_messages};
349
}
353
}
350
354
(-)a/t/db_dependent/Koha/Object.t (-3 / +12 lines)
Lines 870-876 subtest 'set_or_blank' => sub { Link Here
870
870
871
subtest 'messages() and add_message() tests' => sub {
871
subtest 'messages() and add_message() tests' => sub {
872
872
873
    plan tests => 6;
873
    plan tests => 7;
874
875
    $schema->storage->txn_begin;
874
876
875
    my $patron = Koha::Patron->new;
877
    my $patron = Koha::Patron->new;
876
878
Lines 886-890 subtest 'messages() and add_message() tests' => sub { Link Here
886
    is( ref($messages[0]), 'Koha::Object::Message', 'Right type returned' );
888
    is( ref($messages[0]), 'Koha::Object::Message', 'Right type returned' );
887
    is( ref($messages[1]), 'Koha::Object::Message', 'Right type returned' );
889
    is( ref($messages[1]), 'Koha::Object::Message', 'Right type returned' );
888
    is( $messages[0]->message, 'message_1', 'Right message recorded' );
890
    is( $messages[0]->message, 'message_1', 'Right message recorded' );
889
    is( $messages[1]->message, 'message_2', 'Right message recorded' );
891
892
    my $patron_id = $builder->build_object({ class => 'Koha::Patrons' })->id;
893
    # get a patron from the DB, ->new is not called, ->messages should initialize _messages as an empty arrayref
894
    $patron = Koha::Patrons->find( $patron_id );
895
896
    isnt( $patron->messages, undef, '->messages initializes the array if required' );
897
    is( scalar @{ $patron->messages }, 0, '->messages returns an empty arrayref' );
898
899
    $schema->storage->txn_rollback;
890
};
900
};
891
- 

Return to bug 26555