|
Lines 21-27
Link Here
|
| 21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
21 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 22 |
|
22 |
|
| 23 |
use Modern::Perl; |
23 |
use Modern::Perl; |
| 24 |
use Test::More tests => 17; |
24 |
use Test::More tests => 18; |
| 25 |
use Test::Exception; |
25 |
use Test::Exception; |
| 26 |
use Test::MockObject; |
26 |
use Test::MockObject; |
| 27 |
use Test::MockModule; |
27 |
use Test::MockModule; |
|
Lines 196-202
subtest 'hold_patron_name() tests' => sub {
Link Here
|
| 196 |
$schema->storage->txn_rollback; |
196 |
$schema->storage->txn_rollback; |
| 197 |
}; |
197 |
}; |
| 198 |
|
198 |
|
| 199 |
subtest 'Lastseen response' => sub { |
199 |
subtest 'Lastseen response patron_info' => sub { |
| 200 |
|
200 |
|
| 201 |
my $schema = Koha::Database->new->schema; |
201 |
my $schema = Koha::Database->new->schema; |
| 202 |
$schema->storage->txn_begin; |
202 |
$schema->storage->txn_begin; |
|
Lines 247-252
subtest 'Lastseen response' => sub {
Link Here
|
| 247 |
|
247 |
|
| 248 |
}; |
248 |
}; |
| 249 |
|
249 |
|
|
|
250 |
subtest 'Lastseen response patron status' => sub { |
| 251 |
|
| 252 |
my $schema = Koha::Database->new->schema; |
| 253 |
$schema->storage->txn_begin; |
| 254 |
|
| 255 |
plan tests => 6; |
| 256 |
my $builder = t::lib::TestBuilder->new(); |
| 257 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
| 258 |
my ( $response, $findpatron ); |
| 259 |
my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); |
| 260 |
my $seen_patron = $builder->build({ |
| 261 |
source => 'Borrower', |
| 262 |
value => { |
| 263 |
lastseen => '2001-01-01', |
| 264 |
password => hash_password( PATRON_PW ), |
| 265 |
branchcode => $branchcode, |
| 266 |
}, |
| 267 |
}); |
| 268 |
my $cardnum = $seen_patron->{cardnumber}; |
| 269 |
my $sip_patron = C4::SIP::ILS::Patron->new( $cardnum ); |
| 270 |
$findpatron = $sip_patron; |
| 271 |
|
| 272 |
my $siprequest = PATRON_STATUS_REQ. 'engYYYYMMDDZZZZHHMMSS'. |
| 273 |
FID_INST_ID. $branchcode. '|'. |
| 274 |
FID_PATRON_ID. $cardnum. '|'. |
| 275 |
FID_PATRON_PWD. PATRON_PW. '|'; |
| 276 |
my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); |
| 277 |
|
| 278 |
my $server = { ils => $mocks->{ils} }; |
| 279 |
undef $response; |
| 280 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '' ); |
| 281 |
$msg->handle_patron_status( $server ); |
| 282 |
|
| 283 |
isnt( $response, undef, 'At least we got a response.' ); |
| 284 |
my $respcode = substr( $response, 0, 2 ); |
| 285 |
is( $respcode, PATRON_STATUS_RESP, 'Response code fine' ); |
| 286 |
$seen_patron = Koha::Patrons->find({ cardnumber => $seen_patron->{cardnumber} }); |
| 287 |
is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({str => '2001-01-01', dateonly => 1}),'Last seen not updated if not tracking patrons'); |
| 288 |
undef $response; |
| 289 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' ); |
| 290 |
$msg->handle_patron_status( $server ); |
| 291 |
|
| 292 |
isnt( $response, undef, 'At least we got a response.' ); |
| 293 |
$respcode = substr( $response, 0, 2 ); |
| 294 |
is( $respcode, PATRON_STATUS_RESP, 'Response code fine' ); |
| 295 |
$seen_patron = Koha::Patrons->find({ cardnumber => $seen_patron->cardnumber() }); |
| 296 |
is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({dt => dt_from_string(), dateonly => 1}),'Last seen updated if tracking patrons'); |
| 297 |
$schema->storage->txn_rollback; |
| 298 |
|
| 299 |
}; |
| 300 |
|
| 250 |
subtest "Test patron_status_string" => sub { |
301 |
subtest "Test patron_status_string" => sub { |
| 251 |
my $schema = Koha::Database->new->schema; |
302 |
my $schema = Koha::Database->new->schema; |
| 252 |
$schema->storage->txn_begin; |
303 |
$schema->storage->txn_begin; |
| 253 |
- |
|
|