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 => 3; |
24 |
use Test::More tests => 4; |
25 |
use Test::MockObject; |
25 |
use Test::MockObject; |
26 |
use Test::MockModule; |
26 |
use Test::MockModule; |
27 |
use Test::Warn; |
27 |
use Test::Warn; |
Lines 73-78
subtest 'Checkin V2' => sub {
Link Here
|
73 |
$schema->storage->txn_rollback; |
73 |
$schema->storage->txn_rollback; |
74 |
}; |
74 |
}; |
75 |
|
75 |
|
|
|
76 |
subtest 'Lastseen response' => sub { |
77 |
|
78 |
my $schema = Koha::Database->new->schema; |
79 |
$schema->storage->txn_begin; |
80 |
|
81 |
plan tests => 6; |
82 |
my $builder = t::lib::TestBuilder->new(); |
83 |
my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; |
84 |
my ( $response, $findpatron ); |
85 |
my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); |
86 |
my $seen_patron = $builder->build({ |
87 |
source => 'Borrower', |
88 |
value => { |
89 |
lastseen => '2001-01-01', |
90 |
password => hash_password( PATRON_PW ), |
91 |
branchcode => $branchcode, |
92 |
}, |
93 |
}); |
94 |
my $cardnum = $seen_patron->{cardnumber}; |
95 |
my $sip_patron = C4::SIP::ILS::Patron->new( $cardnum ); |
96 |
$findpatron = $sip_patron; |
97 |
|
98 |
my $siprequest = PATRON_INFO. 'engYYYYMMDDZZZZHHMMSS'.'Y '. |
99 |
FID_INST_ID. $branchcode. '|'. |
100 |
FID_PATRON_ID. $cardnum. '|'. |
101 |
FID_PATRON_PWD. PATRON_PW. '|'; |
102 |
my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); |
103 |
|
104 |
my $server = { ils => $mocks->{ils} }; |
105 |
undef $response; |
106 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '' ); |
107 |
$msg->handle_patron_info( $server ); |
108 |
|
109 |
isnt( $response, undef, 'At least we got a response.' ); |
110 |
my $respcode = substr( $response, 0, 2 ); |
111 |
is( $respcode, PATRON_INFO_RESP, 'Response code fine' ); |
112 |
$seen_patron = Koha::Patrons->find({ cardnumber => $seen_patron->{cardnumber} }); |
113 |
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'); |
114 |
undef $response; |
115 |
t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' ); |
116 |
$msg->handle_patron_info( $server ); |
117 |
|
118 |
isnt( $response, undef, 'At least we got a response.' ); |
119 |
$respcode = substr( $response, 0, 2 ); |
120 |
is( $respcode, PATRON_INFO_RESP, 'Response code fine' ); |
121 |
$seen_patron = Koha::Patrons->find({ cardnumber => $seen_patron->cardnumber() }); |
122 |
is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({dt => dt_from_string(), dateonly => 1}),'Last seen updated if tracking patrons'); |
123 |
$schema->storage->txn_rollback; |
124 |
|
125 |
}; |
76 |
# Here is room for some more subtests |
126 |
# Here is room for some more subtests |
77 |
|
127 |
|
78 |
# END of main code |
128 |
# END of main code |