|
Lines 19-25
use Modern::Perl;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use POSIX qw(strftime); |
20 |
use POSIX qw(strftime); |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 54; |
22 |
use Test::More tests => 55; |
|
|
23 |
use Test::MockModule; |
| 23 |
|
24 |
|
| 24 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
| 25 |
use t::lib::Mocks; |
26 |
use t::lib::Mocks; |
|
Lines 101-108
is( $article_request->status, Koha::ArticleRequest::Status::Completed, '$ar->com
Link Here
|
| 101 |
# cancel |
102 |
# cancel |
| 102 |
$article_request->cancel(); |
103 |
$article_request->cancel(); |
| 103 |
is( $article_request->status, Koha::ArticleRequest::Status::Canceled, '$ar->complete() changes status to Canceled' ); |
104 |
is( $article_request->status, Koha::ArticleRequest::Status::Canceled, '$ar->complete() changes status to Canceled' ); |
| 104 |
$article_request->status(Koha::ArticleRequest::Status::Pending); |
105 |
$article_request->set_pending(); |
| 105 |
$article_request->store(); |
|
|
| 106 |
|
106 |
|
| 107 |
is( $article_request->biblio->id, $biblio->id, '$ar->biblio() gets corresponding Koha::Biblio object' ); |
107 |
is( $article_request->biblio->id, $biblio->id, '$ar->biblio() gets corresponding Koha::Biblio object' ); |
| 108 |
is( $article_request->item->id, $item->id, '$ar->item() gets corresponding Koha::Item object' ); |
108 |
is( $article_request->item->id, $item->id, '$ar->item() gets corresponding Koha::Item object' ); |
|
Lines 120-127
is( $patron->article_requests_current()->count(), 0, 'Completed request not retu
Link Here
|
| 120 |
$article_request->cancel(); |
120 |
$article_request->cancel(); |
| 121 |
is( $patron->article_requests_current()->count(), 0, 'Canceled request not returned for article_requests_current' ); |
121 |
is( $patron->article_requests_current()->count(), 0, 'Canceled request not returned for article_requests_current' ); |
| 122 |
|
122 |
|
| 123 |
$article_request->status(Koha::ArticleRequest::Status::Pending); |
123 |
$article_request->set_pending(); |
| 124 |
$article_request->store(); |
|
|
| 125 |
|
124 |
|
| 126 |
is( $patron->article_requests_finished()->count(), 0, 'Open request returned for article_requests_finished' ); |
125 |
is( $patron->article_requests_finished()->count(), 0, 'Open request returned for article_requests_finished' ); |
| 127 |
$article_request->process(); |
126 |
$article_request->process(); |
|
Lines 130-137
$article_request->complete();
Link Here
|
| 130 |
$article_request->cancel(); |
129 |
$article_request->cancel(); |
| 131 |
is( $patron->article_requests_finished()->count(), 1, 'Canceled request not returned for article_requests_finished' ); |
130 |
is( $patron->article_requests_finished()->count(), 1, 'Canceled request not returned for article_requests_finished' ); |
| 132 |
|
131 |
|
| 133 |
$article_request->status(Koha::ArticleRequest::Status::Pending); |
132 |
$article_request->set_pending(); |
| 134 |
$article_request->store(); |
|
|
| 135 |
|
133 |
|
| 136 |
$ar = $biblio->article_requests(); |
134 |
$ar = $biblio->article_requests(); |
| 137 |
is( ref($ar), 'Koha::ArticleRequests', '$biblio->article_requests returns Koha::ArticleRequests object' ); |
135 |
is( ref($ar), 'Koha::ArticleRequests', '$biblio->article_requests returns Koha::ArticleRequests object' ); |
|
Lines 253-255
subtest 'may_article_request' => sub {
Link Here
|
| 253 |
}; |
251 |
}; |
| 254 |
|
252 |
|
| 255 |
$schema->storage->txn_rollback(); |
253 |
$schema->storage->txn_rollback(); |
| 256 |
- |
254 |
|
|
|
255 |
subtest 'set_pending() tests' => sub { |
| 256 |
|
| 257 |
plan tests => 2; |
| 258 |
|
| 259 |
$schema->storage->txn_begin; |
| 260 |
|
| 261 |
my $ar_mock = Test::MockModule->new('Koha::ArticleRequest'); |
| 262 |
$ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } ); |
| 263 |
|
| 264 |
my $ar = $builder->build_object( |
| 265 |
{ |
| 266 |
class => 'Koha::ArticleRequests', |
| 267 |
value => { status => Koha::ArticleRequest::Status::Requested } |
| 268 |
} |
| 269 |
); |
| 270 |
|
| 271 |
$ar->set_pending()->discard_changes; |
| 272 |
|
| 273 |
is( $ar->status, Koha::ArticleRequest::Status::Pending ); |
| 274 |
|
| 275 |
$schema->storage->txn_rollback; |
| 276 |
}; |