Lines 42-51
subtest 'show_history_check' => sub {
Link Here
|
42 |
|
42 |
|
43 |
use_ok('Koha::ILL::Request::Workflow::HistoryCheck'); |
43 |
use_ok('Koha::ILL::Request::Workflow::HistoryCheck'); |
44 |
|
44 |
|
|
|
45 |
my $fake_cardnumber = '123456789'; |
46 |
my $ill_patron = $builder->build_object( |
47 |
{ |
48 |
class => 'Koha::Patrons', |
49 |
value => { cardnumber => $fake_cardnumber } |
50 |
} |
51 |
); |
52 |
|
45 |
my $metadata = { |
53 |
my $metadata = { |
46 |
title => 'This is a title', |
54 |
title => 'This is a title', |
47 |
author => 'This is an author', |
55 |
author => 'This is an author', |
48 |
issn => $issn |
56 |
issn => $issn, |
|
|
57 |
cardnumber => $fake_cardnumber, |
49 |
}; |
58 |
}; |
50 |
|
59 |
|
51 |
# Because hashes can reorder themselves, we need to make sure ours is in a |
60 |
# Because hashes can reorder themselves, we need to make sure ours is in a |
Lines 61-67
subtest 'show_history_check' => sub {
Link Here
|
61 |
|
70 |
|
62 |
is( |
71 |
is( |
63 |
$history_check->prep_metadata($sorted), |
72 |
$history_check->prep_metadata($sorted), |
64 |
'eyJhdXRob3IiOiJUaGlzIGlzIGFuIGF1dGhvciIsImlzc24iOiIzMjEzMjEzMjEiLCJ0aXRsZSI6%0AIlRoaXMgaXMgYSB0aXRsZSJ9%0A', |
73 |
'eyJhdXRob3IiOiJUaGlzIGlzIGFuIGF1dGhvciIsImNhcmRudW1iZXIiOiIxMjM0NTY3ODkiLCJp%0Ac3NuIjoiMzIxMzIxMzIxIiwidGl0bGUiOiJUaGlzIGlzIGEgdGl0bGUifQ%3D%3D%0A', |
65 |
'prep_metadata works' |
74 |
'prep_metadata works' |
66 |
); |
75 |
); |
67 |
|
76 |
|
Lines 77-83
subtest 'show_history_check' => sub {
Link Here
|
77 |
# Mock ILLHistoryCheck enabled |
86 |
# Mock ILLHistoryCheck enabled |
78 |
t::lib::Mocks::mock_preference( 'ILLHistoryCheck', 1 ); |
87 |
t::lib::Mocks::mock_preference( 'ILLHistoryCheck', 1 ); |
79 |
|
88 |
|
80 |
my $ill_request = $builder->build_sample_ill_request(); |
89 |
my $ill_request = $builder->build_sample_ill_request( { borrowernumber => $ill_patron->borrowernumber } ); |
81 |
is( |
90 |
is( |
82 |
$history_check->show_history_check($ill_request), |
91 |
$history_check->show_history_check($ill_request), |
83 |
0, 'Request with ISSN ' . $issn . ' does not exist even though syspref is on. Not showing history check screen' |
92 |
0, 'Request with ISSN ' . $issn . ' does not exist even though syspref is on. Not showing history check screen' |
Lines 92-98
subtest 'show_history_check' => sub {
Link Here
|
92 |
|
101 |
|
93 |
is( |
102 |
is( |
94 |
$history_check->show_history_check($ill_request), |
103 |
$history_check->show_history_check($ill_request), |
95 |
1, 'Request with ISSN ' . $issn . ' exists and syspref is on. Able to show history check screen' |
104 |
1, 'Request with ISSN ' . $issn . ' exists, syspref is on and is same patron. Able to show history check screen' |
96 |
); |
105 |
); |
97 |
|
106 |
|
98 |
# Mock ILLHistoryCheck disabled |
107 |
# Mock ILLHistoryCheck disabled |
Lines 109-121
subtest 'show_history_check' => sub {
Link Here
|
109 |
|
118 |
|
110 |
subtest 'after_request_created' => sub { |
119 |
subtest 'after_request_created' => sub { |
111 |
|
120 |
|
112 |
plan tests => 4; |
121 |
plan tests => 2; |
113 |
|
122 |
|
114 |
$schema->storage->txn_begin; |
123 |
$schema->storage->txn_begin; |
115 |
|
124 |
|
116 |
my $builder = t::lib::TestBuilder->new; |
125 |
my $builder = t::lib::TestBuilder->new; |
117 |
|
126 |
|
118 |
my $metadata = { |
127 |
my $fake_cardnumber = '123456789'; |
|
|
128 |
my $metadata = { |
119 |
title => 'This is a title', |
129 |
title => 'This is a title', |
120 |
author => 'This is an author', |
130 |
author => 'This is an author', |
121 |
issn => $issn |
131 |
issn => $issn |
Lines 127-150
subtest 'after_request_created' => sub {
Link Here
|
127 |
} |
137 |
} |
128 |
); |
138 |
); |
129 |
|
139 |
|
130 |
my $other_patron = $builder->build_object( |
|
|
131 |
{ |
132 |
class => 'Koha::Patrons', |
133 |
} |
134 |
); |
135 |
|
136 |
t::lib::Mocks::mock_userenv( { patron => $authenticated_patron } ); |
140 |
t::lib::Mocks::mock_userenv( { patron => $authenticated_patron } ); |
137 |
|
141 |
|
138 |
# Create an old request |
|
|
139 |
my $existing_ill_request = |
140 |
$builder->build_sample_ill_request( { borrowernumber => $other_patron->borrowernumber } ); |
141 |
$builder->build( |
142 |
{ |
143 |
source => 'Illrequestattribute', |
144 |
value => { illrequest_id => $existing_ill_request->illrequest_id, type => 'issn', value => $issn } |
145 |
} |
146 |
); |
147 |
|
148 |
# Create a new request with new issn |
142 |
# Create a new request with new issn |
149 |
my $new_ill_request = |
143 |
my $new_ill_request = |
150 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
144 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
Lines 165-206
subtest 'after_request_created' => sub {
Link Here
|
165 |
'History check didn\'t find any matching requests. Staff notes have not been updated.' |
159 |
'History check didn\'t find any matching requests. Staff notes have not been updated.' |
166 |
); |
160 |
); |
167 |
|
161 |
|
168 |
# Create a third request with preexisting issn by other patron |
162 |
# Create a second request with preexisting issn by self patron |
|
|
163 |
my $second_ill_request = |
164 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
169 |
my $third_ill_request = |
165 |
my $third_ill_request = |
170 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
166 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
171 |
$metadata->{issn} = $issn; |
167 |
$metadata->{issn} = $issn; |
172 |
$builder->build( |
168 |
$builder->build( |
173 |
{ |
169 |
{ |
174 |
source => 'Illrequestattribute', |
170 |
source => 'Illrequestattribute', |
175 |
value => { illrequest_id => $third_ill_request->illrequest_id, type => 'issn', value => $issn } |
171 |
value => { illrequest_id => $second_ill_request->illrequest_id, type => 'issn', value => $issn } |
176 |
} |
172 |
} |
177 |
); |
173 |
); |
178 |
$opac_history_check->after_request_created( $metadata, $third_ill_request ); |
|
|
179 |
|
180 |
like( |
181 |
$third_ill_request->notesstaff, qr/Request has been submitted by other patrons in the past/, |
182 |
'Contains staffnotes related submissions by other patrons' |
183 |
); |
184 |
|
185 |
# Create a fourth request with preexisting issn by self patron and others |
186 |
my $fourth_ill_request = |
187 |
$builder->build_sample_ill_request( { borrowernumber => $authenticated_patron->borrowernumber } ); |
188 |
$metadata->{issn} = $issn; |
189 |
$builder->build( |
174 |
$builder->build( |
190 |
{ |
175 |
{ |
191 |
source => 'Illrequestattribute', |
176 |
source => 'Illrequestattribute', |
192 |
value => { illrequest_id => $fourth_ill_request->illrequest_id, type => 'issn', value => $issn } |
177 |
value => { illrequest_id => $third_ill_request->illrequest_id, type => 'issn', value => $issn } |
193 |
} |
178 |
} |
194 |
); |
179 |
); |
195 |
$opac_history_check->after_request_created( $metadata, $fourth_ill_request ); |
180 |
$opac_history_check->after_request_created( $metadata, $third_ill_request ); |
196 |
|
|
|
197 |
like( |
198 |
$fourth_ill_request->notesstaff, qr/Request has been submitted by other patrons in the past/, |
199 |
'Contains staffnotes related submissions by other patrons' |
200 |
); |
201 |
|
181 |
|
202 |
like( |
182 |
like( |
203 |
$fourth_ill_request->notesstaff, qr/Request has been submitted by this patron in the past/, |
183 |
$third_ill_request->notesstaff, qr/Request has been submitted by this patron in the past/, |
204 |
'Contains staffnotes related submissions by self patron' |
184 |
'Contains staffnotes related submissions by self patron' |
205 |
); |
185 |
); |
206 |
|
186 |
|
207 |
- |
|
|