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

(-)a/Koha/Object.pm (+15 lines)
Lines 379-384 sub add_message { Link Here
379
    return $self;
379
    return $self;
380
}
380
}
381
381
382
=head3 $object->reset_messages
383
384
    $object->reset_messages;
385
386
Reset the current object's messages.
387
388
=cut
389
390
sub reset_messages {
391
    my ( $self ) = @_;
392
393
    $self->{_messages} = [];
394
    return $self;
395
}
396
382
=head3 $object->TO_JSON
397
=head3 $object->TO_JSON
383
398
384
Returns an unblessed representation of the object, suitable for JSON output.
399
Returns an unblessed representation of the object, suitable for JSON output.
(-)a/t/db_dependent/Koha/Object.t (-3 / +12 lines)
Lines 868-876 subtest 'set_or_blank' => sub { Link Here
868
    $schema->storage->txn_rollback;
868
    $schema->storage->txn_rollback;
869
};
869
};
870
870
871
subtest 'messages() and add_message() tests' => sub {
871
subtest 'messages(), add_message() and reset_messages() tests' => sub {
872
872
873
    plan tests => 7;
873
    plan tests => 10;
874
874
875
    $schema->storage->txn_begin;
875
    $schema->storage->txn_begin;
876
876
Lines 896-900 subtest 'messages() and add_message() tests' => sub { Link Here
896
    isnt( $patron->messages, undef, '->messages initializes the array if required' );
896
    isnt( $patron->messages, undef, '->messages initializes the array if required' );
897
    is( scalar @{ $patron->messages }, 0, '->messages returns an empty arrayref' );
897
    is( scalar @{ $patron->messages }, 0, '->messages returns an empty arrayref' );
898
898
899
    is( $messages[1]->message, 'message_2', 'Right message recorded' );
900
901
    $patron->reset_messages;
902
    @messages = @{ $patron->messages };
903
    is( scalar @messages, 0, 'No messages are returned' );
904
905
    $patron->reset_messages;
906
    @messages = @{ $patron->messages };
907
    is( scalar @messages, 0, 'No messages are returned, things ok when calling on already empty list' );
908
899
    $schema->storage->txn_rollback;
909
    $schema->storage->txn_rollback;
900
};
910
};
901
- 

Return to bug 26651