|
Lines 19-25
use Modern::Perl;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use CGI qw ( -utf8 ); |
20 |
use CGI qw ( -utf8 ); |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 4; |
| 23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
| 24 |
use t::lib::Mocks; |
24 |
use t::lib::Mocks; |
| 25 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
|
Lines 198-200
subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes
Link Here
|
| 198 |
$schema->storage->txn_rollback; |
198 |
$schema->storage->txn_rollback; |
| 199 |
}; |
199 |
}; |
| 200 |
|
200 |
|
| 201 |
- |
201 |
|
|
|
202 |
subtest 'LookupPatron test' => sub { |
| 203 |
|
| 204 |
plan tests => 9; |
| 205 |
|
| 206 |
$schema->storage->txn_begin; |
| 207 |
|
| 208 |
$schema->resultset( 'Issue' )->delete_all; |
| 209 |
$schema->resultset( 'Borrower' )->delete_all; |
| 210 |
$schema->resultset( 'BorrowerAttribute' )->delete_all; |
| 211 |
$schema->resultset( 'BorrowerAttributeType' )->delete_all; |
| 212 |
$schema->resultset( 'Category' )->delete_all; |
| 213 |
$schema->resultset( 'Item' )->delete_all; # 'Branch' deps. on this |
| 214 |
$schema->resultset( 'Branch' )->delete_all; |
| 215 |
|
| 216 |
my $borrower = $builder->build({ |
| 217 |
source => 'Borrower', |
| 218 |
}); |
| 219 |
|
| 220 |
my $query = CGI->new(); |
| 221 |
my $bad_result = C4::ILSDI::Services::LookupPatron($query); |
| 222 |
is( $bad_result->{message}, 'PatronNotFound', 'No parameters' ); |
| 223 |
|
| 224 |
$query->delete_all(); |
| 225 |
$query->param( 'id', $borrower->{firstname} ); |
| 226 |
my $optional_result = C4::ILSDI::Services::LookupPatron($query); |
| 227 |
is( |
| 228 |
$optional_result->{id}, |
| 229 |
$borrower->{borrowernumber}, |
| 230 |
'Valid Firstname only' |
| 231 |
); |
| 232 |
|
| 233 |
$query->delete_all(); |
| 234 |
$query->param( 'id', 'ThereIsNoWayThatThisCouldPossiblyBeValid' ); |
| 235 |
my $bad_optional_result = C4::ILSDI::Services::LookupPatron($query); |
| 236 |
is( $bad_optional_result->{message}, 'PatronNotFound', 'Invalid ID' ); |
| 237 |
|
| 238 |
foreach my $id_type ( |
| 239 |
'cardnumber', |
| 240 |
'userid', |
| 241 |
'email', |
| 242 |
'borrowernumber', |
| 243 |
'surname', |
| 244 |
'firstname' |
| 245 |
) { |
| 246 |
$query->delete_all(); |
| 247 |
$query->param( 'id_type', $id_type ); |
| 248 |
$query->param( 'id', $borrower->{$id_type} ); |
| 249 |
my $result = C4::ILSDI::Services::LookupPatron($query); |
| 250 |
is( $result->{'id'}, $borrower->{borrowernumber}, "Checking $id_type" ); |
| 251 |
} |
| 252 |
|
| 253 |
# Cleanup |
| 254 |
$schema->storage->txn_rollback; |
| 255 |
}; |
| 256 |
|