Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 7; |
22 |
use Test::More tests => 8; |
23 |
|
23 |
|
24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
25 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
Lines 204-209
subtest 'effective_require_strong_password' => sub {
Link Here
|
204 |
$schema->storage->txn_rollback; |
204 |
$schema->storage->txn_rollback; |
205 |
}; |
205 |
}; |
206 |
|
206 |
|
|
|
207 |
subtest 'effective_force_password_reset_when_set_by_staff() tests' => sub { |
208 |
plan tests => 2; |
209 |
|
210 |
subtest 'specific overrides global' => sub { |
211 |
plan tests => 4; |
212 |
|
213 |
$schema->storage->txn_begin; |
214 |
|
215 |
my $category = $builder->build_object({ |
216 |
class => 'Koha::Patron::Categories', |
217 |
value => { |
218 |
force_password_reset_when_set_by_staff => 1 |
219 |
} |
220 |
}); |
221 |
|
222 |
t::lib::Mocks::mock_preference('ForcePasswordResetWhenSetByStaff', 0); |
223 |
ok($category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff unset, but category has the flag set to 1'); |
224 |
|
225 |
t::lib::Mocks::mock_preference('ForcePasswordResetWhenSetByStaff', 1); |
226 |
ok($category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff set and category has the flag set to 1'); |
227 |
|
228 |
# disable |
229 |
$category->force_password_reset_when_set_by_staff(0)->store->discard_changes; |
230 |
|
231 |
t::lib::Mocks::mock_preference('ForcePasswordResetWhenSetByStaff', 0); |
232 |
ok(!$category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff unset, but category has the flag set to 0'); |
233 |
|
234 |
t::lib::Mocks::mock_preference('ForcePasswordResetWhenSetByStaff', 1); |
235 |
ok(!$category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff set and category has the flag set to 0'); |
236 |
|
237 |
$schema->storage->txn_rollback; |
238 |
}; |
239 |
|
240 |
subtest 'no specific rule, global applies' => sub { |
241 |
plan tests => 2; |
242 |
|
243 |
$schema->storage->txn_begin; |
244 |
|
245 |
my $category = $builder->build_object({ |
246 |
class => 'Koha::Patron::Categories', |
247 |
value => { |
248 |
force_password_reset_when_set_by_staff => undef |
249 |
} |
250 |
}); |
251 |
|
252 |
t::lib::Mocks::mock_preference('ForcePasswordResetWhenSetByStaff', 0); |
253 |
ok(!$category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff set to 0 used'); |
254 |
|
255 |
t::lib::Mocks::mock_preference('ForcePasswordResetWhenSetByStaff', 1); |
256 |
ok($category->effective_force_password_reset_when_set_by_staff, 'ForcePasswordResetWhenSetByStaff set to 1 used'); |
257 |
|
258 |
$schema->storage->txn_rollback; |
259 |
}; |
260 |
}; |
261 |
|
262 |
|
207 |
subtest 'get_password_expiry_date() tests' => sub { |
263 |
subtest 'get_password_expiry_date() tests' => sub { |
208 |
|
264 |
|
209 |
plan tests => 3; |
265 |
plan tests => 3; |
210 |
- |
|
|