Lines 3-12
Link Here
|
3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
4 |
|
4 |
|
5 |
use C4::Members qw/AddMember GetMember GetBorrowercategory/; |
5 |
use C4::Members qw/AddMember GetMember GetBorrowercategory/; |
|
|
6 |
use C4::Biblio qw( AddBiblio ); |
7 |
use C4::Items qw( AddItem ); |
8 |
use C4::Reserves qw( AddReserve GetReserve ); |
6 |
use Koha::Libraries; |
9 |
use Koha::Libraries; |
7 |
use CGI qw ( -utf8 ); |
10 |
use CGI qw ( -utf8 ); |
|
|
11 |
use MARC::Record; |
8 |
|
12 |
|
9 |
use Test::More tests => 16; |
13 |
use Test::More tests => 4; |
10 |
use t::lib::Mocks; |
14 |
use t::lib::Mocks; |
11 |
use t::lib::TestBuilder; |
15 |
use t::lib::TestBuilder; |
12 |
|
16 |
|
Lines 48-54
unless ( Koha::Libraries->find('UT') ) {
Link Here
|
48 |
my $borrowernumber = AddMember(%data); |
52 |
my $borrowernumber = AddMember(%data); |
49 |
my $borrower = GetMember( borrowernumber => $borrowernumber ); |
53 |
my $borrower = GetMember( borrowernumber => $borrowernumber ); |
50 |
|
54 |
|
51 |
{ # AuthenticatePatron test |
55 |
subtest 'AuthenticatePatron' => sub { |
|
|
56 |
plan tests => 14; |
52 |
|
57 |
|
53 |
my $query = new CGI; |
58 |
my $query = new CGI; |
54 |
$query->param('username',$borrower->{'userid'}); |
59 |
$query->param('username',$borrower->{'userid'}); |
Lines 89-96
my $borrower = GetMember( borrowernumber => $borrowernumber );
Link Here
|
89 |
$reply = C4::ILSDI::Services::AuthenticatePatron($query); |
94 |
$reply = C4::ILSDI::Services::AuthenticatePatron($query); |
90 |
is($reply->{'code'}, 'PatronNotFound', "non-existing cardnumer/userid - PatronNotFound"); |
95 |
is($reply->{'code'}, 'PatronNotFound', "non-existing cardnumer/userid - PatronNotFound"); |
91 |
is($reply->{'id'}, undef, "id undef"); |
96 |
is($reply->{'id'}, undef, "id undef"); |
92 |
|
97 |
}; |
93 |
} |
|
|
94 |
|
98 |
|
95 |
# End transaction |
99 |
# End transaction |
96 |
$dbh->rollback; |
100 |
$dbh->rollback; |
Lines 109-115
$schema->resultset( 'Item' )->delete_all; # 'Branch' deps. on this
Link Here
|
109 |
$schema->resultset( 'Branch' )->delete_all; |
113 |
$schema->resultset( 'Branch' )->delete_all; |
110 |
|
114 |
|
111 |
|
115 |
|
112 |
{ # GetPatronInfo/GetBorrowerAttributes test for extended patron attributes: |
116 |
subtest 'GetPatronInfo/GetBorrowerAttributes for extended patron attributes' => sub { |
|
|
117 |
plan tests => 1; |
113 |
|
118 |
|
114 |
# Configure Koha to enable ILS-DI server and extended attributes: |
119 |
# Configure Koha to enable ILS-DI server and extended attributes: |
115 |
t::lib::Mocks::mock_preference( 'ILS-DI', 1 ); |
120 |
t::lib::Mocks::mock_preference( 'ILS-DI', 1 ); |
Lines 195-201
$schema->resultset( 'Branch' )->delete_all;
Link Here
|
195 |
|
200 |
|
196 |
# Check results: |
201 |
# Check results: |
197 |
is_deeply( $reply->{'attributes'}, [ $cmp ], 'Test GetPatronInfo - show_attributes parameter' ); |
202 |
is_deeply( $reply->{'attributes'}, [ $cmp ], 'Test GetPatronInfo - show_attributes parameter' ); |
198 |
} |
203 |
}; |
|
|
204 |
|
205 |
$schema->storage->txn_rollback; |
206 |
$schema->storage->txn_begin; |
207 |
|
208 |
subtest 'GetRecords' => sub { |
209 |
plan tests => 1; |
210 |
|
211 |
t::lib::Mocks::mock_preference('ILS-DI', 1); |
212 |
|
213 |
my $builder = t::lib::TestBuilder->new; |
214 |
|
215 |
my $branch = $builder->build({ |
216 |
source => 'Branch', |
217 |
value => { |
218 |
branchcode => 'T_ILSDI', |
219 |
} |
220 |
}); |
221 |
|
222 |
my $category = $builder->build({ |
223 |
source => 'Category', |
224 |
value => { |
225 |
category_type => 'A', |
226 |
} |
227 |
}); |
228 |
|
229 |
# Create a new user: |
230 |
my $borrower = $builder->build({ |
231 |
source => 'Borrower', |
232 |
value => { |
233 |
categorycode => $category->{categorycode}, |
234 |
branchcode => $branch, |
235 |
} |
236 |
}); |
237 |
|
238 |
my ($biblionumber) = AddBiblio(MARC::Record->new, ''); |
239 |
my $item = {}; |
240 |
my $itemnumber = AddItem($item, $biblionumber); |
241 |
|
242 |
my $reserve_id = AddReserve($branch, $borrower->{borrowernumber}, $biblionumber); |
243 |
|
244 |
# Prepare and send web request for IL-SDI server: |
245 |
my $query = new CGI; |
246 |
$query->param( 'service', 'GetRecords' ); |
247 |
$query->param( 'id', $biblionumber ); |
248 |
|
249 |
my $response = C4::ILSDI::Services::GetRecords( $query ); |
250 |
|
251 |
my $reserve = GetReserve($reserve_id); |
252 |
$reserve->{rtimestamp} = $reserve->{timestamp}; |
253 |
|
254 |
is_deeply( $response->{record}->[0]->{reserves}->{reserve}, [ $reserve ], |
255 |
'GetRecords /record/reserves/reserve is as expected' ); |
256 |
}; |
199 |
|
257 |
|
200 |
# Cleanup |
258 |
# Cleanup |
201 |
$schema->storage->txn_rollback; |
259 |
$schema->storage->txn_rollback; |
202 |
- |
|
|