View | Details | Raw Unified | Return to bug 18477
Collapse All | Expand All

(-)a/t/db_dependent/ArticleRequests.t (-3 / +23 lines)
Lines 19-30 use Modern::Perl; Link Here
19
19
20
use POSIX qw(strftime);
20
use POSIX qw(strftime);
21
21
22
use Test::More tests => 49;
22
use Test::More tests => 54;
23
23
24
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
25
25
26
use Koha::Database;
26
use Koha::Database;
27
use Koha::Biblio;
27
use Koha::Biblio;
28
use Koha::Notice::Messages;
28
use Koha::Patron;
29
use Koha::Patron;
29
use Koha::Library;
30
use Koha::Library;
30
31
Lines 73-93 my $patron = Koha::Patron->new( Link Here
73
)->store();
74
)->store();
74
ok( $patron->id, 'Koha::Patron created' );
75
ok( $patron->id, 'Koha::Patron created' );
75
76
77
# store
78
Koha::Notice::Messages->delete;
79
my $article_request_title = 'an article request title';
76
my $article_request = Koha::ArticleRequest->new(
80
my $article_request = Koha::ArticleRequest->new(
77
    {
81
    {
78
        borrowernumber => $patron->id,
82
        borrowernumber => $patron->id,
79
        biblionumber   => $biblio->id,
83
        biblionumber   => $biblio->id,
80
        itemnumber     => $item->id,
84
        itemnumber     => $item->id,
85
        title          => $article_request_title,
81
    }
86
    }
82
)->store();
87
)->store();
88
89
my $notify_message = Koha::Notice::Messages->search->next;
90
is( $notify_message->letter_code, "AR_".Koha::ArticleRequest::Status::Pending);
91
# Default AR_PROCESSING template content "Title: <<article_requests.title>>"
92
like( $notify_message->content, qr{Title: $article_request_title}, 'Values from article_requests table must be fetched for the notification' );
93
83
$article_request = Koha::ArticleRequests->find( $article_request->id );
94
$article_request = Koha::ArticleRequests->find( $article_request->id );
84
ok( $article_request->id, 'Koha::ArticleRequest created' );
95
ok( $article_request->id, 'Koha::ArticleRequest created' );
85
86
is( $article_request->status, Koha::ArticleRequest::Status::Pending, 'New article request has status of Open' );
96
is( $article_request->status, Koha::ArticleRequest::Status::Pending, 'New article request has status of Open' );
97
is( $article_request->updated_on, undef, 'New article request has not an updated_on date set yet' );
98
99
# process
100
Koha::Notice::Messages->delete;
87
$article_request->process();
101
$article_request->process();
102
$notify_message = Koha::Notice::Messages->search->next;
103
is( $notify_message->letter_code, "AR_".Koha::ArticleRequest::Status::Processing);
88
is( $article_request->status, Koha::ArticleRequest::Status::Processing, '$ar->process() changes status to Processing' );
104
is( $article_request->status, Koha::ArticleRequest::Status::Processing, '$ar->process() changes status to Processing' );
105
isnt( $article_request->updated_on, undef, 'Updated article request has an updated_on date set' );
106
107
# complete
89
$article_request->complete();
108
$article_request->complete();
90
is( $article_request->status, Koha::ArticleRequest::Status::Completed, '$ar->complete() changes status to Completed' );
109
is( $article_request->status, Koha::ArticleRequest::Status::Completed, '$ar->complete() changes status to Completed' );
110
111
# cancel
91
$article_request->cancel();
112
$article_request->cancel();
92
is( $article_request->status, Koha::ArticleRequest::Status::Canceled, '$ar->complete() changes status to Canceled' );
113
is( $article_request->status, Koha::ArticleRequest::Status::Canceled, '$ar->complete() changes status to Canceled' );
93
$article_request->status(Koha::ArticleRequest::Status::Pending);
114
$article_request->status(Koha::ArticleRequest::Status::Pending);
94
- 

Return to bug 18477