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