Lines 19-25
use t::lib::Mocks;
Link Here
|
19 |
use t::lib::TestBuilder; |
19 |
use t::lib::TestBuilder; |
20 |
use Test::MockModule; |
20 |
use Test::MockModule; |
21 |
use Test::NoWarnings; |
21 |
use Test::NoWarnings; |
22 |
use Test::More tests => 64; |
22 |
use Test::More tests => 65; |
23 |
|
23 |
|
24 |
BEGIN { |
24 |
BEGIN { |
25 |
use_ok( |
25 |
use_ok( |
Lines 738-743
subtest "test numbering pattern with dates in GetSeq GetNextSeq" => sub {
Link Here
|
738 |
|
738 |
|
739 |
}; |
739 |
}; |
740 |
|
740 |
|
|
|
741 |
subtest "DelSubscription" => sub { |
742 |
plan tests => 5; |
743 |
|
744 |
# Create a mock for C4::Context preferences |
745 |
t::lib::Mocks::mock_preference( "SubscriptionLog", 1 ); |
746 |
|
747 |
# Create a Subscription for testing |
748 |
my $subscription_to_delete = NewSubscription( |
749 |
undef, "", undef, undef, $budget_id, $biblionumber, |
750 |
'2013-01-01', $frequency_id, undef, undef, undef, |
751 |
undef, undef, undef, undef, undef, undef, |
752 |
1, $notes, undef, '2013-01-01', undef, $pattern_id, |
753 |
undef, undef, 0, $internalnotes, 0, |
754 |
undef, undef, 0, undef, '2013-12-31', 0 |
755 |
); |
756 |
|
757 |
# Verify subscription was created |
758 |
my $subscription = GetSubscription($subscription_to_delete); |
759 |
is( |
760 |
$subscription->{subscriptionid}, $subscription_to_delete, |
761 |
'Subscription created successfully for deletion test' |
762 |
); |
763 |
|
764 |
# Create an additional field value for this subscription |
765 |
my $additional_field = $builder->build_object( |
766 |
{ |
767 |
class => 'Koha::AdditionalFields', |
768 |
value => { |
769 |
tablename => 'subscription', |
770 |
name => 'test_field', |
771 |
authorised_value_category => undef, |
772 |
} |
773 |
} |
774 |
); |
775 |
|
776 |
my $field_value = Koha::AdditionalFieldValue->new( |
777 |
{ |
778 |
field_id => $additional_field->id, |
779 |
record_id => $subscription_to_delete, |
780 |
value => 'test_value', |
781 |
record_table => 'subscription', |
782 |
} |
783 |
)->store; |
784 |
|
785 |
# Verify additional field value exists |
786 |
my $count = Koha::AdditionalFieldValues->search( |
787 |
{ |
788 |
'me.record_table' => 'subscription', |
789 |
'me.record_id' => $subscription_to_delete, |
790 |
} |
791 |
)->count; |
792 |
is( $count, 1, 'Additional field value was created for the subscription' ); |
793 |
|
794 |
my $action_logs_before = $schema->resultset('ActionLog')->search()->count; |
795 |
|
796 |
# Delete the subscription |
797 |
DelSubscription($subscription_to_delete); |
798 |
|
799 |
# Test 1: Subscription should be deleted |
800 |
$subscription = GetSubscription($subscription_to_delete); |
801 |
is( $subscription, undef, 'Subscription was successfully deleted' ); |
802 |
|
803 |
# Test 2: Additional field values should be deleted |
804 |
$count = Koha::AdditionalFieldValues->search( |
805 |
{ |
806 |
'me.record_table' => 'subscription', |
807 |
'me.record_id' => $subscription_to_delete, |
808 |
} |
809 |
)->count; |
810 |
is( $count, 0, 'Additional field values were deleted with the subscription' ); |
811 |
|
812 |
# Test 3: Logaction should have been called with correct parameters |
813 |
my $action_logs_after = $schema->resultset('ActionLog')->search()->count; |
814 |
is( |
815 |
$action_logs_after, $action_logs_before + 1, |
816 |
'logaction was called when SubscriptionLog preference is enabled' |
817 |
); |
818 |
}; |
819 |
|
741 |
subtest "_numeration" => sub { |
820 |
subtest "_numeration" => sub { |
742 |
|
821 |
|
743 |
plan tests => 6; |
822 |
plan tests => 6; |
744 |
- |
|
|