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

(-)a/Koha/Account.pm (-1 / +1 lines)
Lines 140-146 sub pay { Link Here
140
    }
140
    }
141
141
142
    my $renew_outcomes = [];
142
    my $renew_outcomes = [];
143
    for my $message ( @{$payment->messages} ) {
143
    for my $message ( @{$payment->object_messages} ) {
144
        push @{$renew_outcomes}, $message->payload;
144
        push @{$renew_outcomes}, $message->payload;
145
    }
145
    }
146
146
(-)a/Koha/Object.pm (-3 / +3 lines)
Lines 335-349 sub get_from_storage { Link Here
335
    return $object_class->_new_from_dbic($stored_object);
335
    return $object_class->_new_from_dbic($stored_object);
336
}
336
}
337
337
338
=head3 $object->messages
338
=head3 $object->object_messages
339
339
340
    my @messages = @{ $object->messages };
340
    my @messages = @{ $object->object_messages };
341
341
342
Returns the (probably non-fatal) messages that were recorded on the object.
342
Returns the (probably non-fatal) messages that were recorded on the object.
343
343
344
=cut
344
=cut
345
345
346
sub messages {
346
sub object_messages {
347
    my ( $self ) = @_;
347
    my ( $self ) = @_;
348
348
349
    $self->{_messages} = []
349
    $self->{_messages} = []
(-)a/acqui/basket.pl (-1 / +1 lines)
Lines 134-140 if ( $op eq 'delete_confirm' ) { Link Here
134
    while ( my $order = $orders->next ) {
134
    while ( my $order = $orders->next ) {
135
        # cancel the order
135
        # cancel the order
136
        $order->cancel({ delete_biblio => $delbiblio });
136
        $order->cancel({ delete_biblio => $delbiblio });
137
        my @messages = @{ $order->messages };
137
        my @messages = @{ $order->object_messages };
138
138
139
        if ( scalar @messages > 0 ) {
139
        if ( scalar @messages > 0 ) {
140
140
(-)a/acqui/cancelorder.pl (-1 / +1 lines)
Lines 57-63 if( $action and $action eq "confirmcancel" ) { Link Here
57
    my $reason = $input->param('reason');
57
    my $reason = $input->param('reason');
58
    my $order  = Koha::Acquisition::Orders->find($ordernumber);
58
    my $order  = Koha::Acquisition::Orders->find($ordernumber);
59
    $order->cancel({ reason => $reason, delete_biblio => $delete_biblio });
59
    $order->cancel({ reason => $reason, delete_biblio => $delete_biblio });
60
    my @messages = @{ $order->messages };
60
    my @messages = @{ $order->object_messages };
61
61
62
    if ( scalar @messages > 0 ) {
62
    if ( scalar @messages > 0 ) {
63
        $template->param( error_delitem => 1 )
63
        $template->param( error_delitem => 1 )
(-)a/catalogue/detail.pl (-2 / +2 lines)
Lines 199-205 my $show_analytics; Link Here
199
if ( $showcomp eq 'both' || $showcomp eq 'staff' ) {
199
if ( $showcomp eq 'both' || $showcomp eq 'staff' ) {
200
    if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) {
200
    if ( my $components = $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) ) {
201
        $show_analytics = 1 if @{$components}; # just show link when having results
201
        $show_analytics = 1 if @{$components}; # just show link when having results
202
        $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->messages};
202
        $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages};
203
        my $parts;
203
        my $parts;
204
        for my $part ( @{$components} ) {
204
        for my $part ( @{$components} ) {
205
            $part = C4::Search::new_record_from_zebra( 'biblioserver', $part );
205
            $part = C4::Search::new_record_from_zebra( 'biblioserver', $part );
Lines 220-226 if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { Link Here
220
    }
220
    }
221
} else { # check if we should show analytics anyway
221
} else { # check if we should show analytics anyway
222
    $show_analytics = 1 if $marc_record && @{$biblio->get_marc_components(1)}; # count matters here, results does not
222
    $show_analytics = 1 if $marc_record && @{$biblio->get_marc_components(1)}; # count matters here, results does not
223
    $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->messages};
223
    $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages};
224
}
224
}
225
225
226
# XSLT processing of some stuff
226
# XSLT processing of some stuff
(-)a/t/db_dependent/Koha/Account/Line.t (-1 / +1 lines)
Lines 383-389 subtest 'apply() tests' => sub { Link Here
383
    $credit_renew = $credit_renew->apply( { debits => $debits_renew } );
383
    $credit_renew = $credit_renew->apply( { debits => $debits_renew } );
384
    is( $called, 1, 'RenewAccruingItemWhenPaid causes C4::Circulation::AddRenew to be called when appropriate' );
384
    is( $called, 1, 'RenewAccruingItemWhenPaid causes C4::Circulation::AddRenew to be called when appropriate' );
385
385
386
    my @messages = @{$credit_renew->messages};
386
    my @messages = @{$credit_renew->object_messages};
387
    is( $messages[0]->type, 'info', 'Info message added for renewal' );
387
    is( $messages[0]->type, 'info', 'Info message added for renewal' );
388
    is( $messages[0]->message, 'renewal', 'Message is "renewal"' );
388
    is( $messages[0]->message, 'renewal', 'Message is "renewal"' );
389
    is( $messages[0]->payload->{itemnumber}, $item->id, 'itemnumber found in payload' );
389
    is( $messages[0]->payload->{itemnumber}, $item->id, 'itemnumber found in payload' );
(-)a/t/db_dependent/Koha/Acquisition/Order.t (-7 / +7 lines)
Lines 638-644 subtest 'cancel() tests' => sub { Link Here
638
    is( $order->cancellationreason, $reason, 'cancellationreason is set' );
638
    is( $order->cancellationreason, $reason, 'cancellationreason is set' );
639
    is( ref(Koha::Items->find($item->id)), 'Koha::Item', 'The item is present' );
639
    is( ref(Koha::Items->find($item->id)), 'Koha::Item', 'The item is present' );
640
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is present' );
640
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is present' );
641
    my @messages = @{ $order->messages };
641
    my @messages = @{ $order->object_messages };
642
    is( $messages[0]->message, 'error_delitem', 'An error message is attached to the order' );
642
    is( $messages[0]->message, 'error_delitem', 'An error message is attached to the order' );
643
643
644
    # Scenario:
644
    # Scenario:
Lines 660-666 subtest 'cancel() tests' => sub { Link Here
660
    is( $order->cancellationreason, $reason, 'cancellationreason is undef' );
660
    is( $order->cancellationreason, $reason, 'cancellationreason is undef' );
661
    is( Koha::Items->find($item->id), undef, 'The item is no longer present' );
661
    is( Koha::Items->find($item->id), undef, 'The item is no longer present' );
662
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is present' );
662
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is present' );
663
    @messages = @{ $order->messages };
663
    @messages = @{ $order->object_messages };
664
    is( scalar @messages, 0, 'No messages' );
664
    is( scalar @messages, 0, 'No messages' );
665
665
666
    # Scenario:
666
    # Scenario:
Lines 696-702 subtest 'cancel() tests' => sub { Link Here
696
    is( Koha::Items->find($item_1->id), undef, 'The item is no longer present' );
696
    is( Koha::Items->find($item_1->id), undef, 'The item is no longer present' );
697
    is( ref(Koha::Items->find($item_2->id)), 'Koha::Item', 'The item is still present' );
697
    is( ref(Koha::Items->find($item_2->id)), 'Koha::Item', 'The item is still present' );
698
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is still present' );
698
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is still present' );
699
    @messages = @{ $order->messages };
699
    @messages = @{ $order->object_messages };
700
    is( $messages[0]->message, 'error_delbiblio_items', 'Cannot delete biblio and it gets notified' );
700
    is( $messages[0]->message, 'error_delbiblio_items', 'Cannot delete biblio and it gets notified' );
701
701
702
    # Scenario:
702
    # Scenario:
Lines 743-749 subtest 'cancel() tests' => sub { Link Here
743
    is( $order->cancellationreason, $reason, 'cancellationreason is undef' );
743
    is( $order->cancellationreason, $reason, 'cancellationreason is undef' );
744
    is( Koha::Items->find($item->id), undef, 'The item is no longer present' );
744
    is( Koha::Items->find($item->id), undef, 'The item is no longer present' );
745
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is still present' );
745
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is still present' );
746
    @messages = @{ $order->messages };
746
    @messages = @{ $order->object_messages };
747
    is( $messages[0]->message, 'error_delbiblio_active_orders', 'Cannot delete biblio and it gets notified' );
747
    is( $messages[0]->message, 'error_delbiblio_active_orders', 'Cannot delete biblio and it gets notified' );
748
748
749
    # Scenario:
749
    # Scenario:
Lines 787-793 subtest 'cancel() tests' => sub { Link Here
787
    is( $order->cancellationreason, $reason, 'cancellationreason is undef' );
787
    is( $order->cancellationreason, $reason, 'cancellationreason is undef' );
788
    is( Koha::Items->find($item->id), undef, 'The item is no longer present' );
788
    is( Koha::Items->find($item->id), undef, 'The item is no longer present' );
789
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is still present' );
789
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is still present' );
790
    @messages = @{ $order->messages };
790
    @messages = @{ $order->object_messages };
791
    is( $messages[0]->message, 'error_delbiblio_subscriptions', 'Cannot delete biblio and it gets notified' );
791
    is( $messages[0]->message, 'error_delbiblio_subscriptions', 'Cannot delete biblio and it gets notified' );
792
792
793
    # Scenario:
793
    # Scenario:
Lines 820-826 subtest 'cancel() tests' => sub { Link Here
820
    is( $order->cancellationreason, $reason, 'cancellationreason is set' );
820
    is( $order->cancellationreason, $reason, 'cancellationreason is set' );
821
    is( Koha::Items->find($item->id), undef, 'The item is not present' );
821
    is( Koha::Items->find($item->id), undef, 'The item is not present' );
822
    is( Koha::Biblios->find($biblio_id), undef, 'The biblio is not present' );
822
    is( Koha::Biblios->find($biblio_id), undef, 'The biblio is not present' );
823
    @messages = @{ $order->messages };
823
    @messages = @{ $order->object_messages };
824
    is( scalar @messages, 0, 'No errors' );
824
    is( scalar @messages, 0, 'No errors' );
825
825
826
    # Scenario:
826
    # Scenario:
Lines 873-879 subtest 'cancel() tests' => sub { Link Here
873
    is( Koha::Items->find($item_1->id), undef, 'The item is no longer present' );
873
    is( Koha::Items->find($item_1->id), undef, 'The item is no longer present' );
874
    is( ref(Koha::Items->find($item_2->id)), 'Koha::Item', 'The on loan item is still present' );
874
    is( ref(Koha::Items->find($item_2->id)), 'Koha::Item', 'The on loan item is still present' );
875
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is still present' );
875
    is( ref(Koha::Biblios->find($biblio_id)), 'Koha::Biblio', 'The biblio is still present' );
876
    @messages = @{ $order->messages };
876
    @messages = @{ $order->object_messages };
877
    is( $messages[0]->message, 'error_delitem', 'Cannot delete on loan item' );
877
    is( $messages[0]->message, 'error_delitem', 'Cannot delete on loan item' );
878
    is( $messages[0]->payload->{item}->id, $item_2->id, 'Cannot delete on loan item' );
878
    is( $messages[0]->payload->{item}->id, $item_2->id, 'Cannot delete on loan item' );
879
    is( $messages[0]->payload->{reason}, 'book_on_loan', 'Item on loan notified' );
879
    is( $messages[0]->payload->{reason}, 'book_on_loan', 'Item on loan notified' );
(-)a/t/db_dependent/Koha/Biblio.t (-1 / +1 lines)
Lines 550-556 subtest 'get_marc_components() tests' => sub { Link Here
550
        qr{^Warning from simple_search_compat: 'error searching analytics'};
550
        qr{^Warning from simple_search_compat: 'error searching analytics'};
551
551
552
    is_deeply(
552
    is_deeply(
553
        $host_biblio->messages,
553
        $host_biblio->object_messages,
554
        [
554
        [
555
            {
555
            {
556
                type    => 'error',
556
                type    => 'error',
(-)a/t/db_dependent/Koha/Object.t (-6 / +5 lines)
Lines 974-986 subtest 'messages() and add_message() tests' => sub { Link Here
974
974
975
    my $patron = Koha::Patron->new;
975
    my $patron = Koha::Patron->new;
976
976
977
    my @messages = @{ $patron->messages };
977
    my @messages = @{ $patron->object_messages };
978
    is( scalar @messages, 0, 'No messages' );
978
    is( scalar @messages, 0, 'No messages' );
979
979
980
    $patron->add_message({ message => "message_1" });
980
    $patron->add_message({ message => "message_1" });
981
    $patron->add_message({ message => "message_2" });
981
    $patron->add_message({ message => "message_2" });
982
982
983
    @messages = @{ $patron->messages };
983
    @messages = @{ $patron->object_messages };
984
984
985
    is( scalar @messages, 2, 'Messages are returned' );
985
    is( scalar @messages, 2, 'Messages are returned' );
986
    is( ref($messages[0]), 'Koha::Object::Message', 'Right type returned' );
986
    is( ref($messages[0]), 'Koha::Object::Message', 'Right type returned' );
Lines 988-998 subtest 'messages() and add_message() tests' => sub { Link Here
988
    is( $messages[0]->message, 'message_1', 'Right message recorded' );
988
    is( $messages[0]->message, 'message_1', 'Right message recorded' );
989
989
990
    my $patron_id = $builder->build_object({ class => 'Koha::Patrons' })->id;
990
    my $patron_id = $builder->build_object({ class => 'Koha::Patrons' })->id;
991
    # get a patron from the DB, ->new is not called, ->messages should initialize _messages as an empty arrayref
991
    # get a patron from the DB, ->new is not called, ->object_messages should initialize _messages as an empty arrayref
992
    $patron = Koha::Patrons->find( $patron_id );
992
    $patron = Koha::Patrons->find( $patron_id );
993
993
994
    isnt( $patron->messages, undef, '->messages initializes the array if required' );
994
    isnt( $patron->object_messages, undef, '->messages initializes the array if required' );
995
    is( scalar @{ $patron->messages }, 0, '->messages returns an empty arrayref' );
995
    is( scalar @{ $patron->object_messages }, 0, '->messages returns an empty arrayref' );
996
996
997
    $schema->storage->txn_rollback;
997
    $schema->storage->txn_rollback;
998
};
998
};
999
- 

Return to bug 29785