Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 12; |
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 846-932
subtest 'article_requests() tests' => sub {
Link Here
|
846 |
|
846 |
|
847 |
$schema->storage->txn_rollback; |
847 |
$schema->storage->txn_rollback; |
848 |
}; |
848 |
}; |
849 |
|
|
|
850 |
subtest 'article_requests_current() tests' => sub { |
851 |
|
852 |
plan tests => 7; |
853 |
|
854 |
$schema->storage->txn_begin; |
855 |
|
856 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
857 |
my $item = $builder->build_sample_item; |
858 |
|
859 |
my $article_request = Koha::ArticleRequest->new( |
860 |
{ |
861 |
borrowernumber => $patron->id, |
862 |
biblionumber => $item->biblionumber, |
863 |
itemnumber => $item->itemnumber, |
864 |
title => "Boo", |
865 |
} |
866 |
)->request(); |
867 |
|
868 |
my $ar = $patron->article_requests(); |
869 |
is( ref($ar), 'Koha::ArticleRequests', |
870 |
'$patron->article_requests returns Koha::ArticleRequests object' ); |
871 |
is( $ar->next->id, $article_request->id, |
872 |
'Returned article request matches' ); |
873 |
|
874 |
is( $patron->article_requests_current()->count(), |
875 |
1, 'Open request returned for article_requests_current' ); |
876 |
$article_request->set_pending(); |
877 |
is( $patron->article_requests_current()->count(), |
878 |
1, 'Pending request returned for article_requests_current' ); |
879 |
$article_request->process(); |
880 |
is( $patron->article_requests_current()->count(), |
881 |
1, 'Processing request returned for article_requests_current' ); |
882 |
$article_request->complete(); |
883 |
is( $patron->article_requests_current()->count(), |
884 |
0, 'Completed request not returned for article_requests_current' ); |
885 |
$article_request->cancel(); |
886 |
is( $patron->article_requests_current()->count(), |
887 |
0, 'Canceled request not returned for article_requests_current' ); |
888 |
|
889 |
$schema->storage->txn_rollback; |
890 |
}; |
891 |
|
892 |
subtest 'article_requests_finished() tests' => sub { |
893 |
|
894 |
plan tests => 7; |
895 |
|
896 |
$schema->storage->txn_begin; |
897 |
|
898 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
899 |
my $item = $builder->build_sample_item; |
900 |
|
901 |
my $article_request = Koha::ArticleRequest->new( |
902 |
{ |
903 |
borrowernumber => $patron->id, |
904 |
biblionumber => $item->biblionumber, |
905 |
itemnumber => $item->itemnumber, |
906 |
title => "Boo", |
907 |
} |
908 |
)->request(); |
909 |
|
910 |
my $ar = $patron->article_requests(); |
911 |
is( ref($ar), 'Koha::ArticleRequests', |
912 |
'$patron->article_requests returns Koha::ArticleRequests object' ); |
913 |
is( $ar->next->id, $article_request->id, |
914 |
'Returned article request matches' ); |
915 |
|
916 |
is( $patron->article_requests_finished->count, |
917 |
0, 'Open request returned for article_requests_finished' ); |
918 |
$article_request->set_pending(); |
919 |
is( $patron->article_requests_finished->count, |
920 |
0, 'Pending request returned for article_requests_finished' ); |
921 |
$article_request->process(); |
922 |
is( $patron->article_requests_finished->count, |
923 |
0, 'Processing request returned for article_requests_finished' ); |
924 |
$article_request->complete(); |
925 |
is( $patron->article_requests_finished->count, |
926 |
1, 'Completed request returned for article_requests_finished' ); |
927 |
$article_request->cancel(); |
928 |
is( $patron->article_requests_finished->count, |
929 |
1, 'Cancelled request not returned for article_requests_finished' ); |
930 |
|
931 |
$schema->storage->txn_rollback; |
932 |
}; |
933 |
- |