Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 2; |
20 |
use Test::More tests => 3; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Mojo; |
22 |
use Test::Mojo; |
23 |
|
23 |
|
Lines 115-117
subtest 'render_resource_deleted() tests' => sub {
Link Here
|
115 |
|
115 |
|
116 |
$schema->storage->txn_rollback; |
116 |
$schema->storage->txn_rollback; |
117 |
}; |
117 |
}; |
118 |
- |
118 |
|
|
|
119 |
subtest 'render_invalid_parameter_value() tests' => sub { |
120 |
|
121 |
plan tests => 3; |
122 |
|
123 |
$schema->storage->txn_begin; |
124 |
|
125 |
my $authorized_patron = $builder->build_object( |
126 |
{ |
127 |
class => 'Koha::Patrons', |
128 |
value => { flags => 1 }, |
129 |
} |
130 |
); |
131 |
my $password = 'thePassword123'; |
132 |
$authorized_patron->set_password( { password => $password, skip_validation => 1 } ); |
133 |
my $userid = $authorized_patron->userid; |
134 |
|
135 |
my $path = '/query/library'; |
136 |
my $uri = '/api/v1/libraries'; |
137 |
my $field = 'library_id'; |
138 |
my $mock_cities = Test::MockModule->new('Koha::REST::V1::CirculationRules'); |
139 |
$mock_cities->mock( |
140 |
'list_effective_rules', |
141 |
sub { |
142 |
my $c = shift->openapi->valid_input or return; |
143 |
return $c->render_invalid_parameter_value( |
144 |
{ |
145 |
path => $path, |
146 |
values => { |
147 |
uri => $uri, |
148 |
field => $field |
149 |
} |
150 |
} |
151 |
); |
152 |
} |
153 |
); |
154 |
|
155 |
my $t = Test::Mojo->new('Koha::REST::V1'); |
156 |
|
157 |
$t->get_ok("//$userid:$password@/api/v1/circulation_rules?library=SOMETHING")->status_is('400')->json_is( |
158 |
{ |
159 |
error => 'Invalid parameter value', |
160 |
error_code => 'invalid_parameter_value', |
161 |
path => $path, |
162 |
values => { |
163 |
uri => $uri, |
164 |
field => $field |
165 |
} |
166 |
} |
167 |
); |
168 |
|
169 |
$schema->storage->txn_rollback; |
170 |
}; |