|
Lines 20-28
Link Here
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
use utf8; |
21 |
use utf8; |
| 22 |
|
22 |
|
| 23 |
use Test::More tests => 6; |
23 |
use Test::More tests => 7; |
| 24 |
use Test::MockModule; |
24 |
use Test::MockModule; |
| 25 |
use Test::Warn; |
25 |
use Test::Warn; |
|
|
26 |
use Test::NoWarnings; |
| 26 |
use CGI qw(-utf8 ); |
27 |
use CGI qw(-utf8 ); |
| 27 |
use File::Temp qw(tempdir); |
28 |
use File::Temp qw(tempdir); |
| 28 |
|
29 |
|
|
Lines 67-83
$context->mock( 'interface', sub { return $interface; } );
Link Here
|
| 67 |
# Mock Letters: GetPreparedLetter, EnqueueLetter and SendQueuedMessages |
68 |
# Mock Letters: GetPreparedLetter, EnqueueLetter and SendQueuedMessages |
| 68 |
# We want to test the params |
69 |
# We want to test the params |
| 69 |
my $mocked_letters = Test::MockModule->new('C4::Letters'); |
70 |
my $mocked_letters = Test::MockModule->new('C4::Letters'); |
|
|
71 |
my $sub_called = {}; |
| 70 |
$mocked_letters->mock( |
72 |
$mocked_letters->mock( |
| 71 |
'GetPreparedLetter', |
73 |
'GetPreparedLetter', |
| 72 |
sub { |
74 |
sub { |
| 73 |
warn "GetPreparedLetter called"; |
75 |
$sub_called->{GetPreparedLetter}++; |
| 74 |
return 1; |
76 |
return 1; |
| 75 |
} |
77 |
} |
| 76 |
); |
78 |
); |
| 77 |
$mocked_letters->mock( |
79 |
$mocked_letters->mock( |
| 78 |
'EnqueueLetter', |
80 |
'EnqueueLetter', |
| 79 |
sub { |
81 |
sub { |
| 80 |
warn "EnqueueLetter called"; |
82 |
$sub_called->{EnqueueLetter}++; |
| 81 |
|
83 |
|
| 82 |
# return a 'message_id' |
84 |
# return a 'message_id' |
| 83 |
return 42; |
85 |
return 42; |
|
Lines 87-93
$mocked_letters->mock(
Link Here
|
| 87 |
'SendQueuedMessages', |
89 |
'SendQueuedMessages', |
| 88 |
sub { |
90 |
sub { |
| 89 |
my $params = shift; |
91 |
my $params = shift; |
| 90 |
warn "SendQueuedMessages called with message_id: $params->{message_id}"; |
92 |
$sub_called->{SendQueuedMessages}->{ $params->{message_id} }++; |
| 91 |
return 1; |
93 |
return 1; |
| 92 |
} |
94 |
} |
| 93 |
); |
95 |
); |
|
Lines 172-178
subtest "get_login_shib tests" => sub {
Link Here
|
| 172 |
|
174 |
|
| 173 |
subtest "checkpw_shib tests" => sub { |
175 |
subtest "checkpw_shib tests" => sub { |
| 174 |
|
176 |
|
| 175 |
plan tests => 54; |
177 |
plan tests => 56; |
| 176 |
|
178 |
|
| 177 |
# Test borrower data |
179 |
# Test borrower data |
| 178 |
my $test_borrowers = [ |
180 |
my $test_borrowers = [ |
|
Lines 251-268
subtest "checkpw_shib tests" => sub {
Link Here
|
| 251 |
$ENV{'emailpro'} = 'me@myemail.com'; |
253 |
$ENV{'emailpro'} = 'me@myemail.com'; |
| 252 |
$ENV{branchcode} = $library->branchcode; # needed since T::D::C does no longer hides the FK constraint |
254 |
$ENV{branchcode} = $library->branchcode; # needed since T::D::C does no longer hides the FK constraint |
| 253 |
|
255 |
|
| 254 |
warnings_are { |
256 |
( $retval, $retcard, $retuserid, $retpatron ) = checkpw_shib($shib_login); |
| 255 |
( $retval, $retcard, $retuserid, $retpatron ) = checkpw_shib($shib_login); |
257 |
is( $sub_called->{GetPreparedLetter}, 1, 'GetPreparedLetter called' ); |
| 256 |
} |
258 |
is( $sub_called->{EnqueueLetter}, 1, 'EnqueueLetter called' ); |
| 257 |
[ |
259 |
is( $sub_called->{SendQueuedMessages}->{42}, 1, 'SendQueuedMessages called with message_id: 42' ); |
| 258 |
'GetPreparedLetter called', |
260 |
is( $retval, "1", "user authenticated" ); |
| 259 |
'EnqueueLetter called', |
261 |
is( $retuserid, "test4321", "expected userid returned" ); |
| 260 |
'SendQueuedMessages called with message_id: 42' |
262 |
is( ref($retpatron), 'Koha::Patron', "expected Koha::Patron object returned" ); |
| 261 |
], |
|
|
| 262 |
"WELCOME notice Prepared, Enqueued and Send"; |
| 263 |
is( $retval, "1", "user authenticated" ); |
| 264 |
is( $retuserid, "test4321", "expected userid returned" ); |
| 265 |
is( ref($retpatron), 'Koha::Patron', "expected Koha::Patron object returned" ); |
| 266 |
$logger->debug_is( "koha borrower field to match: userid", "borrower match field debug info" ) |
263 |
$logger->debug_is( "koha borrower field to match: userid", "borrower match field debug info" ) |
| 267 |
->debug_is( "shibboleth attribute to match: uid", "shib match attribute debug info" )->clear(); |
264 |
->debug_is( "shibboleth attribute to match: uid", "shib match attribute debug info" )->clear(); |
| 268 |
|
265 |
|
| 269 |
- |
|
|