Lines 799-804
subtest 'Backend core methods' => sub {
Link Here
|
799 |
}, |
799 |
}, |
800 |
"Backend confirm: arbitrary stage."); |
800 |
"Backend confirm: arbitrary stage."); |
801 |
|
801 |
|
|
|
802 |
# backend_get_update |
803 |
$backend->mock( |
804 |
'get_supplier_update', |
805 |
sub { |
806 |
my ( $self, $options ) = @_; |
807 |
return $options; |
808 |
} |
809 |
); |
810 |
$backend->mock('capabilities', sub { return sub { return 1; } }); |
811 |
is_deeply($illrq->backend_get_update({}), 1, |
812 |
"Backend get_update method."); |
813 |
|
802 |
$config->set_always('partner_code', "ILLTSTLIB"); |
814 |
$config->set_always('partner_code', "ILLTSTLIB"); |
803 |
$backend->set_always('metadata', { Test => "Foobar" }); |
815 |
$backend->set_always('metadata', { Test => "Foobar" }); |
804 |
my $illbrn = $builder->build({ |
816 |
my $illbrn = $builder->build({ |
Lines 838-844
subtest 'Backend core methods' => sub {
Link Here
|
838 |
|
850 |
|
839 |
subtest 'Helpers' => sub { |
851 |
subtest 'Helpers' => sub { |
840 |
|
852 |
|
841 |
plan tests => 21; |
853 |
plan tests => 25; |
842 |
|
854 |
|
843 |
$schema->storage->txn_begin; |
855 |
$schema->storage->txn_begin; |
844 |
|
856 |
|
Lines 882-887
subtest 'Helpers' => sub {
Link Here
|
882 |
$illrq_obj->_config($config); |
894 |
$illrq_obj->_config($config); |
883 |
$illrq_obj->_backend($backend); |
895 |
$illrq_obj->_backend($backend); |
884 |
|
896 |
|
|
|
897 |
#attach_processors |
898 |
my $type = 'test_type_1'; |
899 |
my $name = 'test_name_1'; |
900 |
my $update = Test::MockObject->new; |
901 |
$update->set_isa('Koha::Illrequest::SupplierUpdate'); |
902 |
$update->{source_type} = $type; |
903 |
$update->{source_name} = $name; |
904 |
$update->{processors} = []; |
905 |
$update->mock('attach_processor', sub { |
906 |
my ( $self, $to_attach ) = @_; |
907 |
push @{$self->{processors}}, $to_attach; |
908 |
}); |
909 |
my $processor = Test::MockObject->new; |
910 |
$processor->{target_source_type} = $type; |
911 |
$processor->{target_source_name} = $name; |
912 |
$illrq_obj->init_processors(); |
913 |
$illrq_obj->push_processor($processor); |
914 |
$illrq_obj->attach_processors($update); |
915 |
is_deeply( |
916 |
scalar @{$update->{processors}}, |
917 |
1, |
918 |
'attaching processors as appropriate works' |
919 |
); |
920 |
|
885 |
# getPrefix |
921 |
# getPrefix |
886 |
$config->set_series('getPrefixes', |
922 |
$config->set_series('getPrefixes', |
887 |
{ HDE => "TEST", TSL => "BAR", default => "DEFAULT" }, |
923 |
{ HDE => "TEST", TSL => "BAR", default => "DEFAULT" }, |
Lines 933-938
subtest 'Helpers' => sub {
Link Here
|
933 |
); |
969 |
); |
934 |
is($notice, 'ILL_PICKUP_READY' ,"Notice is correctly created"); |
970 |
is($notice, 'ILL_PICKUP_READY' ,"Notice is correctly created"); |
935 |
|
971 |
|
|
|
972 |
# ill update notice, passes additional text parameter |
973 |
my $attr_update = Koha::MessageAttributes->find({ message_name => 'Ill_update' }); |
974 |
C4::Members::Messaging::SetMessagingPreference({ |
975 |
borrowernumber => $patron->{borrowernumber}, |
976 |
message_attribute_id => $attr_update->message_attribute_id, |
977 |
message_transport_types => ['email'] |
978 |
}); |
979 |
my $return_patron_update = $illrq_obj->send_patron_notice('ILL_REQUEST_UPDATE', 'Some additional text'); |
980 |
my $notice_update = $schema->resultset('MessageQueue')->search({ |
981 |
letter_code => 'ILL_REQUEST_UPDATE', |
982 |
message_transport_type => 'email', |
983 |
borrowernumber => $illrq_obj->borrowernumber |
984 |
})->next()->letter_code; |
985 |
is_deeply( |
986 |
$return_patron_update, |
987 |
{ result => { success => ['email'], fail => [] } }, |
988 |
"Correct return when notice created" |
989 |
); |
990 |
is($notice_update, 'ILL_REQUEST_UPDATE' ,"Notice is correctly created"); |
991 |
|
992 |
|
936 |
my $return_patron_fail = $illrq_obj->send_patron_notice(); |
993 |
my $return_patron_fail = $illrq_obj->send_patron_notice(); |
937 |
is_deeply( |
994 |
is_deeply( |
938 |
$return_patron_fail, |
995 |
$return_patron_fail, |
Lines 1013-1018
subtest 'Helpers' => sub {
Link Here
|
1013 |
'Correct content returned from get_notice with metadata correctly ordered' |
1070 |
'Correct content returned from get_notice with metadata correctly ordered' |
1014 |
); |
1071 |
); |
1015 |
|
1072 |
|
|
|
1073 |
$illrq_obj->append_to_note('Some text'); |
1074 |
like( |
1075 |
$illrq_obj->notesstaff, |
1076 |
qr/Some text$/, |
1077 |
'appending to a note works' |
1078 |
); |
1079 |
|
1016 |
$schema->storage->txn_rollback; |
1080 |
$schema->storage->txn_rollback; |
1017 |
}; |
1081 |
}; |
1018 |
|
1082 |
|
1019 |
- |
|
|