Bug 34597: Add tests
prove t/db_dependent/Koha/Illrequest.t prove t/db_dependent/Koha/Patron/Categories.t Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
562cb9708f
commit
5793d9107f
2 changed files with 23 additions and 4 deletions
|
@ -20,6 +20,7 @@
|
|||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 3;
|
||||
use Test::MockModule;
|
||||
|
||||
use Koha::ILL::Requests;
|
||||
|
||||
|
@ -30,11 +31,20 @@ my $schema = Koha::Database->new->schema;
|
|||
|
||||
subtest 'patron() tests' => sub {
|
||||
|
||||
plan tests => 3;
|
||||
plan tests => 5;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
|
||||
my $patron_module = Test::MockModule->new('Koha::Patron');
|
||||
|
||||
my $patroncategory = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patron::Categories',
|
||||
value => { can_place_ill_in_opac => 1, BlockExpiredPatronOpacActions => 'ill_request' }
|
||||
}
|
||||
);
|
||||
my $patron =
|
||||
$builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $patroncategory->id } } );
|
||||
my $request =
|
||||
$builder->build_object( { class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->id } } );
|
||||
|
||||
|
@ -46,6 +56,14 @@ subtest 'patron() tests' => sub {
|
|||
|
||||
is( $request->patron, undef );
|
||||
|
||||
# patron is not expired, is allowed
|
||||
$patron_module->mock( 'is_expired', sub { return 0; } );
|
||||
is( $request->can_patron_place_ill_in_opac($patron), 1 );
|
||||
|
||||
# patron is expired, is not allowed
|
||||
$patron_module->mock( 'is_expired', sub { return 1; } );
|
||||
is( $request->can_patron_place_ill_in_opac($patron), 0 );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
|
|
|
@ -103,8 +103,8 @@ subtest 'get_expiry_date' => sub {
|
|||
};
|
||||
|
||||
subtest 'BlockExpiredPatronOpacActions' => sub {
|
||||
plan tests => 3;
|
||||
t::lib::Mocks::mock_preference('BlockExpiredPatronOpacActions', 'hold');
|
||||
plan tests => 4;
|
||||
t::lib::Mocks::mock_preference( 'BlockExpiredPatronOpacActions', 'hold,ill_request' );
|
||||
my $category = Koha::Patron::Category->new({
|
||||
categorycode => 'ya_cat',
|
||||
category_type => 'A',
|
||||
|
@ -113,6 +113,7 @@ subtest 'BlockExpiredPatronOpacActions' => sub {
|
|||
BlockExpiredPatronOpacActions => 'follow_syspref_BlockExpiredPatronOpacActions',
|
||||
})->store;
|
||||
is( $category->effective_BlockExpiredPatronOpacActions_contains('hold'), 1 );
|
||||
is( $category->effective_BlockExpiredPatronOpacActions_contains('ill_request'), 1 );
|
||||
is( $category->effective_BlockExpiredPatronOpacActions_contains('renew'), undef );
|
||||
$category->BlockExpiredPatronOpacActions('renew')->store;
|
||||
is( $category->effective_BlockExpiredPatronOpacActions_contains('renew'), 1 );
|
||||
|
|
Loading…
Reference in a new issue