Lines 619-625
subtest 'cancel() tests' => sub {
Link Here
|
619 |
cancellationreason => undef, |
619 |
cancellationreason => undef, |
620 |
} |
620 |
} |
621 |
} |
621 |
} |
622 |
)->reset_messages; # reset them as TestBuilder doesn't call new |
622 |
); |
623 |
$order->add_item( $item->id ); |
623 |
$order->add_item( $item->id ); |
624 |
|
624 |
|
625 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
625 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
Lines 651-657
subtest 'cancel() tests' => sub {
Link Here
|
651 |
|
651 |
|
652 |
C4::Circulation::AddReturn( $item->barcode ); |
652 |
C4::Circulation::AddReturn( $item->barcode ); |
653 |
|
653 |
|
654 |
$order->reset_messages; |
654 |
$order = Koha::Acquisition::Orders->find($order->ordernumber); |
655 |
$order->cancel({ reason => $reason }) |
655 |
$order->cancel({ reason => $reason }) |
656 |
->discard_changes; |
656 |
->discard_changes; |
657 |
|
657 |
|
Lines 684-690
subtest 'cancel() tests' => sub {
Link Here
|
684 |
cancellationreason => undef, |
684 |
cancellationreason => undef, |
685 |
} |
685 |
} |
686 |
} |
686 |
} |
687 |
)->reset_messages; |
687 |
); |
688 |
$order->add_item( $item_1->id ); |
688 |
$order->add_item( $item_1->id ); |
689 |
|
689 |
|
690 |
$order->cancel({ reason => $reason, delete_biblio => 1 }) |
690 |
$order->cancel({ reason => $reason, delete_biblio => 1 }) |
Lines 697-703
subtest 'cancel() tests' => sub {
Link Here
|
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->messages }; |
700 |
is( $messages[0]->message, 'error_delbiblio', '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: |
703 |
# * order with one item attached |
703 |
# * order with one item attached |
Lines 719-725
subtest 'cancel() tests' => sub {
Link Here
|
719 |
cancellationreason => undef, |
719 |
cancellationreason => undef, |
720 |
} |
720 |
} |
721 |
} |
721 |
} |
722 |
)->reset_messages; |
722 |
); |
723 |
$order->add_item( $item->id ); |
723 |
$order->add_item( $item->id ); |
724 |
|
724 |
|
725 |
# Add another order |
725 |
# Add another order |
Lines 744-750
subtest 'cancel() tests' => sub {
Link Here
|
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->messages }; |
747 |
is( $messages[0]->message, 'error_delbiblio', '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: |
750 |
# * order with one item attached |
750 |
# * order with one item attached |
Lines 766-772
subtest 'cancel() tests' => sub {
Link Here
|
766 |
cancellationreason => undef, |
766 |
cancellationreason => undef, |
767 |
} |
767 |
} |
768 |
} |
768 |
} |
769 |
)->reset_messages; |
769 |
); |
770 |
$order->add_item( $item->id ); |
770 |
$order->add_item( $item->id ); |
771 |
|
771 |
|
772 |
# Add a subscription |
772 |
# Add a subscription |
Lines 788-794
subtest 'cancel() tests' => sub {
Link Here
|
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->messages }; |
791 |
is( $messages[0]->message, 'error_delbiblio', '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: |
794 |
# * order with one item attached |
794 |
# * order with one item attached |
Lines 812-820
subtest 'cancel() tests' => sub {
Link Here
|
812 |
); |
812 |
); |
813 |
$order->add_item( $item->id ); |
813 |
$order->add_item( $item->id ); |
814 |
|
814 |
|
815 |
$order->cancel({ reason => $reason, delete_biblio => 1 }); |
815 |
$order->cancel({ reason => $reason, delete_biblio => 1 }) |
816 |
# refresh the order object |
816 |
->discard_changes; |
817 |
$order->discard_changes; |
|
|
818 |
|
817 |
|
819 |
is( $order->orderstatus, 'cancelled', 'Order is not marked as cancelled' ); |
818 |
is( $order->orderstatus, 'cancelled', 'Order is not marked as cancelled' ); |
820 |
isnt( $order->datecancellationprinted, undef, 'datecancellationprinted is not undef' ); |
819 |
isnt( $order->datecancellationprinted, undef, 'datecancellationprinted is not undef' ); |
821 |
- |
|
|