Lines 19-24
use Modern::Perl;
Link Here
|
19 |
|
19 |
|
20 |
use Test::More tests => 1; |
20 |
use Test::More tests => 1; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
|
|
22 |
use Test::MockObject; |
22 |
use Test::Mojo; |
23 |
use Test::Mojo; |
23 |
use Test::Warn; |
24 |
use Test::Warn; |
24 |
|
25 |
|
Lines 40-50
subtest 'list() tests' => sub {
Link Here
|
40 |
|
41 |
|
41 |
plan tests => 18; |
42 |
plan tests => 18; |
42 |
|
43 |
|
|
|
44 |
# Mock ILLBackend (as object) |
45 |
my $backend = Test::MockObject->new; |
46 |
$backend->set_isa('Koha::Illbackends::Mock'); |
47 |
$backend->set_always('name', 'Mock'); |
48 |
$backend->set_always('capabilities', sub { return 'bar'; } ); |
49 |
$backend->mock( |
50 |
'metadata', |
51 |
sub { |
52 |
my ( $self, $rq ) = @_; |
53 |
return { |
54 |
ID => $rq->illrequest_id, |
55 |
Title => $rq->patron->borrowernumber |
56 |
} |
57 |
} |
58 |
); |
59 |
|
60 |
# Mock Koha::Illrequest::load_backend (to load Mocked Backend) |
43 |
my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); |
61 |
my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); |
44 |
# Mock ->capabilities |
62 |
$illreqmodule->mock( 'load_backend', |
45 |
$illreqmodule->mock( 'capabilities', sub { return 'capable'; } ); |
63 |
sub { my $self = shift; $self->{_my_backend} = $backend; return $self } |
46 |
# Mock ->metadata |
64 |
); |
47 |
$illreqmodule->mock( 'metadata', sub { return 'metawhat?'; } ); |
|
|
48 |
|
65 |
|
49 |
$schema->storage->txn_begin; |
66 |
$schema->storage->txn_begin; |
50 |
|
67 |
|
Lines 67-73
subtest 'list() tests' => sub {
Link Here
|
67 |
{ |
84 |
{ |
68 |
class => 'Koha::Illrequests', |
85 |
class => 'Koha::Illrequests', |
69 |
value => { |
86 |
value => { |
70 |
backend => 'FreeForm', |
87 |
backend => 'Mock', |
71 |
branchcode => $library->branchcode, |
88 |
branchcode => $library->branchcode, |
72 |
borrowernumber => $patron->borrowernumber |
89 |
borrowernumber => $patron->borrowernumber |
73 |
} |
90 |
} |
Lines 86-101
subtest 'list() tests' => sub {
Link Here
|
86 |
$tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); |
103 |
$tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); |
87 |
$tx->req->env( { REMOTE_ADDR => $remote_address } ); |
104 |
$tx->req->env( { REMOTE_ADDR => $remote_address } ); |
88 |
$t->request_ok($tx)->status_is(200) |
105 |
$t->request_ok($tx)->status_is(200) |
89 |
->json_has( '/0/patron', $patron->unblessed ) |
106 |
->json_has( '/0/patron', 'patron embedded' ) |
90 |
->json_has( '/0/capabilities', 'capable' ) |
107 |
->json_has( '/0/capabilities', 'capabilities embedded' ) |
91 |
->json_has( '/0/library', $library->unblessed ) |
108 |
->json_has( '/0/library', 'library embedded' ) |
92 |
->json_has( '/0/metadata', 'metawhat?' ); |
109 |
->json_has( '/0/metadata', 'metadata embedded' ); |
93 |
|
110 |
|
94 |
# Create another ILL request |
111 |
# Create another ILL request |
95 |
my $illrequest2 = $builder->build_object( |
112 |
my $illrequest2 = $builder->build_object( |
96 |
{ |
113 |
{ |
97 |
class => 'Koha::Illrequests', |
114 |
class => 'Koha::Illrequests', |
98 |
value => { |
115 |
value => { |
|
|
116 |
backend => 'Mock', |
99 |
branchcode => $library->branchcode, |
117 |
branchcode => $library->branchcode, |
100 |
borrowernumber => $patron->borrowernumber |
118 |
borrowernumber => $patron->borrowernumber |
101 |
} |
119 |
} |
102 |
- |
|
|