Lines 636-642
subtest 'Backend testing (mocks)' => sub {
Link Here
|
636 |
|
636 |
|
637 |
subtest 'Backend core methods' => sub { |
637 |
subtest 'Backend core methods' => sub { |
638 |
|
638 |
|
639 |
plan tests => 18; |
639 |
plan tests => 19; |
640 |
|
640 |
|
641 |
$schema->storage->txn_begin; |
641 |
$schema->storage->txn_begin; |
642 |
|
642 |
|
Lines 794-799
subtest 'Backend core methods' => sub {
Link Here
|
794 |
}, |
794 |
}, |
795 |
"Backend confirm: arbitrary stage."); |
795 |
"Backend confirm: arbitrary stage."); |
796 |
|
796 |
|
|
|
797 |
# backend_get_update |
798 |
$backend->mock( |
799 |
'get_supplier_update', |
800 |
sub { |
801 |
my ( $self, $options ) = @_; |
802 |
return $options; |
803 |
} |
804 |
); |
805 |
$backend->mock('capabilities', sub { return sub { return 1; } }); |
806 |
is_deeply($illrq->backend_get_update({}), 1, |
807 |
"Backend get_update method."); |
808 |
|
797 |
$config->set_always('partner_code', "ILLTSTLIB"); |
809 |
$config->set_always('partner_code', "ILLTSTLIB"); |
798 |
$backend->set_always('metadata', { Test => "Foobar" }); |
810 |
$backend->set_always('metadata', { Test => "Foobar" }); |
799 |
my $illbrn = $builder->build({ |
811 |
my $illbrn = $builder->build({ |
Lines 833-839
subtest 'Backend core methods' => sub {
Link Here
|
833 |
|
845 |
|
834 |
subtest 'Helpers' => sub { |
846 |
subtest 'Helpers' => sub { |
835 |
|
847 |
|
836 |
plan tests => 21; |
848 |
plan tests => 25; |
837 |
|
849 |
|
838 |
$schema->storage->txn_begin; |
850 |
$schema->storage->txn_begin; |
839 |
|
851 |
|
Lines 877-882
subtest 'Helpers' => sub {
Link Here
|
877 |
$illrq_obj->_config($config); |
889 |
$illrq_obj->_config($config); |
878 |
$illrq_obj->_backend($backend); |
890 |
$illrq_obj->_backend($backend); |
879 |
|
891 |
|
|
|
892 |
#attach_processors |
893 |
my $type = 'test_type_1'; |
894 |
my $name = 'test_name_1'; |
895 |
my $update = Test::MockObject->new; |
896 |
$update->set_isa('Koha::Illrequest::SupplierUpdate'); |
897 |
$update->{source_type} = $type; |
898 |
$update->{source_name} = $name; |
899 |
$update->{processors} = []; |
900 |
$update->mock('attach_processor', sub { |
901 |
my ( $self, $to_attach ) = @_; |
902 |
push @{$self->{processors}}, $to_attach; |
903 |
}); |
904 |
my $processor = Test::MockObject->new; |
905 |
$processor->{target_source_type} = $type; |
906 |
$processor->{target_source_name} = $name; |
907 |
$illrq_obj->init_processors(); |
908 |
$illrq_obj->push_processor($processor); |
909 |
$illrq_obj->attach_processors($update); |
910 |
is_deeply( |
911 |
scalar @{$update->{processors}}, |
912 |
1, |
913 |
'attaching processors as appropriate works' |
914 |
); |
915 |
|
880 |
# getPrefix |
916 |
# getPrefix |
881 |
$config->set_series('getPrefixes', |
917 |
$config->set_series('getPrefixes', |
882 |
{ HDE => "TEST", TSL => "BAR", default => "DEFAULT" }, |
918 |
{ HDE => "TEST", TSL => "BAR", default => "DEFAULT" }, |
Lines 928-933
subtest 'Helpers' => sub {
Link Here
|
928 |
); |
964 |
); |
929 |
is($notice, 'ILL_PICKUP_READY' ,"Notice is correctly created"); |
965 |
is($notice, 'ILL_PICKUP_READY' ,"Notice is correctly created"); |
930 |
|
966 |
|
|
|
967 |
# ill update notice, passes additional text parameter |
968 |
my $attr_update = Koha::MessageAttributes->find({ message_name => 'Ill_update' }); |
969 |
C4::Members::Messaging::SetMessagingPreference({ |
970 |
borrowernumber => $patron->{borrowernumber}, |
971 |
message_attribute_id => $attr_update->message_attribute_id, |
972 |
message_transport_types => ['email'] |
973 |
}); |
974 |
my $return_patron_update = $illrq_obj->send_patron_notice('ILL_REQUEST_UPDATE', 'Some additional text'); |
975 |
my $notice_update = $schema->resultset('MessageQueue')->search({ |
976 |
letter_code => 'ILL_REQUEST_UPDATE', |
977 |
message_transport_type => 'email', |
978 |
borrowernumber => $illrq_obj->borrowernumber |
979 |
})->next()->letter_code; |
980 |
is_deeply( |
981 |
$return_patron_update, |
982 |
{ result => { success => ['email'], fail => [] } }, |
983 |
"Correct return when notice created" |
984 |
); |
985 |
is($notice_update, 'ILL_REQUEST_UPDATE' ,"Notice is correctly created"); |
986 |
|
987 |
|
931 |
my $return_patron_fail = $illrq_obj->send_patron_notice(); |
988 |
my $return_patron_fail = $illrq_obj->send_patron_notice(); |
932 |
is_deeply( |
989 |
is_deeply( |
933 |
$return_patron_fail, |
990 |
$return_patron_fail, |
Lines 1008-1013
subtest 'Helpers' => sub {
Link Here
|
1008 |
'Correct content returned from get_notice with metadata correctly ordered' |
1065 |
'Correct content returned from get_notice with metadata correctly ordered' |
1009 |
); |
1066 |
); |
1010 |
|
1067 |
|
|
|
1068 |
$illrq_obj->append_to_note('Some text'); |
1069 |
like( |
1070 |
$illrq_obj->notesstaff, |
1071 |
qr/Some text$/, |
1072 |
'appending to a note works' |
1073 |
); |
1074 |
|
1011 |
$schema->storage->txn_rollback; |
1075 |
$schema->storage->txn_rollback; |
1012 |
}; |
1076 |
}; |
1013 |
|
1077 |
|
1014 |
- |
|
|