|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 6; |
22 |
use Test::More tests => 7; |
| 23 |
|
23 |
|
| 24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
| 25 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
|
Lines 219-221
subtest 'get_password_expiry_date() tests' => sub {
Link Here
|
| 219 |
is( $category->get_password_expiry_date(), dt_from_string()->add( days => 32 )->ymd, "Date correctly calculated from password_expiry_days when set"); |
219 |
is( $category->get_password_expiry_date(), dt_from_string()->add( days => 32 )->ymd, "Date correctly calculated from password_expiry_days when set"); |
| 220 |
|
220 |
|
| 221 |
}; |
221 |
}; |
| 222 |
- |
222 |
|
|
|
223 |
subtest 'can_make_suggestions' => sub { |
| 224 |
|
| 225 |
plan tests => 6; |
| 226 |
|
| 227 |
$schema->storage->txn_begin; |
| 228 |
|
| 229 |
t::lib::Mocks::mock_preference( 'suggestion', 0 ); |
| 230 |
t::lib::Mocks::mock_preference( 'suggestionPatronCategoryExceptions', undef ); |
| 231 |
|
| 232 |
my $category_1 = $builder->build_object({ class => 'Koha::Patron::Categories' }); |
| 233 |
my $category_2 = $builder->build_object({ class => 'Koha::Patron::Categories' }); |
| 234 |
|
| 235 |
ok( |
| 236 |
!$category_1->can_make_suggestions && !$category_2->can_make_suggestions, |
| 237 |
'suggestions globally disabled, categories not in exceptions' |
| 238 |
); |
| 239 |
|
| 240 |
t::lib::Mocks::mock_preference( 'suggestion', 1 ); |
| 241 |
ok( |
| 242 |
$category_1->can_make_suggestions && $category_2->can_make_suggestions, |
| 243 |
'suggestions globally enabled' |
| 244 |
); |
| 245 |
|
| 246 |
t::lib::Mocks::mock_preference( 'suggestionPatronCategoryExceptions', $category_2->categorycode ); |
| 247 |
ok( |
| 248 |
$category_1->can_make_suggestions && !$category_2->can_make_suggestions, |
| 249 |
'suggestions enabled, suggestionPatronCategoryExceptions set, so present categories not allowed' |
| 250 |
); |
| 251 |
|
| 252 |
t::lib::Mocks::mock_preference( 'suggestionPatronCategoryExceptions', $category_1->categorycode ); |
| 253 |
ok( |
| 254 |
!$category_1->can_make_suggestions && $category_2->can_make_suggestions, |
| 255 |
'suggestions enabled, suggestionPatronCategoryExceptions set, so present categories not allowed' |
| 256 |
); |
| 257 |
|
| 258 |
t::lib::Mocks::mock_preference( 'suggestionPatronCategoryExceptions', join( ',', $category_1->categorycode, $category_2->categorycode) ); |
| 259 |
ok( |
| 260 |
!$category_1->can_make_suggestions && !$category_2->can_make_suggestions, |
| 261 |
'suggestions enabled, suggestionPatronCategoryExceptions set to both categories, both denied' |
| 262 |
); |
| 263 |
|
| 264 |
t::lib::Mocks::mock_preference( 'suggestion', 0 ); |
| 265 |
ok( |
| 266 |
!$category_1->can_make_suggestions && !$category_2->can_make_suggestions, |
| 267 |
'suggestions disabled, no matter what the value of suggestionPatronCategoryExceptions is' |
| 268 |
); |
| 269 |
|
| 270 |
$schema->storage->txn_rollback; |
| 271 |
}; |