Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 9; |
22 |
use Test::More tests => 10; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
use Test::Warn; |
24 |
use Test::Warn; |
25 |
|
25 |
|
Lines 831-833
subtest 'can_request_article() tests' => sub {
Link Here
|
831 |
|
831 |
|
832 |
$schema->storage->txn_rollback; |
832 |
$schema->storage->txn_rollback; |
833 |
}; |
833 |
}; |
834 |
- |
834 |
|
|
|
835 |
subtest 'can_request_article() tests' => sub { |
836 |
|
837 |
plan tests => 3; |
838 |
|
839 |
$schema->storage->txn_begin; |
840 |
|
841 |
my $category = $builder->build_object( |
842 |
{ |
843 |
class => 'Koha::Patron::Categories', |
844 |
value => { article_request_limit => 4 } |
845 |
} |
846 |
); |
847 |
my $patron = $builder->build_object( |
848 |
{ |
849 |
class => 'Koha::Patrons', |
850 |
value => { categorycode => $category->id } |
851 |
} |
852 |
); |
853 |
|
854 |
$builder->build_object( { class => 'Koha::ArticleRequests', value => { status => 'REQUESTED', borrowernumber => $patron->id } } ); |
855 |
$builder->build_object( { class => 'Koha::ArticleRequests', value => { status => 'PENDING', borrowernumber => $patron->id } } ); |
856 |
$builder->build_object( { class => 'Koha::ArticleRequests', value => { status => 'PROCESSING', borrowernumber => $patron->id } } ); |
857 |
$builder->build_object( { class => 'Koha::ArticleRequests', value => { status => 'CANCELED', borrowernumber => $patron->id } } ); |
858 |
|
859 |
ok( $patron->can_request_article, 'Patron has 3 current requests, 4 is the limit: allowed' ); |
860 |
|
861 |
# Completed request, same day |
862 |
my $completed = $builder->build_object( |
863 |
{ |
864 |
class => 'Koha::ArticleRequests', |
865 |
value => { |
866 |
status => 'COMPLETED', |
867 |
borrowernumber => $patron->id |
868 |
} |
869 |
} |
870 |
); |
871 |
|
872 |
ok( !$patron->can_request_article, 'Patron has 3 current requests and a completed one the same day: denied' ); |
873 |
|
874 |
$completed->updated_on( |
875 |
dt_from_string->add( days => -1 )->set( |
876 |
hour => 23, |
877 |
minute => 59, |
878 |
second => 59, |
879 |
) |
880 |
)->store; |
881 |
|
882 |
ok( $patron->can_request_article, 'Patron has 3 current requests and a completed one the day before: allowed' ); |
883 |
|
884 |
$schema->storage->txn_rollback; |
885 |
}; |