|
Lines 8-14
use Koha::DateUtils qw( dt_from_string );
Link Here
|
| 8 |
use Koha::Patrons; |
8 |
use Koha::Patrons; |
| 9 |
|
9 |
|
| 10 |
use Test::NoWarnings; |
10 |
use Test::NoWarnings; |
| 11 |
use Test::More tests => 62; |
11 |
use Test::More tests => 170; |
| 12 |
|
12 |
|
| 13 |
use_ok('Koha::Patron'); |
13 |
use_ok('Koha::Patron'); |
| 14 |
|
14 |
|
|
Lines 49-54
my $inheritCatCode = $builder->build(
Link Here
|
| 49 |
} |
49 |
} |
| 50 |
); |
50 |
); |
| 51 |
|
51 |
|
|
|
52 |
my $yesItypeCode = $builder->build_object({ |
| 53 |
class => 'Koha::ItemTypes', |
| 54 |
value => { |
| 55 |
checkprevcheckout => 'yes', |
| 56 |
} |
| 57 |
}); |
| 58 |
|
| 59 |
my $noItypeCode = $builder->build_object({ |
| 60 |
class => 'Koha::ItemTypes', |
| 61 |
value => { |
| 62 |
checkprevcheckout => 'no', |
| 63 |
} |
| 64 |
}); |
| 65 |
|
| 66 |
my $inheritItypeCode = $builder->build_object({ |
| 67 |
class => 'Koha::ItemTypes', |
| 68 |
value => { |
| 69 |
checkprevcheckout => 'inherit', |
| 70 |
} |
| 71 |
}); |
| 72 |
|
| 52 |
# Create context for some tests late on in the file. |
73 |
# Create context for some tests late on in the file. |
| 53 |
my $library = $builder->build( { source => 'Branch' } ); |
74 |
my $library = $builder->build( { source => 'Branch' } ); |
| 54 |
my $staff = $builder->build( { source => 'Borrower' } ); |
75 |
my $staff = $builder->build( { source => 'Borrower' } ); |
|
Lines 57-62
t::lib::Mocks::mock_userenv( { branchcode => $library->{branchcode} } );
Link Here
|
| 57 |
|
78 |
|
| 58 |
# wants_check_for_previous_checkout |
79 |
# wants_check_for_previous_checkout |
| 59 |
|
80 |
|
|
|
81 |
# We want to test the subroutine without passing the $item parameter |
| 60 |
# We expect the following result matrix: |
82 |
# We expect the following result matrix: |
| 61 |
# |
83 |
# |
| 62 |
# (1/0 indicates the return value of WantsCheckPrevCheckout; i.e. 1 says we |
84 |
# (1/0 indicates the return value of WantsCheckPrevCheckout; i.e. 1 says we |
|
Lines 213-218
map {
Link Here
|
| 213 |
} @{ $_->{categories} }; |
235 |
} @{ $_->{categories} }; |
| 214 |
} @{$mappings}; |
236 |
} @{$mappings}; |
| 215 |
|
237 |
|
|
|
238 |
|
| 239 |
# wants_check_for_previous_checkout |
| 240 |
|
| 241 |
# We want to test the subroutine by passing the $item parameter |
| 242 |
# We expect the following result matrix: |
| 243 |
# |
| 244 |
# (1/0 indicates the return value of WantsCheckPrevCheckout; i.e. 1 says we |
| 245 |
# should check whether the item was previously issued) |
| 246 |
# |
| 247 |
# | System Preference | hardyes | |
| 248 |
# |-------------------+-----------------------------------------------------------------------------------------------------------| |
| 249 |
# | Item Type Setting | yes | no | inherit | |
| 250 |
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------| |
| 251 |
# | Category Setting | yes | no | inherit | yes | no | inherit | yes | no | inherit | |
| 252 |
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------| |
| 253 |
# | Patron Setting | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | |
| 254 |
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---| |
| 255 |
# | Expected Result | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | |
| 256 |
# |
| 257 |
# |
| 258 |
# | System Preference | softyes | |
| 259 |
# |-------------------+-----------------------------------------------------------------------------------------------------------| |
| 260 |
# | Item Type Setting | yes | no | inherit | |
| 261 |
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------| |
| 262 |
# | Category Setting | yes | no | inherit | yes | no | inherit | yes | no | inherit | |
| 263 |
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------| |
| 264 |
# | Patron Setting | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | |
| 265 |
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---| |
| 266 |
# | Expected Result | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | |
| 267 |
# |
| 268 |
# |
| 269 |
# | System Preference | softno | |
| 270 |
# |-------------------+-----------------------------------------------------------------------------------------------------------| |
| 271 |
# | Item Type Setting | yes | no | inherit | |
| 272 |
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------| |
| 273 |
# | Category Setting | yes | no | inherit | yes | no | inherit | yes | no | inherit | |
| 274 |
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------| |
| 275 |
# | Patron Setting | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | |
| 276 |
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---| |
| 277 |
# | Expected Result | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | |
| 278 |
# |
| 279 |
# |
| 280 |
# | System Preference | hardno | |
| 281 |
# |-------------------+-----------------------------------------------------------------------------------------------------------| |
| 282 |
# | Item Type Setting | yes | no | inherit | |
| 283 |
# |-------------------+-----------------------------------+-----------------------------------+-----------------------------------| |
| 284 |
# | Category Setting | yes | no | inherit | yes | no | inherit | yes | no | inherit | |
| 285 |
# |-------------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------| |
| 286 |
# | Patron Setting | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | y | n | i | |
| 287 |
# |-------------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---| |
| 288 |
# | Expected Result | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| 289 |
|
| 290 |
my $itypeCode = { |
| 291 |
'yes' => $yesItypeCode->itemtype, |
| 292 |
'no' => $noItypeCode->itemtype, |
| 293 |
'inherit' => $inheritItypeCode->itemtype, |
| 294 |
}; |
| 295 |
|
| 296 |
foreach my $syspref ('hardyes','softyes','softno','hardno'){ |
| 297 |
t::lib::Mocks::mock_preference( 'checkprevcheckout', $syspref ); |
| 298 |
foreach my $itemtype_setting ('yes','no','inherit'){ #itemtype Setting |
| 299 |
my $item = $builder->build_sample_item( { itype => $itypeCode->{$itemtype_setting} } ); |
| 300 |
foreach my $categorie_settings('yes','no','inherit'){ |
| 301 |
my $catCode = $categorie_settings . 'Cat'; |
| 302 |
foreach my $patron_setting('yes','no','inherit'){ |
| 303 |
my $result = undef; |
| 304 |
$result = 1 if($syspref eq 'hardyes'); |
| 305 |
$result = 0 if($syspref eq 'hardno'); |
| 306 |
$result = 1 if(!defined $result && $itemtype_setting eq 'yes'); |
| 307 |
$result = 0 if(!defined $result && $itemtype_setting eq 'no'); |
| 308 |
$result = 1 if(!defined $result && $patron_setting eq 'yes'); |
| 309 |
$result = 0 if(!defined $result && $patron_setting eq 'no'); |
| 310 |
$result = 1 if(!defined $result && $categorie_settings eq 'yes'); |
| 311 |
$result = 0 if(!defined $result && $categorie_settings eq 'no'); |
| 312 |
$result = 1 if(!defined $result && $syspref eq 'softyes'); |
| 313 |
$result = 0 if(!defined $result && $syspref eq 'softno'); |
| 314 |
my $kpatron = $builder->build( |
| 315 |
{ |
| 316 |
source => 'Borrower', |
| 317 |
value => { |
| 318 |
checkprevcheckout => $patron_setting, |
| 319 |
categorycode => $catCode, |
| 320 |
}, |
| 321 |
} |
| 322 |
); |
| 323 |
my $patron = Koha::Patrons->find( $kpatron->{borrowernumber} ); |
| 324 |
is( |
| 325 |
$patron->wants_check_for_previous_checkout($item), $result, |
| 326 |
"Predicate with syspref " |
| 327 |
. $syspref |
| 328 |
. ", cat " |
| 329 |
. $catCode |
| 330 |
. ", patron " |
| 331 |
. $patron_setting |
| 332 |
. ", item type " |
| 333 |
. $itypeCode->{$itemtype_setting} |
| 334 |
); |
| 335 |
} |
| 336 |
} |
| 337 |
} |
| 338 |
} |
| 339 |
|
| 216 |
# do_check_for_previous_checkout |
340 |
# do_check_for_previous_checkout |
| 217 |
|
341 |
|
| 218 |
# We want to test: |
342 |
# We want to test: |
| 219 |
- |
|
|