|
Lines 20-25
Link Here
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 3; |
|
|
23 |
use Test::MockModule; |
| 23 |
|
24 |
|
| 24 |
use Koha::ILL::Requests; |
25 |
use Koha::ILL::Requests; |
| 25 |
|
26 |
|
|
Lines 30-40
my $schema = Koha::Database->new->schema;
Link Here
|
| 30 |
|
31 |
|
| 31 |
subtest 'patron() tests' => sub { |
32 |
subtest 'patron() tests' => sub { |
| 32 |
|
33 |
|
| 33 |
plan tests => 3; |
34 |
plan tests => 5; |
| 34 |
|
35 |
|
| 35 |
$schema->storage->txn_begin; |
36 |
$schema->storage->txn_begin; |
| 36 |
|
37 |
|
| 37 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
38 |
my $patron_module = Test::MockModule->new('Koha::Patron'); |
|
|
39 |
|
| 40 |
my $patroncategory = $builder->build_object( |
| 41 |
{ |
| 42 |
class => 'Koha::Patron::Categories', |
| 43 |
value => { can_place_ill_in_opac => 1, BlockExpiredPatronOpacActions => 'ill_request' } |
| 44 |
} |
| 45 |
); |
| 46 |
my $patron = |
| 47 |
$builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patroncategory->id } } ); |
| 38 |
my $request = |
48 |
my $request = |
| 39 |
$builder->build_object( { class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->id } } ); |
49 |
$builder->build_object( { class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->id } } ); |
| 40 |
|
50 |
|
|
Lines 46-51
subtest 'patron() tests' => sub {
Link Here
|
| 46 |
|
56 |
|
| 47 |
is( $request->patron, undef ); |
57 |
is( $request->patron, undef ); |
| 48 |
|
58 |
|
|
|
59 |
# patron is not expired, is allowed |
| 60 |
$patron_module->mock( 'is_expired', sub { return 0; } ); |
| 61 |
is( $request->can_patron_place_ill_in_opac($patron), 1 ); |
| 62 |
|
| 63 |
# patron is expired, is not allowed |
| 64 |
$patron_module->mock( 'is_expired', sub { return 1; } ); |
| 65 |
is( $request->can_patron_place_ill_in_opac($patron), 0 ); |
| 66 |
|
| 49 |
$schema->storage->txn_rollback; |
67 |
$schema->storage->txn_rollback; |
| 50 |
}; |
68 |
}; |
| 51 |
|
69 |
|